コード例 #1
0
ファイル: SlidingPaneLayout.java プロジェクト: zezadas/camera
 /*
  * Enabled aggressive block sorting
  */
 private void dimChildView(View object, float f, int n) {
     LayoutParams layoutParams = (LayoutParams)object.getLayoutParams();
     if (f > 0.0f && n != 0) {
         int n2 = (int)((float)((-16777216 & n) >>> 24) * f);
         if (layoutParams.dimPaint == null) {
             layoutParams.dimPaint = new Paint();
         }
         layoutParams.dimPaint.setColorFilter(new PorterDuffColorFilter(n2 << 24 | 16777215 & n, PorterDuff.Mode.SRC_OVER));
         if (ViewCompat.getLayerType((View)object) != 2) {
             ViewCompat.setLayerType((View)object, 2, layoutParams.dimPaint);
         }
         this.invalidateChildRegion((View)object);
         return;
     } else {
         if (ViewCompat.getLayerType((View)object) == 0) return;
         {
             if (layoutParams.dimPaint != null) {
                 layoutParams.dimPaint.setColorFilter(null);
             }
             object = new DisableLayerRunnable((View)object);
             this.mPostedRunnables.add((DisableLayerRunnable)object);
             ViewCompat.postOnAnimation(this, (Runnable)object);
             return;
         }
     }
 }
コード例 #2
0
 void postOnAnimation() {
   if (mEatRunOnAnimationRequest) {
     mReSchedulePostAnimationCallback = true;
   } else {
     removeCallbacks(this);
     ViewCompat.postOnAnimation(PlaylistContainerWrapper.this, this);
   }
 }
コード例 #3
0
 public void run() {
   if (SwipeDismissBehavior.access$100(SwipeDismissBehavior.this) != null
       && SwipeDismissBehavior.access$100(SwipeDismissBehavior.this).continueSettling(true)) {
     ViewCompat.postOnAnimation(mView, this);
   } else if (mDismiss && SwipeDismissBehavior.access$000(SwipeDismissBehavior.this) != null) {
     SwipeDismissBehavior.access$000(SwipeDismissBehavior.this).onDismiss(mView);
     return;
   }
 }
コード例 #4
0
  @SuppressLint("WrongCall")
  @Override
  protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
    super.onLayout(changed, left, top, right, bottom);

    if (mAdapter == null) {
      return;
    }

    // Force the OS to redraw this view
    invalidate();

    // If the data changed then reset everything and render from scratch at the same offset as last
    // time
    if (mDataChanged) {
      int oldCurrentX = mCurrentX;
      initView();
      removeAllViewsInLayout();
      mNextX = oldCurrentX;
      mDataChanged = false;
    }

    // If restoring from a rotation
    if (mRestoreX != null) {
      mNextX = mRestoreX;
      mRestoreX = null;
    }

    // If in a fling
    if (mFlingTracker.computeScrollOffset()) {
      // Compute the next position
      mNextX = mFlingTracker.getCurrX();
    }

    // Prevent scrolling past 0 so you can't scroll past the end of the list to the left
    if (mNextX < 0) {
      mNextX = 0;

      // Show an edge effect absorbing the current velocity
      if (mEdgeGlowLeft.isFinished()) {
        mEdgeGlowLeft.onAbsorb((int) determineFlingAbsorbVelocity());
      }

      mFlingTracker.forceFinished(true);
      setCurrentScrollState(OnScrollStateChangedListener.ScrollState.SCROLL_STATE_IDLE);
    } else if (mNextX > mMaxX) {
      // Clip the maximum scroll position at mMaxX so you can't scroll past the end of the list to
      // the right
      mNextX = mMaxX;

      // Show an edge effect absorbing the current velocity
      if (mEdgeGlowRight.isFinished()) {
        mEdgeGlowRight.onAbsorb((int) determineFlingAbsorbVelocity());
      }

      mFlingTracker.forceFinished(true);
      setCurrentScrollState(OnScrollStateChangedListener.ScrollState.SCROLL_STATE_IDLE);
    }

    // Calculate our delta from the last time the view was drawn
    int dx = mCurrentX - mNextX;
    removeNonVisibleChildren(dx);
    fillList(dx);
    positionChildren(dx);

    // Since the view has now been drawn, update our current position
    mCurrentX = mNextX;

    // If we have scrolled enough to lay out all views, then determine the maximum scroll position
    // now
    if (determineMaxX()) {
      // Redo the layout pass since we now know the maximum scroll position
      onLayout(changed, left, top, right, bottom);
      return;
    }

    // If the fling has finished
    if (mFlingTracker.isFinished()) {
      // If the fling just ended
      if (mCurrentScrollState == OnScrollStateChangedListener.ScrollState.SCROLL_STATE_FLING) {
        setCurrentScrollState(OnScrollStateChangedListener.ScrollState.SCROLL_STATE_IDLE);
      }
    } else {
      // Still in a fling so schedule the next frame
      ViewCompat.postOnAnimation(this, mDelayedLayout);
    }
  }