List of usage examples for android.view ViewGroup removeView
@Override public void removeView(View view)
Note: do not invoke this method from #draw(android.graphics.Canvas) , #onDraw(android.graphics.Canvas) , #dispatchDraw(android.graphics.Canvas) or any related method.
From source file:com.nightlynexus.viewstatepageradapter.ViewStatePagerAdapter.java
@Override public final void destroyItem(ViewGroup container, int position, Object object) { View view = (View) object; destroyView(container, position, view); putInDetached(position, view);/*from www . j a va 2 s . c o m*/ container.removeView(view); attached.remove(position); }
From source file:com.netease.hearttouch.htimagepicker.core.view.photoview.ViewPagerAdapter.java
@Override public void destroyItem(ViewGroup container, int position, Object object) { View view = mPageViews.get(position); // resetPhotoView(view); // ?viewpool? pushViewToPool(view);/* w ww . j a v a2 s . c o m*/ // view pager container.removeView(view); }
From source file:com.yahala.ui.Views.BaseFragment.java
@Override public void onDestroy() { super.onDestroy(); if (removeParentOnDestroy) { if (fragmentView != null) { ViewGroup parent = (ViewGroup) fragmentView.getParent(); if (parent != null) { parent.removeView(fragmentView); }/* ww w .ja va 2 s .c o m*/ fragmentView = null; } parentActivity = null; } }
From source file:com.yahala.ui.Views.BaseFragment.java
public void setParentActivity(ActionBarActivity activity) { if (parentActivity != activity) { parentActivity = activity;//w ww .j a v a2 s .c o m if (fragmentView != null) { ViewGroup parent = (ViewGroup) fragmentView.getParent(); if (parent != null) { parent.removeView(fragmentView); } fragmentView = null; } if (parentActivity != null) { } } }
From source file:me.fireant.photoselect.ui.PhotoSelectedPreviewActivity.java
@Override protected void initData() { if (getIntent() != null) { Intent intent = getIntent();/*w w w .j a v a 2 s. c o m*/ mSelectedPhotos = intent.getParcelableArrayListExtra(BUNDLE_SELECTED_PHOTOS); mSelectIndex = intent.getIntExtra(BUNDLE_SELECT_INDEX, 0); } if (mSelectedPhotos == null || mSelectedPhotos.isEmpty()) { throw new IllegalStateException("selectPhotos must > 0"); } mPagerAdapter = new PagerAdapter() { @Override public int getCount() { return mSelectedPhotos.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 int getItemPosition(Object object) { return POSITION_NONE; } @Override public Object instantiateItem(ViewGroup container, int position) { View rootView = LayoutInflater.from(PhotoSelectedPreviewActivity.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 = mSelectedPhotos.get(position); Picasso.with(PhotoSelectedPreviewActivity.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) { mSelectIndex = position + 1; setActionTitle(); } @Override public void onPageScrollStateChanged(int state) { } }); if (mSelectIndex == 0) { mSelectIndex = mSelectIndex + 1; setActionTitle(); } else { mViewPager.setCurrentItem(mSelectIndex, false); } }
From source file:com.yahala.ui.Views.BaseFragment.java
public void removeSelfFromStack() { if (isFinish) { return;/* w ww .j a v a2s.c om*/ } isFinish = true; if (parentActivity == null) { ApplicationLoader.fragmentsStack.remove(this); onFragmentDestroy(); return; } ((LaunchActivity) parentActivity).removeFromStack(this); if (getActivity() == null) { if (fragmentView != null) { ViewGroup parent = (ViewGroup) fragmentView.getParent(); if (parent != null) { parent.removeView(fragmentView); } fragmentView = null; } parentActivity = null; } else { removeParentOnDestroy = true; } }
From source file:org.artoolkit.ar.unity.UnityARPlayerActivity.java
@Override protected void onPause() { Log.i(TAG, "onPause()"); super.onPause(); // Restore the original view hierarchy. previewInserter.removeAllViews();//from w w w. j a va 2 s . co m previewView = null; // Make sure camera is released in onPause(). ViewGroup decorView = (ViewGroup) getWindow().getDecorView(); decorView.removeView(previewInserter); decorView.addView(unityView); previewInserter = null; unityView = null; }
From source file:com.yahala.ui.Views.BaseFragment.java
public void finishFragment(boolean bySwipe) { if (isFinish || animationInProgress) { return;//from w w w .jav a 2s.com } isFinish = true; if (parentActivity == null) { ApplicationLoader.fragmentsStack.remove(this); onFragmentDestroy(); return; } ((LaunchActivity) parentActivity).finishFragment(bySwipe); ((LaunchActivity) parentActivity).updateActionBar(); if (getActivity() == null) { if (fragmentView != null) { ViewGroup parent = (ViewGroup) fragmentView.getParent(); if (parent != null) { parent.removeView(fragmentView); } fragmentView = null; } parentActivity = null; } else { removeParentOnDestroy = true; } }
From source file:com.xixicm.de.presentation.view.adapter.SentenceDetailPageAdapter.java
/** * Destroy the item from the {@link android.support.v4.view.ViewPager}. In our case this is simply removing the * {@link View}./*from w ww. j av a2 s .c o m*/ */ @Override public void destroyItem(ViewGroup container, int position, Object object) { NetworkImageView nv = (NetworkImageView) ((View) object).findViewById(R.id.image); if (nv != null) { nv.setImageUrl(null, DEVolley.getInstance().getImageLoader()); } container.removeView((View) object); }
From source file:com.achep.base.ui.DialogBuilder.java
/** * Builds dialog's view//ww w . j a v a 2 s . c o m * * @throws IllegalArgumentException when type is not one of defined. * @see #LAYOUT_COMMON * @see #LAYOUT_SKELETON */ public View createView(int type) { LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE); ViewGroup rootLayout = (ViewGroup) createSkeleton(); ViewGroup contentLayout = rootLayout; switch (type) { case LAYOUT_COMMON: final boolean hasMessageOnly = mView == null && mViewRes == 0; final int layoutResource = mContentViewRes != 0 ? mContentViewRes : hasMessageOnly ? R.layout.dialog_message : R.layout.dialog_content; ViewStub viewStub = (ViewStub) inflater.inflate(R.layout.dialog_main_body, rootLayout, true) .findViewById(R.id.placeholder); viewStub.setLayoutResource(layoutResource); contentLayout = (ViewGroup) viewStub.inflate().findViewById(R.id.content); if (contentLayout == null) contentLayout = rootLayout; TextView messageView = (TextView) contentLayout.findViewById(R.id.message); if (messageView != null) { if (!TextUtils.isEmpty(mMessageText)) { messageView.setMovementMethod(new LinkMovementMethod()); messageView.setText(mMessageText); } else { ViewGroup vg = (ViewGroup) messageView.getParent(); vg.removeView(messageView); } } // Fall down. case LAYOUT_SKELETON: if (mViewRes != 0) { inflater.inflate(mViewRes, contentLayout, true); } else if (mView != null) { contentLayout.addView(mView); } return rootLayout; default: throw new IllegalArgumentException(); } }