use of android.view.ViewConfiguration in project UltimateAndroid by cymcsg.
the class KugouLayout method init.
private void init(Context context) {
setBackgroundColor(0x0);
/**
* Distance in pixels a touch can wander before we think the user is scrolling
* */
final ViewConfiguration configuration = ViewConfiguration.get(context);
mTouchSlop = configuration.getScaledTouchSlop();
mMaxVelocity = configuration.getScaledMaximumFlingVelocity();
mContentContainer = new UnClickableFrameLayout(context);
mContentContainer.setId(R.id.kugou_layout_md__content);
/**
* init Property Animation
* */
mAnimatorSet = new AnimatorSet();
mOffsetAnimator = ObjectAnimator.ofFloat(this, aOffset, 0, 0);
mOffsetAnimator.setDuration(ANIM_DURATION);
mAnimatorSet.playTogether(mOffsetAnimator);
mAnimatorSet.setInterpolator(mInterpolator);
mOffsetAnimator.addListener(new Animator.AnimatorListener() {
@Override
public void onAnimationStart(Animator animation) {
}
@Override
public void onAnimationEnd(Animator animation) {
float endValue = (Float) mOffsetAnimator.getAnimatedValue();
if ((endValue == getWidth() || endValue == -getWidth())) {
setVisibility(INVISIBLE);
if (null != mLayoutCloseListener) {
mLayoutCloseListener.onLayoutClose();
}
} else if (endValue == 0 && showingChangeAlpha) {
showingChangeAlpha = false;
}
}
@Override
public void onAnimationCancel(Animator animation) {
}
@Override
public void onAnimationRepeat(Animator animation) {
}
});
/**
* create rebound animator
* */
mSpringSystem = SpringSystem.create();
mSpring = mSpringSystem.createSpring();
SpringConfig config = new SpringConfig(70, 9);
mSpring.setSpringConfig(config);
mSpring.setCurrentValue(0);
mSpring.addListener(new SpringListener() {
@Override
public void onSpringUpdate(Spring spring) {
if (doAnim) {
double newValue = 1 - spring.getCurrentValue();
mOffsetPixels = (float) newValue * mBeginOffsetX;
moveContent();
if (showingChangeAlpha) {
changeAlpha();
}
}
}
@Override
public void onSpringAtRest(Spring spring) {
}
@Override
public void onSpringActivate(Spring spring) {
}
@Override
public void onSpringEndStateChange(Spring spring) {
}
});
/**
* add frame_layout mContentContainer as the parent of the activity's content view
* */
super.addView(mContentContainer, 0, new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
mContentContainer.setLayerType(View.LAYER_TYPE_HARDWARE, null);
}
use of android.view.ViewConfiguration in project UltimateAndroid by cymcsg.
the class ViewDragHelper method setSensitivity.
/**
* Sets the sensitivity of the dragger.
*
* @param context The application context.
* @param sensitivity value between 0 and 1, the final value for touchSlop =
* ViewConfiguration.getScaledTouchSlop * (1 / s);
*/
public void setSensitivity(Context context, float sensitivity) {
float s = Math.max(0f, Math.min(1.0f, sensitivity));
ViewConfiguration viewConfiguration = ViewConfiguration.get(context);
mTouchSlop = (int) (viewConfiguration.getScaledTouchSlop() * (1 / s));
}
use of android.view.ViewConfiguration in project superCleanMaster by joyoyao.
the class ViewDragHelper method setSensitivity.
/**
* Sets the sensitivity of the dragger.
*
* @param context The application context.
* @param sensitivity value between 0 and 1, the final value for touchSlop =
* ViewConfiguration.getScaledTouchSlop * (1 / s);
*/
public void setSensitivity(Context context, float sensitivity) {
float s = Math.max(0f, Math.min(1.0f, sensitivity));
ViewConfiguration viewConfiguration = ViewConfiguration.get(context);
mTouchSlop = (int) (viewConfiguration.getScaledTouchSlop() * (1 / s));
}
use of android.view.ViewConfiguration in project XobotOS by xamarin.
the class StackView method initStackView.
private void initStackView() {
configureViewAnimator(NUM_ACTIVE_VIEWS, 1);
setStaticTransformationsEnabled(true);
final ViewConfiguration configuration = ViewConfiguration.get(getContext());
mTouchSlop = configuration.getScaledTouchSlop();
mMaximumVelocity = configuration.getScaledMaximumFlingVelocity();
mActivePointerId = INVALID_POINTER;
mHighlight = new ImageView(getContext());
mHighlight.setLayoutParams(new LayoutParams(mHighlight));
addViewInLayout(mHighlight, -1, new LayoutParams(mHighlight));
mClickFeedback = new ImageView(getContext());
mClickFeedback.setLayoutParams(new LayoutParams(mClickFeedback));
addViewInLayout(mClickFeedback, -1, new LayoutParams(mClickFeedback));
mClickFeedback.setVisibility(INVISIBLE);
mStackSlider = new StackSlider();
if (sHolographicHelper == null) {
sHolographicHelper = new HolographicHelper(mContext);
}
setClipChildren(false);
setClipToPadding(false);
// This sets the form of the StackView, which is currently to have the perspective-shifted
// views above the active view, and have items slide down when sliding out. The opposite is
// available by using ITEMS_SLIDE_UP.
mStackMode = ITEMS_SLIDE_DOWN;
// This is a flag to indicate the the stack is loading for the first time
mWhichChild = -1;
// Adjust the frame padding based on the density, since the highlight changes based
// on the density
final float density = mContext.getResources().getDisplayMetrics().density;
mFramePadding = (int) Math.ceil(density * FRAME_PADDING);
}
use of android.view.ViewConfiguration in project android_frameworks_base by ResurrectionRemix.
the class HorizontalScrollView method initScrollView.
private void initScrollView() {
mScroller = new OverScroller(getContext());
setFocusable(true);
setDescendantFocusability(FOCUS_AFTER_DESCENDANTS);
setWillNotDraw(false);
final ViewConfiguration configuration = ViewConfiguration.get(mContext);
mTouchSlop = configuration.getScaledTouchSlop();
mMinimumVelocity = configuration.getScaledMinimumFlingVelocity();
mMaximumVelocity = configuration.getScaledMaximumFlingVelocity();
mOverscrollDistance = configuration.getScaledOverscrollDistance();
mOverflingDistance = configuration.getScaledOverflingDistance();
mScrollFactor = configuration.getScaledScrollFactor();
}
Aggregations