public void transformPage(View view, float position) {
    int pageWidth = view.getWidth();

    if (position < -1) { // [-Infinity,-1)
      // This page is way off-screen to the left.
      ViewHelper.setAlpha(view, 0);

    } else if (position <= 0) { // [-1,0]
      // Use the default slide transition when moving to the left page
      ViewHelper.setAlpha(view, 1);
      ViewHelper.setTranslationX(view, 0);
      ViewHelper.setScaleX(view, 1);
      ViewHelper.setScaleY(view, 1);

    } else if (position <= 1) { // (0,1]
      // Fade the page out.
      ViewHelper.setAlpha(view, 1 - position);

      // Counteract the default slide transition
      ViewHelper.setTranslationX(view, pageWidth * -position);

      // Scale the page down (between MIN_SCALE and 1)
      float scaleFactor = MIN_SCALE + (1 - MIN_SCALE) * (1 - Math.abs(position));
      ViewHelper.setScaleX(view, scaleFactor);
      ViewHelper.setScaleY(view, scaleFactor);

    } else { // (1,+Infinity]
      // This page is way off-screen to the right.
      ViewHelper.setAlpha(view, 0);
    }
  }
Пример #2
0
  /** 滚动发生时调用 */
  @Override
  protected void onScrollChanged(int l, int t, int oldl, int oldt) {
    super.onScrollChanged(l, t, oldl, oldt);
    /**
     * 距离qq差别 :1.qq内容区域实现了一个缩放的效果 2.菜单的偏移量一直在变化 3.菜单也存在缩放和透明度的变化 实现1.需要将 0.7 ~ 1.0 (0.7 + 0.3 *
     * scale) 实现2.修改菜单的其实隐藏跨度 实现3.菜单透明度变化0.6 ~ 1.0 ( 0.6 + 0.4 *(1-scale))+缩放:0.7~1.0(1.0 -
     * scale*0.3)
     */
    // l是当前SrocllX值
    float scale = l * 1.0f / mMenuWidth;
    Log.i("SlidingMenu:onScrollChanged", "" + scale);
    // 调用属性动画 设置TranslationX 修改菜单的其实隐藏跨度,其实隐藏60%
    ViewHelper.setTranslationX(mMenu, mMenuWidth * scale * 0.6f);

    // 实现内容区域缩小
    float contextScale = 0.7f + 0.3f * scale;
    // 设置缩放的中心点 设置内容区域缩放值
    ViewHelper.setPivotX(mContent, 0);
    ViewHelper.setPivotY(mContent, mContent.getHeight() / 2);
    ViewHelper.setScaleX(mContent, contextScale);
    ViewHelper.setScaleY(mContent, contextScale);

    // 实现菜单区域缩放
    float menuScale = 1.0f - scale * 0.3f;
    // 实现菜单透明度变化
    float menuAlpha = 0.6f + 0.4f * (1 - scale);
    // 调用属性动画实现
    ViewHelper.setScaleX(mMenu, menuScale);
    ViewHelper.setScaleY(mMenu, menuScale);
    ViewHelper.setAlpha(mMenu, menuAlpha);
  }
Пример #3
0
 private void animateZoom(View left, View right, float positionOffset, boolean in) {
   if (mState != State.IDLE) {
     if (left != null) {
       manageLayer(left, true);
       mScale =
           in
               ? ZOOM_MAX + (1 - ZOOM_MAX) * (1 - positionOffset)
               : 1 + ZOOM_MAX - ZOOM_MAX * (1 - positionOffset);
       ViewHelper.setPivotX(left, left.getMeasuredWidth() * 0.5f);
       ViewHelper.setPivotY(left, left.getMeasuredHeight() * 0.5f);
       ViewHelper.setScaleX(left, mScale);
       ViewHelper.setScaleY(left, mScale);
     }
     if (right != null) {
       manageLayer(right, true);
       mScale =
           in
               ? ZOOM_MAX + (1 - ZOOM_MAX) * positionOffset
               : 1 + ZOOM_MAX - ZOOM_MAX * positionOffset;
       ViewHelper.setPivotX(right, right.getMeasuredWidth() * 0.5f);
       ViewHelper.setPivotY(right, right.getMeasuredHeight() * 0.5f);
       ViewHelper.setScaleX(right, mScale);
       ViewHelper.setScaleY(right, mScale);
     }
   }
 }
