Example usage for android.view WindowManager removeViewImmediate

List of usage examples for android.view WindowManager removeViewImmediate

Introduction

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

Prototype

public void removeViewImmediate(View view);

Source Link

Document

Special variation of #removeView that immediately invokes the given view hierarchy's View#onDetachedFromWindow() View.onDetachedFromWindow() methods before returning.

Usage

From source file:com.readystatesoftware.ghostlog.ServerlessLogScreen.java

private void removeSystemWindow(Activity activity, ListView listView) {
    if (listView != null && listView.getParent() != null) {
        final WindowManager wm = activity.getWindowManager();
        wm.removeViewImmediate(listView);
    }//from   w  ww  .  j av a2s  .c  o m
}

From source file:com.flyingcrop.ScreenCaptureFragment.java

public void saveImage() {
    if (mMediaProjection != null) {

        final Notification.Builder builder = new Notification.Builder(getActivity())
                .setContentTitle(getResources().getString(R.string.fragment_saving_crop))
                .setContentText(getResources().getString(R.string.fragment_wait))
                .setSmallIcon(com.flyingcrop.R.drawable.ab_ico);

        final NotificationManager notificationManager = (NotificationManager) getActivity()
                .getSystemService(Context.NOTIFICATION_SERVICE);

        notificationManager.notify(1, builder.build());

        STORE_DIRECTORY = storage;//from   www  .  j a  v  a 2 s  .c  om

        int flags = DisplayManager.VIRTUAL_DISPLAY_FLAG_OWN_CONTENT_ONLY
                | DisplayManager.VIRTUAL_DISPLAY_FLAG_PUBLIC;

        mImageReader = ImageReader.newInstance(mWidth, mHeight, PixelFormat.RGBA_8888, 2);
        mMediaProjection.createVirtualDisplay("screencap", mWidth, mHeight, mScreenDensity, flags,
                mImageReader.getSurface(), new VirtualDisplayCallback(), mHandler);
        if (ServiceIsRunning()) {
            Intent mIntent = new Intent(getActivity(), Brush.class);
            getActivity().bindService(mIntent, mConnection, Context.BIND_AUTO_CREATE);
        }

        mImageReader.setOnImageAvailableListener(new ImageReader.OnImageAvailableListener() {

            @Override
            public void onImageAvailable(ImageReader reader) {

                image_available = true;

                Log.d("teste", "image_available : " + image_available.toString());

                try {

                    final long time_now = System.currentTimeMillis();
                    image = mImageReader.acquireLatestImage();

                    Log.i(TAG, "Time 1 " + (System.currentTimeMillis() - time_now));

                    if (image != null) {

                        if (ServiceIsRunning()) {
                            if (loop == 0) {
                                View v = mServer.getView();
                                WindowManager wm = mServer.getWindowM();
                                if (v != null)
                                    wm.removeViewImmediate(v);
                                else
                                    mServer.removeAllView();

                            }
                            loop++;
                        }

                        if (!isFolder()) {
                            Notification.Builder builder = new Notification.Builder(getActivity())
                                    .setContentTitle(getResources().getString(R.string.fragment_error))
                                    .setContentText(getResources().getString(R.string.fragment_error_access))
                                    .setSmallIcon(com.flyingcrop.R.drawable.ab_ico);
                            Toast.makeText(getActivity(),
                                    getResources().getString(R.string.fragment_error_toast), Toast.LENGTH_SHORT)
                                    .show();

                            NotificationManager notificationManager = (NotificationManager) getActivity()
                                    .getSystemService(Context.NOTIFICATION_SERVICE);

                            notificationManager.notify(1, builder.build());

                            getActivity().finish();
                        }

                        savePlanes();

                    }

                } catch (Exception e) {
                    e.printStackTrace();
                } finally {
                    if (fos != null) {
                        try {
                            fos.close();
                        } catch (IOException ioe) {
                            ioe.printStackTrace();
                        }
                    }

                    if (bitmap != null) {
                        bitmap.recycle();
                    }

                    if (image != null) {
                        image.close();
                    }
                }
            }

        }, null);
    }
}

From source file:com.example.accessibility.OverlayManager.java

void destroyFeedbackClickView(Context context) {
    WindowManager wm = (WindowManager) getSystemService(WINDOW_SERVICE);

    if (mLV != null) {
        wm.removeViewImmediate(mFCV);
        mFCV = null;//from   w  ww  .  j av  a 2s .  c  o  m
        Log.i("prints", "end of destroyFeedbackClickView");
    }
}

From source file:com.example.accessibility.OverlayManager.java

void destroyOverlayView(Context context) {
    WindowManager wm = (WindowManager) getSystemService(WINDOW_SERVICE);

    if (mLV != null) {
        wm.removeViewImmediate(mLV);
        mLV = null;//from w  w  w.  j  a va 2  s  .c o  m
        Log.i("prints", "end of destroyOverlayView");
    }
}

From source file:kr.wdream.ui.PhotoViewer.java

public void destroyPhotoViewer() {
    if (parentActivity == null || windowView == null) {
        return;/*www  . ja  va 2s.co  m*/
    }
    releasePlayer();
    try {
        if (windowView.getParent() != null) {
            WindowManager wm = (WindowManager) parentActivity.getSystemService(Context.WINDOW_SERVICE);
            wm.removeViewImmediate(windowView);
        }
        windowView = null;
    } catch (Exception e) {
        FileLog.e("tmessages", e);
    }
    if (captionEditText != null) {
        captionEditText.onDestroy();
    }
    Instance = null;
}

From source file:org.telegram.ui.ArticleViewer.java

public void destroyArticleViewer() {
    if (parentActivity == null || windowView == null) {
        return;//from   www  . j  av  a  2  s .  co  m
    }
    releasePlayer();
    try {
        if (windowView.getParent() != null) {
            WindowManager wm = (WindowManager) parentActivity.getSystemService(Context.WINDOW_SERVICE);
            wm.removeViewImmediate(windowView);
        }
        windowView = null;
    } catch (Exception e) {
        FileLog.e(e);
    }
    for (int a = 0; a < createdWebViews.size(); a++) {
        BlockEmbedCell cell = createdWebViews.get(a);
        cell.destroyWebView(true);
    }
    createdWebViews.clear();
    try {
        parentActivity.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
    } catch (Exception e) {
        FileLog.e(e);
    }
    Instance = null;
}