/** * Clean-up the resources attached to this object. This needs to be called when the ImageView is * no longer used. A good example is from {@link android.view.View#onDetachedFromWindow()} or from * {@link android.app.Activity#onDestroy()}. This is automatically called if you are using {@link * uk.co.senab.photoview.PhotoView}. */ @SuppressWarnings("deprecation") public void cleanup() { if (null != mImageView) { // Remove this as a global layout listener ViewTreeObserver observer = mImageView.getViewTreeObserver(); if (null != observer && observer.isAlive()) { observer.removeGlobalOnLayoutListener(this); } // Remove the ImageView's reference to this mImageView.setOnTouchListener(null); // make sure a pending fling runnable won't be run cancelFling(); } if (null != mGestureDetector) { mGestureDetector.setOnDoubleTapListener(null); } // Clear listeners too mMatrixChangeListener = null; mPhotoTapListener = null; mViewTapListener = null; // Finally, clear ImageView mImageView = null; }
@Override public View getView(int position, View convertView, ViewGroup parent) { final ViewHolder viewHolder; if (convertView == null) { LayoutInflater mInflater = (LayoutInflater) context.getSystemService(Activity.LAYOUT_INFLATER_SERVICE); convertView = mInflater.inflate(R.layout.specimen_list_item, null); viewHolder = new ViewHolder(); viewHolder.specimenImageView = (ImageView) convertView.findViewById(R.id.specimen_image); viewHolder.specimenTitleView = (TextView) convertView.findViewById(R.id.specimen_title); viewHolder.specimenScientificName = (TextView) convertView.findViewById(R.id.scientific_name); viewHolder.specimenLocality = (TextView) convertView.findViewById(R.id.specimen_locality); viewHolder.specimenDescription = (TextView) convertView.findViewById(R.id.specimen_description); viewHolder.itemLocatedView = (ImageView) convertView.findViewById(R.id.item_located); convertView.setTag(viewHolder); } else { viewHolder = (ViewHolder) convertView.getTag(); } final SpecimenListItem specimenListItem = objects.get(position); if (specimenListItem.getImagePath() == null) { viewHolder.specimenImageView.setImageResource(specimenListItem.getSpecimenImage()); } else { final ViewTreeObserver vto = viewHolder.specimenImageView.getViewTreeObserver(); if (vto.isAlive()) { vto.addOnPreDrawListener( new ViewTreeObserver.OnPreDrawListener() { public boolean onPreDraw() { if (vto.isAlive()) { vto.removeOnPreDrawListener(this); } thumbnailHeight = viewHolder.specimenImageView.getMeasuredHeight(); thumbnailWidth = viewHolder.specimenImageView.getMeasuredWidth(); if (cancelPotentialWork( specimenListItem.getImagePath(), viewHolder.specimenImageView)) { final LoadThumbnailTask loadThumbnailTask = new LoadThumbnailTask(viewHolder.specimenImageView); final AsyncDrawable asyncDrawable = new AsyncDrawable(resources, bitmapPlaceHolder, loadThumbnailTask); viewHolder.specimenImageView.setImageDrawable(asyncDrawable); thumbnailWidth = viewHolder.specimenImageView.getMeasuredWidth(); loadThumbnailTask.execute(specimenListItem.getImagePath()); } return true; } }); } } viewHolder.specimenTitleView.setText(specimenListItem.getSpecimenTitle()); viewHolder.specimenScientificName.setText(specimenListItem.getScientificName()); viewHolder.specimenLocality.setText(specimenListItem.getSpecimenLocality()); viewHolder.specimenDescription.setText(specimenListItem.getSpecimenDescription()); viewHolder.itemLocatedView.setSelected(specimenListItem.isLocated()); if (onClickListener != null) { viewHolder.specimenImageView.setOnClickListener(onClickListener); } return convertView; }
@Test public void destroy_shouldCallClear_shouldRemoveListenerFromDecorView() throws Exception { Activity activity1 = mock(Activity.class); Window window = mock(Window.class); View decorView = mock(View.class); ViewTreeObserver viewTreeObserver = mock(ViewTreeObserver.class); when(activity1.getWindow()).thenReturn(window); when(window.getDecorView()).thenReturn(decorView); when(decorView.getViewTreeObserver()).thenReturn(viewTreeObserver); when(viewTreeObserver.isAlive()).thenReturn(true); subject = new VisibilityTracker(activity1, trackedViews, visibilityChecker, visibilityHandler); subject.addView(view, MIN_PERCENTAGE_VIEWED); subject.addView(view2, MIN_PERCENTAGE_VIEWED); assertThat(trackedViews).hasSize(2); subject.destroy(); assertThat(trackedViews).isEmpty(); verify(visibilityHandler).removeMessages(0); verify(viewTreeObserver).removeOnPreDrawListener(any(OnPreDrawListener.class)); assertThat(subject.mOnPreDrawListener).isNull(); }
private void unregisterListener() { if (mSuperScrollListener != null && mViewTreeObserver != null) { if (mViewTreeObserver.isAlive()) { mViewTreeObserver.removeOnScrollChangedListener(mSuperScrollListener); } mViewTreeObserver = null; } }
public void onDismiss() { mPopup = null; mMenu.close(); if (mTreeObserver != null) { if (!mTreeObserver.isAlive()) mTreeObserver = mAnchorView.getViewTreeObserver(); mTreeObserver.removeGlobalOnLayoutListener(this); mTreeObserver = null; } }
private void removeObserverForView(final View view) { final ViewTreeObserver treeObserver = view.getViewTreeObserver(); if (treeObserver != null && treeObserver.isAlive()) { if (TiC.JELLY_BEAN_OR_GREATER) { treeObserver.removeOnGlobalLayoutListener(this); } else { treeObserver.removeGlobalOnLayoutListener(this); } } }
/** * Dismisses the popup window with activities. * * @return True if dismissed, false if already dismissed. */ public boolean dismissPopup() { if (isShowingPopup()) { getListPopupWindow().dismiss(); ViewTreeObserver viewTreeObserver = getViewTreeObserver(); if (viewTreeObserver.isAlive()) { viewTreeObserver.removeGlobalOnLayoutListener(mOnGlobalLayoutListener); } } return true; }
@Override public void onDestroy() { super.onDestroy(); if (mScrollView == null) { return; } ViewTreeObserver vto = mScrollView.getViewTreeObserver(); if (vto.isAlive()) { vto.removeGlobalOnLayoutListener(mGlobalLayoutListener); } }
/** * Clean-up the resources attached to this object. This needs to be called when the ImageView is * no longer used. A good example is from {@link android.view.View#onDetachedFromWindow()} or from * {@link android.app.Activity#onDestroy()}. This is automatically called if you are using {@link * EasePhotoView.co.senab.photoview.PhotoView}. */ @SuppressLint("NewApi") @SuppressWarnings("deprecation") public final void cleanup() { if (VERSION.SDK_INT >= VERSION_CODES.JELLY_BEAN) { if (null != mImageView) { mImageView.get().getViewTreeObserver().removeOnGlobalLayoutListener(this); } if (null != mViewTreeObserver && mViewTreeObserver.isAlive()) { mViewTreeObserver.removeOnGlobalLayoutListener(this); mViewTreeObserver = null; // Clear listeners too mMatrixChangeListener = null; mPhotoTapListener = null; mViewTapListener = null; // Finally, clear ImageView mImageView = null; } } else { if (null != mImageView) { mImageView.get().getViewTreeObserver().removeGlobalOnLayoutListener(this); } if (null != mViewTreeObserver && mViewTreeObserver.isAlive()) { mViewTreeObserver.removeGlobalOnLayoutListener(this); mViewTreeObserver = null; // Clear listeners too mMatrixChangeListener = null; mPhotoTapListener = null; mViewTapListener = null; // Finally, clear ImageView mImageView = null; } } }
private void setupSliderValue(final int value, final Slider slider) { ViewTreeObserver viewTreeObserver = slider.getViewTreeObserver(); if (viewTreeObserver.isAlive()) { viewTreeObserver.addOnGlobalLayoutListener( new ViewTreeObserver.OnGlobalLayoutListener() { @Override public void onGlobalLayout() { slider.getViewTreeObserver().removeOnGlobalLayoutListener(this); slider.setValue(value); } }); } }
void clearCallbacksAndListener() { // Keep a reference to the layout listener and remove it here // rather than having the observer remove itself because the observer // we add the listener to will be almost immediately merged into // another observer and will therefore never be alive. If we instead // keep a reference to the listener and remove it here, we get the // current view tree observer and should succeed. ViewTreeObserver observer = view.getViewTreeObserver(); if (observer.isAlive()) { observer.removeOnPreDrawListener(layoutListener); } layoutListener = null; cbs.clear(); }
private void registerListener(View anchor) { if (mSuperScrollListener != null) { ViewTreeObserver vto = (anchor.getWindowToken() != null) ? anchor.getViewTreeObserver() : null; if (vto != mViewTreeObserver) { if (mViewTreeObserver != null && mViewTreeObserver.isAlive()) { mViewTreeObserver.removeOnScrollChangedListener(mSuperScrollListener); } if ((mViewTreeObserver = vto) != null) { vto.addOnScrollChangedListener(mSuperScrollListener); } } } }
private void initViews() { mFABElevation = getResources().getDimensionPixelSize(R.dimen.fab_elevation); mMaxHeaderElevation = getResources().getDimensionPixelSize(R.dimen.session_detail_max_header_elevation); mScrollView = (ObservableScrollView) getActivity().findViewById(R.id.scroll_view); mScrollView.addCallbacks(this); ViewTreeObserver vto = mScrollView.getViewTreeObserver(); if (vto.isAlive()) { vto.addOnGlobalLayoutListener(mGlobalLayoutListener); } mScrollViewChild = getActivity().findViewById(R.id.scroll_view_child); mScrollViewChild.setVisibility(View.INVISIBLE); mDetailsContainer = getActivity().findViewById(R.id.details_container); mHeaderBox = getActivity().findViewById(R.id.header_session); mTitle = (TextView) getActivity().findViewById(R.id.session_title); mSubtitle = (TextView) getActivity().findViewById(R.id.session_subtitle); mPhotoViewContainer = getActivity().findViewById(R.id.session_photo_container); mPhotoView = (ImageView) getActivity().findViewById(R.id.session_photo); mAbstract = (TextView) getActivity().findViewById(R.id.session_abstract); mPlusOneIcon = (ImageView) getActivity().findViewById(R.id.gplus_icon_box); mTwitterIcon = (ImageView) getActivity().findViewById(R.id.twitter_icon_box); // Find view that shows a Videocam icon if the session is being live streamed. mLiveStreamVideocamIconAndText = (TextView) getActivity().findViewById(R.id.live_stream_videocam_icon_and_text); // Find view that shows a play button and some text for the user to watch the session live // stream. mLiveStreamPlayIconAndText = (TextView) getActivity().findViewById(R.id.live_stream_play_icon_and_text); mRequirements = (TextView) getActivity().findViewById(R.id.session_requirements); mTags = (LinearLayout) getActivity().findViewById(R.id.session_tags); mTagsContainer = (ViewGroup) getActivity().findViewById(R.id.session_tags_container); ViewCompat.setTransitionName(mPhotoView, SessionDetailConstants.TRANSITION_NAME_PHOTO); mAddScheduleButtonContainer = getActivity().findViewById(R.id.add_schedule_button_container); mAddScheduleButton = (CheckableFloatingActionButton) getActivity().findViewById(R.id.add_schedule_button); mNoPlaceholderImageLoader = new ImageLoader(getContext()); mSpeakersImageLoader = new ImageLoader(getContext(), R.drawable.person_image_empty); }
/** Runs runnable when the views getWidth() will not return 0 (after it is layed out) */ public static void runWhenGetWidthWorks(final View view, final Runnable runnable) { ViewTreeObserver viewTreeObserver = view.getViewTreeObserver(); if (viewTreeObserver.isAlive()) { viewTreeObserver.addOnGlobalLayoutListener( new OnGlobalLayoutListener() { @Override public void onGlobalLayout() { view.getViewTreeObserver().removeGlobalOnLayoutListener(this); runnable.run(); } }); } }
private void a() { if (b.isEmpty()) {} int i; int j; do { return; i = c(); j = b(); } while ((!a(i)) || (!a(j))); a(i, j); ViewTreeObserver localViewTreeObserver = a.getViewTreeObserver(); if (localViewTreeObserver.isAlive()) { localViewTreeObserver.removeOnPreDrawListener(c); } c = null; }
@Override protected void onDetachedFromWindow() { super.onDetachedFromWindow(); ActivityChooserModel dataModel = mAdapter.getDataModel(); if (dataModel != null) { try { dataModel.unregisterObserver(mModelDataSetOberver); } catch (IllegalStateException e) { // Oh, well... fixes issue #557 } } ViewTreeObserver viewTreeObserver = getViewTreeObserver(); if (viewTreeObserver.isAlive()) { viewTreeObserver.removeGlobalOnLayoutListener(mOnGlobalLayoutListener); } mIsAttachedToWindow = false; }
@Test public void constructor_shouldSetOnPreDrawListenerForDecorView() throws Exception { Activity activity1 = mock(Activity.class); Window window = mock(Window.class); View decorView = mock(View.class); ViewTreeObserver viewTreeObserver = mock(ViewTreeObserver.class); when(activity1.getWindow()).thenReturn(window); when(window.getDecorView()).thenReturn(decorView); when(decorView.getViewTreeObserver()).thenReturn(viewTreeObserver); when(viewTreeObserver.isAlive()).thenReturn(true); subject = new VisibilityTracker(activity1, trackedViews, visibilityChecker, visibilityHandler); assertThat(subject.mRootView.get()).isEqualTo(decorView); assertThat(subject.mOnPreDrawListener).isNotNull(); verify(viewTreeObserver).addOnPreDrawListener(subject.mOnPreDrawListener); }
private void bindViews() { // TIPS: create an observer for notify layout updated layoutapplication = (XKPLayout) findViewById(R.id.layoutapplication); ViewTreeObserver mainLayoutViewTreeObserver = layoutapplication.getViewTreeObserver(); if (mainLayoutViewTreeObserver.isAlive()) { mainLayoutViewTreeObserver.addOnGlobalLayoutListener( new OnGlobalLayoutListener() { @Override public void onGlobalLayout() { if (!mLayoutStarted) { mLayoutStarted = true; onLayoutStarted(); } onLayoutUpdated(); } }); } }
private void toggle(final boolean visible, final boolean animate, boolean force) { if (mVisible != visible || force) { mVisible = visible; int height = getHeight(); if (height == 0 && !force) { ViewTreeObserver vto = getViewTreeObserver(); if (vto.isAlive()) { vto.addOnPreDrawListener( new ViewTreeObserver.OnPreDrawListener() { @Override public boolean onPreDraw() { ViewTreeObserver currentVto = getViewTreeObserver(); if (currentVto.isAlive()) { currentVto.removeOnPreDrawListener(this); } toggle(visible, animate, true); return true; } }); return; } } int translationY = visible ? 0 : height + getMarginBottom(); if (animate) { animate() .setInterpolator(mInterpolator) // .setDuration(TRANSLATE_DURATION_MILLIS) // .translationY(translationY); } else { setTranslationY(translationY); } // On pre-Honeycomb a translated view is still clickable, so we need // to disable clicks manually if (!hasHoneycombApi()) { setClickable(visible); } } }
private void addObserverForView(final View view) { final ViewTreeObserver treeObserver = view.getViewTreeObserver(); if (treeObserver != null && treeObserver.isAlive()) { treeObserver.addOnGlobalLayoutListener(this); } }
@Override protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_flashcards); ButterKnife.bind(this); if (savedInstanceState == null && Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { rootLayout.setVisibility(View.INVISIBLE); cx = getIntent().getIntExtra(REVEAL_X, 0); cy = getIntent().getIntExtra(REVEAL_Y, 0); ViewTreeObserver viewTreeObserver = rootLayout.getViewTreeObserver(); if (viewTreeObserver.isAlive()) { viewTreeObserver.addOnGlobalLayoutListener( new ViewTreeObserver.OnGlobalLayoutListener() { @Override public void onGlobalLayout() { circularRevealActivity(rootLayout, cx, cy, true); rootLayout.getViewTreeObserver().removeOnGlobalLayoutListener(this); } }); } } adapter = new SwipeDeckAdapter( new FlashcardView.IFlashcardListener() { @Override public void onRightClick() { swipeDeck.swipeTopCardRight(500); } @Override public void onWrongClick() { swipeDeck.swipeTopCardLeft(500); } @Override public void onRevealed() { revealedCards.put((int) swipeDeck.getTopCardItemId(), true); } }); swipeDeck.setAdapter(adapter); swipeDeck.setCallback( new SwipeDeck.SwipeDeckCallback() { @Override public void cardSwipedLeft(long positionInAdapter) { FlashcardWord word = adapter.getItem((int) positionInAdapter); getPresenter().onWordWrong(word); if (positionInAdapter == adapter.getCount() - 1) { getPresenter().onCardsDepleted(); } } @Override public void cardSwipedRight(long positionInAdapter) { FlashcardWord word = adapter.getItem((int) positionInAdapter); getPresenter().onWordRight(word); if (positionInAdapter == adapter.getCount() - 1) { getPresenter().onCardsDepleted(); } } @Override public boolean isDragEnabled(long itemId) { return revealedCards.get((int) itemId); } // @Override // public void cardsDepleted() { // getPresenter().onCardsDepleted(); // } // // }); resultErrorList.setLayoutManager( new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false)); }
/** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Log.i(TAG, "onCreate"); // progress = ProgressDialog.show(PdfViewerActivity.this, "Loading", "Loading PDF Page"); /*closeNavigationHandler = new Handler(); closeNavigationThread = new Thread(new Runnable() { public void run() { navigationPanel.startAnimation(AnimationUtils.loadAnimation(PdfViewerActivity.this, R.anim.slide_out)); navigationPanel.setVisibility(View.GONE); } });*/ /*if (navigationPanel == null) { navigationPanel = ((ViewStub) findViewById(R.id.stub_navigation)).inflate(); navigationPanel.setVisibility(View.GONE); ImageButton previous = (ImageButton)navigationPanel.findViewById(R.id.navigation_previous); previous.setBackgroundDrawable(null); }*/ uiHandler = new Handler(); restoreInstance(); mAllShareService = new AllShareService(getApplicationContext()); if (mOldGraphView != null) { System.out.println("mOldGraphView != null"); mGraphView = new GraphView(this); // mGraphView.fileMillis = mOldGraphView.fileMillis; mGraphView.mBi = mOldGraphView.mBi; // mGraphView.mLine1 = mOldGraphView.mLine1; // mGraphView.mLine2 = mOldGraphView.mLine2; // mGraphView.mLine3 = mOldGraphView.mLine3; // mGraphView.mText = mOldGraphView.mText; // mGraphView.pageParseMillis= mOldGraphView.pageParseMillis; // mGraphView.pageRenderMillis= mOldGraphView.pageRenderMillis; mOldGraphView = null; mGraphView.mImageView.setImageBitmap(mGraphView.mBi); mGraphView.updateTexts(); setContentView(mGraphView); // *********************************ALLSHARE**************************** findUiElements(); // checks if image to show exists; if not: create it copyAssets(); // set the image to be shown File dir = Environment.getExternalStorageDirectory(); File file = new File(dir, IMAGE_PATH); mImageUri = Uri.fromFile(file); if (IMAGE_PATH != null) { System.out.println("PDFFILE IMAGE_PATH " + IMAGE_PATH); } if (mImageUri != null) { System.out.println("\n mImageURI " + mImageUri); } else { System.out.println("MIMAGEURI IS NULL"); } System.out.println("DIR " + dir.getAbsolutePath()); if (file != null) { System.out.println("\n file " + file.getAbsolutePath()); } mImageView = (ImageView) findViewById(R.id.pdf_image); if (mImageView == null) { System.out.println("IMAGEVIEW NULL"); } else { System.out.println("IMAGE VIEW NOT NULL"); } mImageView.setImageBitmap(decodeImage(file)); mAllShareService = AllShareService.getInstance(); if (mAllShareService == null) { System.out.println("mAllShareService == null"); } mAllShareService.init(getApplicationContext()); // listens for layout measurements finish ViewTreeObserver viewTreeObserver = mImageView.getViewTreeObserver(); if (viewTreeObserver.isAlive()) { viewTreeObserver.addOnGlobalLayoutListener( new ViewTreeObserver.OnGlobalLayoutListener() { @Override public void onGlobalLayout() { initialize(); System.out.println("GlobalLayout Listener"); scaleTv(0, mImageViewWidth / 2.0f, mImageViewHeight / 2.0f); } }); } // *********************************ALLSHARE**************************** } else { System.out.println("mOldGraphView == null"); mGraphView = new GraphView(this); Intent intent = getIntent(); Log.i(TAG, "" + intent); boolean showImages = getIntent() .getBooleanExtra( PdfViewerActivity.EXTRA_SHOWIMAGES, PdfViewerActivity.DEFAULTSHOWIMAGES); PDFImage.sShowImages = showImages; boolean antiAlias = getIntent() .getBooleanExtra( PdfViewerActivity.EXTRA_ANTIALIAS, PdfViewerActivity.DEFAULTANTIALIAS); PDFPaint.s_doAntiAlias = antiAlias; boolean useFontSubstitution = getIntent() .getBooleanExtra( PdfViewerActivity.EXTRA_USEFONTSUBSTITUTION, PdfViewerActivity.DEFAULTUSEFONTSUBSTITUTION); PDFFont.sUseFontSubstitution = useFontSubstitution; boolean keepCaches = getIntent() .getBooleanExtra( PdfViewerActivity.EXTRA_KEEPCACHES, PdfViewerActivity.DEFAULTKEEPCACHES); HardReference.sKeepCaches = keepCaches; if (intent != null) { if ("android.intent.action.VIEW".equals(intent.getAction())) { pdffilename = storeUriContentToFile(intent.getData()); } else { pdffilename = getIntent().getStringExtra(PdfViewerActivity.EXTRA_PDFFILENAME); } } if (pdffilename == null) pdffilename = "no file selected"; mPage = STARTPAGE; mZoom = STARTZOOM; setContent(null); } }
public void testIsAlive() { final LinearLayout layout = (LinearLayout) mActivity.findViewById(R.id.linearlayout); mViewTreeObserver = layout.getViewTreeObserver(); assertTrue(mViewTreeObserver.isAlive()); }
private void setUI() { getActionBar().setSubtitle(R.string.subtitle_activity_cropping); mImageResultContainer = (RelativeLayout) findViewById(R.id.imageResultContainer); LayoutInflater inflater = getLayoutInflater(); inflater.inflate(R.layout.crop_rectangle, mImageResultContainer, true); // mImageResultContainer.addView(mCropRectangle); mCropRectangle = (CropRectangle) findViewById(R.id.cropRectangle); ((RelativeLayout) mCropRectangle.getParent()).removeView(mCropRectangle); mImageResultContainer.addView(mCropRectangle); // Fetch screen height and width, to use as our max size when loading // images as this // activity runs full screen final DisplayMetrics displayMetrics = new DisplayMetrics(); getWindowManager().getDefaultDisplay().getMetrics(displayMetrics); final int height = displayMetrics.heightPixels; final int width = displayMetrics.widthPixels; // For this sample we'll use half of the longest width to resize our // images. As the // image scaling ensures the image is larger than this, we should be // left with a // resolution that is appropriate for both portrait and landscape. // For // best image quality // we shouldn't divide by 2, but this will use more memory and // require a // larger memory // cache. final int longest = (height > width ? height : width); // BitmapFactory.Options options = new BitmapFactory.Options(); // options.inSampleSize = 2; // Bitmap bm = BitmapFactory.decodeFile(mCurrentPhotoPath, options); // mResultImageView.setImageBitmap(bm); // The ImageFetcher takes care of loading images into our ImageView // children asynchronously mImageFetcher = new ImageFetcher(this, longest); mImageFetcher.loadImage(mCurrentPhotoPath, mResultImageView); final Activity activity = this; ViewTreeObserver viewTreeObserver = mResultImageView.getViewTreeObserver(); if (viewTreeObserver.isAlive()) { viewTreeObserver.addOnGlobalLayoutListener( new OnGlobalLayoutListener() { @SuppressWarnings("deprecation") @Override public void onGlobalLayout() { if (mRectLeft != 0) { Log.d(Constants.DEBUG, "CROP rect set mrectleft" + mRectLeft); mCropRectangle.setCropRectangle( new RectF(mRectLeft, mRectTop, mRectRight, mRectBottom)); } mCropRectangle.setReportView(mResultImageView, activity); mResultImageView.getViewTreeObserver().removeGlobalOnLayoutListener(this); } }); } }
/** Stop receiving onPreDraw() notifications. */ private void unregisterPreDrawListener() { if (mViewTreeObserver != null && mViewTreeObserver.isAlive()) { mViewTreeObserver.removeOnPreDrawListener(this); } mViewTreeObserver = null; }
package com.actionbarsherlock.internal.widget;