Пример #4
0
  /**
   * Scale title view and move it in Flexible space
   *
   * @param scrollY
   */
  private void updateFlexibleSpaceText(final int scrollY) {
    if (!mIsToolbarShown) return;

    int adjustedScrollY = scrollY;
    if (scrollY < 0) {
      adjustedScrollY = 0;
    } else if (scrollY > mParallaxImageHeight) {
      adjustedScrollY = mParallaxImageHeight;
    }

    float maxScale = 1.6f;
    float scale =
        maxScale
            * ((float) (mParallaxImageHeight - mToolbarHeight) - adjustedScrollY)
            / (mParallaxImageHeight - mToolbarHeight);
    if (scale < 0) {
      scale = 0;
    }

    ViewHelper.setPivotX(mTitle, 0);
    ViewHelper.setPivotY(mTitle, 0);
    ViewHelper.setScaleX(mTitle, 1 + scale);
    ViewHelper.setScaleY(mTitle, 1 + scale);

    int maxTitleTranslation = (int) (mParallaxImageHeight * 0.4f);
    int titleTranslation = (int) (maxTitleTranslation * ((float) scale / maxScale));
    ViewHelper.setTranslationY(mTitle, titleTranslation);
  }
Пример #5
0
 private void animateAccordion(View left, View right, float positionOffset) {
   if (mState != State.IDLE) {
     if (left != null) {
       manageLayer(left, true);
       ViewHelper.setPivotX(left, left.getMeasuredWidth());
       ViewHelper.setPivotY(left, 0);
       ViewHelper.setScaleX(left, 1 - positionOffset);
     }
     if (right != null) {
       manageLayer(right, true);
       ViewHelper.setPivotX(right, 0);
       ViewHelper.setPivotY(right, 0);
       ViewHelper.setScaleX(right, positionOffset);
     }
   }
 }
 @Override
 protected void onTransform(View view, float position) {
   final float scale = position < 0 ? position + 1f : Math.abs(1f - position);
   ViewHelper.setScaleX(view, scale);
   ViewHelper.setScaleY(view, scale);
   ViewHelper.setPivotX(view, view.getWidth() * 0.5f);
   ViewHelper.setPivotY(view, view.getHeight() * 0.5f);
   ViewHelper.setAlpha(view, position < -1f || position > 1f ? 0f : 1f - (scale - 1f));
 }
Пример #7
0
 @Override
 public void initView(View item, int position, int scrollDirection) {
   ViewHelper.setPivotX(item, item.getWidth() / 2);
   ViewHelper.setPivotY(item, item.getHeight() / 2);
   ViewHelper.setScaleX(item, INITIAL_SCALE_FACTOR);
   ViewHelper.setScaleY(item, INITIAL_SCALE_FACTOR);
   ViewHelper.setTranslationY(item, item.getHeight() / 2 * scrollDirection);
   ViewHelper.setAlpha(item, JazzyHelper.OPAQUE / 2);
 }
 public static void reset(View view) {
   ViewHelper.setAlpha(view, 1);
   ViewHelper.setScaleX(view, 1);
   ViewHelper.setScaleY(view, 1);
   ViewHelper.setTranslationX(view, 0);
   ViewHelper.setTranslationY(view, 0);
   ViewHelper.setRotation(view, 0);
   ViewHelper.setRotationY(view, 0);
   ViewHelper.setRotationX(view, 0);
 }
