Example usage for android.widget RelativeLayout removeView

List of usage examples for android.widget RelativeLayout removeView

Introduction

In this page you can find the example usage for android.widget RelativeLayout 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.breadwallet.tools.animation.BRAnimator.java

public static void showCopyBubble(final Activity context, final View v, final View t) {
    try {//w  w w. j  av  a 2  s. c  o m
        if (context == null)
            return;
        if (v != null)
            v.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    if (copy == null)
                        copy = context.getLayoutInflater().inflate(R.layout.copy, null);
                    if (copy == null)
                        return;
                    final RelativeLayout root = (RelativeLayout) context.findViewById(R.id.main_layout);
                    root.removeView(copy);
                    copy.setClickable(true);
                    copy.setOnClickListener(new View.OnClickListener() {
                        @Override
                        public void onClick(View view) {
                            try {
                                if (t != null) {
                                    BRClipboardManager.copyToClipboard(context,
                                            ((TextView) t).getText().toString());
                                    Log.e(TAG, "clicked copy: " + ((TextView) t).getText().toString());
                                }
                                hideCopyBubble(context);
                            } catch (Exception e) {
                                e.printStackTrace();
                            }
                        }
                    });
                    root.addView(copy);
                    copy.setY(getRelativeTop(v));
                    copy.setX(MainActivity.screenParametersPoint.x / 2 - 40);
                }
            });
        if (t != null)
            t.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    View parent = (View) t.getParent();
                    if (parent != null)
                        parent.performClick();
                }
            });
    } catch (Exception e) {
        e.printStackTrace();
    }

}

From source file:com.breadwallet.tools.animation.BRAnimator.java

