Example usage for android.widget FrameLayout removeView

List of usage examples for android.widget FrameLayout removeView

Introduction

In this page you can find the example usage for android.widget FrameLayout removeView.

Prototype

@Override
public void removeView(View view) 

Source Link

Document

Note: do not invoke this method from #draw(android.graphics.Canvas) , #onDraw(android.graphics.Canvas) , #dispatchDraw(android.graphics.Canvas) or any related method.

Usage

From source file:com.community.yuequ.bottombar.BottomBarBadge.java

void removeFromTab(BottomBarTab tab) {
    FrameLayout badgeAndTabContainer = (FrameLayout) getParent();
    ViewGroup originalTabContainer = (ViewGroup) badgeAndTabContainer.getParent();

    badgeAndTabContainer.removeView(tab);
    originalTabContainer.removeView(badgeAndTabContainer);
    originalTabContainer.addView(tab, tab.getIndexInTabContainer());
}

From source file:org.chromium.content_shell.Shell.java

/**
 * Set the SurfaceView being renderered to as soon as it is available.
 *//*  w  w  w  .  j  av a 2 s .  co  m*/
public void setContentViewRenderView(ContentViewRenderView contentViewRenderView) {
    FrameLayout contentViewHolder = (FrameLayout) findViewById(R.id.contentview_holder);
    if (contentViewRenderView == null) {
        if (mContentViewRenderView != null) {
            contentViewHolder.removeView(mContentViewRenderView);
        }
    } else {
        contentViewHolder.addView(contentViewRenderView, new FrameLayout.LayoutParams(
                FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT));
    }
    mContentViewRenderView = contentViewRenderView;
}

From source file:pum.android.project.tools.displayingbitmaps.ImageWorker.java

/**
 * Called when the processing is complete and the final drawable should be
 * set on the ImageView.//from ww w . ja va2s . c  om
 *
 * @param imageView
 * @param drawable
 */
private void setImageDrawable(ImageView imageView, Drawable drawable) {
    try {
        ViewGroup viewGroup = (ViewGroup) imageView.getParent();
        if (viewGroup instanceof FrameLayout) {
            FrameLayout parent = (FrameLayout) viewGroup;
            View view;
            if ((view = parent.getChildAt(1)) instanceof ProgressBar)
                parent.removeView(view);
        }
    } catch (Exception e) {
        Log.e(getClass().getSimpleName(), "onPostExecute, progressBar not found", e);
    }

    if (mFadeInBitmap) {
        // Transition drawable with a transparent drawable and the final drawable
        final TransitionDrawable td = new TransitionDrawable(
                new Drawable[] { new ColorDrawable(android.R.color.transparent), drawable });
        // Set background to loading bitmap
        imageView.setBackgroundDrawable(new BitmapDrawable(mResources, mLoadingBitmap));

        imageView.setImageDrawable(td);
        td.startTransition(FADE_IN_TIME);
    } else {
        imageView.setImageDrawable(drawable);
    }
}

From source file:kuta.adrian.cv.displayingbitmaps.ImageWorker.java

/**
 * Called when the processing is complete and the final drawable should be
 * set on the ImageView.//from w w w.  ja v  a  2  s  . com
 *
 * @param imageView
 * @param drawable
 */
private void setImageDrawable(ImageView imageView, Drawable drawable) {
    try {
        ViewGroup viewGroup = (ViewGroup) imageView.getParent();
        if (viewGroup instanceof FrameLayout) {
            FrameLayout parent = (FrameLayout) viewGroup;
            View view;
            if ((view = parent.getChildAt(0)) instanceof ProgressBar)
                parent.removeView(view);
        }
    } catch (Exception e) {
        Log.e(getClass().getSimpleName(), "onPostExecute, progressBar not found", e);
    }

    if (mFadeInBitmap) {
        // Transition drawable with a transparent drawable and the final drawable
        final TransitionDrawable td = new TransitionDrawable(new Drawable[] {
                new ColorDrawable(ContextCompat.getColor(imageView.getContext(), android.R.color.transparent)),
                drawable });
        // Set background to loading bitmap
        if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN)
            imageView.setBackgroundDrawable(new BitmapDrawable(mResources, mLoadingBitmap));
        else
            imageView.setBackground(new BitmapDrawable(mResources, mLoadingBitmap));

        imageView.setImageDrawable(td);
        td.startTransition(FADE_IN_TIME);
    } else {
        imageView.setImageDrawable(drawable);
    }
}

From source file:org.godotengine.godot.AdMob.java