Пример #9
0
  @Override
  public void onScrollChanged(int scrollY, boolean firstScroll, boolean dragging) {
    // Translate overlay and image
    float flexibleRange = mFlexibleSpaceImageHeight - mActionBarSize;
    int minOverlayTransitionY = mActionBarSize - mOverlayView.getHeight();
    ViewHelper.setTranslationY(
        mOverlayView, ScrollUtils.getFloat(-scrollY, minOverlayTransitionY, 0));
    ViewHelper.setTranslationY(
        mImageView, ScrollUtils.getFloat(-scrollY / 2, minOverlayTransitionY, 0));

    // Change alpha of overlay
    ViewHelper.setAlpha(mOverlayView, ScrollUtils.getFloat((float) scrollY / flexibleRange, 0, 1));

    // Scale title text
    float scale =
        1
            + ScrollUtils.getFloat(
                (flexibleRange - scrollY) / flexibleRange, 0, MAX_TEXT_SCALE_DELTA);
    ViewHelper.setPivotX(mTitleView, 0);
    ViewHelper.setPivotY(mTitleView, 0);
    ViewHelper.setScaleX(mTitleView, scale);
    ViewHelper.setScaleY(mTitleView, scale);

    // Translate title text
    int maxTitleTranslationY = (int) (mFlexibleSpaceImageHeight - mTitleView.getHeight() * scale);
    int titleTranslationY = maxTitleTranslationY - scrollY;
    ViewHelper.setTranslationY(mTitleView, titleTranslationY);

    // Translate FAB
    int maxFabTranslationY = mFlexibleSpaceImageHeight - mFab.getHeight() / 2;
    float fabTranslationY =
        ScrollUtils.getFloat(
            -scrollY + mFlexibleSpaceImageHeight - mFab.getHeight() / 2,
            mActionBarSize - mFab.getHeight() / 2,
            maxFabTranslationY);
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) {
      // On pre-honeycomb, ViewHelper.setTranslationX/Y does not set margin,
      // which causes FAB's OnClickListener not working.
      FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams) mFab.getLayoutParams();
      lp.leftMargin = mOverlayView.getWidth() - mFabMargin - mFab.getWidth();
      lp.topMargin = (int) fabTranslationY;
      mFab.requestLayout();
    } else {
      ViewHelper.setTranslationX(mFab, mOverlayView.getWidth() - mFabMargin - mFab.getWidth());
      ViewHelper.setTranslationY(mFab, fabTranslationY);
    }

    // Show/hide FAB
    if (fabTranslationY < mFlexibleSpaceShowFabOffset) {
      hideFab();
    } else {
      showFab();
    }
  }
 /**
  * reset the view to default status
  *
  * @param target
  */
 public void reset(View target) {
   ViewHelper.setAlpha(target, 1);
   ViewHelper.setScaleX(target, 1);
   ViewHelper.setScaleY(target, 1);
   ViewHelper.setTranslationX(target, 0);
   ViewHelper.setTranslationY(target, 0);
   ViewHelper.setRotation(target, 0);
   ViewHelper.setRotationY(target, 0);
   ViewHelper.setRotationX(target, 0);
   ViewHelper.setPivotX(target, target.getMeasuredWidth() / 2.0f);
   ViewHelper.setPivotY(target, target.getMeasuredHeight() / 2.0f);
 }
  @Override
  protected void onTransform(View view, float position) {
    final float height = view.getHeight();
    final float width = view.getWidth();
    final float scale = min(position > 0 ? 1f : Math.abs(1f + position), 0.5f);

    ViewHelper.setScaleX(view, scale);
    ViewHelper.setScaleY(view, scale);
    ViewHelper.setPivotX(view, width * 0.5f);
    ViewHelper.setPivotY(view, height * 0.5f);
    ViewHelper.setTranslationX(view, position > 0 ? width * position : -width * position * 0.25f);
  }
Пример #12
0
 protected void animateStack(View left, View right, float effectOffset, int positionOffsetPixels) {
   if (right != null) {
     mScale = (1 - SCALE_MAX) * effectOffset + SCALE_MAX;
     mTrans = -getWidth() - getPageMargin() + positionOffsetPixels;
     ViewHelper.setScaleX(right, mScale);
     ViewHelper.setScaleY(right, mScale);
     ViewHelper.setTranslationX(right, mTrans);
   }
   if (left != null) {
     left.bringToFront();
   }
 }
