Example usage for android.view WindowManager removeView

List of usage examples for android.view WindowManager removeView

Introduction

In this page you can find the example usage for android.view WindowManager removeView.

Prototype

public void removeView(View view);

Source Link

Usage

From source file:Main.java

public static void closeProgress(Context context, ProgressBar pBar) {
    WindowManager winManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
    winManager.removeView(pBar);
}

From source file:uk.co.alt236.floatinginfo.provider.generalinfo.GeneralInfoProvider.java

private void removeSystemWindow() {
    if (mUiManager.getView() != null && mUiManager.getView().getParent() != null) {
        final WindowManager wm = (WindowManager) getSystemService(Context.WINDOW_SERVICE);
        wm.removeView(mUiManager.getView());
    }//  w  ww .  ja  v a2 s.c o m
}

From source file:at.andreasrohner.spartantimelapserec.BackgroundService.java

@Override
public void onDestroy() {
    created = false;/*  www  . j  a v  a2 s .co  m*/
    File projectDir = null;

    final Handler handler = new Handler(handlerThread.getLooper());
    handler.post(new Runnable() {
        @Override
        public void run() {
            if (recorder != null)
                recorder.stop();
            handlerThread.quit();
        }
    });

    try {
        handlerThread.join(5000);
        if (handlerThread.isAlive()) {
            handlerThread.quit();
            handlerThread.join(2000);
        }
    } catch (Exception e) {
    }

    if (recorder != null) {
        projectDir = recorder.getOutputDir();
        recorder = null;
    }

    if (surfaceView != null) {
        WindowManager winMgr = (WindowManager) getSystemService(Context.WINDOW_SERVICE);
        winMgr.removeView(surfaceView);
    }

    if (wakeLock != null)
        wakeLock.release();

    if (projectDir != null && projectDir.exists())
        sendBroadcast(new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE, Uri.fromFile(projectDir)));
}

From source file:jp.morihirosoft.twwb.TwwbService.java

private void unblockScreen() {
    if (DEBUG)/* www  . ja  va2  s.  c  om*/
        Log.d(TAG, "unblockScreen");
    if (mBlockScreen != null) {
        WindowManager wm = (WindowManager) getSystemService(Context.WINDOW_SERVICE);
        wm.removeView(mBlockScreen);
        mBlockScreen = null;
    }
}

From source file:de.localtoast.launchit.BackgroundService.java

private void removeView() {
    WindowManager wm = (WindowManager) getSystemService(WINDOW_SERVICE);
    try {//from   www .j  a  va2s  .c o m
        wm.removeView(sidebar);
    } catch (IllegalArgumentException e1) {
        try {
            wm.removeView(touchArea);
        } catch (IllegalArgumentException e2) {
            // if now view was attached, we just do nothing
        }
    }
}

From source file:com.cn21.speedtest.service.LogService.java

private void removeSystemWindow() {
    if (mLogListView != null && mLogListView.getParent() != null) {
        final WindowManager wm = (WindowManager) getSystemService(WINDOW_SERVICE);
        wm.removeView(mLogListView);
    }/*  ww  w  .  j av  a  2  s  .  c  om*/
}

From source file:org.easyaccess.SwipingUtils.java

@Override
public void onResume() {
    super.onResume();
    // check if keyboard is connected or accessibility services are enabled
    if (Utils.isAccessibilityEnabled(getApplicationContext())
            || getResources().getConfiguration().keyboard != Configuration.KEYBOARD_NOKEYS) {
        TTS.speak(getResources().getString(R.string.appNameTalkBackFriendly));
    }/*www  .j  av a2s. c o m*/
    WindowManager windowManager = getWindowManager();
    LayoutInflater inflater = getLayoutInflater();
    LayoutParamsAndViewUtils layoutParamsAndView = ScreenCurtainFunctions.prepareForCurtainCheck(inflater);

    ScreenCurtainFunctions appState = ((ScreenCurtainFunctions) getApplicationContext());
    if (appState.getState() && !curtainSet) {
        curtainView = layoutParamsAndView.getView();
        windowManager.addView(curtainView, layoutParamsAndView.getLayoutParams());
        curtainSet = true;
    } else if (!appState.getState() && curtainSet) {
        windowManager.removeView(curtainView);
        curtainSet = false;
    }
}

