Java 类android.view.ViewTreeObserver.OnPreDrawListener 实例源码

项目:PaoMovie    文件:DragGridView.java   
/**
 * 交换item,并且控制item之间的显示与隐藏效果
 * 
 * @param moveX
 * @param moveY
 */
private void onSwapItem(int moveX, int moveY) {
    // 获取我们手指移动到的那个item的position
    final int tempPosition = pointToPosition(moveX, moveY);

    // 假如tempPosition 改变了并且tempPosition不等�?-1,则进行交�?
    if (tempPosition != mDragPosition
            && tempPosition != AdapterView.INVALID_POSITION
            && mAnimationEnd) {
        mDragAdapter.reorderItems(mDragPosition, tempPosition);
        mDragAdapter.setHideItem(tempPosition);

        final ViewTreeObserver observer = getViewTreeObserver();
        observer.addOnPreDrawListener(new OnPreDrawListener() {

            @Override
            public boolean onPreDraw() {
                observer.removeOnPreDrawListener(this);
                animateReorder(mDragPosition, tempPosition);
                mDragPosition = tempPosition;
                return true;
            }
        });

    }
}
项目:letv    文件:BackStackRecord.java   
private void prepareSharedElementTransition(TransitionState state, View sceneRoot, Object sharedElementTransition, Fragment inFragment, Fragment outFragment, boolean isBack, ArrayList<View> sharedElementTargets) {
    final View view = sceneRoot;
    final Object obj = sharedElementTransition;
    final ArrayList<View> arrayList = sharedElementTargets;
    final TransitionState transitionState = state;
    final boolean z = isBack;
    final Fragment fragment = inFragment;
    final Fragment fragment2 = outFragment;
    sceneRoot.getViewTreeObserver().addOnPreDrawListener(new OnPreDrawListener() {
        public boolean onPreDraw() {
            view.getViewTreeObserver().removeOnPreDrawListener(this);
            if (obj != null) {
                FragmentTransitionCompat21.removeTargets(obj, arrayList);
                arrayList.clear();
                ArrayMap<String, View> namedViews = BackStackRecord.this.mapSharedElementsIn(transitionState, z, fragment);
                FragmentTransitionCompat21.setSharedElementTargets(obj, transitionState.nonExistentView, namedViews, arrayList);
                BackStackRecord.this.setEpicenterIn(namedViews, transitionState);
                BackStackRecord.this.callSharedElementEnd(transitionState, fragment, fragment2, z, namedViews);
            }
            return true;
        }
    });
}
项目:boohee_v5.6    文件:ViewAnimator.java   
public ViewAnimator start() {
    if (this.prev != null) {
        this.prev.start();
    } else {
        this.animatorSet = createAnimatorSet();
        if (this.waitForThisViewHeight != null) {
            this.waitForThisViewHeight.getViewTreeObserver().addOnPreDrawListener(new OnPreDrawListener() {
                public boolean onPreDraw() {
                    ViewAnimator.this.animatorSet.start();
                    ViewAnimator.this.waitForThisViewHeight.getViewTreeObserver()
                            .removeOnPreDrawListener(this);
                    return false;
                }
            });
        } else {
            this.animatorSet.start();
        }
    }
    return this;
}
项目:boohee_v5.6    文件:BackStackRecord.java   
private void prepareSharedElementTransition(TransitionState state, View sceneRoot, Object sharedElementTransition, Fragment inFragment, Fragment outFragment, boolean isBack, ArrayList<View> sharedElementTargets) {
    final View view = sceneRoot;
    final Object obj = sharedElementTransition;
    final ArrayList<View> arrayList = sharedElementTargets;
    final TransitionState transitionState = state;
    final boolean z = isBack;
    final Fragment fragment = inFragment;
    final Fragment fragment2 = outFragment;
    sceneRoot.getViewTreeObserver().addOnPreDrawListener(new OnPreDrawListener() {
        public boolean onPreDraw() {
            view.getViewTreeObserver().removeOnPreDrawListener(this);
            if (obj != null) {
                FragmentTransitionCompat21.removeTargets(obj, arrayList);
                arrayList.clear();
                ArrayMap<String, View> namedViews = BackStackRecord.this.mapSharedElementsIn(transitionState, z, fragment);
                FragmentTransitionCompat21.setSharedElementTargets(obj, transitionState.nonExistentView, namedViews, arrayList);
                BackStackRecord.this.setEpicenterIn(namedViews, transitionState);
                BackStackRecord.this.callSharedElementEnd(transitionState, fragment, fragment2, z, namedViews);
            }
            return true;
        }
    });
}
项目:sealtalk-android-master    文件:DragPointView.java   
private void initbg() {
    setGravity(Gravity.CENTER);
    getViewTreeObserver().addOnPreDrawListener(new OnPreDrawListener() {

        @SuppressWarnings("deprecation")
        @Override
        public boolean onPreDraw() {
            if (!initBgFlag) {
                DragPointView.this.setBackgroundDrawable(createStateListDrawable(
                            (getHeight() > getWidth() ? getHeight() : getWidth()) / 2, backgroundColor));
                initBgFlag = true;
                return false;
            }
            return true;
        }
    });
}
项目:rongyunDemo    文件:DragPointView.java   
private void initbg() {
    setGravity(Gravity.CENTER);
    getViewTreeObserver().addOnPreDrawListener(new OnPreDrawListener() {

        @SuppressWarnings("deprecation")
        @Override
        public boolean onPreDraw() {
            if (!initBgFlag) {
                DragPointView.this.setBackgroundDrawable(createStateListDrawable(
                            (getHeight() > getWidth() ? getHeight() : getWidth()) / 2, backgroundColor));
                initBgFlag = true;
                return false;
            }
            return true;
        }
    });
}
项目:RongCloudJcenter    文件:DragPointView.java   
private void initbg() {
    setGravity(Gravity.CENTER);
    getViewTreeObserver().addOnPreDrawListener(new OnPreDrawListener() {

        @SuppressWarnings("deprecation")
        @Override
        public boolean onPreDraw() {
            if (!initBgFlag) {
                DragPointView.this.setBackgroundDrawable(createStateListDrawable(
                            (getHeight() > getWidth() ? getHeight() : getWidth()) / 2, backgroundColor));
                initBgFlag = true;
                return false;
            }
            return true;
        }
    });
}
项目:android_packages_apps_tv    文件:SetupActivity.java   
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    SetupAnimationHelper.initialize(this);
    setContentView(R.layout.activity_setup);
    mFragmentTransitionDuration = getResources().getInteger(
            R.integer.setup_fragment_transition_duration);
    // Show initial fragment only when the saved state is not restored, because the last
    // fragment is restored if savesInstanceState is not null.
    if (savedInstanceState == null) {
        // This is the workaround to show the first fragment with delay to show the fragment
        // enter transition. See http://b/26255145
        getWindow().getDecorView().getViewTreeObserver().addOnPreDrawListener(
                new OnPreDrawListener() {
                    @Override
                    public boolean onPreDraw() {
                        getWindow().getDecorView().getViewTreeObserver()
                                .removeOnPreDrawListener(this);
                        showInitialFragment();
                        return true;
                    }
                });
    } else {
        mShowInitialFragment = false;
    }
}
项目:glide-support    文件:TestFragment.java   
private void load(final ImageView imageView) {
    if (imageView.getHeight() == 0) {
        // wait for layout, same as glide SizeDeterminer does
        imageView.getViewTreeObserver().addOnPreDrawListener(new OnPreDrawListener() {
            @Override public boolean onPreDraw() {
                imageView.getViewTreeObserver().removeOnPreDrawListener(this);
                load(imageView); // call the same method, but we can be sure now getHeight() is a value
                return true;
            }
        });
    } else {
        Glide
                .with(imageView.getContext())
                .load("whatever")
                .fitCenter()
                .override(Target.SIZE_ORIGINAL, imageView.getHeight())
                .into(imageView);
    }
}
项目:sealtalk-android    文件:DragPointView.java   
private void initbg() {
    setGravity(Gravity.CENTER);
    getViewTreeObserver().addOnPreDrawListener(new OnPreDrawListener() {

        @SuppressWarnings("deprecation")
        @Override
        public boolean onPreDraw() {
            if (!initBgFlag) {
                DragPointView.this.setBackgroundDrawable(createStateListDrawable(
                            (getHeight() > getWidth() ? getHeight() : getWidth()) / 2, backgroundColor));
                initBgFlag = true;
                return false;
            }
            return true;
        }
    });
}
项目:MyStudyHelper    文件:BallView.java   
public BallView(Context context, AttributeSet attrs) {
    super(context, attrs);
    // TODO Auto-generated constructor stub
    final ViewTreeObserver view=this.getViewTreeObserver();
    view.addOnPreDrawListener(new OnPreDrawListener() { 
        @Override
        public boolean onPreDraw() {
            BallView.this.getViewTreeObserver().removeOnPreDrawListener(this);
            mViewHeight = BallView.this.getLayoutParams().height;
            mViewWidth = BallView.this.getLayoutParams().width;
               play();
            return true; 
        }
    });

}
项目:FMTech    文件:EditorialDescriptionSection.java   
protected void onFinishInflate()
{
  super.onFinishInflate();
  getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener()
  {
    public final boolean onPreDraw()
    {
      if (EditorialDescriptionSection.this.isExpansionNotNeeded()) {
        EditorialDescriptionSection.this.mFooterLabel.setVisibility(8);
      }
      for (;;)
      {
        EditorialDescriptionSection.this.getViewTreeObserver().removeOnPreDrawListener(this);
        return true;
        EditorialDescriptionSection.this.mFooterLabel.setVisibility(0);
      }
    }
  });
}
项目:FMTech    文件:CoordinatorLayout.java   
public void onAttachedToWindow()
{
  super.onAttachedToWindow();
  resetTouchBehaviors();
  if (this.mNeedsPreDrawListener)
  {
    if (this.mOnPreDrawListener == null) {
      this.mOnPreDrawListener = new OnPreDrawListener();
    }
    getViewTreeObserver().addOnPreDrawListener(this.mOnPreDrawListener);
  }
  if ((this.mLastInsets == null) && (ViewCompat.getFitsSystemWindows(this))) {
    ViewCompat.requestApplyInsets(this);
  }
  this.mIsAttachedToWindow = true;
}
项目:BeautyGallery    文件:WelcomeActivity.java   
private void initViews() {
    mWelcomeImg.getViewTreeObserver().addOnPreDrawListener(
            new OnPreDrawListener() {

                @Override
                public boolean onPreDraw() {
                    mWelcomeImg.getViewTreeObserver()
                            .removeOnPreDrawListener(this);
                    // 加载背景图构建Bitmap
                    mWelcomeImg.buildDrawingCache();
                    // 获取ImageView缓存的Bitmap
                    Bitmap bmp = mWelcomeImg.getDrawingCache();
                    // 在异步任务中执行模糊
                    new BlurTask().execute(bmp);
                    return true;
                }
            });
}
项目:Fabric-Example-App-Android    文件:MraidController.java   
@Override
public void run() {
    for (final View view : mViews) {
        // Immediately count down for any views that already have a size
        if (view.getHeight() > 0 || view.getWidth() > 0) {
            countDown();
            continue;
        }

        // For views that didn't have a size, listen (once) for a preDraw. Note
        // that this doesn't leak because the ViewTreeObserver gets detached when
        // the view is no longer part of the view hierarchy.
        view.getViewTreeObserver().addOnPreDrawListener(new OnPreDrawListener() {
            @Override
            public boolean onPreDraw() {
                view.getViewTreeObserver().removeOnPreDrawListener(this);
                countDown();
                return true;
            }
        });
    }
}
项目:mc_backup    文件:TabStripView.java   
/**
 * Ensures the tab at the given position is visible. If we are not restoring tabs and
 * shouldAnimate == true, the tab will animate to be visible, if it is not already visible.
 */