Пример #13
0
 protected void animateStack(
     View left, View right, float positionOffset, int positionOffsetPixels) {
   if (mState != State.IDLE) {
     if (right != null) {
       manageLayer(right, true);
       mScale = (1 - SCALE_MAX) * positionOffset + SCALE_MAX;
       mTrans = -getWidth() - getPageMargin() + positionOffsetPixels;
       ViewHelper.setScaleX(right, mScale);
       ViewHelper.setScaleY(right, mScale);
       ViewHelper.setTranslationX(right, mTrans);
     }
   }
 }
Пример #14
0
  /**
   * start any animation through percent
   *
   * @param percent the percent start any animation
   */
  private void setAnimation(float percent) {

    // the left panel's animation
    // the left panel's scale of x is 0.5-1
    ViewHelper.setScaleX(leftGroup, evalute(percent, 0.5f, 1.0f));
    // the left panel's scale of y is 0.5-1
    ViewHelper.setScaleY(leftGroup, evalute(percent, 0.5f, 1.0f));
    // the left panel's tranlation range is -rangewidth-0
    ViewHelper.setTranslationX(leftGroup, evalute(percent, -mRangeWidth, 0));
    // the left panel's alpha range is 0.5-1
    ViewHelper.setAlpha(leftGroup, evalute(percent, 0.5f, 1.0f));

    // the main panel's animation
    // the main panel's scale of x is 1.0-0.8
    ViewHelper.setScaleX(mainGroup, evalute(percent, 1.0f, 0.8f));
    // the main panel's scale of y is 1.0-0.8
    ViewHelper.setScaleY(mainGroup, evalute(percent, 1.0f, 0.8f));
    // the background's animation
    getBackground()
        .setColorFilter(
            (Integer) evaluateColor(percent, Color.BLACK, Color.TRANSPARENT), Mode.SRC_OVER);
  }
Пример #15
0
 /**
  * 根据滑动的距离的比例,进行平移动画
  *
  * @param percent
  */
 private void animateView(float percent) {
   float f1 = 1 - percent * 0.5f;
   // 沿着水平X轴平移
   ViewHelper.setTranslationX(
       vg_left, -vg_left.getWidth() / 2.5f + vg_left.getWidth() / 2.5f * percent);
   if (isShowShadow) {
     // 阴影效果视图大小进行缩放
     ViewHelper.setScaleX(iv_shadow, f1 * 1.2f * (1 - percent * 0.10f));
     ViewHelper.setScaleY(iv_shadow, f1 * 1.85f * (1 - percent * 0.10f));
   }
   getBackground()
       .setColorFilter(evaluate(percent, Color.BLACK, Color.TRANSPARENT), Mode.SRC_OVER);
 }
 @Override
 protected void onTransform(View view, float position) {
   final float scale = 1f + Math.abs(position);
   ViewHelper.setScaleX(view, scale);
   ViewHelper.setScaleY(view, scale);
   ViewHelper.setPivotX(view, view.getWidth() * 0.5f);
   ViewHelper.setPivotY(view, view.getWidth() * 0.5f);
   ViewHelper.setAlpha(view, position < -1f || position > 1f ? 0f : 1f - (scale - 1f));
   if (position < -0.9) {
     // -0.9 to prevent a small bug
     ViewHelper.setTranslationX(view, view.getWidth() * position);
   }
 }
  private void translateTab(int scrollY, boolean animated) {
    int flexibleSpaceImageHeight =
        getResources().getDimensionPixelSize(R.dimen.flexible_space_image_height);
    int tabHeight = getResources().getDimensionPixelSize(R.dimen.tab_height);
    View imageView = findViewById(R.id.image);
    View overlayView = findViewById(R.id.overlay);
    TextView titleView = (TextView) findViewById(R.id.title);

    // Translate overlay and image
    float flexibleRange = flexibleSpaceImageHeight - getActionBarSize();
    int minOverlayTransitionY = tabHeight - overlayView.getHeight();
    ViewHelper.setTranslationY(
        overlayView, ScrollUtils.getFloat(-scrollY, minOverlayTransitionY, 0));
    ViewHelper.setTranslationY(
        imageView, ScrollUtils.getFloat(-scrollY / 2, minOverlayTransitionY, 0));

    // Change alpha of overlay
    ViewHelper.setAlpha(overlayView, ScrollUtils.getFloat((float) scrollY / flexibleRange, 0, 1));

    // Scale title text
    float scale =
        1
            + ScrollUtils.getFloat(
                (flexibleRange - scrollY - tabHeight) / flexibleRange, 0, MAX_TEXT_SCALE_DELTA);
    setPivotXToTitle(titleView);
    ViewHelper.setPivotY(titleView, 0);
    ViewHelper.setScaleX(titleView, scale);
    ViewHelper.setScaleY(titleView, scale);

    // Translate title text
    int maxTitleTranslationY = flexibleSpaceImageHeight - tabHeight - getActionBarSize();
    int titleTranslationY = maxTitleTranslationY - scrollY;
    ViewHelper.setTranslationY(titleView, titleTranslationY);

    // If tabs are moving, cancel it to start a new animation.
    ViewPropertyAnimator.animate(mSlidingTabLayout).cancel();
    // Tabs will move between the top of the screen to the bottom of the image.
    float translationY =
        ScrollUtils.getFloat(
            -scrollY + mFlexibleSpaceHeight - mTabHeight, 0, mFlexibleSpaceHeight - mTabHeight);
    if (animated) {
      // Animation will be invoked only when the current tab is changed.
      ViewPropertyAnimator.animate(mSlidingTabLayout)
          .translationY(translationY)
          .setDuration(200)
          .start();
    } else {
      // When Fragments' scroll, translate tabs immediately (without animation).
      ViewHelper.setTranslationY(mSlidingTabLayout, translationY);
    }
  }
