下面列出了android.view.WindowManager#removeViewImmediate ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
public void destroyPhotoViewer() {
NotificationCenter.getInstance(currentAccount).removeObserver(this, NotificationCenter.messagesDeleted);
NotificationCenter.getInstance(currentAccount).removeObserver(this, NotificationCenter.updateMessageMedia);
NotificationCenter.getInstance(currentAccount).removeObserver(this, NotificationCenter.didCreatedNewDeleteTask);
isVisible = false;
currentProvider = null;
if (currentThumb != null) {
currentThumb.release();
currentThumb = null;
}
releasePlayer();
if (parentActivity != null && windowView != null) {
try {
if (windowView.getParent() != null) {
WindowManager wm = (WindowManager) parentActivity.getSystemService(Context.WINDOW_SERVICE);
wm.removeViewImmediate(windowView);
}
windowView = null;
} catch (Exception e) {
FileLog.e(e);
}
}
Instance = null;
}
/**
* 取消吐司弹窗
*/
void cancel() {
// 移除之前移除吐司的任务
removeMessages(hashCode());
if (isShow()) {
try {
Activity topActivity = mWindowHelper.getTopActivity();
if (topActivity != null) {
WindowManager windowManager = (WindowManager) topActivity.getSystemService(Context.WINDOW_SERVICE);
if (windowManager != null) {
windowManager.removeViewImmediate(mToast.getView());
}
}
} catch (IllegalArgumentException ignored) {
// 如果当前 WindowManager 没有附加这个 View 则会抛出异常
// java.lang.IllegalArgumentException: View=android.widget.TextView not attached to window manager
}
// 当前没有显示
setShow(false);
}
}
public void destroyPhotoViewer() {
NotificationCenter.getInstance(currentAccount).removeObserver(this, NotificationCenter.messagesDeleted);
NotificationCenter.getInstance(currentAccount).removeObserver(this, NotificationCenter.updateMessageMedia);
NotificationCenter.getInstance(currentAccount).removeObserver(this, NotificationCenter.didCreatedNewDeleteTask);
isVisible = false;
currentProvider = null;
if (currentThumb != null) {
currentThumb.release();
currentThumb = null;
}
releasePlayer();
if (parentActivity != null && windowView != null) {
try {
if (windowView.getParent() != null) {
WindowManager wm = (WindowManager) parentActivity.getSystemService(Context.WINDOW_SERVICE);
wm.removeViewImmediate(windowView);
}
windowView = null;
} catch (Exception e) {
FileLog.e(e);
}
}
Instance = null;
}
public void destroyPhotoViewer() {
if (parentActivity == null || windowView == null) {
return;
}
try {
if (windowView.getParent() != null) {
WindowManager wm = (WindowManager) parentActivity
.getSystemService(Context.WINDOW_SERVICE);
wm.removeViewImmediate(windowView);
}
windowView = null;
} catch (Exception e) {
e.printStackTrace();
}
parentActivity = null;
Instance = null;
}
public void destroyPhotoViewer() {
NotificationCenter.getInstance(currentAccount).removeObserver(this, NotificationCenter.messagesDeleted);
NotificationCenter.getInstance(currentAccount).removeObserver(this, NotificationCenter.updateMessageMedia);
NotificationCenter.getInstance(currentAccount).removeObserver(this, NotificationCenter.didCreatedNewDeleteTask);
isVisible = false;
currentProvider = null;
if (currentThumb != null) {
currentThumb.release();
currentThumb = null;
}
releasePlayer();
if (parentActivity != null && windowView != null) {
try {
if (windowView.getParent() != null) {
WindowManager wm = (WindowManager) parentActivity.getSystemService(Context.WINDOW_SERVICE);
wm.removeViewImmediate(windowView);
}
windowView = null;
} catch (Exception e) {
FileLog.e(e);
}
}
Instance = null;
}
public void destroyPhotoViewer() {
NotificationCenter.getInstance(currentAccount).removeObserver(this, NotificationCenter.messagesDeleted);
NotificationCenter.getInstance(currentAccount).removeObserver(this, NotificationCenter.updateMessageMedia);
NotificationCenter.getInstance(currentAccount).removeObserver(this, NotificationCenter.didCreatedNewDeleteTask);
isVisible = false;
currentProvider = null;
if (currentThumb != null) {
currentThumb.release();
currentThumb = null;
}
releasePlayer();
if (parentActivity != null && windowView != null) {
try {
if (windowView.getParent() != null) {
WindowManager wm = (WindowManager) parentActivity.getSystemService(Context.WINDOW_SERVICE);
wm.removeViewImmediate(windowView);
}
windowView = null;
} catch (Exception e) {
FileLog.e(e);
}
}
Instance = null;
}
public void detachFromWindow(WindowManager windowManager) {
this.windowManager = null;
if (isAdded) {
removeSleepRunnable();
if (getContext() instanceof Activity) {
windowManager.removeViewImmediate(this);
} else {
windowManager.removeView(this);
}
isAdded = false;
sleep = false;
}
}
public void detachFromWindow(WindowManager windowManager) {
if (!isAdded) return;
isAdded = false;
removeOnLayoutChangeListener(layoutChangeListener);
if (getContext() instanceof Activity) {
windowManager.removeViewImmediate(this);
} else {
windowManager.removeView(this);
}
}
public void detachFromWindow(WindowManager windowManager) {
if (isAdded) {
toggle(0);
mMenuLayout.setVisibility(GONE);
if (getContext() instanceof Activity) {
windowManager.removeViewImmediate(this);
} else {
windowManager.removeView(this);
}
isAdded = false;
}
}
private void handleDestroyActivity(IBinder token, boolean finishing,
int configChanges, boolean getNonConfigInstance) {
ActivityClientRecord r = performDestroyActivity(token, finishing,
configChanges, getNonConfigInstance);
if (r != null) {
cleanUpPendingRemoveWindows(r);
WindowManager wm = r.activity.getWindowManager();
View v = r.activity.mDecor;
if (v != null) {
if (r.activity.mVisibleFromServer) {
mNumVisibleActivities--;
}
IBinder wtoken = v.getWindowToken();
if (r.activity.mWindowAdded) {
if (r.onlyLocalRequest) {
// Hold off on removing this until the new activity's
// window is being added.
r.mPendingRemoveWindow = v;
r.mPendingRemoveWindowManager = wm;
} else {
wm.removeViewImmediate(v);
}
}
if (wtoken != null && r.mPendingRemoveWindow == null) {
WindowManagerImpl.getDefault().closeAll(wtoken,
r.activity.getClass().getName(), "Activity");
}
r.activity.mDecor = null;
}
if (r.mPendingRemoveWindow == null) {
// If we are delaying the removal of the activity window, then
// we can't clean up all windows here. Note that we can't do
// so later either, which means any windows that aren't closed
// by the app will leak. Well we try to warning them a lot
// about leaking windows, because that is a bug, so if they are
// using this recreate facility then they get to live with leaks.
WindowManagerImpl.getDefault().closeAll(token,
r.activity.getClass().getName(), "Activity");
}
// Mocked out contexts won't be participating in the normal
// process lifecycle, but if we're running with a proper
// ApplicationContext we need to have it tear down things
// cleanly.
Context c = r.activity.getBaseContext();
if (c instanceof ContextImpl) {
((ContextImpl) c).scheduleFinalCleanup(
r.activity.getClass().getName(), "Activity");
}
}
if (finishing) {
try {
ActivityManagerNative.getDefault().activityDestroyed(token);
} catch (RemoteException ex) {
// If the system process has died, it's game over for everyone.
}
}
}
private void handleDestroyActivity(IBinder token, boolean finishing,
int configChanges, boolean getNonConfigInstance) {
ActivityClientRecord r = performDestroyActivity(token, finishing,
configChanges, getNonConfigInstance);
if (r != null) {
cleanUpPendingRemoveWindows(r);
WindowManager wm = r.activity.getWindowManager();
View v = r.activity.mDecor;
if (v != null) {
if (r.activity.mVisibleFromServer) {
mNumVisibleActivities--;
}
IBinder wtoken = v.getWindowToken();
if (r.activity.mWindowAdded) {
if (r.onlyLocalRequest) {
// Hold off on removing this until the new activity's
// window is being added.
r.mPendingRemoveWindow = v;
r.mPendingRemoveWindowManager = wm;
} else {
wm.removeViewImmediate(v);
}
}
if (wtoken != null && r.mPendingRemoveWindow == null) {
WindowManagerImpl.getDefault().closeAll(wtoken,
r.activity.getClass().getName(), "Activity");
}
r.activity.mDecor = null;
}
if (r.mPendingRemoveWindow == null) {
// If we are delaying the removal of the activity window, then
// we can't clean up all windows here. Note that we can't do
// so later either, which means any windows that aren't closed
// by the app will leak. Well we try to warning them a lot
// about leaking windows, because that is a bug, so if they are
// using this recreate facility then they get to live with leaks.
WindowManagerImpl.getDefault().closeAll(token,
r.activity.getClass().getName(), "Activity");
}
// Mocked out contexts won't be participating in the normal
// process lifecycle, but if we're running with a proper
// ApplicationContext we need to have it tear down things
// cleanly.
Context c = r.activity.getBaseContext();
if (c instanceof ContextImpl) {
((ContextImpl) c).scheduleFinalCleanup(
r.activity.getClass().getName(), "Activity");
}
}
if (finishing) {
try {
ActivityManagerNative.getDefault().activityDestroyed(token);
} catch (RemoteException ex) {
// If the system process has died, it's game over for everyone.
}
}
}
@Override
public void StopAnimation(WindowManager Wm) {
win.mLoop = false; // 控制结束
Wm.removeViewImmediate(win);
}
@Override
public void StopAnimation(WindowManager Wm) {
Wm.removeViewImmediate(win);
}
@Override
public void StopAnimation(WindowManager Wm) {
// Wm.removeView(win);
Wm.removeViewImmediate(win);
}
@Override
public void StopAnimation(WindowManager Wm) {
pwv.mLoop = false;
Wm.removeViewImmediate(pwv);
pwv = null;
}
@Override
protected void onDestroy() {
super.onDestroy();
//PPApplication.logE("LockDeviceActivity.onDestroy", "displayed="+displayed);
final Context appContext = getApplicationContext();
boolean canWriteSettings;// = true;
//if (android.os.Build.VERSION.SDK_INT >= 23)
canWriteSettings = Settings.System.canWrite(appContext);
if (displayed && (PhoneProfilesService.getInstance() != null) && canWriteSettings) {
displayed = false;
if (view != null)
try {
WindowManager windowManager = (WindowManager) getSystemService(Context.WINDOW_SERVICE);
if (windowManager != null)
windowManager.removeViewImmediate(view);
} catch (Exception e) {
PPApplication.recordException(e);
}
LockDeviceActivityFinishBroadcastReceiver.removeAlarm(appContext);
PPApplication.lockDeviceActivity = null;
Settings.System.putInt(appContext.getContentResolver(), Settings.System.SCREEN_OFF_TIMEOUT, PPApplication.screenTimeoutBeforeDeviceLock);
// change screen timeout
//final DataWrapper dataWrapper = new DataWrapper(appContext, false, 0, false);
final int screenTimeout = ApplicationPreferences.prefActivatedProfileScreenTimeout;
//PPApplication.logE("LockDeviceActivity.onDestroy", "screenTimeout="+screenTimeout);
if ((screenTimeout > 0) && (Permissions.checkScreenTimeout(appContext))) {
//PPApplication.logE("LockDeviceActivity.onDestroy", "permission ok");
if (PPApplication.screenTimeoutHandler != null) {
PPApplication.screenTimeoutHandler.post(new Runnable() {
public void run() {
//PPApplication.logE("LockDeviceActivity.onDestroy", "call ActivateProfileHelper.setScreenTimeout");
ActivateProfileHelper.setScreenTimeout(screenTimeout, appContext);
}
});
}/* else {
dataWrapper.getActivateProfileHelper().setScreenTimeout(screenTimeout);
}*/
}
//dataWrapper.invalidateDataWrapper();
}
}
@Override
public void removeFromWindowManager(WindowManager windowManager) {
windowManager.removeViewImmediate(this);
}
@Override
public void removeFromWindowManager(WindowManager windowManager) {
windowManager.removeViewImmediate(this);
}