Пример #1
0
 private void showFab() {
   if (!mFabIsShown) {
     ViewPropertyAnimator.animate(mFab).cancel();
     ViewPropertyAnimator.animate(mFab).scaleX(1).scaleY(1).setDuration(200).start();
     mFabIsShown = true;
   }
 }
Пример #2
0
 private void hideFab() {
   if (mFabIsShown) {
     ViewPropertyAnimator.animate(mFab).cancel();
     ViewPropertyAnimator.animate(mFab).scaleX(0).scaleY(0).setDuration(200).start();
     mFabIsShown = false;
   }
 }
  /**
   * 彈幾個按鈕出嚟
   *
   * @param durationMillis 用幾多時間
   */
  public void startAnimationsIn(int durationMillis) {
    isOpen = true;
    for (int i = 0; i < clayout.getChildCount(); i++) {
      final LinearLayout inoutimagebutton = (LinearLayout) clayout.getChildAt(i);

      double offangle = fullangle / (amount - 1);

      final double deltaY, deltaX;
      if (pc == LEFTCENTER || pc == RIGHTCENTER) {
        deltaX = Math.sin(offangle * i * Math.PI / 180) * R;
        deltaY = Math.cos(offangle * i * Math.PI / 180) * R;
      } else {
        deltaY = Math.sin(offangle * i * Math.PI / 180) * R;
        deltaX = Math.cos(offangle * i * Math.PI / 180) * R;
      }

      ViewPropertyAnimator viewPropertyAnimator = viewAnimators.get(i);
      viewPropertyAnimator.setListener(null);

      inoutimagebutton.setVisibility(View.VISIBLE);
      viewPropertyAnimator
          .x((float) (inoutimagebutton.getLeft() + xOri * deltaX))
          .y((float) (inoutimagebutton.getTop() + yOri * deltaY));
    }
  }
Пример #4
0
  public void show(final View view, Bundle bundle) {
    view.setEnabled(false);
    this.view = view;
    String text = bundle.getString("text");
    tv.setText(text);
    String content = bundle.getString("content");
    contentTv.setText("服务内容:" + content);
    String time = bundle.getString("time");
    timeTv.setText("时间:" + time);
    String location = bundle.getString("location");
    locationTv.setText("地点:" + location);
    ViewHelper.setRotationY(view, 0);
    ViewHelper.setRotationY(root, -90);
    root.setVisibility(View.VISIBLE);

    ViewPropertyAnimator.animate(view)
        .rotationY(90)
        .setDuration(300)
        .setListener(null)
        .setInterpolator(new AccelerateInterpolator());

    ViewPropertyAnimator.animate(root)
        .rotationY(0)
        .setDuration(200)
        .setStartDelay(300)
        .setListener(
            new AnimatorListenerAdapter() {
              @Override
              public void onAnimationEnd(Animator animation) {
                ViewHelper.setRotationY(view, 0);
              }
            });
  }
Пример #5
0
  private void doJazzinessImpl(View item, int position, int scrollDirection) {
    ViewPropertyAnimator animator =
        ViewPropertyAnimator.animate(item)
            .setDuration(DURATION)
            .setInterpolator(new AccelerateDecelerateInterpolator());

    scrollDirection = scrollDirection > 0 ? 1 : -1;
    mTransitionEffect.initView(item, position, scrollDirection);
    mTransitionEffect.setupAnimation(item, position, scrollDirection, animator);
    animator.start();
  }
 /**
  * 收埋幾個按鈕入去
  *
  * @param durationMillis 用幾多時間
  */
 public void startAnimationsOut(int durationMillis) {
   isOpen = false;
   for (int i = 0; i < clayout.getChildCount(); i++) {
     final LinearLayout inoutimagebutton = (LinearLayout) clayout.getChildAt(i);
     ViewPropertyAnimator viewPropertyAnimator = viewAnimators.get(i);
     viewPropertyAnimator.setListener(null);
     viewPropertyAnimator
         .x((float) inoutimagebutton.getLeft())
         .y((float) inoutimagebutton.getTop());
     viewPropertyAnimator.setListener(new AnimListener(inoutimagebutton));
   }
 }
  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);
    }
  }
Пример #8
0
 public void setupAnimation(
     View paramView,
     int paramInt1,
     int paramInt2,
     ViewPropertyAnimator paramViewPropertyAnimator) {
   paramViewPropertyAnimator.scaleX(1.0F).scaleY(1.0F);
 }