Пример #18
0
  protected void animateStack(
      Fragment left, Fragment right, float effectOffset, int positionOffsetPixels) {
    if (right != null) {
      /** 缩小比例 如果手指从右到左的滑动(切换到后一个):0.0~1.0,即从一半到最大 如果手指从左到右的滑动(切换到前一个):1.0~0,即从最大到一半 */
      float mScale = (1 - SCALE_MAX) * effectOffset + SCALE_MAX;
      /** x偏移量: 如果手指从右到左的滑动(切换到后一个):0-720 如果手指从左到右的滑动(切换到前一个):720-0 */
      int mTrans = -getWidth() - getPageMargin() + positionOffsetPixels;
      ViewHelper.setScaleX(right.getView(), mScale);
      ViewHelper.setScaleY(right.getView(), mScale);
      ViewHelper.setTranslationX(right.getView(), mTrans);
    }

    if (left != null) {
      left.getView().bringToFront();
    }
  }
Пример #19
0
  @Override
  protected void onScrollChanged(int l, int t, int oldl, int oldt) {
    // 首次使用获取banner初始高度和宽度
    if (originHeight == -1 || originWidth == -1) {
      originHeight = mTopView.getHeight();
      originWidth = mTopView.getWidth();
    }

    // t为ScrollView向上滑动的量, 两者相减即为当前banner所需的高度
    int height = originHeight - t;
    // 计算缩放比例
    float newRatio = (float) height / (float) originHeight;

    // 修改banner的属性
    if (height >= 0) {
      ViewHelper.setScaleX(mTopView, newRatio);
      ViewHelper.setScaleY(mTopView, newRatio);
      ViewHelper.setY(mTopView, t / 2);
      ViewHelper.setAlpha(mTopView, newRatio);
    }
    super.onScrollChanged(l, t, oldl, oldt);
  }
Пример #20
0
 public void setScaleX(float x) {
   ViewHelper.setScaleX(this, x);
 }
