当前位置: 首页>>代码示例>>Java>>正文


Java OnPreDrawListener类代码示例

本文整理汇总了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;
			}
		});

	}
}
 
开发者ID:smartbeng,项目名称:PaoMovie,代码行数:32,代码来源:DragGridView.java

示例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;
        }
    });
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:24,代码来源:BackStackRecord.java

示例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;
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:21,代码来源:ViewAnimator.java

示例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;
        }
    });
}
 
开发者ID:LanguidSheep,项目名称:sealtalk-android-master,代码行数:18,代码来源:DragPointView.java

示例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;
    }
}
 
开发者ID:trevd,项目名称:android_packages_apps_tv,代码行数:27,代码来源:SetupActivity.java

示例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);
	}
}
 
开发者ID:TWiStErRob,项目名称:glide-support,代码行数:20,代码来源:TestFragment.java

示例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; 
		}
	});

}
 
开发者ID:CrazyRunning,项目名称:MyStudyHelper,代码行数:17,代码来源:BallView.java

示例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);
      }
    }
  });
}
 
开发者ID:ChiangC,项目名称:FMTech,代码行数:20,代码来源:EditorialDescriptionSection.java

示例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;
}
 
开发者ID:ChiangC,项目名称:FMTech,代码行数:17,代码来源:CoordinatorLayout.java

示例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;
				}
			});
}
 
开发者ID:xiaozhi003,项目名称:BeautyGallery,代码行数:19,代码来源:WelcomeActivity.java

示例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;
            }
        });
    }
}
 
开发者ID:JSafaiyeh,项目名称:Fabric-Example-App-Android,代码行数:23,代码来源:MraidController.java

示例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;
        }
    });
}
 
开发者ID:jrconlin,项目名称:mc_backup,代码行数:22,代码来源:TabStripView.java

示例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;
    }
  });
}
 
开发者ID:mmmsplay10,项目名称:QuizUpWinner,代码行数:17,代码来源:ProfilePictureWithLevel.java

示例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;
				}
			});
}
 
开发者ID:cymcsg,项目名称:UltimateAndroid,代码行数:26,代码来源:TriangleView.java

示例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;
				}
			});
}
 
开发者ID:cymcsg,项目名称:UltimateAndroid,代码行数:25,代码来源:RotaryView.java


注:本文中的android.view.ViewTreeObserver.OnPreDrawListener类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。