Пример #9
0
 @Override
 public void setupAnimation(
     View item, int position, int scrollDirection, ViewPropertyAnimator animator) {
   animator
       .rotationXBy(INITIAL_ROTATION_ANGLE * scrollDirection)
       .translationYBy(-item.getHeight() * 2 * scrollDirection);
 }
Пример #10
0
 @Override
 public void setupAnimation(
     View item, int position, int scrollDirection, ViewPropertyAnimator animator) {
   animator
       .translationYBy(-item.getHeight() / 2 * scrollDirection)
       .scaleX(1)
       .scaleY(1)
       .alpha(JazzyHelper.OPAQUE);
 }
Пример #11
0
 private void slideUp() {
   ViewPropertyAnimator.animate(mView)
       .setStartDelay(1000)
       .alpha(0f)
       .translationY(-mView.getHeight() + mTranslationY)
       .setInterpolator(new AccelerateInterpolator())
       .setDuration(300)
       .start();
 }
Пример #12
0
  public void showUndoBar(boolean immediate, CharSequence message, Parcelable undoToken) {
    mUndoToken = undoToken;
    mUndoMessage = message;
    mMessageView.setText(mUndoMessage);

    //        mHideHandler.removeCallbacks(mHideRunnable);
    //        mHideHandler.postDelayed(mHideRunnable,
    //                mBarView.getResources().getInteger(R.integer.undobar_hide_delay));

    mBarView.setVisibility(View.VISIBLE);
    if (immediate) {
      //            mBarView.setAlpha(1);
      AlphaManager.setAlpha(mBarView, 1);
    } else {
      mBarAnimator.cancel();
      mBarAnimator
          .alpha(1)
          .setDuration(mBarView.getResources().getInteger(android.R.integer.config_shortAnimTime))
          .setListener(null);
    }
  }
Пример #13
0
  public void hideUndoBar(boolean immediate) {
    //        mHideHandler.removeCallbacks(mHideRunnable);
    if (immediate) {
      mBarView.setVisibility(View.GONE);
      AlphaManager.setAlpha(mBarView, 0);
      mUndoMessage = null;
      mUndoToken = null;

    } else {
      mBarAnimator.cancel();
      mBarAnimator
          .alpha(0)
          .setDuration(mBarView.getResources().getInteger(android.R.integer.config_shortAnimTime))
          .setListener(
              new AnimatorListenerAdapter() {
                @Override
                public void onAnimationEnd(Animator animation) {
                  mBarView.setVisibility(View.GONE);
                  mUndoMessage = null;
                  mUndoToken = null;
                }
              });
    }
  }
Пример #14
0
 public LoadToast show() {
   if (!mInflated) {
     mShowCalled = true;
     return this;
   }
   mView.show();
   ViewHelper.setTranslationX(mView, (mParentView.getWidth() - mView.getWidth()) / 2);
   ViewHelper.setAlpha(mView, 0f);
   ViewHelper.setTranslationY(mView, -mView.getHeight() + mTranslationY);
   // mView.setVisibility(View.VISIBLE);
   ViewPropertyAnimator.animate(mView)
       .alpha(1f)
       .translationY(25 + mTranslationY)
       .setInterpolator(new DecelerateInterpolator())
       .setDuration(300)
       .setStartDelay(0)
       .start();
   return this;
 }
  private void toggle(final boolean visible, final boolean animate, boolean force) {
    if (mVisible != visible || force) {
      mVisible = visible;
      int height = getHeight();
      if (height == 0 && !force) {
        ViewTreeObserver vto = getViewTreeObserver();
        if (vto.isAlive()) {
          vto.addOnPreDrawListener(
              new ViewTreeObserver.OnPreDrawListener() {
                @Override
                public boolean onPreDraw() {
                  ViewTreeObserver currentVto = getViewTreeObserver();
                  if (currentVto.isAlive()) {
                    currentVto.removeOnPreDrawListener(this);
                  }
                  toggle(visible, animate, true);
                  return true;
                }
              });
          return;
        }
      }
      int translationY = visible ? 0 : height + getMarginBottom();
      if (animate) {
        ViewPropertyAnimator.animate(this)
            .setInterpolator(mInterpolator)
            .setDuration(TRANSLATE_DURATION_MILLIS)
            .translationY(translationY);
      } else {
        ViewHelper.setTranslationY(this, translationY);
      }

      // On pre-Honeycomb a translated view is still clickable, so we need to disable clicks
      // manually
      if (!hasHoneycombApi()) {
        setClickable(visible);
      }
    }
  }
  @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;
  }