public void createBanner() {
    if (AdMobConfig == null) {
        return;/*from  ww  w.  ja  va2 s.c  om*/
    }

    FrameLayout layout = ((Godot) activity).layout; // Getting Godots framelayout
    FrameLayout.LayoutParams AdParams = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT,
            FrameLayout.LayoutParams.WRAP_CONTENT);

    if (mAdView != null) {
        layout.removeView(mAdView);
    }

    if (AdMobConfig.optString("BannetGravity", "BOTTOM").equals("BOTTOM")) {
        AdParams.gravity = Gravity.BOTTOM;
    } else {
        AdParams.gravity = Gravity.TOP;
    }

    AdRequest.Builder adRequestB = new AdRequest.Builder();
    adRequestB.tagForChildDirectedTreatment(true);

    if (BuildConfig.DEBUG) {
        adRequestB.addTestDevice(AdRequest.DEVICE_ID_EMULATOR);
        adRequestB.addTestDevice(Utils.getDeviceId(activity));
    }

    AdRequest adRequest = adRequestB.build();

    String ad_unit_id = AdMobConfig.optString("BannerAdId", "");

    if (ad_unit_id.length() <= 0) {
        Utils.d("AdMob:Banner:UnitId:NotProvided");
        ad_unit_id = activity.getString(R.string.banner_ad_unit_id);
    }

    mAdView = new AdView(activity);
    mAdView.setBackgroundColor(Color.TRANSPARENT);
    mAdView.setAdUnitId(ad_unit_id);
    mAdView.setAdSize(AdSize.SMART_BANNER);

    mAdView.setAdListener(new AdListener() {
        @Override
        public void onAdLoaded() {
            Utils.d("AdMob:Banner:OnAdLoaded");
            Utils.callScriptFunc("AdMob_Banner", "loaded");
        }

        @Override
        public void onAdFailedToLoad(int errorCode) {
            Utils.w("AdMob:Banner:onAdFailedToLoad:" + errorCode);
            Utils.callScriptFunc("AdMob_Banner", "load_failed");
        }
    });

    mAdView.setVisibility(View.INVISIBLE);
    mAdView.loadAd(adRequest);

    layout.addView(mAdView, AdParams);
}

From source file:fr.tvbarthel.attempt.googlyzooapp.MainActivity.java

@Override
public void onPreviewReleased(FrameLayout preview) {
    preview.removeView(mRoundedOverlay);
    preview.removeView(mCameraInstructions);
    preview.removeView(mCapturePreview);
    preview.removeView(mSaveButton);//from   w w w.  java2s .c o  m
    preview.removeView(mShareButton);
}

From source file:de.mrapp.android.preference.activity.PreferenceFragment.java

/**
 * Initializes the list view, which is used to show the fragment's preferences.
 *//*from  ww  w .j  a v  a  2  s .  com*/
private void initializeListView() {
    listView = (ListView) parentView.findViewById(android.R.id.list);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
        FrameLayout listContainer = (FrameLayout) parentView.findViewById(android.R.id.list_container);
        listContainer.removeView(listView);
    } else {
        parentView.removeView(listView);
    }

    frameLayout = new FrameLayout(getActivity());
    frameLayout.setId(R.id.preference_fragment_frame_layout);
    parentView.addView(frameLayout, listView.getLayoutParams());
    frameLayout.addView(listView, FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT);
    int paddingTop = getResources().getDimensionPixelSize(R.dimen.list_view_padding_top);
    listView.setPadding(0, paddingTop, 0, 0);
}

From source file:com.vidinoti.pixlive.PixLive.java

protected void pluginInitialize() {

    startSDK(cordova.getActivity());//from  w  w  w. j ava  2s . c o  m

    VDARSDKController.getInstance().setEnableCodesRecognition(true);

    VDARSDKController.getInstance().setActivity(cordova.getActivity());
    VDARSDKController.getInstance().registerEventReceiver(this);

    VDARSDKController.getInstance().addNewAfterLoadingTask(new Runnable() {
        @Override
        public void run() {

            Intent intent = cordova.getActivity().getIntent();

            if (intent != null && intent.getExtras() != null && intent.getExtras().getString("nid") != null) {

                VDARSDKController.getInstance().processNotification(intent.getExtras().getString("nid"),
                        intent.getExtras().getBoolean("remote"));
            }
        }
    });

    cordova.getActivity().runOnUiThread(new Runnable() {
        public void run() {
            if (touchView == null) {
                View v = webView.getView();

                FrameLayout parent = ((FrameLayout) v.getParent());
                parent.removeView(v);

                touchView = new TouchInterceptorView(cordova.getActivity());

                touchView.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
                        ViewGroup.LayoutParams.MATCH_PARENT));

                cordova.getActivity().setContentView(touchView);

                touchView.addView(v);

                v.setBackgroundColor(Color.TRANSPARENT);
            }
        }
    });
}

