コード例 #1
0
 /** 布局加载完成回调 做一些初始化的操作 */
 @Override
 protected void onFinishInflate() {
   super.onFinishInflate();
   if (isShowShadow) {
     iv_shadow = new ImageView(context);
     iv_shadow.setImageResource(R.mipmap.shadow);
     LayoutParams lp = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
     addView(iv_shadow, 1, lp);
   }
   // 左侧界面
   vg_left = (RelativeLayout) getChildAt(0);
   // 右侧(主)界面
   vg_main = (CustomRelativeLayout) getChildAt(isShowShadow ? 2 : 1);
   vg_main.setDragLayout(this);
   vg_left.setClickable(true);
   vg_main.setClickable(true);
 }
コード例 #2
0
  @Override
  public void run() {

    int amount = 2;
    if (_button == Viewer.MINUS) {
      amount = -amount;
    }
    _rl.handleEvent(_state, amount * 5);
    _handler.postDelayed(this, 100);
  }
コード例 #3
0
 public void close(boolean animate) {
   if (animate) {
     // 继续滑动
     if (dragHelper.smoothSlideViewTo(vg_main, 0, 0)) {
       ViewCompat.postInvalidateOnAnimation(this);
     }
   } else {
     vg_main.layout(0, 0, width, height);
     dispatchDragEvent(0);
   }
 }
コード例 #4
0
 public void open(boolean animate) {
   if (animate) {
     // 继续滑动
     if (dragHelper.smoothSlideViewTo(vg_main, range, 0)) {
       ViewCompat.postInvalidateOnAnimation(this);
     }
   } else {
     vg_main.layout(range, 0, range * 2, height);
     dispatchDragEvent(range);
   }
 }
コード例 #5
0
 @Override
 protected void onDraw(Canvas canvas) {
   super.onDraw(canvas);
   if (pendingProgress != progress) {
     if (pendingProgress > progress) {
       updateBarProgress(true);
     } else if (pendingProgress < progress) {
       updateBarProgress(false);
     }
     invalidate();
   }
   is_animating = pendingProgress != progress;
 }
コード例 #6
0
        /**
         * 子View被拖拽 移动的时候回调的方法
         *
         * @param changedView View whose position changed
         * @param left New X coordinate of the left edge of the view
         * @param top New Y coordinate of the top edge of the view
         * @param dx Change in X position from the last call
         * @param dy Change in Y position from the last call
         */
        @Override
        public void onViewPositionChanged(View changedView, int left, int top, int dx, int dy) {
          if (changedView == vg_main) {
            mainLeft = left;
          } else {
            mainLeft = mainLeft + left;
          }
          if (mainLeft < 0) {
            mainLeft = 0;
          } else if (mainLeft > range) {
            mainLeft = range;
          }

          if (isShowShadow) {
            iv_shadow.layout(mainLeft, 0, mainLeft + width, height);
          }
          if (changedView == vg_left) {
            vg_left.layout(0, 0, width, height);
            vg_main.layout(mainLeft, 0, mainLeft + width, height);
          }

          dispatchDragEvent(mainLeft);
        }
コード例 #7
0
 /**
  * 调用进行left和main 视图进行位置布局
  *
  * @param changed
  * @param left
  * @param top
  * @param right
  * @param bottom
  */
 @Override
 protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
   vg_left.layout(0, 0, width, height);
   vg_main.layout(mainLeft, 0, mainLeft + width, height);
 }