private void ensurePositionIsVisible(final int position, final boolean shouldAnimate) {
    // We just want to move the strip to the right position
    // when restoring tabs on startup.
    if (isRestoringTabs || !shouldAnimate) {
        setSelection(position);
        return;
    }

    getViewTreeObserver().addOnPreDrawListener(new OnPreDrawListener() {
        @Override
        public boolean onPreDraw() {
            getViewTreeObserver().removeOnPreDrawListener(this);
            smoothScrollToPosition(position);
            return true;
        }
    });
}
项目:QuizUpWinner    文件:ProfilePictureWithLevel.java   
public void setLevelBorder( paramⅹ)
{
  final ArrayList localArrayList = ɫ.ˊ(new ArrayList(paramⅹ..values()));
  getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener()
  {
    public final boolean onPreDraw()
    {
      ProfilePictureWithLevel.this.getViewTreeObserver().removeOnPreDrawListener(this);
      if (localArrayList.size() <= 0)
        ProfilePictureWithLevel.this.setBorderColor(ProfilePictureWithLevel.this.getResources().getColor(2131230745));
      else
        ((ImageView)ProfilePictureWithLevel.this.findViewById(2131296844)).setImageBitmap(ProfilePictureWithLevel.ˊ(ProfilePictureWithLevel.this, localArrayList));
      return true;
    }
  });
}
项目:UltimateAndroid    文件:TriangleView.java   
/**
 * 
 * @param context
 * @param gender
 *            性别 0代表女 1代表男
 * @param than
 *            百分比
 */
