Example usage for android.view ViewGroup removeView

List of usage examples for android.view ViewGroup removeView

Introduction

In this page you can find the example usage for android.view ViewGroup 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:jahirfiquitiva.iconshowcase.fragments.CreditsFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    context = getActivity();//from   w w  w  .j av a2  s .  c  om

    YOU_HAVE_WEBSITE = context.getResources().getBoolean(R.bool.you_have_a_website);

    libsLinks = context.getResources().getStringArray(R.array.libs_links);
    contributorsLinks = context.getResources().getStringArray(R.array.contributors_links);
    uiCollaboratorsLinks = context.getResources().getStringArray(R.array.ui_collaborators_links);
    designerLinks = context.getResources().getStringArray(R.array.iconpack_author_links);

    if (layout != null) {
        ViewGroup parent = (ViewGroup) layout.getParent();
        if (parent != null) {
            parent.removeView(layout);
        }
    }

    layout = (ViewGroup) inflater.inflate(R.layout.credits_section, container, false);

    setupViews(layout);

    ImageView designerBanner = (ImageView) layout.findViewById(R.id.designerHeader);
    Glide.with(context).load(Utils.getStringFromResources(context, R.string.iconpack_author_banner))
            .centerCrop().into(designerBanner);

    ImageView designerPhoto = (ImageView) layout.findViewById(R.id.designerPhoto);
    Glide.with(context).load(Utils.getStringFromResources(context, R.string.iconpack_author_photo))
            .into(designerPhoto);

    CardView sherryCV = (CardView) layout.findViewById(R.id.sherryCard);
    sherryCV.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            ISDialogs.showSherryDialog(context);
        }
    });

    CardView contributorsCV = (CardView) layout.findViewById(R.id.contributorsCard);
    contributorsCV.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            ISDialogs.showContributorsDialog(context, contributorsLinks);
        }
    });

    CardView uiCollabs = (CardView) layout.findViewById(R.id.uiDesignCard);
    uiCollabs.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            ISDialogs.showUICollaboratorsDialog(context, uiCollaboratorsLinks);
        }
    });

    CardView libsCard = (CardView) layout.findViewById(R.id.libsCard);
    libsCard.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            ISDialogs.showLibrariesDialog(context, libsLinks);
        }
    });

    CardView translators = (CardView) layout.findViewById(R.id.translatorsCard);
    translators.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            ISDialogs.showTranslatorsDialogs(context);
        }
    });

    return layout;
}

From source file:com.android.gallery3d.filtershow.category.MainPanel.java

@Override
public void onDestroyView() {
    super.onDestroyView();
    if (mMainView != null) {
        if (mMainView.getParent() != null) {
            ViewGroup parent = (ViewGroup) mMainView.getParent();
            parent.removeView(mMainView);
        }/* www  .ja v a2 s .c  om*/
    }
}

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

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View fragment = inflater.inflate(R.layout.fragment_flash_as, container, false);
    AppCompatTextView tvFlashAs = (AppCompatTextView) fragment.findViewById(R.id.tvFlashAs);
    tvFlashAs.setText(String.format(getString(R.string.flash_as), mImg.getName()));
    mOptAsRecovery = (RadioButton) fragment.findViewById(R.id.optAsRecovery);
    mOptAsKernel = (RadioButton) fragment.findViewById(R.id.optAsKernel);
    mButFlashAs = (AppCompatButton) fragment.findViewById(R.id.bFlashAs);
    final AppCompatButton ButCancel = (AppCompatButton) fragment.findViewById(R.id.bCancel);
    ButCancel.setOnClickListener(new View.OnClickListener() {
        @Override//from ww  w .j  a v a2  s.  c  o  m
        public void onClick(View v) {
            if (!mCloseApp) {
                new AlertDialog.Builder(mContext).setTitle(R.string.exit_app)
                        .setPositiveButton(R.string.positive, new DialogInterface.OnClickListener() {
                            @Override
                            public void onClick(DialogInterface dialog, int which) {
                                mActivity.finish();
                            }
                        }).setNegativeButton(R.string.negative, new DialogInterface.OnClickListener() {
                            @Override
                            public void onClick(DialogInterface dialog, int which) {
                                mActivity.switchTo(FlashFragment.newInstance(mActivity));
                            }
                        }).setCancelable(false).show();
            } else {
                mActivity.finish();
            }
        }
    });
    View.OnClickListener listener = new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            if (view.getTag().toString().equals("recovery")) {
                mOptAsKernel.setChecked(false);
            } else {
                mOptAsRecovery.setChecked(false);
            }
            mButFlashAs.setEnabled(true);
        }
    };
    mButFlashAs.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            if (mImg.exists()) {
                int job = mOptAsRecovery.isChecked() ? FlashUtil.JOB_FLASH_RECOVERY
                        : FlashUtil.JOB_FLASH_KERNEL;
                FlashUtil flashUtil = new FlashUtil(mActivity, mImg, job);
                flashUtil.setKeepAppOpen(false);
                flashUtil.execute();
            } else {
                mActivity.finish();
            }
        }
    });
    mOptAsRecovery.setOnClickListener(listener);
    mOptAsKernel.setOnClickListener(listener);
    ViewGroup parent;
    if (!mDevice.isRecoverySupported()) {
        if ((parent = (ViewGroup) mOptAsRecovery.getParent()) != null) {
            parent.removeView(mOptAsRecovery);
            mOptAsKernel.setChecked(true);
        }
    }
    if (!mDevice.isKernelSupported()) {
        if ((parent = (ViewGroup) mOptAsKernel.getParent()) != null) {
            parent.removeView((mOptAsKernel));
        }
    }
    return fragment;
}