Пример #21
0
  @Override
  public boolean dispatchTouchEvent(MotionEvent ev) {
    float currentActivityScaleX = ViewHelper.getScaleX(viewActivity);
    if (currentActivityScaleX == 1.0f) setScaleDirectionByRawX(ev.getRawX());

    switch (ev.getAction()) {
      case MotionEvent.ACTION_DOWN:
        lastActionDownX = ev.getX();
        lastActionDownY = ev.getY();
        isInIgnoredView = isInIgnoredView(ev) && !isOpened();
        pressedState = PRESSED_DOWN;
        break;

      case MotionEvent.ACTION_MOVE:
        if (isInIgnoredView || isInDisableDirection(scaleDirection)) break;

        if (pressedState != PRESSED_DOWN && pressedState != PRESSED_MOVE_HORIZONTAL) break;

        int xOffset = (int) (ev.getX() - lastActionDownX);
        int yOffset = (int) (ev.getY() - lastActionDownY);

        if (pressedState == PRESSED_DOWN) {
          if (yOffset > 25 || yOffset < -25) {
            pressedState = PRESSED_MOVE_VERTICAL;
            break;
          }
          if (xOffset < -50 || xOffset > 50) {
            pressedState = PRESSED_MOVE_HORIZONTAL;
            ev.setAction(MotionEvent.ACTION_CANCEL);
          }
        } else if (pressedState == PRESSED_MOVE_HORIZONTAL) {
          if (currentActivityScaleX < 0.95) showScrollViewMenu(scrollViewMenu);

          float targetScale = getTargetScale(ev.getRawX());
          if (mUse3D) {
            int angle = scaleDirection == DIRECTION_LEFT ? -ROTATE_Y_ANGLE : ROTATE_Y_ANGLE;
            angle *= (1 - targetScale) * 2;
            ViewHelper.setRotationY(viewActivity, angle);

            ViewHelper.setScaleX(imageViewShadow, targetScale - shadowAdjustScaleX);
            ViewHelper.setScaleY(imageViewShadow, targetScale - shadowAdjustScaleY);
          } else {
            ViewHelper.setScaleX(imageViewShadow, targetScale + shadowAdjustScaleX);
            ViewHelper.setScaleY(imageViewShadow, targetScale + shadowAdjustScaleY);
          }
          ViewHelper.setScaleX(viewActivity, targetScale);
          ViewHelper.setScaleY(viewActivity, targetScale);
          ViewHelper.setAlpha(scrollViewMenu, (1 - targetScale) * 2.0f);

          lastRawX = ev.getRawX();
          return true;
        }

        break;

      case MotionEvent.ACTION_UP:
        if (isInIgnoredView) break;
        if (pressedState != PRESSED_MOVE_HORIZONTAL) break;

        pressedState = PRESSED_DONE;
        if (isOpened()) {
          if (currentActivityScaleX > 0.56f) closeMenu();
          else openMenu(scaleDirection);
        } else {
          if (currentActivityScaleX < 0.94f) {
            openMenu(scaleDirection);
          } else {
            closeMenu();
          }
        }

        break;
    }
    lastRawX = ev.getRawX();
    return super.dispatchTouchEvent(ev);
  }
Пример #22
0
 public void initView(View paramView, int paramInt1, int paramInt2) {
   ViewHelper.setPivotX(paramView, paramView.getWidth() / 2);
   ViewHelper.setPivotY(paramView, paramView.getHeight() / 2);
   ViewHelper.setScaleX(paramView, 0.01F);
   ViewHelper.setScaleY(paramView, 0.01F);
 }