public TriangleView(Context context, int gender, int than) {
    super(context);
    tag = get(lenght);
    this.gender = gender;
    ratio = than;
    this.than = (int) ((100.0f - than) / (100.0f / tag[lenght - 1]));
    setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT,
            LayoutParams.MATCH_PARENT));
    this.getViewTreeObserver().addOnPreDrawListener(
            new OnPreDrawListener() {
                public boolean onPreDraw() {
                    init();
                    getViewTreeObserver().removeOnPreDrawListener(this);
                    return false;
                }
            });
}
项目:UltimateAndroid    文件:RotaryView.java   
public void init() {
    paint = new Paint();
    paint.setAntiAlias(true);
    paint.setStyle(Paint.Style.FILL_AND_STROKE);

    paintWhite = new Paint();
    paintWhite.setAntiAlias(true);
    paintWhite.setColor(0xffffffff);

    paintWhite.setStyle(Paint.Style.FILL_AND_STROKE);

    bitmapRefreshPaint = new Paint();
    bitmapRefreshPaint.setAntiAlias(true);
    setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT,
            LayoutParams.MATCH_PARENT));
    this.getViewTreeObserver().addOnPreDrawListener(// 绘制完毕
            new OnPreDrawListener() {
                public boolean onPreDraw() {
                    Init();
                    getViewTreeObserver().removeOnPreDrawListener(this);
                    return false;
                }
            });
}
项目:UltimateAndroid    文件:TriangleView.java   
/**
 * 
 * @param context
 * @param gender
 *            性别 0代表女 1代表男
 * @param than
 *            百分比
 */
