Ejemplo n.º 1
0
  /** Overrides to provide fading when slide removal is enabled. */
  @Override
  public void onDragFloatView(View floatView, Point position, Point touch) {

    if (mRemoveEnabled) {
      int x = touch.x;

      if (mRemoveMode == SLIDE_RIGHT_REMOVE) {
        int width = mDslv.getWidth();
        int thirdWidth = width / 3;

        float alpha;
        if (x < thirdWidth) {
          alpha = 1.0f;
        } else if (x < width - thirdWidth) {
          alpha = ((float) (width - thirdWidth - x)) / ((float) thirdWidth);
        } else {
          alpha = 0.0f;
        }
        mDslv.setFloatAlpha(mOrigFloatAlpha * alpha);
      } else if (mRemoveMode == SLIDE_LEFT_REMOVE) {
        int width = mDslv.getWidth();
        int thirdWidth = width / 3;

        float alpha;
        if (x < thirdWidth) {
          alpha = 0.0f;
        } else if (x < width - thirdWidth) {
          alpha = ((float) (x - thirdWidth)) / ((float) thirdWidth);
        } else {
          alpha = 1.0f;
        }
        mDslv.setFloatAlpha(mOrigFloatAlpha * alpha);
      }
    }
  }