public static void hideCopyBubble(final Activity context) {
    try {/*from  w  ww.  j a  v a2  s  .com*/
        if (context == null)
            return;
        if (copy == null)
            return;
        final RelativeLayout root = (RelativeLayout) context.findViewById(R.id.main_layout);
        if (copy.getVisibility() == View.VISIBLE) {
            Animation animation = new AlphaAnimation(1f, 0f);
            animation.setDuration(150);
            animation.setAnimationListener(new Animation.AnimationListener() {
                @Override
                public void onAnimationStart(Animation animation) {

                }

                @Override
                public void onAnimationEnd(Animation animation) {
                    root.removeView(copy);
                }

                @Override
                public void onAnimationRepeat(Animation animation) {

                }
            });
            copy.startAnimation(animation);
        }

    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:com.cranberrygame.cordova.plugin.ad.admob.Util.java

protected void removeBannerViewOverlap() {
    if (bannerView == null)
        return;//from w ww .  j a  v  a  2  s.  c o  m

    RelativeLayout bannerViewLayout = (RelativeLayout) bannerView.getParent();
    if (bannerViewLayout != null) {
        bannerViewLayout.removeView(bannerView);
        bannerView.destroy();
        bannerView = null;
    }
}

From source file:com.primalpond.hunt.TheHunt.java

private void returnFromTutorial() {
    mInTutorial = false;/*  w  w  w. j a v a 2s . c  o m*/

    mGLView.onPause();
    final RelativeLayout rootLayout = (RelativeLayout) findViewById(R.id.root_layout);
    Handler handler = new Handler();
    class RefreshRunnable implements Runnable {

        public RefreshRunnable() {

        }

        public void run() {
            rootLayout.removeView(findViewById(R.id.glSurfaceView));

            D3GLSurfaceView surfaceview = new D3GLSurfaceView(getApplication(), null,
                    new TheHuntRenderer(TheHunt.this));
            surfaceview.setId(R.id.glSurfaceView);
            rootLayout.addView(surfaceview);

            mGLView = (D3GLSurfaceView) findViewById(R.id.glSurfaceView);

            View actionBarPart = findViewById(R.id.actionBarPart);
            actionBarPart.bringToFront();

            mGLView.mRenderer.setActivity(TheHunt.this);
            MyApplication.setFirstRun(false);
        }
    }
    ;

    RefreshRunnable r = new RefreshRunnable();
    handler.postDelayed(r, 500);
}

From source file:com.primalpond.hunt.TheHunt.java

private void beginTutorial() {
    mInTutorial = true;/*  w ww .ja  v  a 2s.  com*/

    if (mGLView != null) {
        mGLView.onPause();
    }
    final RelativeLayout rootLayout = (RelativeLayout) findViewById(R.id.root_layout);
    Handler handler = new Handler();
    class RefreshRunnable implements Runnable {

        public RefreshRunnable() {

        }

        public void run() {
            rootLayout.removeView(findViewById(R.id.glSurfaceView));

            D3GLSurfaceView surfaceview = new D3GLSurfaceView(getApplication(), null,
                    new TutorialRenderer(TheHunt.this));
            surfaceview.setId(R.id.glSurfaceView);
            rootLayout.addView(surfaceview);

            View actionBarPart = findViewById(R.id.actionBarPart);
            actionBarPart.bringToFront();

            mGLView = (D3GLSurfaceView) findViewById(R.id.glSurfaceView);

            FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
            mTutorialFragment = new TutorialFragment();
            ft.add(R.id.root_layout, mTutorialFragment);
            ft.commit();
            mGLView.mRenderer.setActivity(TheHunt.this);
            onToHideNavigation();
        }
    }
    ;

    RefreshRunnable r = new RefreshRunnable();
    handler.postDelayed(r, 500);
}

From source file:com.cranberrygame.cordova.plugin.ad.admob.Util.java

private void _preloadBannerAd_overlap() {
    if (bannerViewLayout == null) {
        bannerViewLayout = new RelativeLayout(cordova.getActivity());//   
        RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(
                RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT);
        //webView.addView(bannerViewLayout, params);
        bannerViewLayout.setLayoutParams(params);
        //webView.addView(bannerViewLayout);//cordova5 build error
        ((ViewGroup) getView(webView)).addView(bannerViewLayout);
    }// ww w  . ja  va 2s . c  o m

    if (bannerView != null) {
        //if banner is showing
        RelativeLayout bannerViewLayout = (RelativeLayout) bannerView.getParent();
        if (bannerViewLayout != null) {
            bannerViewLayout.removeView(bannerView);
            bannerView.destroy();
            bannerView = null;
        }
    }
}

From source file:com.cranberrygame.cordova.plugin.ad.admob.Util.java

private void _hideBannerAd_overlap() {
    if (bannerView != null) {
        //if banner is showing
        RelativeLayout bannerViewLayout = (RelativeLayout) bannerView.getParent();
        if (bannerViewLayout != null) {
            bannerViewLayout.removeView(bannerView);
            bannerView.destroy();//from   w ww. j ava 2s  . com
            bannerView = null;
        }
    }
}

From source file:com.cranberrygame.cordova.plugin.ad.admob.Util.java

private void _preloadBannerAd_overlap() {
    if (bannerViewLayout == null) {
        bannerViewLayout = new RelativeLayout(cordova.getActivity());//   
        RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(
                RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT);
        //webView.addView(bannerViewLayout, params);
        bannerViewLayout.setLayoutParams(params);
        webView.addView(bannerViewLayout);
    }//  w  w w  .  jav a2  s .  co  m

    if (bannerView != null) {
        //if banner is showing
        RelativeLayout bannerViewLayout = (RelativeLayout) bannerView.getParent();
        if (bannerViewLayout != null) {
            bannerViewLayout.removeView(bannerView);
            bannerView.destroy();
            bannerView = null;
        }
    }
}

From source file:com.cranberrygame.cordova.plugin.ad.revmob.Util.java

protected void removeBannerViewOverlap() {
    if (bannerView == null)
        return;//from  www .  j  a  v  a 2s. co  m

    RelativeLayout bannerViewLayout = (RelativeLayout) bannerView.getParent();
    if (bannerViewLayout != null) {
        bannerViewLayout.removeView(bannerView);
        //bannerView.destroy();//revmob build error
        bannerView = null;
    }
}

From source file:de.mkrtchyan.recoverytools.RecoveryTools.java

public void optimizeLayout() throws NullPointerException {

    try {//from ww  w .  ja  v  a2  s . co  m
        if (mDevice.isRecoverySupported() || mDevice.isKernelSupported()) {
            /** If device is supported start setting up layout */
            if (getIntent().getAction().equals(Intent.ACTION_VIEW)) {
                /** Setting layout for flashing over external App for example File Browser */
                setContentView(R.layout.flash_as);
                RelativeLayout FlashAsLayout = (RelativeLayout) findViewById(R.layout.flash_as);
                String path;
                if ((path = getIntent().getData().getPath()) != null) {
                    final File IMG = new File(path);
                    if (IMG.exists()) {
                        TextView tvFlashAs = (TextView) findViewById(R.id.tvFlashAs);
                        tvFlashAs.setText(String.format(getString(R.string.flash_as), IMG.getName()));
                    } else {
                        exit();
                    }
                    RadioButton optAsRecovery = (RadioButton) findViewById(R.id.optAsRecovery);
                    RadioButton optAsKernel = (RadioButton) findViewById(R.id.optAsKernel);

                    if (!mDevice.isRecoverySupported()) {
                        FlashAsLayout.removeView(optAsRecovery);
                        optAsKernel.setChecked(true);
                    }
                    if (!mDevice.isKernelSupported()) {
                        FlashAsLayout.removeView((optAsKernel));
                    }
                } else {
                    exit();
                }
            } else {
                setContentView(R.layout.recovery_tools);

                mRecoveryToolsLayout = (DrawerLayout) findViewById(R.id.RecoveryToolsLayout);
                mSwipeUpdater = (SwipeRefreshLayout) findViewById(R.id.swipe_updater);
                mSwipeUpdater.setColorScheme(R.color.custom_green, android.R.color.black, R.color.custom_green,
                        android.R.color.darker_gray);
                mSwipeUpdater.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
                    @Override
                    public void onRefresh() {
                        Downloader updater = new Downloader(mContext, "http://dslnexus.de/Android/", "img_sums",
                                RecoveryCollectionFile, new Runnable() {
                                    @Override
                                    public void run() {
                                        mDevice = new Device(mContext);
                                    }
                                });
                        updater.setOverrideFile(true);
                        updater.setRetry(true);
                        updater.setHidden(true);
                        Toast.makeText(mContext, "Refreshing recovery list", Toast.LENGTH_SHORT).show();
                        updater.setAfterDownload(new Runnable() {
                            @Override
                            public void run() {
                                mSwipeUpdater.setRefreshing(false);
                                Toast.makeText(mContext, "Update finished", Toast.LENGTH_SHORT).show();
                                mDevice.loadRecoveryList();
                            }
                        });
                        updater.execute();
                    }
                });
                LayoutInflater layoutInflater = getLayoutInflater();

                DrawerLayout mMenuDrawer = (DrawerLayout) layoutInflater.inflate(R.layout.menu_drawer,
                        mRecoveryToolsLayout, true);
                DrawerLayout mBackupDrawer = (DrawerLayout) layoutInflater.inflate(R.layout.backup_drawer,
                        mRecoveryToolsLayout, true);
                mRecoveryToolsLayout.setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START);
                ActionBarDrawerToggle mDrawerToggle = new ActionBarDrawerToggle(mActivity, mRecoveryToolsLayout,
                        R.drawable.ic_drawer, R.string.settings, R.string.app_name);
                mRecoveryToolsLayout.setDrawerListener(mDrawerToggle);
                mDrawerToggle.syncState();
                mDrawerToggle.setDrawerIndicatorEnabled(true);
                getSupportActionBar().setDisplayHomeAsUpEnabled(true);
                getSupportActionBar().setHomeButtonEnabled(true);

                String Styles[] = getResources().getStringArray(R.array.styles);
                if (mMenuDrawer != null) {
                    Spinner spStyle = (Spinner) mMenuDrawer.findViewById(R.id.spStyle);
                    ArrayAdapter<String> adapter = new ArrayAdapter<String>(mActivity,
                            R.layout.custom_list_item, Styles);
                    adapter.setDropDownViewResource(R.layout.custom_list_item);

                    spStyle.setAdapter(adapter);
                    spStyle.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
                        @Override
                        public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
                            switch (position) {
                            case 1:
                                Common.setIntegerPref(mContext, PREF_NAME, PREF_STYLE,
                                        APPCOMPAT_LIGHT_DARK_BAR);
                                restartActivity();
                                break;
                            case 2:
                                Common.setIntegerPref(mContext, PREF_NAME, PREF_STYLE, APPCOMPAT_LIGHT);
                                restartActivity();
                                break;
                            case 3:
                                Common.setIntegerPref(mContext, PREF_NAME, PREF_STYLE, APPCOMPAT_DARK);
                                restartActivity();
                                break;
                            }
                        }

                        @Override
                        public void onNothingSelected(AdapterView<?> parent) {

                        }
                    });
                    CheckBox cbShowAds = (CheckBox) mMenuDrawer.findViewById(R.id.cbShowAds);
                    CheckBox cbLog = (CheckBox) mMenuDrawer.findViewById(R.id.cbLog);

                    cbShowAds.setChecked(Common.getBooleanPref(mContext, PREF_NAME, PREF_KEY_ADS));
                    cbLog.setChecked(Common.getBooleanPref(mContext, Shell.PREF_NAME, Shell.PREF_LOG));
                    if (cbLog.isChecked()) {
                        findViewById(R.id.bShowLogs).setVisibility(View.VISIBLE);
                    } else {
                        findViewById(R.id.bShowLogs).setVisibility(View.INVISIBLE);
                    }
                    cbShowAds.setChecked(Common.getBooleanPref(mContext, PREF_NAME, PREF_KEY_ADS));

                }

                final TextView RecoveryVersion = (TextView) findViewById(R.id.tvVersion);
                RecoveryVersion.setText(mDevice.getRecoveryVersion() + "\n" + mDevice.getKernelVersion());
                loadBackupDrawer();

                AdView adView = (AdView) findViewById(R.id.adView);
                ViewGroup MainParent = (ViewGroup) adView.getParent();
                /** Removing ads if user has turned off */
                if (!Common.getBooleanPref(mContext, PREF_NAME, PREF_KEY_ADS)) {
                    if (adView != null && MainParent != null) {
                        MainParent.removeView(adView);
                    }
                }

                if (MainParent != null) {
                    if (!mDevice.isKernelSupported()) {
                        /** If Kernel flashing is not supported remove flash options */
                        MainParent.removeView(findViewById(R.id.bFlashKernel));
                    }
                    if (!mDevice.isRecoverySupported()) {
                        /** If Recovery flashing is not supported remove flash options */
                        MainParent.removeView(findViewById(R.id.bFlashRecovery));
                    }
                }

                if (mBackupDrawer != null) {
                    ViewGroup BackupDrawerParent = (ViewGroup) mBackupDrawer.getParent();
                    if (mDevice.isRecoveryOverRecovery()) {
                        BackupDrawerParent.removeView(mBackupDrawer);
                    } else {
                        View createKernelBackup = findViewById(R.id.bCreateKernelBackup);
                        View kernelBackups = findViewById(R.id.lvKernelBackups);
                        View createRecoveryBackup = findViewById(R.id.bCreateRecoveryBackup);
                        View recoveryBackups = findViewById(R.id.lvRecoveryBackups);
                        if (!mDevice.isKernelSupported()) {
                            /** If Kernel flashing is not supported remove backup views */
                            ((ViewGroup) createKernelBackup.getParent()).removeView(createKernelBackup);
                            ((ViewGroup) kernelBackups.getParent()).removeView(kernelBackups);
                        }
                        if (!mDevice.isRecoverySupported()) {
                            /** If Recovery flashing is not supported remove backup views */
                            ((ViewGroup) createRecoveryBackup.getParent()).removeView(createRecoveryBackup);
                            ((ViewGroup) recoveryBackups.getParent()).removeView(recoveryBackups);
                        }
                    }
                }
            }
        }

    } catch (NullPointerException e) {
        throw new NullPointerException("Error while setting up Layout " + e.getMessage());
    }
}