From source file:de.madvertise.android.sdk.MadvertiseMraidView.java

public MadvertiseMraidView(Context context) {
    super(context);
    setVerticalScrollBarEnabled(false);/*  www  . j  a va2s . c  o m*/
    setHorizontalScrollBarEnabled(false);
    setScrollBarStyle(WebView.SCROLLBARS_OUTSIDE_OVERLAY);
    setBackgroundColor(Color.TRANSPARENT);
    WebSettings settings = getSettings();
    settings.setCacheMode(WebSettings.LOAD_CACHE_ELSE_NETWORK);
    settings.setJavaScriptEnabled(true);
    //settings.setPluginsEnabled(true);

    // Initialize the default expand properties.
    DisplayMetrics metrics = getContext().getResources().getDisplayMetrics();
    mExpandProperties = new ExpandProperties(metrics.widthPixels, metrics.heightPixels);
    MadvertiseUtil.logMessage(null, Log.INFO,
            "Setting default expandProperties : " + mExpandProperties.toJson().toString());

    // This bridge stays available until this view is destroyed, hence no
    // reloading when displaying new ads is necessary.
    addJavascriptInterface(mBridge, "mraid_bridge");

    setWebViewClient(new WebViewClient() {
        private boolean mError = false;

        @Override
        public boolean shouldOverrideUrlLoading(WebView view, final String url) {
            post(new Runnable() {
                @Override
                public void run() {
                    if (mListener != null) {
                        mListener.onAdClicked();
                    }
                    final Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url),
                            getContext().getApplicationContext(), MadvertiseActivity.class);
                    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                    getContext().startActivity(intent);
                }
            });
            return true;
        }

        @Override
        public void onPageFinished(WebView view, String url) {
            super.onPageFinished(view, url);
            if (!url.endsWith("mraid.js") && !mError) {
                MadvertiseUtil.logMessage(null, Log.DEBUG, "Setting mraid to default");
                checkReady();

                // Close button in default size for interstitial ads
                if (mPlacementType == MadvertiseUtil.PLACEMENT_TYPE_INTERSTITIAL) {
                    mCloseButton = addCloseButtonToViewGroup(((ViewGroup) getParent()));
                    mCloseButton.setImageResource(android.R.drawable.ic_menu_close_clear_cancel);
                }
            }
        }

        @Override
        public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
            super.onReceivedError(view, errorCode, description, failingUrl);
            mError = true;
        }
    });

    // Comment this in to enable video tag-capability.
    this.setWebChromeClient(new WebChromeClient() {

        @Override
        public void onShowCustomView(View view, CustomViewCallback callback) {
            MadvertiseUtil.logMessage(null, Log.INFO, "showing VideoView");
            super.onShowCustomView(view, callback);
            if (view instanceof FrameLayout) {
                FrameLayout frame = (FrameLayout) view;
                if (frame.getFocusedChild() instanceof VideoView) {
                    mVideo = (VideoView) ((FrameLayout) view).getFocusedChild();
                    frame.removeView(mVideo);
                    ((ViewGroup) getParent()).addView(mVideo);

                    // Will also be called onError
                    mVideo.setOnCompletionListener(new OnCompletionListener() {

                        @Override
                        public void onCompletion(MediaPlayer player) {
                            player.stop();
                        }
                    });

                    mVideo.setOnErrorListener(new OnErrorListener() {

                        @Override
                        public boolean onError(MediaPlayer mp, int what, int extra) {
                            MadvertiseUtil.logMessage(null, Log.WARN, "Error while playing video");

                            if (mListener != null) {
                                mListener.onError(new IOException("Error while playing video"));
                            }

                            // We return false in order to call
                            // onCompletion()
                            return false;
                        }
                    });

                    mVideo.start();
                }
            }
        }

        @Override
        public void onHideCustomView() {
            if (mVideo != null) {
                ((ViewGroup) getParent()).removeView(mVideo);
                if (mVideo.isPlaying()) {
                    mVideo.stopPlayback();
                }
            }
        }
    });
}

From source file:com.sabaibrowser.UI.java

private void hideCustomView() {
    FrameLayout decor = (FrameLayout) mActivity.getWindow().getDecorView();
    decor.removeView(mFullscreenContainer);
    mFullscreenContainer = null;/*from   w  ww  .j av  a 2s .co  m*/
    mCustomView = null;
    // Show the content view.
    mActivity.setRequestedOrientation(mOriginalOrientation);
}