本文整理汇总了Java中android.view.ViewTreeObserver.OnPreDrawListener类的典型用法代码示例。如果您正苦于以下问题:Java OnPreDrawListener类的具体用法?Java OnPreDrawListener怎么用?Java OnPreDrawListener使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
OnPreDrawListener类属于android.view.ViewTreeObserver包,在下文中一共展示了OnPreDrawListener类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onSwapItem
import android.view.ViewTreeObserver.OnPreDrawListener; //导入依赖的package包/类
/**
* 交换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;
}
});
}
}
示例2: prepareSharedElementTransition
import android.view.ViewTreeObserver.OnPreDrawListener; //导入依赖的package包/类
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;
}
});
}
示例3: start
import android.view.ViewTreeObserver.OnPreDrawListener; //导入依赖的package包/类
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;
}
示例4: initbg
import android.view.ViewTreeObserver.OnPreDrawListener; //导入依赖的package包/类
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;
}
});
}
示例5: onCreate
import android.view.ViewTreeObserver.OnPreDrawListener; //导入依赖的package包/类
@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;
}
}
示例6: load
import android.view.ViewTreeObserver.OnPreDrawListener; //导入依赖的package包/类
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);
}
}
示例7: BallView
import android.view.ViewTreeObserver.OnPreDrawListener; //导入依赖的package包/类
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;
}
});
}
示例8: onFinishInflate
import android.view.ViewTreeObserver.OnPreDrawListener; //导入依赖的package包/类
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);
}
}
});
}
示例9: onAttachedToWindow
import android.view.ViewTreeObserver.OnPreDrawListener; //导入依赖的package包/类
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;
}
示例10: initViews
import android.view.ViewTreeObserver.OnPreDrawListener; //导入依赖的package包/类
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;
}
});
}
示例11: run
import android.view.ViewTreeObserver.OnPreDrawListener; //导入依赖的package包/类
@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;
}
});
}
}
示例12: ensurePositionIsVisible
import android.view.ViewTreeObserver.OnPreDrawListener; //导入依赖的package包/类
/**
* 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;
}
});
}
示例13: setLevelBorder
import android.view.ViewTreeObserver.OnPreDrawListener; //导入依赖的package包/类
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;
}
});
}
示例14: TriangleView
import android.view.ViewTreeObserver.OnPreDrawListener; //导入依赖的package包/类
/**
*
* @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;
}
});
}
示例15: init
import android.view.ViewTreeObserver.OnPreDrawListener; //导入依赖的package包/类
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;
}
});
}