public TriangleView(Context context, int gender, int than) {
    super(context);
    tag = get(lenght);
    this.gender = gender;
    ratio = than;
    this.than = (int) ((100.0f - than) / (100.0f / tag[lenght - 1]));
    setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT,
            LayoutParams.MATCH_PARENT));
    this.getViewTreeObserver().addOnPreDrawListener(
            new OnPreDrawListener() {
                public boolean onPreDraw() {
                    init();
                    getViewTreeObserver().removeOnPreDrawListener(this);
                    return false;
                }
            });
}
项目:UltimateAndroid    文件:RotaryView.java   
public void init() {
    paint = new Paint();
    paint.setAntiAlias(true);
    paint.setStyle(Paint.Style.FILL_AND_STROKE);

    paintWhite = new Paint();
    paintWhite.setAntiAlias(true);
    paintWhite.setColor(0xffffffff);

    paintWhite.setStyle(Paint.Style.FILL_AND_STROKE);

    bitmapRefreshPaint = new Paint();
    bitmapRefreshPaint.setAntiAlias(true);
    setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT,
            LayoutParams.MATCH_PARENT));
    this.getViewTreeObserver().addOnPreDrawListener(// 绘制完毕
            new OnPreDrawListener() {
                public boolean onPreDraw() {
                    Init();
                    getViewTreeObserver().removeOnPreDrawListener(this);
                    return false;
                }
            });
}
项目:Auie    文件:UEFontAwesome.java   
public UEFontAwesomeDrawable(Context context, final View view, String text, int color) {
    this.text = Html.fromHtml(text).toString();
    mTextPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG);
    mTextPaint.setTypeface(typeface);
    mTextPaint.setDither(true);
    mTextPaint.setColor(color);
    mTextPaint.setTextAlign(Paint.Align.CENTER);
    mTextPaint.measureText(text);
    view.getViewTreeObserver().addOnPreDrawListener(new OnPreDrawListener() {
        @Override
        public boolean onPreDraw() {
            width = view.getWidth();
            height = view.getHeight();
            mTextPaint.setTextSize(Math.min(width, height));
            view.getViewTreeObserver().removeOnPreDrawListener(this);
            return false;
        }
    });
}
项目:Auie    文件:UI2048GameView.java   
@SuppressLint("ClickableViewAccessibility")
private void init(){
    setColumnCount(4);
    try{
        setBackgroundColor(((ColorDrawable) getBackground()).getColor());           
    }catch(Exception e){            
        setBackgroundColor(DEFAULT_BACKGROUND);
    }
    setOnTouchListener(onTouchListener);
    getViewTreeObserver().addOnPreDrawListener(new OnPreDrawListener() {

        @Override
        public boolean onPreDraw() {
            int w = getWidth();
            int h = getHeight();
            cardSize = (Math.min(w, h) - cardDistance)/4;
            initCards();
            startGame();
            getViewTreeObserver().removeOnPreDrawListener(this);
            return false;
        }
    });
}
项目:Auie    文件:UISwitchButton.java   
@SuppressLint("ClickableViewAccessibility")
@SuppressWarnings("deprecation")
public void init(){
    setOnTouchListener(this);
    HEIGHT = ((WindowManager) getContext().getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay().getHeight();
    getViewTreeObserver().addOnPreDrawListener(new OnPreDrawListener() {

        @Override
        public boolean onPreDraw() {
            DP = UEMethod.dp2px(getContext(), 1);
            LayoutParams params = getLayoutParams();
            if (getHeight() >= HEIGHT - DP * 72) {
                params.height = 30 * DP;
            }
            params.width = (int) (params.height * 2.5);
            setLayoutParams(params);
            getViewTreeObserver().removeOnPreDrawListener(this);
            return false;
        }
    });
}
项目:WidgyWidgets    文件:KnobViewActivity.java   
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_knobview);
    findViewById(R.id.knob1).getViewTreeObserver().addOnPreDrawListener(new OnPreDrawListener() {

        @Override
        public boolean onPreDraw() {
            View v = findViewById(R.id.knob1);
            v.getViewTreeObserver().removeOnPreDrawListener(this);
            int width = v.getWidth();
            int height = v.getHeight();
            v.getLayoutParams().width = Math.min(width, height);
            v.getLayoutParams().height = Math.min(width, height);
            v.requestLayout();
            return false;
        }
    });
}
项目:qvod    文件:TextViewExpandableAnimation.java   
public void setText(CharSequence charSequence) {

        textContent = charSequence;

        textView.setText(charSequence.toString());

        ViewTreeObserver viewTreeObserver = textView.getViewTreeObserver();
        viewTreeObserver.addOnPreDrawListener(new OnPreDrawListener() {

            @Override
            public boolean onPreDraw() {
                if (!isInitTextView) {
                    return true;
                }
                textLines = textView.getLineCount();
                isExpandNeeded = textLines > expandLines;
                isInitTextView = false;
                if (isExpandNeeded) {
                    isShrink = true;
                    doAnimation(textLines, expandLines, WHAT_ANIMATION_END);
                } else {
                    isShrink = false;
                    doNotExpand();
                }
                return true;
            }
        });

        if (!isInitTextView) {
            textLines = textView.getLineCount();
        }

    }
