예제 #1
0
 @Override
 protected void onLayout(boolean changed, int l, int t, int r, int b) {
   mBgView.layout(l, t, r, b);
   int dragViewHeight = mHeaderView.getMeasuredHeight();
   int dragViewWidth = mHeaderView.getMeasuredWidth();
   mDragRange = mContentView.getMeasuredHeight(); // parentViewHeight -
   // dragViewHeight;
   if (Constants.hasEnterpriseAccountLoggedIn()) {
     mTop = 0;
   }
   LogUtil.d(
       TAG,
       "onLayout:"
           + "changed:"
           + changed
           + ",l:"
           + l
           + ",t:"
           + t
           + ",r:"
           + r
           + ",b:"
           + b
           + ",mDragRange"
           + mDragRange
           + ",mtop----"
           + mTop
           + " drageViewWidth----"
           + dragViewWidth
           + " dragViewHeight----"
           + dragViewHeight);
   mContentView.layout(0, 0, r, mTop);
   mHeaderView.layout(
       20, mTop + mHeaderView.getPaddingTop(), 20 + dragViewWidth, mTop + dragViewHeight);
 }
예제 #2
0
  @Override
  protected void onFinishInflate() {
    LogUtil.d(TAG, "onFInishInflate");
    mHeaderView = (ImageView) findViewById(R.id.view_header);
    mContentView = findViewById(R.id.view_content);
    mBgView = new View(getContext());
    mBgView.setBackgroundResource(R.color.translucent);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
      mBgView.setAlpha(0.0f);
    }
    mBgView.setVisibility(View.GONE);
    mBgView.setOnClickListener(
        new OnClickListener() {
          @Override
          public void onClick(View v) {
            maximize();
          }
        });
    addView(mBgView, 0);

    if (isUnderEnterprise) {
      mHeaderView.setImageResource(R.drawable.flag);
    }
  }
예제 #3
0
  @Override
  public boolean onInterceptTouchEvent(MotionEvent ev) {
    final int action = MotionEventCompat.getActionMasked(ev);

    if (action != MotionEvent.ACTION_DOWN) {
      mDragHelper.cancel();
      return super.onInterceptTouchEvent(ev);
    }

    if (action == MotionEvent.ACTION_CANCEL || action == MotionEvent.ACTION_UP) {
      mDragHelper.cancel();
      return false;
    }

    final float x = ev.getX();
    final float y = ev.getY();
    boolean interceptTap = false;

    switch (action) {
      case MotionEvent.ACTION_DOWN:
        mInitialMotionX = x;
        mInitialMotionY = y;
        interceptTap = mDragHelper.isViewUnder(mHeaderView, (int) x, (int) y);
        break;

      case MotionEvent.ACTION_MOVE:
        final float adx = Math.abs(x - mInitialMotionX);
        final float ady = Math.abs(y - mInitialMotionY);
        final int slop = mDragHelper.getTouchSlop();
        LogUtil.d(TAG, "adx:" + adx + " ady:" + ady + " slop:" + slop);
        if (ady > slop && adx > ady) {
          mDragHelper.cancel();
          return false;
        }
        break;
    }

    return mDragHelper.shouldInterceptTouchEvent(ev) || interceptTap;
  }