From source file:io.bunnyblue.noticedog.app.lockscreen.ui.LockScreenWidget.java

void changeState(WidgetState nextState) {
    Log.d(TAG, "Switching state from: " + this.currentState + " to: " + nextState);
    LayoutParams layoutParams;/*  w  ww.j a va 2  s .co  m*/
    switch (nextState) {
    case stateShown:
        this.widgetView.clearAnimation();
        this.widgetView.setX(0.0f);
        this.widgetView.setAlpha(0.0f);
        this.widgetView.animate().alpha(0.0f).setDuration(0).withEndAction(new Runnable() {
            public void run() {
                LockScreenWidget.this.widgetView.animate().alpha(DefaultRetryPolicy.DEFAULT_BACKOFF_MULT)
                        .setDuration(200).setInterpolator(new DecelerateInterpolator())
                        .withEndAction(new Runnable() {
                            public void run() {
                                LockScreenWidget.this.enableTouchOnRootView(true);
                                LockScreenWidget.this.currentState = WidgetState.stateShown;
                            }
                        });
            }
        });
        this.currentState = WidgetState.stateInterpolatingToShown;
        return;
    case stateUnlockToContinueShown:
        enableTouchOnRootView(false);
        this.unlockToContinueView = ((LayoutInflater) this.context
                .getSystemService(Context.LAYOUT_INFLATER_SERVICE))
                        .inflate(R.layout.lockscreen_unlock_to_continue_view, null);
        addToFullscreenView(this.unlockToContinueView);
        ViewGroup.LayoutParams layoutParams2 = this.unlockToContinueView.getLayoutParams();
        layoutParams2.width = -1;
        this.unlockToContinueView.setLayoutParams(layoutParams2);
        this.unlockToContinueView.setAlpha(0.0f);
        this.widgetView.clearAnimation();
        this.widgetView.animate().alpha(0.0f).setDuration(200).setInterpolator(new AccelerateInterpolator())
                .withEndAction(new Runnable() {
                    public void run() {
                        LockScreenWidget.this.unlockToContinueView.animate()
                                .alpha(DefaultRetryPolicy.DEFAULT_BACKOFF_MULT).setDuration(200)
                                .setStartDelay(100).setInterpolator(new DecelerateInterpolator())
                                .withEndAction(new Runnable() {
                                    public void run() {
                                        LockScreenWidget.this.currentState = WidgetState.stateUnlockToContinueShown;
                                    }
                                });
                    }
                });
        this.currentState = WidgetState.stateInterpolatingToUnlockToContinueShown;
        return;
    case stateUnlockToContinueHidden:
        enableTouchOnRootView(false);
        this.widgetView.clearAnimation();
        this.unlockToContinueView.clearAnimation();
        this.unlockToContinueView.animate().alpha(0.0f).setDuration(200)
                .setInterpolator(new AccelerateInterpolator()).withEndAction(new Runnable() {
                    public void run() {
                        LockScreenWidget.this.widgetView.animate()
                                .alpha(DefaultRetryPolicy.DEFAULT_BACKOFF_MULT).setDuration(200)
                                .setStartDelay(100).setInterpolator(new DecelerateInterpolator())
                                .withEndAction(new Runnable() {
                                    public void run() {
                                        LockScreenWidget.this.currentState = WidgetState.stateShown;
                                        LockScreenWidget.this.clearFullscreenView();
                                        LockScreenWidget.this.unlockToContinueView = null;
                                        LockScreenWidget.this.enableTouchOnRootView(true);
                                        LockScreenWidget.this.currentState = WidgetState.stateShown;
                                    }
                                });
                    }
                });
        this.currentState = WidgetState.stateInterpolatingToUnlockToContinueHidden;
        return;
    case stateCleared:
        enableTouchOnRootView(false);
        this.widgetView.clearAnimation();
        this.widgetView.animate().alpha(0.0f).setDuration(200).setInterpolator(new AccelerateInterpolator())
                .withEndAction(new Runnable() {
                    public void run() {
                        if (LockScreenWidget.this.listener != null) {
                            LockScreenWidget.this.listener.onWidgetCleared();
                        }
                        LockScreenWidget.this.currentState = WidgetState.stateCleared;
                    }
                });
        this.currentState = WidgetState.stateInterpolatingToCleared;
        return;
    case stateMoving:
        this.widgetView.clearAnimation();
        layoutParams = (LayoutParams) this.rootView.getLayoutParams();
        this.screenshotView = duplicateView(this.widgetView);
        this.screenshotView.setY((float) layoutParams.y);
        Log.d(TAG, "Setting widget view screenshot to Y position = " + layoutParams.y);
        addToFullscreenView(this.screenshotView);
        this.widgetView.animate().alpha(0.0f).setDuration(0).setStartDelay(100);
        this.screenshotView.animate().scaleX(RELOCATE_WINDOW_SCALE).scaleY(RELOCATE_WINDOW_SCALE)
                .setDuration(200).withEndAction(new Runnable() {
                    public void run() {
                        LockScreenWidget.this.currentState = WidgetState.stateMoving;
                    }
                });
        this.screenshotView.performHapticFeedback(3, 2);
        this.currentState = WidgetState.stateInterpolatingToMoving;
        return;
    case stateStopMoving:
        WindowManager windowManager = (WindowManager) this.context.getSystemService("window");
        layoutParams = (LayoutParams) this.rootView.getLayoutParams();
        layoutParams.y = (int) this.screenshotView.getY();
        windowManager.updateViewLayout(this.rootView, layoutParams);
        this.screenshotView.setScaleY(RELOCATE_WINDOW_SCALE);
        this.screenshotView.setScaleX(RELOCATE_WINDOW_SCALE);
        this.screenshotView.animate().scaleY(DefaultRetryPolicy.DEFAULT_BACKOFF_MULT)
                .scaleX(DefaultRetryPolicy.DEFAULT_BACKOFF_MULT).setDuration(200).withEndAction(new Runnable() {
                    public void run() {
                        LockScreenWidget.this.widgetView.animate()
                                .alpha(DefaultRetryPolicy.DEFAULT_BACKOFF_MULT).setDuration(0)
                                .withEndAction(new Runnable() {
                                    public void run() {
                                        LockScreenWidget.this.clearFullscreenView();
                                        LockScreenWidget.this.screenshotView = null;
                                        LockScreenWidget.this.currentState = WidgetState.stateShown;
                                    }
                                });
                    }
                });
        ((Settings) GuiceModule.get().getInstance(Settings.class))
                .updateLockscreenWidgetY(this.screenshotView.getY());
        this.currentState = WidgetState.stateInterpolatingToStopMoving;
        Log.d(TAG, "Restoring widget view at Y position = " + layoutParams.y + " with height = "
                + layoutParams.height);
        return;
    case stateHidden:
        enableTouchOnRootView(false);
        this.widgetView.clearAnimation();
        this.widgetView.animate().alpha(0.0f).setDuration(200).setInterpolator(new AccelerateInterpolator())
                .withEndAction(new Runnable() {
                    public void run() {
                        LockScreenWidget.this.enableTouchOnRootView(false);
                        LockScreenWidget.this.currentState = WidgetState.stateHidden;
                    }
                });
        this.currentState = WidgetState.stateInterpolatingToHidden;
        return;
    case stateTerminated:
        enableTouchOnRootView(false);
        this.widgetView.clearAnimation();
        this.fullscreenView.clearAnimation();
        if (this.unlockToContinueView != null) {
            this.unlockToContinueView.clearAnimation();
            this.unlockToContinueView.animate().alpha(0.0f).setDuration(200)
                    .setInterpolator(new AccelerateInterpolator());
        }
        this.widgetView.animate().alpha(0.0f).setDuration(200).setInterpolator(new AccelerateInterpolator())
                .withEndAction(new Runnable() {
                    public void run() {
                        WindowManager wm = (WindowManager) LockScreenWidget.this.context
                                .getSystemService("window");
                        try {
                            wm.removeView(LockScreenWidget.this.fullscreenView);
                        } catch (Exception e) {
                        }
                        try {
                            wm.removeView(LockScreenWidget.this.rootView);
                        } catch (Exception e2) {
                        }
                        LockScreenWidget.this.widgetView = null;
                        LockScreenWidget.this.screenshotView = null;
                        LockScreenWidget.this.unlockToContinueView = null;
                        LockScreenWidget.this.fullscreenView = null;
                        LockScreenWidget.this.rootView = null;
                        LockScreenWidget.this.context = null;
                        LockScreenWidget.this.currentState = WidgetState.stateTerminated;
                    }
                });
        this.currentState = WidgetState.stateInterpolatingToTerminated;
        return;
    default:
        return;
    }
}

