use of android.view.ViewConfiguration in project UltimateAndroid by cymcsg.
the class FlipViewController method init.
private void init(Context context, int orientation) {
ViewConfiguration configuration = ViewConfiguration.get(getContext());
touchSlop = configuration.getScaledTouchSlop();
this.flipOrientation = orientation;
setupSurfaceView(context);
}
use of android.view.ViewConfiguration in project UltimateAndroid by cymcsg.
the class FlipView method init.
private void init() {
final Context context = getContext();
final ViewConfiguration configuration = ViewConfiguration.get(context);
mScroller = new Scroller(context, flipInterpolator);
mTouchSlop = configuration.getScaledPagingTouchSlop();
mMinimumVelocity = configuration.getScaledMinimumFlingVelocity();
mMaximumVelocity = configuration.getScaledMaximumFlingVelocity();
mShadowPaint.setColor(Color.BLACK);
mShadowPaint.setStyle(Style.FILL);
mShadePaint.setColor(Color.BLACK);
mShadePaint.setStyle(Style.FILL);
mShinePaint.setColor(Color.WHITE);
mShinePaint.setStyle(Style.FILL);
}
use of android.view.ViewConfiguration in project android_packages_apps_Launcher2 by CyanogenMod.
the class DeleteDropTarget method onFlingToDelete.
public void onFlingToDelete(final DragObject d, int x, int y, PointF vel) {
final boolean isAllApps = d.dragSource instanceof AppsCustomizePagedView;
// Don't highlight the icon as it's animating
d.dragView.setColor(0);
d.dragView.updateInitialScaleToCurrentScale();
// Don't highlight the target if we are flinging from AllApps
if (isAllApps) {
resetHoverColor();
}
if (mFlingDeleteMode == MODE_FLING_DELETE_TO_TRASH) {
// Defer animating out the drop target if we are animating to it
mSearchDropTargetBar.deferOnDragEnd();
mSearchDropTargetBar.finishAnimations();
}
final ViewConfiguration config = ViewConfiguration.get(mLauncher);
final DragLayer dragLayer = mLauncher.getDragLayer();
final int duration = FLING_DELETE_ANIMATION_DURATION;
final long startTime = AnimationUtils.currentAnimationTimeMillis();
// NOTE: Because it takes time for the first frame of animation to actually be
// called and we expect the animation to be a continuation of the fling, we have
// to account for the time that has elapsed since the fling finished. And since
// we don't have a startDelay, we will always get call to update when we call
// start() (which we want to ignore).
final TimeInterpolator tInterpolator = new TimeInterpolator() {
private int mCount = -1;
private float mOffset = 0f;
@Override
public float getInterpolation(float t) {
if (mCount < 0) {
mCount++;
} else if (mCount == 0) {
mOffset = Math.min(0.5f, (float) (AnimationUtils.currentAnimationTimeMillis() - startTime) / duration);
mCount++;
}
return Math.min(1f, mOffset + t);
}
};
AnimatorUpdateListener updateCb = null;
if (mFlingDeleteMode == MODE_FLING_DELETE_TO_TRASH) {
updateCb = createFlingToTrashAnimatorListener(dragLayer, d, vel, config);
} else if (mFlingDeleteMode == MODE_FLING_DELETE_ALONG_VECTOR) {
updateCb = createFlingAlongVectorAnimatorListener(dragLayer, d, vel, startTime, duration, config);
}
Runnable onAnimationEndRunnable = new Runnable() {
@Override
public void run() {
mSearchDropTargetBar.onDragEnd();
// itself, otherwise, complete the drop to initiate the deletion process
if (!isAllApps) {
mLauncher.exitSpringLoadedDragMode();
completeDrop(d);
}
mLauncher.getDragController().onDeferredEndFling(d);
}
};
dragLayer.animateView(d.dragView, updateCb, duration, tInterpolator, onAnimationEndRunnable, DragLayer.ANIMATION_END_DISAPPEAR, null);
}
use of android.view.ViewConfiguration in project AndroidDevelop by 7449.
the class TabView method init.
private void init() {
// 把一个值从dip转换成px
mIndicatorHeight = dip2px(mIndicatorHeight);
mDividerPadding = dip2px(mDividerPadding);
mTabPadding = dip2px(mTabPadding);
mDividerWidth = dip2px(mDividerWidth);
mTabTextSize = dip2px(mTabTextSize);
// 创建一个scroller
mScroller = ScrollerCompat.create(getContext());
// 获取一个系统关于View的常量配置类
final ViewConfiguration configuration = ViewConfiguration.get(getContext());
// 获取滑动的最小距离
mTouchSlop = configuration.getScaledTouchSlop();
// 获取fling的最小速度
mMinimumVelocity = configuration.getScaledMinimumFlingVelocity();
// 获取fling的最大速度
mMaximumVelocity = configuration.getScaledMaximumFlingVelocity();
mLeftEdge = new EdgeEffectCompat(getContext());
mRightEdge = new EdgeEffectCompat(getContext());
}
use of android.view.ViewConfiguration in project UltimateAndroid by cymcsg.
the class DraggableGridViewPager method initDraggableGridViewPager.
private void initDraggableGridViewPager() {
setWillNotDraw(false);
setDescendantFocusability(FOCUS_AFTER_DESCENDANTS);
setFocusable(true);
setChildrenDrawingOrderEnabled(true);
final Context context = getContext();
final ViewConfiguration configuration = ViewConfiguration.get(context);
final float density = context.getResources().getDisplayMetrics().density;
mGridGap = (int) (DEFAULT_GRID_GAP * density);
// internal paddings
mPaddingLeft = getPaddingLeft();
mPaddingTop = getPaddingTop();
mPaddingRight = getPaddingRight();
mPaddingButtom = getPaddingBottom();
super.setPadding(0, 0, 0, 0);
mScroller = new Scroller(context, sInterpolator);
mTouchSlop = ViewConfigurationCompat.getScaledPagingTouchSlop(configuration);
mMinimumVelocity = (int) (MIN_FLING_VELOCITY * density);
mMaximumVelocity = configuration.getScaledMaximumFlingVelocity();
mFlingDistance = (int) (MIN_DISTANCE_FOR_FLING * density);
mCloseEnough = (int) (CLOSE_ENOUGH * density);
}
Aggregations