From source file:com.demo.common.base.BaseNoToolBarFragment.java

@Nullable
@Override//from w  ww .  j a v a2 s. co m
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
        @Nullable Bundle savedInstanceState) {
    if (mContentView == null) {
        mContentView = inflater.inflate(getLayoutId(), container, false);
        ButterKnife.bind(this, mContentView);
        if (null != getLoadingTargetView()) {
            mController = new VaryViewHelperController(getLoadingTargetView());
        }
        initView(mContentView);
    } else {
        ViewGroup parent = (ViewGroup) mContentView.getParent();
        if (parent != null) {
            parent.removeView(mContentView);
        }
    }
    L.d(this.getClass().getName(), "onCreateView");
    return mContentView;
}

From source file:com.example.ibesteeth.git_keybordtest.emoji.KJEmojiFragment.java

@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
        @Nullable Bundle savedInstanceState) {
    if (null != mRootView) {
        ViewGroup parent = (ViewGroup) mRootView.getParent();
        if (null != parent) {
            parent.removeView(mRootView);
        }/*from www .  ja v a 2 s  .  com*/
    } else {
        mRootView = (LinearLayout) inflater.inflate(R.layout.frag_main, container, false);
        initWidget(mRootView);
    }
    return mRootView;
}

From source file:com.android.messaging.ui.FixedViewPagerAdapter.java

@Override
public void destroyItem(final ViewGroup container, final int position, final Object object) {
    final PagerViewHolder viewHolder = getViewHolder(position);
    final View destroyedView = viewHolder.destroyView();
    if (destroyedView != null) {
        container.removeView(destroyedView);
    }//from   www .j a v a 2s.  co m
}

From source file:com.actionbarsherlock.internal.view.menu.BaseMenuPresenter.java

/**
 * Add an item view at the given index./*from ww w  .j  a v  a 2s  .com*/
 *
 * @param itemView View to add
 * @param childIndex Index within the parent to insert at
 */
protected void addItemView(View itemView, int childIndex) {
    final ViewGroup currentParent = (ViewGroup) itemView.getParent();
    if (currentParent != null) {
        currentParent.removeView(itemView);
    }
    ((ViewGroup) mMenuView).addView(itemView, childIndex);
}