项目:letv    文件:StarRankActivity.java   
private void applyBlur(final ImageView iv) {
    iv.getViewTreeObserver().addOnPreDrawListener(new OnPreDrawListener(this) {
        final /* synthetic */ StarRankActivity this$0;

        public boolean onPreDraw() {
            iv.getViewTreeObserver().removeOnPreDrawListener(this);
            iv.buildDrawingCache();
            BlurUtils.star_blur(this.this$0.mContext, iv.getDrawingCache(), this.this$0.mZoomImg);
            return true;
        }
    });
}
项目:letv    文件:StarActivity.java   
private void applyBlur(final ImageView iv) {
    iv.getViewTreeObserver().addOnPreDrawListener(new OnPreDrawListener(this) {
        final /* synthetic */ StarActivity this$0;

        public boolean onPreDraw() {
            iv.getViewTreeObserver().removeOnPreDrawListener(this);
            iv.buildDrawingCache();
            BlurUtils.star_blur(this.this$0.mContext, iv.getDrawingCache(), this.this$0.mZoomImg);
            return true;
        }
    });
}
项目:letv    文件:BackStackRecord.java   
private void excludeHiddenFragmentsAfterEnter(View sceneRoot, TransitionState state, int containerId, Object transition) {
    final View view = sceneRoot;
    final TransitionState transitionState = state;
    final int i = containerId;
    final Object obj = transition;
    sceneRoot.getViewTreeObserver().addOnPreDrawListener(new OnPreDrawListener() {
        public boolean onPreDraw() {
            view.getViewTreeObserver().removeOnPreDrawListener(this);
            BackStackRecord.this.excludeHiddenFragments(transitionState, i, obj);
            return true;
        }
    });
}
项目:fragmentnav    文件:Androids.java   
public static void execOnViewPreDraw(final View view, final Runnable runnable) {
    if (view != null && runnable != null) {
        view.getViewTreeObserver().addOnPreDrawListener(new OnPreDrawListener() {

            @Override
            public boolean onPreDraw() {
                view.getViewTreeObserver().removeOnPreDrawListener(this);
                runnable.run();
                return true;
            }
        });
    }
}
项目:fragmentnav    文件:Androids.java   
public static void execOnViewPreDraw(final View view, final Runnable runnable) {
    if (view != null && runnable != null) {
        view.getViewTreeObserver().addOnPreDrawListener(new OnPreDrawListener() {

            @Override
            public boolean onPreDraw() {
                view.getViewTreeObserver().removeOnPreDrawListener(this);
                runnable.run();
                return true;
            }
        });
    }
}
项目:FragmentRigger    文件:SharedTargetFragment.java   
private void onUiReady() {
  imageView.getViewTreeObserver().addOnPreDrawListener(new OnPreDrawListener() {
    @Override
    public boolean onPreDraw() {
      imageView.getViewTreeObserver().removeOnPreDrawListener(this);
      prepareScene();
      runEnterAnimation();
      return true;
    }
  });
}
项目:OSchina_resources_android    文件:KJDragGridView.java   
/**
 * 交换item,并且控制item之间的显示与隐藏效果
 *
 * @param moveX
 * @param moveY
 */