From source file:android.support.v7.app.AppCompatDelegateImplV7.java

private void closePanel(PanelFeatureState st, boolean doCallback) {
    if (doCallback && st.featureId == FEATURE_OPTIONS_PANEL && mDecorContentParent != null
            && mDecorContentParent.isOverflowMenuShowing()) {
        checkCloseActionMenu(st.menu);/*from w ww . j a v a  2s  . c om*/
        return;
    }

    final boolean wasOpen = st.isOpen;

    final WindowManager wm = (WindowManager) mContext.getSystemService(Context.WINDOW_SERVICE);
    if (wm != null && wasOpen && st.decorView != null) {
        wm.removeView(st.decorView);
    }

    st.isPrepared = false;
    st.isHandled = false;
    st.isOpen = false;

    if (wasOpen && doCallback) {
        // If the panel was open and we should callback, do so. This should be done after
        // isOpen is updated to ensure that we do not get into an infinite recursion
        callOnPanelClosed(st.featureId, st, null);
    }

    // This view is no longer shown, so null it out
    st.shownPanelView = null;

    // Next time the menu opens, it should not be in expanded mode, so
    // force a refresh of the decor
    st.refreshDecorView = true;

    if (mPreparedPanel == st) {
        mPreparedPanel = null;
    }
}

From source file:android.support.v7ox.app.AppCompatDelegateImplV7.java

private void closePanel(PanelFeatureState st, boolean doCallback) {
    if (doCallback && st.featureId == FEATURE_OPTIONS_PANEL && mDecorContentParent != null
            && mDecorContentParent.isOverflowMenuShowing()) {
        checkCloseActionMenu(st.menu);//from   w  w w. j a v  a  2 s  .  c  o m
        return;
    }

    final WindowManager wm = (WindowManager) mContext.getSystemService(Context.WINDOW_SERVICE);
    if (wm != null && st.isOpen && st.decorView != null) {
        wm.removeView(st.decorView);

        if (doCallback) {
            callOnPanelClosed(st.featureId, st, null);
        }
    }

    st.isPrepared = false;
    st.isHandled = false;
    st.isOpen = false;

    // This view is no longer shown, so null it out
    st.shownPanelView = null;

    // Next time the menu opens, it should not be in expanded mode, so
    // force a refresh of the decor
    st.refreshDecorView = true;

    if (mPreparedPanel == st) {
        mPreparedPanel = null;
    }
}