From source file:com.wms.opensource.ezchannel.activity.VideoListFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    if (layout != null) {
        // We need to remove layout from its parent first. Otherwise, adding layout to different viewgroup will result in error 
        ViewGroup parent = (ViewGroup) layout.getParent();
        parent.removeView(layout);
        return layout;
    }/*from  w w  w . j  a  v  a 2  s. co  m*/

    if (listView == null) {
        layout = new RelativeLayout(getActivity());
        listView = new ListView(getActivity());
        layout.addView(listView);

        imageViewStandardThumbnail = new ImageView(getActivity());
        RelativeLayout.LayoutParams imageViewParams = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
                LayoutParams.WRAP_CONTENT);
        imageViewParams.addRule(RelativeLayout.CENTER_IN_PARENT);
        imageViewStandardThumbnail.setLayoutParams(imageViewParams);
        imageViewStandardThumbnail.setVisibility(View.INVISIBLE);
        imageViewStandardThumbnail.setBackgroundResource(R.drawable.border);
        imageViewStandardThumbnail.setOnClickListener(new ImageView.OnClickListener() {

            @Override
            public void onClick(View v) {
                // Dismiss the image view
                v.setVisibility(View.INVISIBLE);
                Animation myAnim = AnimationUtils.loadAnimation(VideoListFragment.this.getActivity(),
                        R.anim.fadeout);
                v.startAnimation(myAnim);
            }

        });
        layout.addView(imageViewStandardThumbnail);

        progressBar = new ProgressBar(getActivity(), null, android.R.attr.progressBarStyleLarge);

        // Center a view in relative layout
        RelativeLayout.LayoutParams progressBarBarams = new RelativeLayout.LayoutParams(
                LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
        progressBarBarams.addRule(RelativeLayout.CENTER_IN_PARENT);
        progressBar.setLayoutParams(progressBarBarams);
        progressBar.setVisibility(View.INVISIBLE);
        layout.addView(progressBar);

        // Before reloading videos, display videos if they have been saved before.            
        String videosFilePath = "";
        if (VideoListFragmentActivity.videoSource == YouTubeVideoSource.Playlist) {
            videosFilePath = StorageUtil.getTempDirectory(this.getActivity()) + "/"
                    + PersistFileNameProvider.getYouTubePlaylistPersistFileName(playlistID, page);
        } else {
            videosFilePath = StorageUtil.getTempDirectory(this.getActivity()) + "/" + PersistFileNameProvider
                    .getYouTubeSearchListPersistFileName(getActivity().getString(R.string.appID), page);
        }

        boolean videosFileExists = FileUtil.fileExist(videosFilePath);
        if (videosFileExists) {
            loadPlaylistVideosFromLocalTask = new LoadCachedVideosTask(getActivity(), loadVideosHandler,
                    VideoListFragmentActivity.videoSource, progressBar, playlistID, page);
            loadPlaylistVideosFromLocalTask.execute();
        } else {
            NetworkStatus networkStatus = NetworkUtil.getNetworkStatus(getActivity());
            if (networkStatus.equals(NetworkStatus.WIFI_CONNECTED)
                    || networkStatus.equals(NetworkStatus.MOBILE_CONNECTED)) {
                String pageToken = page == 1 ? null : VideoListFragmentActivity.pageTokens.get(page - 1); // page start from 1
                if (VideoListFragmentActivity.videoSource == YouTubeVideoSource.Playlist) {
                    loadVideosTask = new LoadVideosTask(getActivity(), loadVideosHandler,
                            YouTubeVideoSource.Playlist, playlistID, pageToken, page);
                } else {
                    loadVideosTask = new LoadVideosTask(getActivity(), loadVideosHandler,
                            YouTubeVideoSource.Search, queryTerm, pageToken, page);
                }
                loadVideosTask.execute();
            } else {
                Toast.makeText(getActivity(), getString(R.string.noNetworkAvailable), Toast.LENGTH_LONG).show();
            }
        }
    }
    return layout;
}

From source file:me.fireant.photoselect.ui.PhotoPreviewActivity.java

@Override
protected void initData() {
    Intent intent = getIntent();//  ww w  .j  a v a 2  s.  c o  m
    if (intent != null) {
        mPhotos = intent.getParcelableArrayListExtra(BUNDLE_PHOTOS);
        mSelectIndex = intent.getIntExtra(BUNDLE_SELECT_INDEX, 0);
        mSelectedPhotos = intent.getParcelableArrayListExtra(BUNDLE_SELECTED_PHOTOS);
        mMaxSelectPhotoCount = intent.getIntExtra(BUNDLE_MAX_SELECT_COUNT, 1);
    }

    if (mSelectedPhotos == null) {
        mSelectedPhotos = new ArrayList<>();
    }

    mPagerAdapter = new PagerAdapter() {
        @Override
        public int getCount() {
            return mPhotos.size();
        }

        @Override
        public boolean isViewFromObject(View view, Object object) {
            return view == object;
        }

        @Override
        public void destroyItem(ViewGroup container, int position, Object object) {
            container.removeView((View) object);
        }

        @Override
        public Object instantiateItem(ViewGroup container, int position) {
            View rootView = LayoutInflater.from(PhotoPreviewActivity.this)
                    .inflate(R.layout.list_cell_photo_preview, null);
            final ImageView photoView = (ImageView) rootView.findViewById(R.id.iv_photo);
            final ProgressBar pbLoading = (ProgressBar) rootView.findViewById(R.id.pb_loading);
            final Photo photo = mPhotos.get(position);

            Picasso.with(PhotoPreviewActivity.this).load(new File(photo.getPath()))
                    .error(R.drawable.ic_photo_error).into(photoView, new Callback() {
                        @Override
                        public void onSuccess() {
                            photoView.setVisibility(View.VISIBLE);
                            pbLoading.setVisibility(View.GONE);
                        }

                        @Override
                        public void onError() {

                        }
                    });

            container.addView(rootView);

            return rootView;
        }
    };

    mViewPager.setAdapter(mPagerAdapter);

    mViewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
        @Override
        public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
        }

        @Override
        public void onPageSelected(int position) {
            checkChecked(position);
            mSelectIndex = position + 1;
            setActionTitle();
        }

        @Override
        public void onPageScrollStateChanged(int state) {

        }
    });
    if (mSelectIndex == 0) {
        checkChecked(mSelectIndex);
        mSelectIndex = mSelectIndex + 1;
        setActionTitle();
    } else {
        mViewPager.setCurrentItem(mSelectIndex, false);
    }
}

From source file:ch.epfl.sweng.evento.gui.infinite_pager_adapter.InfinitePagerAdapter.java

@Override
public void destroyItem(final ViewGroup container, final int position, final Object object) {
    final PageModel model = (PageModel) object;
    container.removeView(model.getParentView());
}