private void onSwapItem(int moveX, int moveY) {
    // 获取我们手指移动到的那个item的position

    final int tempPosition = pointToPosition(moveX, moveY);

    // 假如tempPosition 改变了并且tempPosition不等于-1,则进行交换

    if (tempPosition != mDragPosition
            && tempPosition != AdapterView.INVALID_POSITION
            && mAnimationEnd) {
        mDragAdapter.reorderItems(mDragPosition, tempPosition);
        mDragAdapter.setHideItem(tempPosition);

        final ViewTreeObserver observer = getViewTreeObserver();
        observer.addOnPreDrawListener(new OnPreDrawListener() {

            @Override
            public boolean onPreDraw() {
                observer.removeOnPreDrawListener(this);
                animateReorder(mDragPosition, tempPosition);
                mDragPosition = tempPosition;
                return true;
            }
        });

    }
}
项目:boohee_v5.6    文件:BackStackRecord.java   
private void excludeHiddenFragmentsAfterEnter(View sceneRoot, TransitionState state, int containerId, Object transition) {
    final View view = sceneRoot;
    final TransitionState transitionState = state;
    final int i = containerId;
    final Object obj = transition;
    sceneRoot.getViewTreeObserver().addOnPreDrawListener(new OnPreDrawListener() {
        public boolean onPreDraw() {
            view.getViewTreeObserver().removeOnPreDrawListener(this);
            BackStackRecord.this.excludeHiddenFragments(transitionState, i, obj);
            return true;
        }
    });
}
项目:boohee_v5.6    文件:FragmentTransitionCompat21.java   
public static void cleanupTransitions(View sceneRoot, View nonExistentView, Object enterTransitionObject, ArrayList<View> enteringViews, Object exitTransitionObject, ArrayList<View> exitingViews, Object sharedElementTransitionObject, ArrayList<View> sharedElementTargets, Object overallTransitionObject, ArrayList<View> hiddenViews, Map<String, View> renamedViews) {
    final Transition enterTransition = (Transition) enterTransitionObject;
    final Transition exitTransition = (Transition) exitTransitionObject;
    final Transition sharedElementTransition = (Transition) sharedElementTransitionObject;
    final Transition overallTransition = (Transition) overallTransitionObject;
    if (overallTransition != null) {
        final View view = sceneRoot;
        final ArrayList<View> arrayList = enteringViews;
        final ArrayList<View> arrayList2 = exitingViews;
        final ArrayList<View> arrayList3 = sharedElementTargets;
        final Map<String, View> map = renamedViews;
        final ArrayList<View> arrayList4 = hiddenViews;
        final View view2 = nonExistentView;
        sceneRoot.getViewTreeObserver().addOnPreDrawListener(new OnPreDrawListener() {
            public boolean onPreDraw() {
                view.getViewTreeObserver().removeOnPreDrawListener(this);
                if (enterTransition != null) {
                    FragmentTransitionCompat21.removeTargets(enterTransition, arrayList);
                }
                if (exitTransition != null) {
                    FragmentTransitionCompat21.removeTargets(exitTransition, arrayList2);
                }
                if (sharedElementTransition != null) {
                    FragmentTransitionCompat21.removeTargets(sharedElementTransition, arrayList3);
                }
                for (Entry<String, View> entry : map.entrySet()) {
                    ((View) entry.getValue()).setTransitionName((String) entry.getKey());
                }
                int numViews = arrayList4.size();
                for (int i = 0; i < numViews; i++) {
                    overallTransition.excludeTarget((View) arrayList4.get(i), false);
                }
                overallTransition.excludeTarget(view2, false);
                return true;
            }
        });
    }
}
项目:boohee_v5.6    文件:FloatingActionButtonImpl.java   
private void ensurePreDrawListener() {
    if (this.mPreDrawListener == null) {
        this.mPreDrawListener = new OnPreDrawListener() {
            public boolean onPreDraw() {
                FloatingActionButtonImpl.this.onPreDraw();
                return true;
            }
        };
    }
}
项目:FMRadio    文件:FmScroller.java   
/**
 * Runs a piece of code just before the next draw, after layout and measurement
 *
 * @param view The view depend on
 * @param drawNextFrame Whether to draw next frame
 * @param runnable The executed runnable instance
 */