Пример #23
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_my_profile);

    mFlexibleSpaceImageHeight =
        getResources().getDimensionPixelSize(R.dimen.flexible_space_image_height);
    mFlexibleSpaceShowFabOffset =
        getResources().getDimensionPixelSize(R.dimen.flexible_space_show_fab_offset);
    mActionBarSize = getActionBarSize();
    setSupportActionBar((Toolbar) findViewById(R.id.toolbar));
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    mImageView = findViewById(R.id.image);
    mOverlayView = findViewById(R.id.overlay);
    mScrollView = (ObservableScrollView) findViewById(R.id.scroll);
    mScrollView.setScrollViewCallbacks(this);
    mTitleView = (TextView) findViewById(R.id.title);
    mTitleView.setText(getTitle());
    setTitle(null);
    mFab = findViewById(R.id.fab);
    mFab.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            Intent intent = new Intent(getApplicationContext(), EditProfile.class);
            startActivity(intent);
          }
        });
    mFabMargin = getResources().getDimensionPixelSize(R.dimen.margin_standard);
    ViewHelper.setScaleX(mFab, 0);
    ViewHelper.setScaleY(mFab, 0);

    ScrollUtils.addOnGlobalLayoutListener(
        mScrollView,
        new Runnable() {
          @Override
          public void run() {
            mScrollView.scrollTo(0, mFlexibleSpaceImageHeight - mActionBarSize);

            // If you'd like to start from scrollY == 0, don't write like this:
            // mScrollView.scrollTo(0, 0);
            // The initial scrollY is 0, so it won't invoke onScrollChanged().
            // To do this, use the following:
            // onScrollChanged(0, false, false);

            // You can also achieve it with the following codes.
            // This causes scroll change from 1 to 0.
            mScrollView.scrollTo(0, 1);
            mScrollView.scrollTo(0, 0);
          }
        });

    File path =
        new File(Environment.getExternalStorageDirectory(), "/weHappening/profile_image.png");
    Bitmap b = null;
    if (path.exists()) {
      try {
        b = BitmapFactory.decodeStream(new FileInputStream(path));
      } catch (FileNotFoundException e) {
        e.printStackTrace();
      }
      CircularImageView img = (CircularImageView) findViewById(R.id.imgPicker);
      img.setImageBitmap(b);
    } else {
      CircularImageView img = (CircularImageView) findViewById(R.id.imgPicker);
      img.setImageDrawable(getResources().getDrawable(R.drawable.ic_person));
    }
  }
  @Override
  public View getView(final int position, View convertView, ViewGroup parent) {
    ViewHolder mHolder;
    if (convertView != null) {
      mHolder = (ViewHolder) convertView.getTag();
    } else {
      convertView = (SwipeLayout) mInflater.inflate(R.layout.list_item_swipe, null);
      mHolder = ViewHolder.fromValues(convertView);
      convertView.setTag(mHolder);
    }
    SwipeLayout view = (SwipeLayout) convertView;

    view.close(false, false);

    view.getFrontView()
        .setOnClickListener(
            new OnClickListener() {

              @Override
              public void onClick(View v) {
                Utils.showToast(mContext, "item click: " + position);
              }
            });

    view.setSwipeListener(mSwipeListener);

    mHolder.mImage.setImageResource(HEAD_IDS[position % HEAD_IDS.length]);
    mHolder.mName.setText(NAMES[position % NAMES.length]);

    mHolder.mButtonCall.setTag(position);
    mHolder.mButtonCall.setOnClickListener(onActionClick);

    mHolder.mButtonDel.setTag(position);
    mHolder.mButtonDel.setOnClickListener(onActionClick);

    TextView mUnreadView = mHolder.mReminder;
    boolean visiable = !mRemoved.contains(position);
    mUnreadView.setVisibility(visiable ? View.VISIBLE : View.GONE);

    if (visiable) {
      mUnreadView.setText(String.valueOf(position));
      mUnreadView.setTag(position);
      GooViewListener mGooListener =
          new GooViewListener(mContext, mUnreadView) {
            @Override
            public void onDisappear(PointF mDragCenter) {
              super.onDisappear(mDragCenter);

              mRemoved.add(position);
              notifyDataSetChanged();
              Utils.showToast(mContext, "Cheers! We have get rid of it!");
            }

            @Override
            public void onReset(boolean isOutOfRange) {
              super.onReset(isOutOfRange);

              notifyDataSetChanged();
              Utils.showToast(mContext, isOutOfRange ? "Are you regret?" : "Try again!");
            }
          };
      mUnreadView.setOnTouchListener(mGooListener);
    }
    ViewHelper.setRotationX(view, 60);
    ViewPropertyAnimator.animate(view)
        .rotationX(0)
        .setDuration(600)
        .setInterpolator(new OvershootInterpolator(8))
        .start();
    ViewHelper.setScaleX(view, 0.4f);
    ViewPropertyAnimator.animate(view)
        .scaleX(1f)
        .setDuration(600)
        .setInterpolator(new OvershootInterpolator(8))
        .start();
    return view;
  }
 private void setSize(View view, float position, float percentage) {
   ViewHelper.setScaleX(view, (position != 0 && position != 1) ? percentage : 1);
   ViewHelper.setScaleY(view, (position != 0 && position != 1) ? percentage : 1);
 }
 @Override
 public void set(View object, Float value) {
   ViewHelper.setScaleX(object, value);
 }