Java Code Examples for android.view.ViewTreeObserver#removeOnDrawListener()
The following examples show how to use
android.view.ViewTreeObserver#removeOnDrawListener() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RunReviewOverlay.java From science-journal with Apache License 2.0 | 5 votes |
public void refreshAfterChartLoad(final boolean backUpdateProgressBar, final int numAttempts) { if (!chartController.hasDrawnChart()) { // Refresh the Run Review Overlay after the line graph presenter's chart // has finished drawing itself. final ViewTreeObserver observer = chartController.getChartViewTreeObserver(); if (observer == null) { return; } observer.removeOnDrawListener(onDrawListener); onDrawListener = new ViewTreeObserver.OnDrawListener() { @Override public void onDraw() { RunReviewOverlay.this.post( new Runnable() { @Override public void run() { if (!observer.isAlive()) { if (numAttempts < MAX_REFRESH_ATTEMPTS) { // Just try again, maybe it will come alive. refreshAfterChartLoad(backUpdateProgressBar, numAttempts + 1); } return; } // The ViewTreeObserver calls its listeners without an iterator, // so we need to remove the listener outside the flow or we risk // an index-out-of-bounds crash in the case of multiple listeners. observer.removeOnDrawListener(onDrawListener); onDrawListener = null; refresh(backUpdateProgressBar); } }); } }; observer.addOnDrawListener(onDrawListener); } else { refresh(backUpdateProgressBar); } }
Example 2
Source File: RunReviewOverlay.java From science-journal with Apache License 2.0 | 5 votes |
public void onDestroy() { if (chartController != null) { chartController.removeChartDataLoadedCallback(this); if (onDrawListener != null) { final ViewTreeObserver observer = chartController.getChartViewTreeObserver(); if (observer != null) { observer.removeOnDrawListener(onDrawListener); } onDrawListener = null; } onLabelClickListener = null; timestampChangeListener = null; onSeekbarTouchListener = null; } }
Example 3
Source File: PEWTextView.java From ParallaxEverywhere with MIT License | 5 votes |
@Override protected void onDetachedFromWindow() { ViewTreeObserver viewTreeObserver = getViewTreeObserver(); viewTreeObserver.removeOnScrollChangedListener(mOnScrollChangedListener); if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { viewTreeObserver.removeOnGlobalLayoutListener(mOnGlobalLayoutListener); } else { viewTreeObserver.removeGlobalOnLayoutListener(mOnGlobalLayoutListener); } if (updateOnDraw && android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { viewTreeObserver.removeOnDrawListener(onDrawListener); } super.onDetachedFromWindow(); }
Example 4
Source File: PEWImageView.java From ParallaxEverywhere with MIT License | 5 votes |
@Override protected void onDetachedFromWindow() { ViewTreeObserver viewTreeObserver = getViewTreeObserver(); viewTreeObserver.removeOnScrollChangedListener(mOnScrollChangedListener); if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { viewTreeObserver.removeOnGlobalLayoutListener(mOnGlobalLayoutListener); } else { viewTreeObserver.removeGlobalOnLayoutListener(mOnGlobalLayoutListener); } if (updateOnDraw && android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { viewTreeObserver.removeOnDrawListener(onDrawListener); } super.onDetachedFromWindow(); }