private void doOnPreDraw(final View view, final boolean drawNextFrame,
        final Runnable runnable) {
    final OnPreDrawListener listener = new OnPreDrawListener() {
        @Override
        public boolean onPreDraw() {
            view.getViewTreeObserver().removeOnPreDrawListener(this);
            runnable.run();
            return drawNextFrame;
        }
    };
    view.getViewTreeObserver().addOnPreDrawListener(listener);
}
项目:TAG    文件:PublishActivity.java   
public void gridviewInit() {
    adapter = new GridAdapter(this);
    adapter.setSelectedPosition(0);
    int size = 0;
    if (bmp.size() < 6) {
        size = bmp.size() + 1;
    } else {
        size = bmp.size();
    }
    LayoutParams params = gridview.getLayoutParams();
    final int width = size * (int) (dp * 9.4f);
    params.width = width;
    gridview.setLayoutParams(params);
    gridview.setColumnWidth((int) (dp * 9.4f));
    gridview.setStretchMode(GridView.NO_STRETCH);
    gridview.setNumColumns(size);
    gridview.setAdapter(adapter);
    gridview.setOnItemClickListener(this);

    selectimg_horizontalScrollView.getViewTreeObserver()
            .addOnPreDrawListener(// 绘制完毕
                    new OnPreDrawListener() {
                        public boolean onPreDraw() {
                            selectimg_horizontalScrollView.scrollTo(width,
                                    0);
                            selectimg_horizontalScrollView
                                    .getViewTreeObserver()
                                    .removeOnPreDrawListener(this);
                            return false;
                        }
                    });
}
项目:YingBeautyNote    文件:HTQDragGridView.java   
/**
 * 交换item,并且控制item之间的显示与隐藏效果
 * 
 * @param moveX
 * @param moveY
 */
