2020import android .animation .AnimatorListenerAdapter ;
2121import android .animation .ObjectAnimator ;
2222import android .content .Context ;
23+ import android .content .res .Resources ;
2324import android .content .res .TypedArray ;
2425import android .graphics .Canvas ;
2526import android .graphics .Paint ;
@@ -247,12 +248,12 @@ public SlidingChallengeLayout(Context context, AttributeSet attrs, int defStyle)
247248 mMinVelocity = vc .getScaledMinimumFlingVelocity ();
248249 mMaxVelocity = vc .getScaledMaximumFlingVelocity ();
249250
250- mDragHandleEdgeSlop = getResources (). getDimensionPixelSize (
251- R .dimen .kg_edge_swipe_region_size );
251+ final Resources res = getResources ();
252+ mDragHandleEdgeSlop = res . getDimensionPixelSize ( R .dimen .kg_edge_swipe_region_size );
252253
253254 mTouchSlop = ViewConfiguration .get (context ).getScaledTouchSlop ();
254255
255- final float density = getResources () .getDisplayMetrics ().density ;
256+ final float density = res .getDisplayMetrics ().density ;
256257
257258 // top half of the lock icon, plus another 25% to be sure
258259 mDragHandleClosedAbove = (int ) (DRAG_HANDLE_CLOSED_ABOVE * density + 0.5f );
@@ -261,7 +262,7 @@ public SlidingChallengeLayout(Context context, AttributeSet attrs, int defStyle)
261262 mDragHandleOpenBelow = (int ) (DRAG_HANDLE_OPEN_BELOW * density + 0.5f );
262263
263264 // how much space to account for in the handle when closed
264- mChallengeBottomBound = mDragHandleClosedBelow ;
265+ mChallengeBottomBound = res . getDimensionPixelSize ( R . dimen . kg_widget_pager_bottom_padding ) ;
265266
266267 setWillNotDraw (false );
267268 }
@@ -535,6 +536,11 @@ private int getChallengeMargin(boolean expanded) {
535536 return expanded && mHasGlowpad ? 0 : mDragHandleEdgeSlop ;
536537 }
537538
539+ private float getChallengeAlpha () {
540+ float x = mChallengeOffset - 1 ;
541+ return x * x * x + 1.f ;
542+ }
543+
538544 @ Override
539545 public void requestDisallowInterceptTouchEvent (boolean allowIntercept ) {
540546 // We'll intercept whoever we feel like! ...as long as it isn't a challenge view.
@@ -570,7 +576,8 @@ public boolean onInterceptTouchEvent(MotionEvent ev) {
570576
571577 if (!mIsBouncing &&
572578 (isInDragHandle (x , y ) || crossedDragHandle (x , y , mGestureStartY ) ||
573- (isInChallengeView (x , y ) && mScrollState == SCROLL_STATE_SETTLING )) &&
579+ (isInChallengeView (x , y ) &&
580+ (mScrollState == SCROLL_STATE_SETTLING || !mChallengeShowing ))) &&
574581 mActivePointerId == INVALID_POINTER ) {
575582 mActivePointerId = ev .getPointerId (i );
576583 mGestureStartX = x ;
@@ -860,7 +867,7 @@ protected void onLayout(boolean changed, int l, int t, int r, int b) {
860867 // we never want less than the handle size showing at the bottom.
861868 final int bottom = layoutBottom + (int ) ((childHeight - mChallengeBottomBound )
862869 * (1 - mChallengeOffset ));
863- child .setAlpha (mChallengeOffset / 2 + 0.5f );
870+ child .setAlpha (getChallengeAlpha () );
864871 child .layout (left , bottom - childHeight , left + childWidth , bottom );
865872 } else {
866873 // Non-challenge views lay out from the upper left, layered.
@@ -938,7 +945,7 @@ public void draw(Canvas c) {
938945 }
939946
940947 if (mDragIconDrawable != null ) {
941- final int closedTop = getLayoutBottom () - mChallengeBottomBound ;
948+ final int closedTop = getLayoutBottom () - mDragHandleClosedBelow ;
942949 final int iconWidth = mDragIconDrawable .getIntrinsicWidth ();
943950 final int iconHeight = mDragIconDrawable .getIntrinsicHeight ();
944951 final int iconLeft = (challengeLeft + challengeRight - iconWidth ) / 2 ;
@@ -996,7 +1003,7 @@ private boolean moveChallengeTo(int bottom) {
9961003 mChallengeView .layout (mChallengeView .getLeft (),
9971004 bottom - mChallengeView .getHeight (), mChallengeView .getRight (), bottom );
9981005
999- mChallengeView .setAlpha (offset / 2 + 0.5f );
1006+ mChallengeView .setAlpha (getChallengeAlpha () );
10001007 if (mScrollListener != null ) {
10011008 mScrollListener .onScrollPositionChanged (offset , mChallengeView .getTop ());
10021009 }
0 commit comments