private void onSwapItem(int moveX, int moveY) {
    // 获取我们手指移动到的那个item的position

    final int tempPosition = pointToPosition(moveX, moveY);

    // 假如tempPosition 改变了并且tempPosition不等于-1,则进行交换

    if (tempPosition != mDragPosition
            && tempPosition != AdapterView.INVALID_POSITION
            && mAnimationEnd) {
        mDragAdapter.reorderItems(mDragPosition, tempPosition);
        mDragAdapter.setHideItem(tempPosition);

        final ViewTreeObserver observer = getViewTreeObserver();
        observer.addOnPreDrawListener(new OnPreDrawListener() {

            @Override
            public boolean onPreDraw() {
                observer.removeOnPreDrawListener(this);
                animateReorder(mDragPosition, tempPosition);
                mDragPosition = tempPosition;
                return true;
            }
        });

    }
}
项目:material-components-android    文件:ExpandableBehavior.java   
@CallSuper
@Override
public boolean onLayoutChild(CoordinatorLayout parent, final View child, int layoutDirection) {
  if (!ViewCompat.isLaidOut(child)) {
    final ExpandableWidget dep = findExpandableWidget(parent, child);
    if (dep != null && didStateChange(dep.isExpanded())) {
      currentState = dep.isExpanded() ? STATE_EXPANDED : STATE_COLLAPSED;
      @State final int expectedState = currentState;
      child
          .getViewTreeObserver()
          .addOnPreDrawListener(
              new OnPreDrawListener() {
                @Override
                public boolean onPreDraw() {
                  child.getViewTreeObserver().removeOnPreDrawListener(this);
                  // Proceed only if the state did not change while we're waiting for pre-draw.
                  if (currentState == expectedState) {
                    onExpandedStateChange((View) dep, child, dep.isExpanded(), false);
                  }
                  return false;
                }
              });
    }
  }

  return false;
}