Java Code Examples for android.view.animation.AnticipateInterpolator

The following are top voted examples for showing how to use android.view.animation.AnticipateInterpolator. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: Bigbang   File: ShareCard.java   Source Code and License 6 votes vote down vote up
public void hide() {
    post(new Runnable() {
        @Override
        public void run() {
            ObjectAnimator objectAnimator = ObjectAnimator.ofInt(ShareCard.this, "height", 0);
            objectAnimator.addListener(new AnimatorListenerAdapter() {
                @Override
                public void onAnimationEnd(Animator animation) {
                    super.onAnimationEnd(animation);
                    setVisibility(GONE);
                    if (mListener != null) {
                        mListener.onClick(ShareCard.this);
                    }
                }
            });
            objectAnimator.setDuration(500);
            objectAnimator.setInterpolator(new AnticipateInterpolator());
            objectAnimator.setRepeatCount(0);
            objectAnimator.start();
        }
    });
}
 
Example 2
Project: Bigbang   File: IntroCard.java   Source Code and License 6 votes vote down vote up
public void hide() {
    post(new Runnable() {
        @Override
        public void run() {
            ObjectAnimator objectAnimator = ObjectAnimator.ofInt(IntroCard.this, "height", 0);
            objectAnimator.addListener(new AnimatorListenerAdapter() {
                @Override
                public void onAnimationEnd(Animator animation) {
                    super.onAnimationEnd(animation);
                    setVisibility(GONE);
                    if (mListener != null) {
                        mListener.onClick(IntroCard.this);
                    }
                }
            });
            objectAnimator.setDuration(500);
            objectAnimator.setInterpolator(new AnticipateInterpolator());
            objectAnimator.setRepeatCount(0);
            objectAnimator.start();
        }
    });
}
 
Example 3
Project: ArcLayout-master   File: DemoLikePathActivity.java   Source Code and License 6 votes vote down vote up
@SuppressWarnings("NewApi")
private void hideMenu() {

  List<Animator> animList = new ArrayList<>();

  for (int i = arcLayout.getChildCount() - 1; i >= 0; i--) {
    animList.add(createHideItemAnimator(arcLayout.getChildAt(i)));
  }

  AnimatorSet animSet = new AnimatorSet();
  animSet.setDuration(400);
  animSet.setInterpolator(new AnticipateInterpolator());
  animSet.playTogether(animList);
  animSet.addListener(new AnimatorListenerAdapter() {
    @Override
    public void onAnimationEnd(Animator animation) {
      super.onAnimationEnd(animation);
      menuLayout.setVisibility(View.INVISIBLE);
    }
  });
  animSet.start();

}
 
Example 4
Project: ArcLayout-master   File: MainActivity.java   Source Code and License 6 votes vote down vote up
@SuppressWarnings("NewApi")
private void hideMenu() {

    List<Animator> animList = new ArrayList<>();

    for (int i = arcLayout.getChildCount() - 1; i >= 0; i--) {
        animList.add(createHideItemAnimator(arcLayout.getChildAt(i)));
    }

    AnimatorSet animSet = new AnimatorSet();
    animSet.setDuration(time);
    animSet.setInterpolator(new AnticipateInterpolator());
    animSet.playTogether(animList);
    animSet.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
            super.onAnimationEnd(animation);
            menuLayout.setVisibility(View.GONE);
        }
    });
    animSet.start();

}
 
Example 5
Project: AndroidArcMenu   File: AnimatorUtils.java   Source Code and License 6 votes vote down vote up
static void hideMenu(ViewGroup viewGroup, Point touchPoint) {
    List<Animator> animList = new ArrayList<>();

    for (int i = viewGroup.getChildCount() - 1; i >= 0; i--) {
        animList.add(createHideItemAnimator(viewGroup.getChildAt(i), touchPoint));
    }

    AnimatorSet animSet = new AnimatorSet();
    animSet.setDuration(ANIM_DURATION);
    animSet.setInterpolator(new AnticipateInterpolator());
    animSet.playTogether(animList);
    animSet.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
            super.onAnimationEnd(animation);
        }
    });
    animSet.start();
}
 
Example 6
Project: AndroidArcMenu   File: AnimatorUtils.java   Source Code and License 6 votes vote down vote up
static void openMenu(ViewGroup viewGroup, int openIndex, AnimatorListenerAdapter endListener) {
    List<Animator> animList = new ArrayList<>();

    for (int i = viewGroup.getChildCount() - 1; i >= 0; i--) {
        if (openIndex == i) {
            animList.add(createOpenItemAnimator(viewGroup.getChildAt(i)));
        } else {
            animList.add(createStayHideItemAnimator(viewGroup.getChildAt(i)));
        }
    }
    AnimatorSet animSet = new AnimatorSet();
    animSet.setDuration(ANIM_DURATION);
    animSet.setInterpolator(new AnticipateInterpolator());
    animSet.playTogether(animList);
    animSet.addListener(endListener);
    animSet.start();
}
 
Example 7
Project: TanTanPaneView   File: CircleMenu.java   Source Code and License 6 votes vote down vote up
/**
 * 启动取消动画
 */
private void startCancelMenuAnima() {
    ValueAnimator cancelAnima = ValueAnimator.ofFloat(1.f, 100.f);
    cancelAnima.setDuration(500);
    cancelAnima.setInterpolator(new AnticipateInterpolator());
    cancelAnima.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(ValueAnimator valueAnimator) {
            fraction = valueAnimator.getAnimatedFraction();
            itemMenuRadius = (1 - fraction) * partSize;
            itemIconSize = (int) ((1 - fraction) * iconSize);
            invalidate();
        }
    });
    cancelAnima.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
            status = STATUS_MENU_CLOSED;
            if (onMenuStatusChangeListener != null)
                onMenuStatusChangeListener.onMenuClosed();
        }
    });
    cancelAnima.start();
}
 
Example 8
Project: animated-spans   File: EditTextAnimations.java   Source Code and License 6 votes vote down vote up
public static void acceptAndClear(final EditText editText) {
    Spannable text = editText.getText();
    if (TextUtils.isEmpty(text)) {
        return;
    }
    PropertySpan propertySpan = new PropertySpan(editText);
    propertySpan.setClipOffset(0, editText.getResources().getDimensionPixelOffset(R.dimen.clip_offset_bottom));
    text.setSpan(propertySpan, 0, text.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
    editText.setText(text);

    ObjectAnimator moveUp = ObjectAnimator.ofFloat(propertySpan, PropertySpan.TRANSLATION_Y, 0, -editText.getHeight() / 4);
    moveUp.setDuration(300);
    moveUp.setInterpolator(new AnticipateInterpolator());
    ObjectAnimator fadeOut = ObjectAnimator.ofFloat(propertySpan, PropertySpan.ALPHA, 1, 0);
    fadeOut.setDuration(300);
    AnimatorSet set = new AnimatorSet();
    set.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
            editText.setText(null);
        }
    });
    set.playTogether(moveUp, fadeOut);
    set.start();
}
 
Example 9
Project: SegmentedButton   File: SegmentedButtonGroup.java   Source Code and License 6 votes vote down vote up
private void initInterpolations() {
    ArrayList<Class> interpolatorList = new ArrayList<Class>() {{
        add(FastOutSlowInInterpolator.class);
        add(BounceInterpolator.class);
        add(LinearInterpolator.class);
        add(DecelerateInterpolator.class);
        add(CycleInterpolator.class);
        add(AnticipateInterpolator.class);
        add(AccelerateDecelerateInterpolator.class);
        add(AccelerateInterpolator.class);
        add(AnticipateOvershootInterpolator.class);
        add(FastOutLinearInInterpolator.class);
        add(LinearOutSlowInInterpolator.class);
        add(OvershootInterpolator.class);
    }};

    try {
        interpolatorSelector = (Interpolator) interpolatorList.get(animateSelector).newInstance();
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
Example 10
Project: android-transition   File: DrawerGradientActivity.java   Source Code and License 6 votes vote down vote up
public void updateTransition(View v) {
    mDrawerListenerAdapter.removeAllTransitions();

    ViewTransitionBuilder builder = ViewTransitionBuilder.transit(mGradient).translationX(-mGradient.getWidth(), 0);
    switch (v.getId()) {
        case R.id.interpolator_default:
            break;
        case R.id.interpolator_linear:
            builder.interpolator(new LinearInterpolator());
            break;
        case R.id.interpolator_accelerate:
            builder.interpolator(new AccelerateInterpolator());
            break;
        case R.id.interpolator_decelerate:
            builder.interpolator(new DecelerateInterpolator());
            break;
        case R.id.interpolator_fastout:
            builder.interpolator(new FastOutLinearInInterpolator());
            break;
        case R.id.interpolator_anticipate:
            builder.interpolator(new AnticipateInterpolator());
            break;
    }
    mDrawerListenerAdapter.addTransition(builder);
}
 
Example 11
Project: breadwallet-android   File: FragmentFingerprint.java   Source Code and License 6 votes vote down vote up
private void animateSignalSlide(final boolean reverse) {
    float layoutTY = fingerPrintLayout.getTranslationY();
    if (!reverse) {
        fingerPrintLayout.setTranslationY(layoutTY + BreadActivity.screenParametersPoint.y);
        fingerPrintLayout.animate()
                .translationY(layoutTY)
                .setDuration(ANIMATION_DURATION + 200)
                .setInterpolator(new DecelerateOvershootInterpolator(2.0f, 1f))
                .withLayer();
    } else {
        fingerPrintLayout.animate()
                .translationY(1500)
                .setDuration(ANIMATION_DURATION)
                .withLayer().setInterpolator(new AnticipateInterpolator(2f)).setListener(new AnimatorListenerAdapter() {
            @Override
            public void onAnimationEnd(Animator animation) {
                super.onAnimationEnd(animation);
                if (getActivity() != null)
                    getActivity().getFragmentManager().beginTransaction().remove(FragmentFingerprint.this).commit();
            }
        });

    }

}
 
Example 12
Project: CircularProgressDrawable   File: MainActivity.java   Source Code and License 6 votes vote down vote up
/**
 * Style 3 animation will turn a 3/4 animation with Anticipate/Overshoot interpolation to a
 * blank waiting - like state, wait for 2 seconds then return to the original state
 *
 * @return Animation
 */
private Animator prepareStyle3Animation() {
    AnimatorSet animation = new AnimatorSet();

    ObjectAnimator progressAnimation = ObjectAnimator.ofFloat(drawable, CircularProgressDrawable.PROGRESS_PROPERTY, 0.75f, 0f);
    progressAnimation.setDuration(1200);
    progressAnimation.setInterpolator(new AnticipateInterpolator());

    Animator innerCircleAnimation = ObjectAnimator.ofFloat(drawable, CircularProgressDrawable.CIRCLE_SCALE_PROPERTY, 0.75f, 0f);
    innerCircleAnimation.setDuration(1200);
    innerCircleAnimation.setInterpolator(new AnticipateInterpolator());

    ObjectAnimator invertedProgress = ObjectAnimator.ofFloat(drawable, CircularProgressDrawable.PROGRESS_PROPERTY, 0f, 0.75f);
    invertedProgress.setDuration(1200);
    invertedProgress.setStartDelay(3200);
    invertedProgress.setInterpolator(new OvershootInterpolator());

    Animator invertedCircle = ObjectAnimator.ofFloat(drawable, CircularProgressDrawable.CIRCLE_SCALE_PROPERTY, 0f, 0.75f);
    invertedCircle.setDuration(1200);
    invertedCircle.setStartDelay(3200);
    invertedCircle.setInterpolator(new OvershootInterpolator());

    animation.playTogether(progressAnimation, innerCircleAnimation, invertedProgress, invertedCircle);
    return animation;
}
 
Example 13
Project: LuaViewPlayground   File: UDInterpolator.java   Source Code and License 5 votes vote down vote up
public static Interpolator parse(Integer type, Float cycles) {
        if (type != null) {
            switch (type) {
                case 0:
                    return new AccelerateDecelerateInterpolator();
                case 1:
                    return new AccelerateInterpolator();
                case 2:
                    return new AnticipateInterpolator();
                case 3:
                    return new AnticipateOvershootInterpolator();
                case 4:
                    return new BounceInterpolator();
                case 5:
                    return new CycleInterpolator((cycles != null && cycles > 0) ? cycles : 1f);
                case 6:
                    return new DecelerateInterpolator();
                case 7:
                    return new LinearInterpolator();
                case 8:
                    return new OvershootInterpolator();
                //暂时不支持的
//            case 7: return new FastOutLinearInterplator();
//            case 8: return new FastOutSlowInInterplator();
//            case 10: return new LinearOutSlowInInterplator();
//            case 12: return new PathInterplator();
                default:
                    return new LinearInterpolator();
            }
        } else {
            return new LinearInterpolator();
        }
    }
 
Example 14
Project: AndroidSkinAnimator   File: TranslationHideAnimator.java   Source Code and License 5 votes vote down vote up
@Override
public SkinAnimator apply(@NonNull final View view, @Nullable final Action action) {
    animator = ObjectAnimator.ofPropertyValuesHolder(view,
            PropertyValuesHolder.ofFloat("alpha", 1, 0),
            PropertyValuesHolder.ofFloat("translationX", view.getLeft(), view.getRight()));
    animator.setDuration(3 * PRE_DURATION);
    animator.setInterpolator(new AnticipateInterpolator());
    animator.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
            super.onAnimationEnd(animation);
            resetView(view);
            if (action != null) {
                action.action();
            }
        }
    });
    return this;
}
 
Example 15
Project: AndroidSkinAnimator   File: ScaleHideAnimator.java   Source Code and License 5 votes vote down vote up
@Override
public SkinAnimator apply(@NonNull final View view, @Nullable final Action action) {
    animator = ObjectAnimator.ofPropertyValuesHolder(view,
            PropertyValuesHolder.ofFloat("alpha", 1, 0),
            PropertyValuesHolder.ofFloat("scaleX", 1, 0),
            PropertyValuesHolder.ofFloat("scaleY", 1, 0)
    );
    animator.setDuration(3 * PRE_DURATION);
    animator.setInterpolator(new AnticipateInterpolator());
    animator.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
            super.onAnimationEnd(animation);
            resetView(view);
            if (action != null) {
                action.action();
            }
        }
    });
    return this;
}
 
Example 16
Project: AndroidSkinAnimator   File: TranslationAnimator.java   Source Code and License 5 votes vote down vote up
@Override
public SkinAnimator apply(@NonNull View view, @Nullable final Action action) {
    this.targetView = view;
    preAnimator = ObjectAnimator.ofPropertyValuesHolder(targetView,
            PropertyValuesHolder.ofFloat("alpha", 1, 0),
            PropertyValuesHolder.ofFloat("translationX",
                    view.getLeft(), view.getRight()))
            .setDuration(PRE_DURATION * 3);
    preAnimator.setInterpolator(new AnticipateInterpolator());
    afterAnimator = ObjectAnimator.ofPropertyValuesHolder(targetView,
            PropertyValuesHolder.ofFloat("translationX",
                    view.getRight(), view.getLeft()))
            .setDuration(AFTER_DURATION * 2);
    afterAnimator.setInterpolator(new BounceInterpolator());

    preAnimator.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
            super.onAnimationEnd(animation);
            targetView.setAlpha(1);
            if (action != null) {
                action.action();
            }
            afterAnimator.start();
        }
    });
    return this;
}
 
Example 17
Project: Farmacias   File: Utils.java   Source Code and License 5 votes vote down vote up
/**
 * Creates interpolator.
 *
 * @param interpolatorType
 * @return
 */
public static TimeInterpolator createInterpolator(@IntRange(from = 0, to = 10) final int interpolatorType) {
    switch (interpolatorType) {
        case ACCELERATE_DECELERATE_INTERPOLATOR:
            return new AccelerateDecelerateInterpolator();
        case ACCELERATE_INTERPOLATOR:
            return new AccelerateInterpolator();
        case ANTICIPATE_INTERPOLATOR:
            return new AnticipateInterpolator();
        case ANTICIPATE_OVERSHOOT_INTERPOLATOR:
            return new AnticipateOvershootInterpolator();
        case BOUNCE_INTERPOLATOR:
            return new BounceInterpolator();
        case DECELERATE_INTERPOLATOR:
            return new DecelerateInterpolator();
        case FAST_OUT_LINEAR_IN_INTERPOLATOR:
            return new FastOutLinearInInterpolator();
        case FAST_OUT_SLOW_IN_INTERPOLATOR:
            return new FastOutSlowInInterpolator();
        case LINEAR_INTERPOLATOR:
            return new LinearInterpolator();
        case LINEAR_OUT_SLOW_IN_INTERPOLATOR:
            return new LinearOutSlowInInterpolator();
        case OVERSHOOT_INTERPOLATOR:
            return new OvershootInterpolator();
        default:
            return new LinearInterpolator();
    }
}
 
Example 18
Project: Hotspot-master-devp   File: AnimationUtil.java   Source Code and License 5 votes vote down vote up
private static void setEffect(Animation animation, int interpolatorType, long durationMillis, long delayMillis) {
	switch (interpolatorType) {
		case 0:
			animation.setInterpolator(new LinearInterpolator());
			break;
		case 1:
			animation.setInterpolator(new AccelerateInterpolator());
			break;
		case 2:
			animation.setInterpolator(new DecelerateInterpolator());
			break;
		case 3:
			animation.setInterpolator(new AccelerateDecelerateInterpolator());
			break;
		case 4:
			animation.setInterpolator(new BounceInterpolator());
			break;
		case 5:
			animation.setInterpolator(new OvershootInterpolator());
			break;
		case 6:
			animation.setInterpolator(new AnticipateInterpolator());
			break;
		case 7:
			animation.setInterpolator(new AnticipateOvershootInterpolator());
			break;
		default:
			break;
	}
	animation.setDuration(durationMillis);
	animation.setStartOffset(delayMillis);
}
 
Example 19
Project: Synapse   File: NeuralModelActivity.java   Source Code and License 5 votes vote down vote up
public void onConfirm(View view) {
    final Model model = checkInputs();

    if (model == null) {
        return;
    }

    final Intent intent = new Intent(this, MainService.class);
    intent.putExtra(MainService.ACTION_KEY, MainService.ACTION_TRAIN);
    intent.putExtra(MainService.EXTRAS_NEURAL_CONFIG, model);
    startService(intent);

    final int height = mContainer.getHeight();
    final Activity that = this;

    mPage.setClickable(false);

    mContainer.animate()
            .y(-height)
            .alpha(0F)
            .setInterpolator(new AnticipateInterpolator())
            .setDuration(300)
            .withEndAction(new Runnable() {
                @Override
                public void run() {
                    if (!that.isFinishing()) {
                        that.finish();
                    }
                }
            }).start();

    Tracker.getInstance()
            .event(TrackCons.Model.CLICK_TRAIN)
            .put(TrackCons.Key.MSG, snapshot(model))
            .log();
}
 
Example 20
Project: AnimatedArcProgressView   File: OpacityAnimation.java   Source Code and License 5 votes vote down vote up
private void initAuraAnimators(final int index, ValueAnimator opacityAnimator) {
    opacityAnimator.setRepeatMode(ValueAnimator.REVERSE);
    final float opacityDecelerateFactor = 1.f + 0.8f * (index + 1);
    opacityAnimator.setInterpolator(new AnticipateInterpolator(opacityDecelerateFactor));
    opacityAnimator.setIntValues(255, 50, 255, 50);
    opacityAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            final int opacity = (int) animation.getAnimatedValue();
            mAlphaOpacityList.set(index, opacity);
        }
    });
}
 
Example 21
Project: MaterialDesignDemo   File: ObjectAnimationActivity.java   Source Code and License 5 votes vote down vote up
private void startAnimation() {
        ObjectAnimator oa = ObjectAnimator.ofFloat(mIvPic, "translationY", 0, 400);
        // 加速减速插值器
//        AccelerateDecelerateInterpolator interpolator = new AccelerateDecelerateInterpolator();
        // 加速插值器
//        AccelerateInterpolator interpolator = new AccelerateInterpolator(0.8f);
        // 回荡秋千插值器
        AnticipateInterpolator interpolator = new AnticipateInterpolator(0.8f);
        oa.setInterpolator(interpolator);
        oa.start();
    }
 
Example 22
Project: Tab_Navigator   File: Utils.java   Source Code and License 5 votes vote down vote up
/**
 * Creates interpolator.
 * @return  a timeinterpolator
 * @param interpolatorType a int value from 0 to 10
 */
public static TimeInterpolator createInterpolator(
    @IntRange(from = 0, to = 10) final int interpolatorType) {
  switch (interpolatorType) {
    case ACCELERATE_DECELERATE_INTERPOLATOR:
      return new AccelerateDecelerateInterpolator();
    case ACCELERATE_INTERPOLATOR:
      return new AccelerateInterpolator();
    case ANTICIPATE_INTERPOLATOR:
      return new AnticipateInterpolator();
    case ANTICIPATE_OVERSHOOT_INTERPOLATOR:
      return new AnticipateOvershootInterpolator();
    case BOUNCE_INTERPOLATOR:
      return new BounceInterpolator();
    case DECELERATE_INTERPOLATOR:
      return new DecelerateInterpolator();
    case FAST_OUT_LINEAR_IN_INTERPOLATOR:
      return new FastOutLinearInInterpolator();
    case FAST_OUT_SLOW_IN_INTERPOLATOR:
      return new FastOutSlowInInterpolator();
    case LINEAR_INTERPOLATOR:
      return new LinearInterpolator();
    case LINEAR_OUT_SLOW_IN_INTERPOLATOR:
      return new LinearOutSlowInInterpolator();
    case OVERSHOOT_INTERPOLATOR:
      return new OvershootInterpolator();
    default:
      return new LinearInterpolator();
  }
}
 
Example 23
Project: samples   File: PathProgressDrawable.java   Source Code and License 5 votes vote down vote up
public void setAnimatedPoints(int animatedPoints) {
        float dist = 1f / (float) (animatedPoints - 2);
//        Interpolator interpolator = new AccelerateInterpolator();
//        Interpolator interpolator = new DecelerateInterpolator();
        Interpolator interpolator = new AnticipateInterpolator();

        mFactor = new float[animatedPoints];
        for (int i = 0; i < animatedPoints - 1; i++) {
            mFactor[i] = 1f + interpolator.getInterpolation(dist * i);
        }
        mFactor[animatedPoints - 1] = 1f;
    }
 
Example 24
Project: TanTanPaneView   File: MainActivity.java   Source Code and License 5 votes vote down vote up
private void initView() {
//       tv = (MarqueTextView) findViewById(R.id.tv_marque);
//        Timer timer =  new Timer();
//        TimerTask task = new TimerTask() {
//            @Override
//            public void run() {
//                index ++;
//                if (index > 2) {
//                    index = 0;
//                }
//                MainActivity.this.runOnUiThread(new Runnable() {
//                    @Override
//                    public void run() {
//                        tv.setText(names[index]);
//                    }
//                });
//
//            }
//        };
//        timer.schedule(task,1000,1000);
        findViewById(R.id.iv_head).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Log.e("aaaa","onclick");
//                v.animate().setDuration(1000).scaleX(2).scaleY(2).setInterpolator(new BounceInterpolator()).start();
                AnimatorSet set = new AnimatorSet();
                set.setInterpolator(new AnticipateInterpolator());
                set.playTogether(
                        ObjectAnimator.ofFloat(v,"scaleX",1f,2f),
                         ObjectAnimator.ofFloat(v,"scaleX",2f,1f),
                         ObjectAnimator.ofFloat(v,"scaleY",1f,2f),
                         ObjectAnimator.ofFloat(v,"scaleY",2f,1f));
                set.setDuration(1000).start();
            }
        });


    }
 
Example 25
Project: JPTabBar   File: RotateAnimater.java   Source Code and License 5 votes vote down vote up
@Override
public void onSelectChanged(View v, boolean selected) {
    int end = selected ? 360 : 0;
    ObjectAnimator rotateAnimator = ObjectAnimator.ofFloat(v, "rotation",  end);
    rotateAnimator.setDuration(400);
    rotateAnimator.setInterpolator(new AnticipateInterpolator());
    rotateAnimator.start();
}
 
Example 26
Project: JPTabBar   File: JumpAnimater.java   Source Code and License 5 votes vote down vote up
@Override
public void onSelectChanged(View v, boolean selected) {
    int end = selected?-10:0;
    ObjectAnimator jumpAnimator = ObjectAnimator.ofFloat(v,"translationY",end);
    jumpAnimator.setDuration(300);
    jumpAnimator.setInterpolator(new AnticipateInterpolator());
    jumpAnimator.start();
}
 
Example 27
Project: IndicatorBox   File: GeneralAnimatorGenerator.java   Source Code and License 5 votes vote down vote up
/**
 * Make a shrink animation.
 * @param duration
 * @return
 */
public static Animator shrinkAnimator(int duration){
    AnimatorSet animatorSet = new AnimatorSet();
    ObjectAnimator xExpandAnimator = new ObjectAnimator();
    xExpandAnimator.setPropertyName("scaleX");
    xExpandAnimator.setFloatValues(1.0f, 0.5f);
    ObjectAnimator yExpandAnimator = new ObjectAnimator();
    yExpandAnimator.setPropertyName("scaleY");
    yExpandAnimator.setFloatValues(1.0f, 0.5f);
    animatorSet.play(xExpandAnimator).with(yExpandAnimator);
    animatorSet.setDuration(duration);
    animatorSet.setInterpolator(new AnticipateInterpolator());
    return animatorSet;
}
 
Example 28
Project: AyoSunny   File: AnimationController.java   Source Code and License 5 votes vote down vote up
private static void setEffect(Animation animation, int interpolatorType, long durationMillis, long delayMillis) {
	switch (interpolatorType) {
		case 0:
			animation.setInterpolator(new LinearInterpolator());
			break;
		case 1:
			animation.setInterpolator(new AccelerateInterpolator());
			break;
		case 2:
			animation.setInterpolator(new DecelerateInterpolator());
			break;
		case 3:
			animation.setInterpolator(new AccelerateDecelerateInterpolator());
			break;
		case 4:
			animation.setInterpolator(new BounceInterpolator());
			break;
		case 5:
			animation.setInterpolator(new OvershootInterpolator());
			break;
		case 6:
			animation.setInterpolator(new AnticipateInterpolator());
			break;
		case 7:
			animation.setInterpolator(new AnticipateOvershootInterpolator());
			break;
		default:
			break;
	}
	animation.setDuration(durationMillis);
	animation.setStartOffset(delayMillis);
}
 
Example 29
Project: RadioRealButton   File: RadioRealButtonGroup.java   Source Code and License 5 votes vote down vote up
private void initInterpolations() {
    Class[] interpolations = {
            FastOutSlowInInterpolator.class,
            BounceInterpolator.class,
            LinearInterpolator.class,
            DecelerateInterpolator.class,
            CycleInterpolator.class,
            AnticipateInterpolator.class,
            AccelerateDecelerateInterpolator.class,
            AccelerateInterpolator.class,
            AnticipateOvershootInterpolator.class,
            FastOutLinearInInterpolator.class,
            LinearOutSlowInInterpolator.class,
            OvershootInterpolator.class};

    try {
        interpolatorText = (Interpolator) interpolations[animateTextsEnter].newInstance();
        interpolatorDrawablesEnter = (Interpolator) interpolations[animateDrawablesEnter].newInstance();
        interpolatorSelector = (Interpolator) interpolations[animateSelector].newInstance();

        interpolatorTextExit = (Interpolator) interpolations[animateTextsExit].newInstance();
        interpolatorDrawablesExit = (Interpolator) interpolations[animateDrawablesExit].newInstance();

    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
Example 30
Project: lunzi   File: AnimationController.java   Source Code and License 5 votes vote down vote up
private static void setEffect(Animation animation, int interpolatorType, long durationMillis, long delayMillis) {
    switch (interpolatorType) {
        case 0:
            animation.setInterpolator(new LinearInterpolator());
            break;
        case 1:
            animation.setInterpolator(new AccelerateInterpolator());
            break;
        case 2:
            animation.setInterpolator(new DecelerateInterpolator());
            break;
        case 3:
            animation.setInterpolator(new AccelerateDecelerateInterpolator());
            break;
        case 4:
            animation.setInterpolator(new BounceInterpolator());
            break;
        case 5:
            animation.setInterpolator(new OvershootInterpolator());
            break;
        case 6:
            animation.setInterpolator(new AnticipateInterpolator());
            break;
        case 7:
            animation.setInterpolator(new AnticipateOvershootInterpolator());
            break;
        default:
            break;
    }
    animation.setDuration(durationMillis);
    animation.setStartOffset(delayMillis);
}
 
Example 31
Project: android-DecoView-charting   File: SampleInterpolatorsFragment.java   Source Code and License 5 votes vote down vote up
@Override
protected void createTracks() {
    if (getView() != null) {
        createTracks(R.id.dynamicArcView1, new LinearInterpolator(), Color.parseColor("#CC0000"));
        createTracks(R.id.dynamicArcView2, new AnticipateInterpolator(), Color.parseColor("#048482"));
        createTracks(R.id.dynamicArcView3, new AccelerateInterpolator(), Color.parseColor("#003366"));
        createTracks(R.id.dynamicArcView4, new DecelerateInterpolator(), Color.parseColor("#66A7C5"));
        createTracks(R.id.dynamicArcView5, new BounceInterpolator(), Color.parseColor("#FF6000"));
        createTracks(R.id.dynamicArcView6, new OvershootInterpolator(), Color.parseColor("#6F0564"));
    }
}
 
Example 32
Project: itsnat_droid   File: TestSetupAssetLayoutAnimations2.java   Source Code and License 5 votes vote down vote up
private static void initInterpolatorAnticipateTest(TestActivity act, View rootView,InflatedLayout layout)
{
    TextView textView = getTextView(rootView,R.id.anticipateInterpolatorTestId1);
    Animation animation = getAnimation(act,layout);

    AnticipateInterpolator interpolator = (AnticipateInterpolator)getInterpolator(
            R.anim.test_interpolator_anticipate_compiled,
            "@assets:anim/res/anim/test_interpolator_anticipate_asset.xml",act,layout);

    animation.setInterpolator(interpolator);
    textView.startAnimation(animation);

    Assert.assertEquals((Float)TestUtil.getField(interpolator,AnticipateInterpolator.class,"mTension"),4.0f);
}
 
Example 33
Project: qconrio   File: TransitionsExampleFragment.java   Source Code and License 5 votes vote down vote up
@Override
public void onNextPressed() {
    switch (++currentStep) {
        case 2:
            gif1.setVisibility(View.VISIBLE);
            Utils.startGif(gif1);
            break;
        case 3:
            gif2.setVisibility(View.VISIBLE);
            Utils.stopGif(gif1);
            Utils.startGif(gif2);
            break;
        case 4:
            Utils.stopGif(gif2);
            gif1.animate().translationX(-gif1.getWidth()).alpha(0f)
                    .setStartDelay(0).setInterpolator(new AnticipateInterpolator(1f));
            gif2.animate().translationX(gif2.getWidth()).alpha(0f)
                    .setStartDelay(0).setInterpolator(new AnticipateInterpolator(1f));

            gif3.setVisibility(View.VISIBLE);
            Utils.startGif(gif3);
            gif3.setAlpha(0f);
            gif3.setScaleX(0f);
            gif3.setScaleY(0f);
            gif3.animate().alpha(1f).scaleY(1f).scaleX(1f)
                    .setInterpolator(new OvershootInterpolator(5f))
                    .setStartDelay(200).setDuration(500);
            break;
        case 5:
            ((MainActivity) getActivity()).nextFragment();
    }
}
 
Example 34
Project: qconrio   File: TransitionsExampleFragment.java   Source Code and License 5 votes vote down vote up
@Override
public void onPrevPressed() {
    if (--currentStep > 0) {
        switch (currentStep) {
            case 1:
                gif1.setVisibility(View.GONE);
                Utils.stopGif(gif1);
                break;
            case 2:
                Utils.startGif(gif1);
                Utils.stopGif(gif2);
                gif2.setVisibility(View.GONE);
                break;
            case 3:
                gif1.animate().translationX(1f).alpha(1f)
                        .setStartDelay(400).setInterpolator(new OvershootInterpolator(1f));
                gif2.animate().translationX(1f).alpha(1f)
                        .setStartDelay(400).setInterpolator(new OvershootInterpolator(1f));
                gif3.animate().alpha(0f).scaleY(0f).scaleX(0f)
                    .setInterpolator(new AnticipateInterpolator(3f))
                    .setStartDelay(0).setDuration(500);
                Utils.stopGif(gif3);
                Utils.startGif(gif2);
        }
        return;
    }
    super.onPrevPressed();
}
 
Example 35
Project: itheima   File: AnimationController.java   Source Code and License 5 votes vote down vote up
private static void setEffect(Animation animation, int interpolatorType, long durationMillis, long delayMillis) {
	switch (interpolatorType) {
		case 0:
			animation.setInterpolator(new LinearInterpolator());
			break;
		case 1:
			animation.setInterpolator(new AccelerateInterpolator());
			break;
		case 2:
			animation.setInterpolator(new DecelerateInterpolator());
			break;
		case 3:
			animation.setInterpolator(new AccelerateDecelerateInterpolator());
			break;
		case 4:
			animation.setInterpolator(new BounceInterpolator());
			break;
		case 5:
			animation.setInterpolator(new OvershootInterpolator());
			break;
		case 6:
			animation.setInterpolator(new AnticipateInterpolator());
			break;
		case 7:
			animation.setInterpolator(new AnticipateOvershootInterpolator());
			break;
		default:
			break;
	}
	animation.setDuration(durationMillis);
	animation.setStartOffset(delayMillis);
}
 
Example 36
Project: itheima   File: MainActivity.java   Source Code and License 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	setContentView(R.layout.activity_main);

	imageView = (ImageView) findViewById(R.id.imageView1);

	btn01 = (Button) findViewById(R.id.button1);
	btn01.setOnClickListener(new MyOnClickListener(InterpolatorType.Accelerate));
	
	btn02 = (Button) findViewById(R.id.button2);
	btn02.setOnClickListener(new MyOnClickListener(InterpolatorType.Decelerate));
	
	btn03 = (Button) findViewById(R.id.button3);
	btn03.setOnClickListener(new MyOnClickListener(InterpolatorType.AccelerateDecelerate));
	
	btn04 = (Button) findViewById(R.id.button4);
	btn04.setOnClickListener(new MyOnClickListener(InterpolatorType.LinearInterpolator));
	
	btn05 = (Button) findViewById(R.id.button5);
	btn05.setOnClickListener(new MyOnClickListener(InterpolatorType.BounceInterpolator));
	
	btn06 = (Button) findViewById(R.id.button6);
	btn06.setOnClickListener(new MyOnClickListener(InterpolatorType.AnticipateInterpolator));
	
	btn07 = (Button) findViewById(R.id.button7);
	btn07.setOnClickListener(new MyOnClickListener(InterpolatorType.AnticipateOvershootInterpolator));
	
	btn08 = (Button) findViewById(R.id.button8);
	btn08.setOnClickListener(new MyOnClickListener(InterpolatorType.CycleInterpolator));
	
	btn09 = (Button) findViewById(R.id.button9);
	btn09.setOnClickListener(new MyOnClickListener(InterpolatorType.OvershootInterpolator));
}
 
Example 37
Project: ExpandableButtonMenu   File: ExpandableButtonMenu.java   Source Code and License 5 votes vote down vote up
/**
 * Initialized animation properties
 */
private void calculateAnimationProportions() {
    TRANSLATION_Y = sHeight * buttonDistanceY;
    TRANSLATION_X = sWidth * buttonDistanceX;

    anticipation = new AnticipateInterpolator(INTERPOLATOR_WEIGHT);
    overshoot = new OvershootInterpolator(INTERPOLATOR_WEIGHT);
}
 
Example 38
Project: PropertyAnimatorDemo   File: InterpolatorActivity.java   Source Code and License 4 votes vote down vote up
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
@OnClick({R.id.LinearInterpolator, R.id.AccelerateDecelerateInterpolator,
        R.id.AccelerateInterpolator, R.id.AnticipateInterpolator, R.id.BounceInterpolator,
        R.id.CycleInterpolator, R.id.DecelerateInterpolator, R.id.AnticipateOvershootInterpolator,
        R.id.OvershootInterpolator, R.id.PathInterpolator})
public void onClick(View view) {
    switch (view.getId()) {
        //匀速线性
        case R.id.LinearInterpolator:
            objectAnimator.setInterpolator(new LinearInterpolator());
            break;
        //先加速后减速
        case R.id.AccelerateDecelerateInterpolator:
            objectAnimator.setInterpolator(new AccelerateDecelerateInterpolator());
            break;
        //一直加速
        case R.id.AccelerateInterpolator:
            objectAnimator.setInterpolator(new AccelerateInterpolator());
            break;
        //反向移动然后正向加速
        case R.id.AnticipateInterpolator:
            objectAnimator.setInterpolator(new AnticipateInterpolator());
            break;
        //加速下落回弹
        case R.id.BounceInterpolator:
            objectAnimator.setInterpolator(new BounceInterpolator());
            break;
        //循环播放 参数指定循环次数
        case R.id.CycleInterpolator:
            objectAnimator.setInterpolator(new CycleInterpolator(2f));
            break;
        //减速效果
        case R.id.DecelerateInterpolator:
            objectAnimator.setInterpolator(new DecelerateInterpolator());
            break;
        //反向超过原来位置 然后正向加速超过规定位置 返回
        case R.id.AnticipateOvershootInterpolator:
            objectAnimator.setInterpolator(new AnticipateOvershootInterpolator());
            break;
        //向前甩一定值后再回到原来位置  可以传值指定加速度值
        case R.id.OvershootInterpolator:
            objectAnimator.setInterpolator(new OvershootInterpolator());
            break;
        case R.id.PathInterpolator:
            Intent intent=new Intent(InterpolatorActivity.this,InterpolatorPathActivity.class);
            startActivity(intent);
            break;

    }
    objectAnimator.start();
}
 
Example 39
Project: editor-sql   File: FloatingActionMenu.java   Source Code and License 4 votes vote down vote up
private void init(Context context, AttributeSet attrs) {
    TypedArray attr = context.obtainStyledAttributes(attrs, R.styleable.FloatingActionMenu, 0, 0);
    mButtonSpacing = attr.getDimensionPixelSize(R.styleable.FloatingActionMenu_menu_buttonSpacing, mButtonSpacing);
    mLabelsMargin = attr.getDimensionPixelSize(R.styleable.FloatingActionMenu_menu_labels_margin, mLabelsMargin);
    mLabelsPosition = attr.getInt(R.styleable.FloatingActionMenu_menu_labels_position, LABELS_POSITION_LEFT);
    mLabelsShowAnimation = attr.getResourceId(R.styleable.FloatingActionMenu_menu_labels_showAnimation,
            R.anim.bottom_in);
    mLabelsHideAnimation = attr.getResourceId(R.styleable.FloatingActionMenu_menu_labels_hideAnimation,
            R.anim.bottom_out);
    mLabelsPaddingTop = attr.getDimensionPixelSize(R.styleable.FloatingActionMenu_menu_labels_paddingTop, mLabelsPaddingTop);
    mLabelsPaddingRight = attr.getDimensionPixelSize(R.styleable.FloatingActionMenu_menu_labels_paddingRight, mLabelsPaddingRight);
    mLabelsPaddingBottom = attr.getDimensionPixelSize(R.styleable.FloatingActionMenu_menu_labels_paddingBottom, mLabelsPaddingBottom);
    mLabelsPaddingLeft = attr.getDimensionPixelSize(R.styleable.FloatingActionMenu_menu_labels_paddingLeft, mLabelsPaddingLeft);
    mLabelsTextColor = attr.getColorStateList(R.styleable.FloatingActionMenu_menu_labels_textColor);
    // set default value if null same as for textview
    if (mLabelsTextColor == null) {
        mLabelsTextColor = ColorStateList.valueOf(Color.WHITE);
    }
    mLabelsTextSize = attr.getDimension(R.styleable.FloatingActionMenu_menu_labels_textSize, getResources().getDimension(R.dimen.labels_text_size));
    mLabelsCornerRadius = attr.getDimensionPixelSize(R.styleable.FloatingActionMenu_menu_labels_cornerRadius, mLabelsCornerRadius);
    mLabelsShowShadow = attr.getBoolean(R.styleable.FloatingActionMenu_menu_labels_showShadow, true);
    mLabelsColorNormal = attr.getColor(R.styleable.FloatingActionMenu_menu_labels_colorNormal, 0xFF333333);
    mLabelsColorPressed = attr.getColor(R.styleable.FloatingActionMenu_menu_labels_colorPressed, 0xFF444444);
    mLabelsColorRipple = attr.getColor(R.styleable.FloatingActionMenu_menu_labels_colorRipple, 0x66FFFFFF);
    mMenuShowShadow = attr.getBoolean(R.styleable.FloatingActionMenu_menu_showShadow, true);
    mMenuShadowColor = attr.getColor(R.styleable.FloatingActionMenu_menu_shadowColor, 0x66000000);
    mMenuShadowRadius = attr.getDimension(R.styleable.FloatingActionMenu_menu_shadowRadius, mMenuShadowRadius);
    mMenuShadowXOffset = attr.getDimension(R.styleable.FloatingActionMenu_menu_shadowXOffset, mMenuShadowXOffset);
    mMenuShadowYOffset = attr.getDimension(R.styleable.FloatingActionMenu_menu_shadowYOffset, mMenuShadowYOffset);
    mMenuColorNormal = attr.getColor(R.styleable.FloatingActionMenu_menu_colorNormal, 0xFFDA4336);
    mMenuColorPressed = attr.getColor(R.styleable.FloatingActionMenu_menu_colorPressed, 0xFFE75043);
    mMenuColorRipple = attr.getColor(R.styleable.FloatingActionMenu_menu_colorRipple, 0x99FFFFFF);
    mAnimationDelayPerItem = attr.getInt(R.styleable.FloatingActionMenu_menu_animationDelayPerItem, 50);
    mIcon = attr.getDrawable(R.styleable.FloatingActionMenu_menu_icon);
    if (mIcon == null) {
        mIcon = getResources().getDrawable(R.drawable.ic_add_fab);
    }
    mLabelsSingleLine = attr.getBoolean(R.styleable.FloatingActionMenu_menu_labels_singleLine, false);
    mLabelsEllipsize = attr.getInt(R.styleable.FloatingActionMenu_menu_labels_ellipsize, 0);
    mLabelsMaxLines = attr.getInt(R.styleable.FloatingActionMenu_menu_labels_maxLines, -1);
    mMenuFabSize = attr.getInt(R.styleable.FloatingActionMenu_menu_fab_size, FloatingActionButton.SIZE_NORMAL);
    mLabelsStyle = attr.getResourceId(R.styleable.FloatingActionMenu_menu_labels_style, 0);
    mOpenDirection = attr.getInt(R.styleable.FloatingActionMenu_menu_openDirection, OPEN_UP);
    mBackgroundColor = attr.getColor(R.styleable.FloatingActionMenu_menu_backgroundColor, Color.RED);

    if (attr.hasValue(R.styleable.FloatingActionMenu_menu_fab_label)) {
        mUsingMenuLabel = true;
        mMenuLabelText = attr.getString(R.styleable.FloatingActionMenu_menu_fab_label);
    }

    if (attr.hasValue(R.styleable.FloatingActionMenu_menu_labels_padding)) {
        int padding = attr.getDimensionPixelSize(R.styleable.FloatingActionMenu_menu_labels_padding, 0);
        initPadding(padding);
    }

    mOpenInterpolator = new OvershootInterpolator();
    mCloseInterpolator = new AnticipateInterpolator();
    mLabelsContext = new ContextThemeWrapper(getContext(), mLabelsStyle);

    initBackgroundDimAnimation();
    createMenuButton();
    initMenuButtonAnimations(attr);

    attr.recycle();
}
 
Example 40
Project: MDWechat   File: FloatingActionMenu.java   Source Code and License 4 votes vote down vote up
private void init(Context context, AttributeSet attrs) {
        TypedArray attr = context.obtainStyledAttributes(attrs, R.styleable.FloatingActionMenu, 0, 0);
        mButtonSpacing = attr.getDimensionPixelSize(R.styleable.FloatingActionMenu_menu_buttonSpacing, mButtonSpacing);
        mLabelsMargin = attr.getDimensionPixelSize(R.styleable.FloatingActionMenu_menu_labels_margin, mLabelsMargin);
        mLabelsPosition = attr.getInt(R.styleable.FloatingActionMenu_menu_labels_position, LABELS_POSITION_LEFT);
        mLabelsShowAnimation = attr.getResourceId(R.styleable.FloatingActionMenu_menu_labels_showAnimation,
                mLabelsPosition == LABELS_POSITION_LEFT ? R.anim.fab_slide_in_from_right : R.anim.fab_slide_in_from_left);
        mLabelsHideAnimation = attr.getResourceId(R.styleable.FloatingActionMenu_menu_labels_hideAnimation,
                mLabelsPosition == LABELS_POSITION_LEFT ? R.anim.fab_slide_out_to_right : R.anim.fab_slide_out_to_left);
        mLabelsPaddingTop = attr.getDimensionPixelSize(R.styleable.FloatingActionMenu_menu_labels_paddingTop, mLabelsPaddingTop);
        mLabelsPaddingRight = attr.getDimensionPixelSize(R.styleable.FloatingActionMenu_menu_labels_paddingRight, mLabelsPaddingRight);
        mLabelsPaddingBottom = attr.getDimensionPixelSize(R.styleable.FloatingActionMenu_menu_labels_paddingBottom, mLabelsPaddingBottom);
        mLabelsPaddingLeft = attr.getDimensionPixelSize(R.styleable.FloatingActionMenu_menu_labels_paddingLeft, mLabelsPaddingLeft);
        mLabelsTextColor = attr.getColorStateList(R.styleable.FloatingActionMenu_menu_labels_textColor);
        // set default value if null same as for textview
        if (mLabelsTextColor == null) {
            mLabelsTextColor = ColorStateList.valueOf(Color.WHITE);
        }
        mLabelsTextSize = attr.getDimension(R.styleable.FloatingActionMenu_menu_labels_textSize, getResources().getDimension(R.dimen.labels_text_size));
        mLabelsCornerRadius = attr.getDimensionPixelSize(R.styleable.FloatingActionMenu_menu_labels_cornerRadius, mLabelsCornerRadius);
        mLabelsShowShadow = attr.getBoolean(R.styleable.FloatingActionMenu_menu_labels_showShadow, true);
        mLabelsColorNormal = attr.getColor(R.styleable.FloatingActionMenu_menu_labels_colorNormal, 0xFF333333);
        mLabelsColorPressed = attr.getColor(R.styleable.FloatingActionMenu_menu_labels_colorPressed, 0xFF444444);
        mLabelsColorRipple = attr.getColor(R.styleable.FloatingActionMenu_menu_labels_colorRipple, 0x66FFFFFF);
        mMenuShowShadow = attr.getBoolean(R.styleable.FloatingActionMenu_menu_showShadow, true);
        mMenuShadowColor = attr.getColor(R.styleable.FloatingActionMenu_menu_shadowColor, 0x66000000);
        mMenuShadowRadius = attr.getDimension(R.styleable.FloatingActionMenu_menu_shadowRadius, mMenuShadowRadius);
        mMenuShadowXOffset = attr.getDimension(R.styleable.FloatingActionMenu_menu_shadowXOffset, mMenuShadowXOffset);
        mMenuShadowYOffset = attr.getDimension(R.styleable.FloatingActionMenu_menu_shadowYOffset, mMenuShadowYOffset);
        mMenuColorNormal = attr.getColor(R.styleable.FloatingActionMenu_menu_colorNormal, 0xFFDA4336);
        mMenuColorPressed = attr.getColor(R.styleable.FloatingActionMenu_menu_colorPressed, 0xFFE75043);
        mMenuColorRipple = attr.getColor(R.styleable.FloatingActionMenu_menu_colorRipple, 0x99FFFFFF);
        mAnimationDelayPerItem = attr.getInt(R.styleable.FloatingActionMenu_menu_animationDelayPerItem, 50);
        mIcon = attr.getDrawable(R.styleable.FloatingActionMenu_menu_icon);
        if (mIcon == null) {
//            mIcon = getResources().getDrawable(R.drawable.fab_add);
        }
        mLabelsSingleLine = attr.getBoolean(R.styleable.FloatingActionMenu_menu_labels_singleLine, false);
        mLabelsEllipsize = attr.getInt(R.styleable.FloatingActionMenu_menu_labels_ellipsize, 0);
        mLabelsMaxLines = attr.getInt(R.styleable.FloatingActionMenu_menu_labels_maxLines, -1);
        mMenuFabSize = attr.getInt(R.styleable.FloatingActionMenu_menu_fab_size, FloatingActionButton.SIZE_NORMAL);
        mLabelsStyle = attr.getResourceId(R.styleable.FloatingActionMenu_menu_labels_style, 0);
        String customFont = attr.getString(R.styleable.FloatingActionMenu_menu_labels_customFont);
        try {
            if (!TextUtils.isEmpty(customFont)) {
                mCustomTypefaceFromFont = Typeface.createFromAsset(getContext().getAssets(), customFont);
            }
        } catch (RuntimeException ex) {
            throw new IllegalArgumentException("Unable to load specified custom font: " + customFont, ex);
        }
        mOpenDirection = attr.getInt(R.styleable.FloatingActionMenu_menu_openDirection, OPEN_UP);
        mBackgroundColor = attr.getColor(R.styleable.FloatingActionMenu_menu_backgroundColor, Color.TRANSPARENT);

        if (attr.hasValue(R.styleable.FloatingActionMenu_menu_fab_label)) {
            mUsingMenuLabel = true;
            mMenuLabelText = attr.getString(R.styleable.FloatingActionMenu_menu_fab_label);
        }

        if (attr.hasValue(R.styleable.FloatingActionMenu_menu_labels_padding)) {
            int padding = attr.getDimensionPixelSize(R.styleable.FloatingActionMenu_menu_labels_padding, 0);
            initPadding(padding);
        }

        mOpenInterpolator = new OvershootInterpolator();
        mCloseInterpolator = new AnticipateInterpolator();
        mLabelsContext = new ContextThemeWrapper(getContext(), mLabelsStyle);

        initBackgroundDimAnimation();
        createMenuButton();
        initMenuButtonAnimations(attr);

        attr.recycle();

        this.requestFocus();
        this.setFocusableInTouchMode(true);
    }
 
Example 41
Project: ChatExchange-old   File: RecyclerAdapter.java   Source Code and License 4 votes vote down vote up
MyViewHolder(View v)
{
    super(v); // done this way instead of view tagging
    mItem = v;
    mTextView = v.findViewById(R.id.chatroomName);
    mImageView = v.findViewById(R.id.chatroomImg);
    mCloseChat = v.findViewById(R.id.close_chat_img);

    mBehind = v.findViewById(R.id.behind_views);
    mContainer = v.findViewById(R.id.chat_item_container);

    mCloseChat.setScaleX(0f);
    mCloseChat.setScaleY(0f);

    ObjectAnimator revealAnimatorX = ObjectAnimator.ofFloat(
            mCloseChat,
            "scaleX",
            0f,
            1.0f
    );

    ObjectAnimator revealAnimatorY = ObjectAnimator.ofFloat(
            mCloseChat,
            "scaleY",
            0f,
            1.0f
    );

    mCloseButtonRevealSet.play(revealAnimatorX);
    mCloseButtonRevealSet.play(revealAnimatorY);
    mCloseButtonRevealSet.setInterpolator(new OvershootInterpolator());
    mCloseButtonRevealSet.setDuration((long) Utils.getAnimDuration(mContext.getResources().getInteger(R.integer.animation_duration_ms) - 200, mContext));
    mCloseButtonRevealSet.addListener(mRevealListener);

    ObjectAnimator hideAnimatorX = ObjectAnimator.ofFloat(
            mCloseChat,
            "scaleX",
            1.0f,
            0f
    );

    ObjectAnimator hideAnimatorY = ObjectAnimator.ofFloat(
            mCloseChat,
            "scaleY",
            1.0f,
            0f
    );

    mCloseButtonHideSet.play(hideAnimatorX);
    mCloseButtonHideSet.play(hideAnimatorY);
    mCloseButtonHideSet.setInterpolator(new AnticipateInterpolator());
    mCloseButtonHideSet.setDuration((long) Utils.getAnimDuration(mContext.getResources().getInteger(R.integer.animation_duration_ms) - 200, mContext));
    mCloseButtonHideSet.addListener(mHideListener);
}
 
Example 42
Project: ChatExchange-old   File: FloatingActionMenu.java   Source Code and License 4 votes vote down vote up
private void init(Context context, AttributeSet attrs) {
    TypedArray attr = context.obtainStyledAttributes(attrs, R.styleable.FloatingActionMenu, 0, 0);
    mOpenRotationLeft = attr.getInt(R.styleable.FloatingActionMenu_menu_fab_open_rotation_left, (int)OPENED_PLUS_ROTATION_LEFT);
    mOpenRotationRight = attr.getInt(R.styleable.FloatingActionMenu_menu_fab_open_rotation_right, (int)OPENED_PLUS_ROTATION_RIGHT);
    mAnimationDuration = attr.getInt((int)getAnimDuration(R.styleable.FloatingActionMenu_menu_fab_animation_duration, context), (int)getAnimDuration(ANIMATION_DURATION, context));
    mButtonSpacing = attr.getDimensionPixelSize(R.styleable.FloatingActionMenu_menu_buttonSpacing, mButtonSpacing);
    mLabelsMargin = attr.getDimensionPixelSize(R.styleable.FloatingActionMenu_menu_labels_margin, mLabelsMargin);
    mLabelsPosition = attr.getInt(R.styleable.FloatingActionMenu_menu_labels_position, LABELS_POSITION_LEFT);
    mLabelsShowAnimation = attr.getResourceId(R.styleable.FloatingActionMenu_menu_labels_showAnimation,
            mLabelsPosition == LABELS_POSITION_LEFT ? R.anim.fab_slide_in_from_right : R.anim.fab_slide_in_from_left);
    mLabelsHideAnimation = attr.getResourceId(R.styleable.FloatingActionMenu_menu_labels_hideAnimation,
            mLabelsPosition == LABELS_POSITION_LEFT ? R.anim.fab_slide_out_to_right : R.anim.fab_slide_out_to_left);
    mLabelsPaddingTop = attr.getDimensionPixelSize(R.styleable.FloatingActionMenu_menu_labels_paddingTop, mLabelsPaddingTop);
    mLabelsPaddingRight = attr.getDimensionPixelSize(R.styleable.FloatingActionMenu_menu_labels_paddingRight, mLabelsPaddingRight);
    mLabelsPaddingBottom = attr.getDimensionPixelSize(R.styleable.FloatingActionMenu_menu_labels_paddingBottom, mLabelsPaddingBottom);
    mLabelsPaddingLeft = attr.getDimensionPixelSize(R.styleable.FloatingActionMenu_menu_labels_paddingLeft, mLabelsPaddingLeft);
    mLabelsTextColor = attr.getColorStateList(R.styleable.FloatingActionMenu_menu_labels_textColor);
    // set default value if null same as for textview
    if (mLabelsTextColor == null) {
        mLabelsTextColor = ColorStateList.valueOf(Color.WHITE);
    }
    mLabelsTextSize = attr.getDimension(R.styleable.FloatingActionMenu_menu_labels_textSize, getResources().getDimension(R.dimen.labels_text_size));
    mLabelsCornerRadius = attr.getDimensionPixelSize(R.styleable.FloatingActionMenu_menu_labels_cornerRadius, mLabelsCornerRadius);
    mLabelsShowShadow = attr.getBoolean(R.styleable.FloatingActionMenu_menu_labels_showShadow, true);
    mLabelsColorNormal = attr.getColor(R.styleable.FloatingActionMenu_menu_labels_colorNormal, 0xFF333333);
    mLabelsColorPressed = attr.getColor(R.styleable.FloatingActionMenu_menu_labels_colorPressed, 0xFF444444);
    mLabelsColorRipple = attr.getColor(R.styleable.FloatingActionMenu_menu_labels_colorRipple, 0x66FFFFFF);
    mMenuShowShadow = attr.getBoolean(R.styleable.FloatingActionMenu_menu_showShadow, true);
    mMenuShadowColor = attr.getColor(R.styleable.FloatingActionMenu_menu_shadowColor, 0x66000000);
    mMenuShadowRadius = attr.getDimension(R.styleable.FloatingActionMenu_menu_shadowRadius, mMenuShadowRadius);
    mMenuShadowXOffset = attr.getDimension(R.styleable.FloatingActionMenu_menu_shadowXOffset, mMenuShadowXOffset);
    mMenuShadowYOffset = attr.getDimension(R.styleable.FloatingActionMenu_menu_shadowYOffset, mMenuShadowYOffset);
    mMenuColorNormal = attr.getColor(R.styleable.FloatingActionMenu_menu_colorNormal, 0xFFDA4336);
    mMenuColorPressed = attr.getColor(R.styleable.FloatingActionMenu_menu_colorPressed, 0xFFE75043);
    mMenuColorRipple = attr.getColor(R.styleable.FloatingActionMenu_menu_colorRipple, 0x99FFFFFF);
    mAnimationDelayPerItem = attr.getInt(R.styleable.FloatingActionMenu_menu_animationDelayPerItem, 50);
    try
    {
        mIcon = VectorDrawableCompat.create(attr.getResources(), attr.getResourceId(R.styleable.FloatingActionMenu_menu_icon, R.drawable.fab_add), null);
    } catch (Resources.NotFoundException e) {
        e.printStackTrace();
        mIcon = getResources().getDrawable(R.drawable.fab_add);
    }
    mLabelsSingleLine = attr.getBoolean(R.styleable.FloatingActionMenu_menu_labels_singleLine, false);
    mLabelsEllipsize = attr.getInt(R.styleable.FloatingActionMenu_menu_labels_ellipsize, 0);
    mLabelsMaxLines = attr.getInt(R.styleable.FloatingActionMenu_menu_labels_maxLines, -1);
    mMenuFabSize = attr.getInt(R.styleable.FloatingActionMenu_menu_fab_size, FloatingActionButton.SIZE_NORMAL);
    mLabelsStyle = attr.getResourceId(R.styleable.FloatingActionMenu_menu_labels_style, 0);
    String customFont = attr.getString(R.styleable.FloatingActionMenu_menu_labels_customFont);
    try {
        if (!TextUtils.isEmpty(customFont)) {
            mCustomTypefaceFromFont = Typeface.createFromAsset(getContext().getAssets(), customFont);
        }
    } catch (RuntimeException ex) {
        throw new IllegalArgumentException("Unable to load specified custom font: " + customFont, ex);
    }
    mOpenDirection = attr.getInt(R.styleable.FloatingActionMenu_menu_openDirection, OPEN_UP);
    mBackgroundColor = attr.getColor(R.styleable.FloatingActionMenu_menu_backgroundColor, Color.TRANSPARENT);

    if (attr.hasValue(R.styleable.FloatingActionMenu_menu_fab_label)) {
        mUsingMenuLabel = true;
        mMenuLabelText = attr.getString(R.styleable.FloatingActionMenu_menu_fab_label);
    }

    if (attr.hasValue(R.styleable.FloatingActionMenu_menu_labels_padding)) {
        int padding = attr.getDimensionPixelSize(R.styleable.FloatingActionMenu_menu_labels_padding, 0);
        initPadding(padding);
    }

    mOpenInterpolator = new OvershootInterpolator();
    mCloseInterpolator = new AnticipateInterpolator();
    mLabelsContext = new ContextThemeWrapper(getContext(), mLabelsStyle);

    initBackgroundDimAnimation();
    createMenuButton();
    initMenuButtonAnimations(attr);

    attr.recycle();
}
 
Example 43
Project: Toodoo   File: FloatingActionMenu.java   Source Code and License 4 votes vote down vote up
private void init(Context context, AttributeSet attrs) {
    TypedArray attr = context.obtainStyledAttributes(attrs, R.styleable.FloatingActionMenu, 0, 0);
    mButtonSpacing = attr.getDimensionPixelSize(R.styleable.FloatingActionMenu_menu_buttonSpacing, mButtonSpacing);
    mLabelsMargin = attr.getDimensionPixelSize(R.styleable.FloatingActionMenu_menu_labels_margin, mLabelsMargin);
    mLabelsPosition = attr.getInt(R.styleable.FloatingActionMenu_menu_labels_position, LABELS_POSITION_LEFT);
    mLabelsShowAnimation = attr.getResourceId(R.styleable.FloatingActionMenu_menu_labels_showAnimation,
            mLabelsPosition == LABELS_POSITION_LEFT ? R.anim.fab_slide_in_from_right : R.anim.fab_slide_in_from_left);
    mLabelsHideAnimation = attr.getResourceId(R.styleable.FloatingActionMenu_menu_labels_hideAnimation,
            mLabelsPosition == LABELS_POSITION_LEFT ? R.anim.fab_slide_out_to_right : R.anim.fab_slide_out_to_left);
    mLabelsPaddingTop = attr.getDimensionPixelSize(R.styleable.FloatingActionMenu_menu_labels_paddingTop, mLabelsPaddingTop);
    mLabelsPaddingRight = attr.getDimensionPixelSize(R.styleable.FloatingActionMenu_menu_labels_paddingRight, mLabelsPaddingRight);
    mLabelsPaddingBottom = attr.getDimensionPixelSize(R.styleable.FloatingActionMenu_menu_labels_paddingBottom, mLabelsPaddingBottom);
    mLabelsPaddingLeft = attr.getDimensionPixelSize(R.styleable.FloatingActionMenu_menu_labels_paddingLeft, mLabelsPaddingLeft);
    mLabelsTextColor = attr.getColorStateList(R.styleable.FloatingActionMenu_menu_labels_textColor);
    // set default value if null same as for textview
    if (mLabelsTextColor == null) {
        mLabelsTextColor = ColorStateList.valueOf(Color.WHITE);
    }
    mLabelsTextSize = attr.getDimension(R.styleable.FloatingActionMenu_menu_labels_textSize, getResources().getDimension(R.dimen.labels_text_size));
    mLabelsCornerRadius = attr.getDimensionPixelSize(R.styleable.FloatingActionMenu_menu_labels_cornerRadius, mLabelsCornerRadius);
    mLabelsShowShadow = attr.getBoolean(R.styleable.FloatingActionMenu_menu_labels_showShadow, true);
    mLabelsColorNormal = attr.getColor(R.styleable.FloatingActionMenu_menu_labels_colorNormal, 0xFFa99494);
    mLabelsColorPressed = attr.getColor(R.styleable.FloatingActionMenu_menu_labels_colorPressed, 0xFFa99494);
    mLabelsColorRipple = attr.getColor(R.styleable.FloatingActionMenu_menu_labels_colorRipple, 0x66FFFFFF);
    mMenuShowShadow = attr.getBoolean(R.styleable.FloatingActionMenu_menu_showShadow, true);
    mMenuShadowColor = attr.getColor(R.styleable.FloatingActionMenu_menu_shadowColor, 0x66000000);
    mMenuShadowRadius = attr.getDimension(R.styleable.FloatingActionMenu_menu_shadowRadius, mMenuShadowRadius);
    mMenuShadowXOffset = attr.getDimension(R.styleable.FloatingActionMenu_menu_shadowXOffset, mMenuShadowXOffset);
    mMenuShadowYOffset = attr.getDimension(R.styleable.FloatingActionMenu_menu_shadowYOffset, mMenuShadowYOffset);
    mMenuColorNormal = attr.getColor(R.styleable.FloatingActionMenu_menu_colorNormal, 0xFFFF5252);
    mMenuColorPressed = attr.getColor(R.styleable.FloatingActionMenu_menu_colorPressed, 0xFFFF5252);
    mMenuColorRipple = attr.getColor(R.styleable.FloatingActionMenu_menu_colorRipple, 0x99FFFFFF);
    mAnimationDelayPerItem = attr.getInt(R.styleable.FloatingActionMenu_menu_animationDelayPerItem, 50);
    mIcon = attr.getDrawable(R.styleable.FloatingActionMenu_menu_icon);
    if (mIcon == null) {
        mIcon = getResources().getDrawable(R.drawable.fab_add);
    }
    mLabelsSingleLine = attr.getBoolean(R.styleable.FloatingActionMenu_menu_labels_singleLine, false);
    mLabelsEllipsize = attr.getInt(R.styleable.FloatingActionMenu_menu_labels_ellipsize, 0);
    mLabelsMaxLines = attr.getInt(R.styleable.FloatingActionMenu_menu_labels_maxLines, -1);
    mMenuFabSize = attr.getInt(R.styleable.FloatingActionMenu_menu_fab_size, FloatingActionButton.SIZE_NORMAL);
    mLabelsStyle = attr.getResourceId(R.styleable.FloatingActionMenu_menu_labels_style, 0);
    String customFont = attr.getString(R.styleable.FloatingActionMenu_menu_labels_customFont);
    try {
        if (!TextUtils.isEmpty(customFont)) {
            mCustomTypefaceFromFont = Typeface.createFromAsset(getContext().getAssets(), customFont);
        }
    } catch (RuntimeException ex) {
        throw new IllegalArgumentException("Unable to load specified custom font: " + customFont, ex);
    }
    mOpenDirection = attr.getInt(R.styleable.FloatingActionMenu_menu_openDirection, OPEN_UP);
    mBackgroundColor = attr.getColor(R.styleable.FloatingActionMenu_menu_backgroundColor, Color.TRANSPARENT);

    if (attr.hasValue(R.styleable.FloatingActionMenu_menu_fab_label)) {
        mUsingMenuLabel = true;
        mMenuLabelText = attr.getString(R.styleable.FloatingActionMenu_menu_fab_label);
    }

    if (attr.hasValue(R.styleable.FloatingActionMenu_menu_labels_padding)) {
        int padding = attr.getDimensionPixelSize(R.styleable.FloatingActionMenu_menu_labels_padding, 0);
        initPadding(padding);
    }

    mOpenInterpolator = new OvershootInterpolator();
    mCloseInterpolator = new AnticipateInterpolator();
    mLabelsContext = new ContextThemeWrapper(getContext(), mLabelsStyle);

    initBackgroundDimAnimation();
    createMenuButton();
    initMenuButtonAnimations(attr);

    attr.recycle();
}
 
Example 44
Project: SlidingPanel   File: SlidingPanelAnimator.java   Source Code and License 4 votes vote down vote up
/**
 * Sets interpolator to AnimationSet object.
 *
 * @param interpolator - string value, responsible for setting concrete interpolator to AnimationSet object.
 * @return AnimationSet object with applied interpolator.
 */
private AnimationSet setInterpolator(String interpolator) {
    AnimationSet animationSet = new AnimationSet(true);

    switch (interpolator) {
        case "decelerate":
            animationSet.setInterpolator(new DecelerateInterpolator(1.0f));
            break;

        case "accelerate":
            animationSet.setInterpolator(new AccelerateInterpolator(1.0f));
            break;

        case "accelerateDecelerate":
            animationSet.setInterpolator(new AccelerateDecelerateInterpolator());
            break;

        case "anticipate":
            animationSet.setInterpolator(new AnticipateInterpolator(1.0f));
            break;

        case "anticipateOvershoot":
            animationSet.setInterpolator(new AnticipateOvershootInterpolator(1.0f));
            break;

        case "bounce":
            animationSet.setInterpolator(new BounceInterpolator());
            break;

        case "cycle":
            animationSet.setInterpolator(new CycleInterpolator(1.0f));
            break;

        case "overshoot":
            animationSet.setInterpolator(new OvershootInterpolator(1.0f));
            break;

        default:
            animationSet.setInterpolator(new LinearInterpolator());
            break;
    }

    return animationSet;
}
 
Example 45
Project: MaterialFBook   File: FloatingActionMenu.java   Source Code and License 4 votes vote down vote up
private void init(Context context, AttributeSet attrs) {
    TypedArray attr = context.obtainStyledAttributes(attrs, R.styleable.FloatingActionMenu, 0, 0);
    mButtonSpacing = attr.getDimensionPixelSize(R.styleable.FloatingActionMenu_menu_buttonSpacing, mButtonSpacing);
    mLabelsMargin = attr.getDimensionPixelSize(R.styleable.FloatingActionMenu_menu_labels_margin, mLabelsMargin);
    mLabelsPosition = attr.getInt(R.styleable.FloatingActionMenu_menu_labels_position, LABELS_POSITION_LEFT);
    mLabelsShowAnimation = attr.getResourceId(R.styleable.FloatingActionMenu_menu_labels_showAnimation,
            mLabelsPosition == LABELS_POSITION_LEFT ? R.anim.fab_slide_in_from_right : R.anim.fab_slide_in_from_left);
    mLabelsHideAnimation = attr.getResourceId(R.styleable.FloatingActionMenu_menu_labels_hideAnimation,
            mLabelsPosition == LABELS_POSITION_LEFT ? R.anim.fab_slide_out_to_right : R.anim.fab_slide_out_to_left);
    mLabelsPaddingTop = attr.getDimensionPixelSize(R.styleable.FloatingActionMenu_menu_labels_paddingTop, mLabelsPaddingTop);
    mLabelsPaddingRight = attr.getDimensionPixelSize(R.styleable.FloatingActionMenu_menu_labels_paddingRight, mLabelsPaddingRight);
    mLabelsPaddingBottom = attr.getDimensionPixelSize(R.styleable.FloatingActionMenu_menu_labels_paddingBottom, mLabelsPaddingBottom);
    mLabelsPaddingLeft = attr.getDimensionPixelSize(R.styleable.FloatingActionMenu_menu_labels_paddingLeft, mLabelsPaddingLeft);
    mLabelsTextColor = attr.getColorStateList(R.styleable.FloatingActionMenu_menu_labels_textColor);
    // set default value if null same as for textview
    if (mLabelsTextColor == null) {
        mLabelsTextColor = ColorStateList.valueOf(Color.WHITE);
    }
    mLabelsTextSize = attr.getDimension(R.styleable.FloatingActionMenu_menu_labels_textSize, getResources().getDimension(R.dimen.labels_text_size));
    mLabelsCornerRadius = attr.getDimensionPixelSize(R.styleable.FloatingActionMenu_menu_labels_cornerRadius, mLabelsCornerRadius);
    mLabelsShowShadow = attr.getBoolean(R.styleable.FloatingActionMenu_menu_labels_showShadow, true);
    mLabelsColorNormal = attr.getColor(R.styleable.FloatingActionMenu_menu_labels_colorNormal, 0xFF333333);
    mLabelsColorPressed = attr.getColor(R.styleable.FloatingActionMenu_menu_labels_colorPressed, 0xFF444444);
    mLabelsColorRipple = attr.getColor(R.styleable.FloatingActionMenu_menu_labels_colorRipple, 0x66FFFFFF);
    mMenuShowShadow = attr.getBoolean(R.styleable.FloatingActionMenu_menu_showShadow, true);
    mMenuShadowColor = attr.getColor(R.styleable.FloatingActionMenu_menu_shadowColor, 0x66000000);
    mMenuShadowRadius = attr.getDimension(R.styleable.FloatingActionMenu_menu_shadowRadius, mMenuShadowRadius);
    mMenuShadowXOffset = attr.getDimension(R.styleable.FloatingActionMenu_menu_shadowXOffset, mMenuShadowXOffset);
    mMenuShadowYOffset = attr.getDimension(R.styleable.FloatingActionMenu_menu_shadowYOffset, mMenuShadowYOffset);
    mMenuColorNormal = attr.getColor(R.styleable.FloatingActionMenu_menu_colorNormal, 0xFFDA4336);
    mMenuColorPressed = attr.getColor(R.styleable.FloatingActionMenu_menu_colorPressed, 0xFFE75043);
    mMenuColorRipple = attr.getColor(R.styleable.FloatingActionMenu_menu_colorRipple, 0x99FFFFFF);
    mAnimationDelayPerItem = attr.getInt(R.styleable.FloatingActionMenu_menu_animationDelayPerItem, 50);
    mIcon = attr.getDrawable(R.styleable.FloatingActionMenu_menu_icon);
    if (mIcon == null) {
        mIcon = ResourcesCompat.getDrawable(getResources(), R.drawable.ic_fab_menu, null);
    }
    mLabelsSingleLine = attr.getBoolean(R.styleable.FloatingActionMenu_menu_labels_singleLine, false);
    mLabelsEllipsize = attr.getInt(R.styleable.FloatingActionMenu_menu_labels_ellipsize, 0);
    mLabelsMaxLines = attr.getInt(R.styleable.FloatingActionMenu_menu_labels_maxLines, -1);
    mMenuFabSize = attr.getInt(R.styleable.FloatingActionMenu_menu_fab_size, FloatingActionButton.SIZE_NORMAL);
    mLabelsStyle = attr.getResourceId(R.styleable.FloatingActionMenu_menu_labels_style, 0);
    String customFont = attr.getString(R.styleable.FloatingActionMenu_menu_labels_customFont);
    try {
        if (!TextUtils.isEmpty(customFont)) {
            mCustomTypefaceFromFont = Typeface.createFromAsset(getContext().getAssets(), customFont);
        }
    } catch (RuntimeException ex) {
        throw new IllegalArgumentException("Unable to load specified custom font: " + customFont, ex);
    }
    mOpenDirection = attr.getInt(R.styleable.FloatingActionMenu_menu_openDirection, OPEN_UP);
    mBackgroundColor = attr.getColor(R.styleable.FloatingActionMenu_menu_backgroundColor, Color.TRANSPARENT);

    if (attr.hasValue(R.styleable.FloatingActionMenu_menu_fab_label)) {
        mUsingMenuLabel = true;
        mMenuLabelText = attr.getString(R.styleable.FloatingActionMenu_menu_fab_label);
    }

    if (attr.hasValue(R.styleable.FloatingActionMenu_menu_labels_padding)) {
        int padding = attr.getDimensionPixelSize(R.styleable.FloatingActionMenu_menu_labels_padding, 0);
        initPadding(padding);
    }

    mOpenInterpolator = new OvershootInterpolator();
    mCloseInterpolator = new AnticipateInterpolator();
    mLabelsContext = new ContextThemeWrapper(getContext(), mLabelsStyle);

    initBackgroundDimAnimation();
    createMenuButton();
    initMenuButtonAnimations(attr);

    attr.recycle();
}
 
Example 46
Project: android-ui-toolkit-demos   File: MainActivity.java   Source Code and License 4 votes vote down vote up
/**
 * This method is called to populate the UI according to which interpolator was
 * selected.
 */
private void populateParametersUI(String interpolatorName, LinearLayout parent) {
    parent.removeAllViews();
    try {
        switch (interpolatorName) {
            case "Quadratic Path":
                createQuadraticPathInterpolator(parent);
                break;
            case "Cubic Path":
                createCubicPathInterpolator(parent);
                break;
            case "AccelerateDecelerate":
                mVisualizer.setInterpolator(new AccelerateDecelerateInterpolator());
                break;
            case "Linear":
                mVisualizer.setInterpolator(new LinearInterpolator());
                break;
            case "Bounce":
                mVisualizer.setInterpolator(new BounceInterpolator());
                break;
            case "Accelerate":
                Constructor<AccelerateInterpolator> decelConstructor =
                        AccelerateInterpolator.class.getConstructor(float.class);
                createParamaterizedInterpolator(parent, decelConstructor, "Factor", 1, 5, 1);
                break;
            case "Decelerate":
                Constructor<DecelerateInterpolator> accelConstructor =
                        DecelerateInterpolator.class.getConstructor(float.class);
                createParamaterizedInterpolator(parent, accelConstructor, "Factor", 1, 5, 1);
                break;
            case "Overshoot":
                Constructor<OvershootInterpolator> overshootConstructor =
                        OvershootInterpolator.class.getConstructor(float.class);
                createParamaterizedInterpolator(parent, overshootConstructor, "Tension", 1, 5, 1);
                break;
            case "Anticipate":
                Constructor<AnticipateInterpolator> anticipateConstructor =
                        AnticipateInterpolator.class.getConstructor(float.class);
                createParamaterizedInterpolator(parent, anticipateConstructor, "Tension", 1, 5, 1);
                break;
        }
    } catch (NoSuchMethodException e) {
        Log.e("InterpolatorPlayground", "Error constructing interpolator: " + e);
    }
}
 
Example 47
Project: EEAnimator   File: EEAnimationBuilder.java   Source Code and License 4 votes vote down vote up
public EEViewAnimator anticipate() {
    return eeViewAnimator.interpolator(new AnticipateInterpolator());
}
 
Example 48
Project: CardsView   File: CardGroup.java   Source Code and License 4 votes vote down vote up
/**
 * 是否是外部的命令导致滑动
 * @param deltaX
 * @param isOutOrder
 */
private void makeFirstViewLeave(int deltaX, boolean isOutOrder) {
    moving = true;
    makeUnderViewReplace(1);
    makeUnderViewReplace(2);

    final CardView firstSlideView = getFirstSlideView();
    final float rotate = firstSlideView.getCardRotation();
    final int startX = firstSlideView.getScrollX();
    final int startY = firstSlideView.getScrollY();

    int endX = deltaX < 0 ? -screenWidth : screenWidth;
    endX = endX * 3 / 2;
    int endRotate = rotate == 0 ? 0 : rotate < 0 ? -45 : 45;

    final int distanceOfX = endX - startX;
    final float deltaRotate = endRotate - rotate;

    ValueAnimator animator = ValueAnimator.ofFloat(0, 1);
    animator.setTarget(firstSlideView);
    animator.setDuration(ANIM_DURATION + 50);//动画时间+50,保证相对于其他卡片,这个动画是最后一个执行完成的,否则刷新数据源时效果会出问题
    animator.setInterpolator(isOutOrder? new AnticipateInterpolator() : new LinearInterpolator());
    animator.addUpdateListener(animation -> {
        float percent = (float) animation.getAnimatedValue();
        firstSlideView.scrollTo((int) (startX + percent * distanceOfX), startY);
        firstSlideView.setReleaseRotation(rotate + deltaRotate * percent);

        //动画执行完成时移出第一张卡片的数据,刷新数据源
        if (percent == 1) {
            T card = contentList.remove(0);
            setContentList(contentList);
            //发送相应通知
            if (deltaX > 0) {
                if (moveToLeftListener != null) {
                    moveToLeftListener.onMoveToLeft(card);
                }
            } else {
                if (moveToRightListener != null) {
                    moveToRightListener.onMoveToRight(card);
                }
            }
            moving = false;
        }
    });

    animator.start();
}
 
Example 49
Project: AnimatorDemo   File: InterpolatorFragment.java   Source Code and License 4 votes vote down vote up
@Override
protected Animator prepareAnimator(int width, int height) {
    int offset = width / 8;
    int start = offset;
    int end = width - offset;

    x1Animator = new ValueAnimator();
    x1Animator.setIntValues(start, end);
    // default interpolator is AccelerateDecelerateInterpolator

    x2Animator = new ValueAnimator();
    x2Animator.setIntValues(start, end);
    x2Animator.setInterpolator(new LinearInterpolator());

    x3Animator = new ValueAnimator();
    x3Animator.setIntValues(start, end);
    x3Animator.setInterpolator(new AccelerateInterpolator());

    x4Animator = new ValueAnimator();
    x4Animator.setIntValues(start, end);
    x4Animator.setInterpolator(new DecelerateInterpolator());

    x5Animator = new ValueAnimator();
    x5Animator.setIntValues(start, end);
    x5Animator.setInterpolator(new OvershootInterpolator());

    x6Animator = new ValueAnimator();
    x6Animator.setIntValues(start, end);
    x6Animator.setInterpolator(new AnticipateInterpolator());

    x7Animator = new ValueAnimator();
    x7Animator.setIntValues(start, end);
    x7Animator.setInterpolator(new AnticipateOvershootInterpolator());

    AnimatorSet as = new AnimatorSet();
    as.play(x1Animator).with(x2Animator);
    as.play(x1Animator).with(x3Animator);
    as.play(x1Animator).with(x4Animator);
    as.play(x1Animator).with(x5Animator);
    as.play(x1Animator).with(x6Animator);
    as.play(x1Animator).with(x7Animator);

    as.setDuration(5000);

    paint = new Paint();
    paint.setColor(Color.MAGENTA);

    return as;
}
 
Example 50
Project: betwixt   File: Interpolators.java   Source Code and License 4 votes vote down vote up
/**
 * <strong>ANDROID INTERPOLATOR</strong><br/><br/>
 * An interpolator where the change starts backward then flings forward.
 */
@NonNull
public static Interpolator anticipate() {
    return new AnticipateInterpolator();
}
 
Example 51
Project: clear-todolist   File: FloatingActionMenu.java   Source Code and License 4 votes vote down vote up
private void init(Context context, AttributeSet attrs) {
    TypedArray attr = context.obtainStyledAttributes(attrs, R.styleable.FloatingActionMenu, 0, 0);
    mButtonSpacing = attr.getDimensionPixelSize(R.styleable.FloatingActionMenu_menu_buttonSpacing, mButtonSpacing);
    mLabelsMargin = attr.getDimensionPixelSize(R.styleable.FloatingActionMenu_menu_labels_margin, mLabelsMargin);
    mLabelsPosition = attr.getInt(R.styleable.FloatingActionMenu_menu_labels_position, LABELS_POSITION_LEFT);
    mLabelsShowAnimation = attr.getResourceId(R.styleable.FloatingActionMenu_menu_labels_showAnimation,
            mLabelsPosition == LABELS_POSITION_LEFT ? R.anim.fab_slide_in_from_right : R.anim.fab_slide_in_from_left);
    mLabelsHideAnimation = attr.getResourceId(R.styleable.FloatingActionMenu_menu_labels_hideAnimation,
            mLabelsPosition == LABELS_POSITION_LEFT ? R.anim.fab_slide_out_to_right : R.anim.fab_slide_out_to_left);
    mLabelsPaddingTop = attr.getDimensionPixelSize(R.styleable.FloatingActionMenu_menu_labels_paddingTop, mLabelsPaddingTop);
    mLabelsPaddingRight = attr.getDimensionPixelSize(R.styleable.FloatingActionMenu_menu_labels_paddingRight, mLabelsPaddingRight);
    mLabelsPaddingBottom = attr.getDimensionPixelSize(R.styleable.FloatingActionMenu_menu_labels_paddingBottom, mLabelsPaddingBottom);
    mLabelsPaddingLeft = attr.getDimensionPixelSize(R.styleable.FloatingActionMenu_menu_labels_paddingLeft, mLabelsPaddingLeft);
    mLabelsTextColor = attr.getColorStateList(R.styleable.FloatingActionMenu_menu_labels_textColor);
    // set default value if null same as for textview
    if (mLabelsTextColor == null) {
        mLabelsTextColor = ColorStateList.valueOf(Color.WHITE);
    }
    mLabelsTextSize = attr.getDimension(R.styleable.FloatingActionMenu_menu_labels_textSize, getResources().getDimension(R.dimen.labels_text_size));
    mLabelsCornerRadius = attr.getDimensionPixelSize(R.styleable.FloatingActionMenu_menu_labels_cornerRadius, mLabelsCornerRadius);
    mLabelsShowShadow = attr.getBoolean(R.styleable.FloatingActionMenu_menu_labels_showShadow, true);
    mLabelsColorNormal = attr.getColor(R.styleable.FloatingActionMenu_menu_labels_colorNormal, 0xFF333333);
    mLabelsColorPressed = attr.getColor(R.styleable.FloatingActionMenu_menu_labels_colorPressed, 0xFF444444);
    mLabelsColorRipple = attr.getColor(R.styleable.FloatingActionMenu_menu_labels_colorRipple, 0x66FFFFFF);
    mMenuShowShadow = attr.getBoolean(R.styleable.FloatingActionMenu_menu_showShadow, true);
    mMenuShadowColor = attr.getColor(R.styleable.FloatingActionMenu_menu_shadowColor, 0x66000000);
    mMenuShadowRadius = attr.getDimension(R.styleable.FloatingActionMenu_menu_shadowRadius, mMenuShadowRadius);
    mMenuShadowXOffset = attr.getDimension(R.styleable.FloatingActionMenu_menu_shadowXOffset, mMenuShadowXOffset);
    mMenuShadowYOffset = attr.getDimension(R.styleable.FloatingActionMenu_menu_shadowYOffset, mMenuShadowYOffset);
    mMenuColorNormal = attr.getColor(R.styleable.FloatingActionMenu_menu_colorNormal, 0xFFDA4336);
    mMenuColorPressed = attr.getColor(R.styleable.FloatingActionMenu_menu_colorPressed, 0xFFE75043);
    mMenuColorRipple = attr.getColor(R.styleable.FloatingActionMenu_menu_colorRipple, 0x99FFFFFF);
    mAnimationDelayPerItem = attr.getInt(R.styleable.FloatingActionMenu_menu_animationDelayPerItem, 50);
    mIcon = attr.getDrawable(R.styleable.FloatingActionMenu_menu_icon);
    if (mIcon == null) {
        mIcon = getResources().getDrawable(R.drawable.fab_add);
    }
    mLabelsSingleLine = attr.getBoolean(R.styleable.FloatingActionMenu_menu_labels_singleLine, false);
    mLabelsEllipsize = attr.getInt(R.styleable.FloatingActionMenu_menu_labels_ellipsize, 0);
    mLabelsMaxLines = attr.getInt(R.styleable.FloatingActionMenu_menu_labels_maxLines, -1);
    mMenuFabSize = attr.getInt(R.styleable.FloatingActionMenu_menu_fab_size, FloatingActionButton.SIZE_NORMAL);
    mLabelsStyle = attr.getResourceId(R.styleable.FloatingActionMenu_menu_labels_style, 0);
    mOpenDirection = attr.getInt(R.styleable.FloatingActionMenu_menu_openDirection, OPEN_UP);
    mBackgroundColor = attr.getColor(R.styleable.FloatingActionMenu_menu_backgroundColor, Color.TRANSPARENT);

    if (attr.hasValue(R.styleable.FloatingActionMenu_menu_fab_label)) {
        mUsingMenuLabel = true;
        mMenuLabelText = attr.getString(R.styleable.FloatingActionMenu_menu_fab_label);
    }

    if (attr.hasValue(R.styleable.FloatingActionMenu_menu_labels_padding)) {
        int padding = attr.getDimensionPixelSize(R.styleable.FloatingActionMenu_menu_labels_padding, 0);
        initPadding(padding);
    }

    mOpenInterpolator = new OvershootInterpolator();
    mCloseInterpolator = new AnticipateInterpolator();
    mLabelsContext = new ContextThemeWrapper(getContext(), mLabelsStyle);

    initBackgroundDimAnimation();
    createMenuButton();
    initMenuButtonAnimations(attr);

    attr.recycle();
}
 
Example 52
Project: neveshtanak-Deprecated-   File: FloatingActionMenu.java   Source Code and License 4 votes vote down vote up
private void init(Context context, AttributeSet attrs) {
    TypedArray attr = context.obtainStyledAttributes(attrs, R.styleable.FloatingActionMenu, 0, 0);
    mButtonSpacing = attr.getDimensionPixelSize(R.styleable.FloatingActionMenu_menu_buttonSpacing, mButtonSpacing);
    mLabelsMargin = attr.getDimensionPixelSize(R.styleable.FloatingActionMenu_menu_labels_margin, mLabelsMargin);
    mLabelsPosition = attr.getInt(R.styleable.FloatingActionMenu_menu_labels_position, LABELS_POSITION_LEFT);
    mLabelsShowAnimation = attr.getResourceId(R.styleable.FloatingActionMenu_menu_labels_showAnimation,
            mLabelsPosition == LABELS_POSITION_LEFT ? R.anim.fab_slide_in_from_right : R.anim.fab_slide_in_from_left);
    mLabelsHideAnimation = attr.getResourceId(R.styleable.FloatingActionMenu_menu_labels_hideAnimation,
            mLabelsPosition == LABELS_POSITION_LEFT ? R.anim.fab_slide_out_to_right : R.anim.fab_slide_out_to_left);
    mLabelsPaddingTop = attr.getDimensionPixelSize(R.styleable.FloatingActionMenu_menu_labels_paddingTop, mLabelsPaddingTop);
    mLabelsPaddingRight = attr.getDimensionPixelSize(R.styleable.FloatingActionMenu_menu_labels_paddingRight, mLabelsPaddingRight);
    mLabelsPaddingBottom = attr.getDimensionPixelSize(R.styleable.FloatingActionMenu_menu_labels_paddingBottom, mLabelsPaddingBottom);
    mLabelsPaddingLeft = attr.getDimensionPixelSize(R.styleable.FloatingActionMenu_menu_labels_paddingLeft, mLabelsPaddingLeft);
    mLabelsTextColor = attr.getColor(R.styleable.FloatingActionMenu_menu_labels_textColor, Color.WHITE);
    mLabelsTextSize = attr.getDimension(R.styleable.FloatingActionMenu_menu_labels_textSize, getResources().getDimension(R.dimen.labels_text_size));
    mLabelsCornerRadius = attr.getDimensionPixelSize(R.styleable.FloatingActionMenu_menu_labels_cornerRadius, mLabelsCornerRadius);
    mLabelsShowShadow = attr.getBoolean(R.styleable.FloatingActionMenu_menu_labels_showShadow, true);
    mLabelsColorNormal = attr.getColor(R.styleable.FloatingActionMenu_menu_labels_colorNormal, 0xFF333333);
    mLabelsColorPressed = attr.getColor(R.styleable.FloatingActionMenu_menu_labels_colorPressed, 0xFF444444);
    mLabelsColorRipple = attr.getColor(R.styleable.FloatingActionMenu_menu_labels_colorRipple, 0x66FFFFFF);
    mMenuShowShadow = attr.getBoolean(R.styleable.FloatingActionMenu_menu_showShadow, true);
    mMenuShadowColor = attr.getColor(R.styleable.FloatingActionMenu_menu_shadowColor, 0x66000000);
    mMenuShadowRadius = attr.getDimension(R.styleable.FloatingActionMenu_menu_shadowRadius, mMenuShadowRadius);
    mMenuShadowXOffset = attr.getDimension(R.styleable.FloatingActionMenu_menu_shadowXOffset, mMenuShadowXOffset);
    mMenuShadowYOffset = attr.getDimension(R.styleable.FloatingActionMenu_menu_shadowYOffset, mMenuShadowYOffset);
    mMenuColorNormal = attr.getColor(R.styleable.FloatingActionMenu_menu_colorNormal, 0xFFDA4336);
    mMenuColorPressed = attr.getColor(R.styleable.FloatingActionMenu_menu_colorPressed, 0xFFE75043);
    mMenuColorRipple = attr.getColor(R.styleable.FloatingActionMenu_menu_colorRipple, 0x99FFFFFF);
    mAnimationDelayPerItem = attr.getInt(R.styleable.FloatingActionMenu_menu_animationDelayPerItem, 50);
    mIcon = attr.getDrawable(R.styleable.FloatingActionMenu_menu_icon);
    if (mIcon == null) {
        mIcon = getResources().getDrawable(R.drawable.fab_add);
    }
    mLabelsSingleLine = attr.getBoolean(R.styleable.FloatingActionMenu_menu_labels_singleLine, false);
    mLabelsEllipsize = attr.getInt(R.styleable.FloatingActionMenu_menu_labels_ellipsize, 0);
    mLabelsMaxLines = attr.getInt(R.styleable.FloatingActionMenu_menu_labels_maxLines, -1);
    mMenuFabSize = attr.getInt(R.styleable.FloatingActionMenu_menu_fab_size, FloatingActionButton.SIZE_NORMAL);
    mLabelsStyle = attr.getResourceId(R.styleable.FloatingActionMenu_menu_labels_style, 0);
    mOpenDirection = attr.getInt(R.styleable.FloatingActionMenu_menu_openDirection, OPEN_UP);
    mBackgroundColor = attr.getColor(R.styleable.FloatingActionMenu_menu_backgroundColor, Color.TRANSPARENT);

    if (attr.hasValue(R.styleable.FloatingActionMenu_menu_labels_padding)) {
        int padding = attr.getDimensionPixelSize(R.styleable.FloatingActionMenu_menu_labels_padding, 0);
        initPadding(padding);
    }
    attr.recycle();

    mOpenInterpolator = new OvershootInterpolator();
    mCloseInterpolator = new AnticipateInterpolator();
    mLabelsContext = new ContextThemeWrapper(getContext(), mLabelsStyle);

    initMenuButtonAnimations();
    initBackgroundDimAnimation();
    createMenuButton();
}
 
Example 53
Project: NQH_FloatingActionButton   File: FloatingActionMenu.java   Source Code and License 4 votes vote down vote up
private void init(Context context, AttributeSet attrs) {
    TypedArray attr = context.obtainStyledAttributes(attrs, R.styleable.FloatingActionMenu, 0, 0);
    mButtonSpacing = attr.getDimensionPixelSize(R.styleable.FloatingActionMenu_menu_buttonSpacing, mButtonSpacing);
    mLabelsMargin = attr.getDimensionPixelSize(R.styleable.FloatingActionMenu_menu_labels_margin, mLabelsMargin);
    mLabelsShowAnimation = attr.getResourceId(R.styleable.FloatingActionMenu_menu_labels_showAnimation, R.anim.fab_slide_in_from_right);
    mLabelsHideAnimation = attr.getResourceId(R.styleable.FloatingActionMenu_menu_labels_hideAnimation, R.anim.fab_slide_out_to_right);
    mLabelsPaddingTop = attr.getDimensionPixelSize(R.styleable.FloatingActionMenu_menu_labels_paddingTop, mLabelsPaddingTop);
    mLabelsPaddingRight = attr.getDimensionPixelSize(R.styleable.FloatingActionMenu_menu_labels_paddingRight, mLabelsPaddingRight);
    mLabelsPaddingBottom = attr.getDimensionPixelSize(R.styleable.FloatingActionMenu_menu_labels_paddingBottom, mLabelsPaddingBottom);
    mLabelsPaddingLeft = attr.getDimensionPixelSize(R.styleable.FloatingActionMenu_menu_labels_paddingLeft, mLabelsPaddingLeft);
    mLabelsTextColor = attr.getColor(R.styleable.FloatingActionMenu_menu_labels_textColor, Color.WHITE);
    mLabelsTextSize = attr.getDimension(R.styleable.FloatingActionMenu_menu_labels_textSize, getResources().getDimension(R.dimen.labels_text_size));
    mLabelsCornerRadius = attr.getDimensionPixelSize(R.styleable.FloatingActionMenu_menu_labels_cornerRadius, mLabelsCornerRadius);
    mLabelsShowShadow = attr.getBoolean(R.styleable.FloatingActionMenu_menu_labels_showShadow, true);
    mLabelsColorNormal = attr.getColor(R.styleable.FloatingActionMenu_menu_labels_colorNormal, 0xFF333333);
    mLabelsColorPressed = attr.getColor(R.styleable.FloatingActionMenu_menu_labels_colorPressed, 0xFF444444);
    mLabelsColorRipple = attr.getColor(R.styleable.FloatingActionMenu_menu_labels_colorRipple, 0x66FFFFFF);
    mMenuShowShadow = attr.getBoolean(R.styleable.FloatingActionMenu_menu_showShadow, true);
    mMenuShadowColor = attr.getColor(R.styleable.FloatingActionMenu_menu_shadowColor, 0x66000000);
    mMenuShadowRadius = attr.getDimension(R.styleable.FloatingActionMenu_menu_shadowRadius, mMenuShadowRadius);
    mMenuShadowXOffset = attr.getDimension(R.styleable.FloatingActionMenu_menu_shadowXOffset, mMenuShadowXOffset);
    mMenuShadowYOffset = attr.getDimension(R.styleable.FloatingActionMenu_menu_shadowYOffset, mMenuShadowYOffset);
    mMenuColorNormal = attr.getColor(R.styleable.FloatingActionMenu_menu_colorNormal, 0xFFDA4336);
    mMenuColorPressed = attr.getColor(R.styleable.FloatingActionMenu_menu_colorPressed, 0xFFE75043);
    mMenuColorRipple = attr.getColor(R.styleable.FloatingActionMenu_menu_colorRipple, 0x99FFFFFF);
    mAnimationDelayPerItem = attr.getInt(R.styleable.FloatingActionMenu_menu_animationDelayPerItem, 50);
    mIcon = attr.getDrawable(R.styleable.FloatingActionMenu_menu_icon);
    if (mIcon == null) {
        mIcon = getResources().getDrawable(R.drawable.fab_add);
    }
    mLabelsSingleLine = attr.getBoolean(R.styleable.FloatingActionMenu_menu_labels_singleLine, false);
    mLabelsEllipsize = attr.getInt(R.styleable.FloatingActionMenu_menu_labels_ellipsize, 0);
    mLabelsMaxLines = attr.getInt(R.styleable.FloatingActionMenu_menu_labels_maxLines, -1);
    mMenuFabSize = attr.getInt(R.styleable.FloatingActionMenu_menu_fab_size, FloatingActionButton.SIZE_NORMAL);
    mLabelsStyle = attr.getResourceId(R.styleable.FloatingActionMenu_menu_labels_style, 0);

    if (attr.hasValue(R.styleable.FloatingActionMenu_menu_labels_padding)) {
        int padding = attr.getDimensionPixelSize(R.styleable.FloatingActionMenu_menu_labels_padding, 0);
        initPadding(padding);
    }
    attr.recycle();

    mOpenInterpolator = new OvershootInterpolator();
    mCloseInterpolator = new AnticipateInterpolator();

    createMenuButton();
}
 
Example 54
Project: flowzr-android-black   File: MyFloatingActionMenu.java   Source Code and License 4 votes vote down vote up
private void init(Context context, AttributeSet attrs) {
        TypedArray attr = context.obtainStyledAttributes(attrs, R.styleable.FloatingActionMenu, 0, 0);
        mButtonSpacing = attr.getDimensionPixelSize(R.styleable.FloatingActionMenu_menu_buttonSpacing, mButtonSpacing);
        mLabelsMargin = attr.getDimensionPixelSize(R.styleable.FloatingActionMenu_menu_labels_margin, mLabelsMargin);
        mLabelsPosition = attr.getInt(R.styleable.FloatingActionMenu_menu_labels_position, LABELS_POSITION_LEFT);
        mLabelsShowAnimation = attr.getResourceId(R.styleable.FloatingActionMenu_menu_labels_showAnimation,
                mLabelsPosition == LABELS_POSITION_LEFT ? R.anim.fab_slide_in_from_right : R.anim.fab_slide_in_from_left);
        mLabelsHideAnimation = attr.getResourceId(R.styleable.FloatingActionMenu_menu_labels_hideAnimation,
                mLabelsPosition == LABELS_POSITION_LEFT ? R.anim.fab_slide_out_to_right : R.anim.fab_slide_out_to_left);
        mLabelsPaddingTop = attr.getDimensionPixelSize(R.styleable.FloatingActionMenu_menu_labels_paddingTop, mLabelsPaddingTop);
        mLabelsPaddingRight = attr.getDimensionPixelSize(R.styleable.FloatingActionMenu_menu_labels_paddingRight, mLabelsPaddingRight);
        mLabelsPaddingBottom = attr.getDimensionPixelSize(R.styleable.FloatingActionMenu_menu_labels_paddingBottom, mLabelsPaddingBottom);
        mLabelsPaddingLeft = attr.getDimensionPixelSize(R.styleable.FloatingActionMenu_menu_labels_paddingLeft, mLabelsPaddingLeft);
        mLabelsTextColor = attr.getColorStateList(R.styleable.FloatingActionMenu_menu_labels_textColor);
        // set default value if null same as for textview
        if (mLabelsTextColor == null) {
            mLabelsTextColor = ColorStateList.valueOf(Color.WHITE);
        }
        mLabelsTextSize = attr.getDimension(R.styleable.FloatingActionMenu_menu_labels_textSize, getResources().getDimension(R.dimen.labels_text_size));
        mLabelsCornerRadius = attr.getDimensionPixelSize(R.styleable.FloatingActionMenu_menu_labels_cornerRadius, mLabelsCornerRadius);
        mLabelsShowShadow = attr.getBoolean(R.styleable.FloatingActionMenu_menu_labels_showShadow, true);
        mLabelsColorNormal = attr.getColor(R.styleable.FloatingActionMenu_menu_labels_colorNormal, 0xFF333333);
        mLabelsColorPressed = attr.getColor(R.styleable.FloatingActionMenu_menu_labels_colorPressed, 0xFF444444);
        mLabelsColorRipple = attr.getColor(R.styleable.FloatingActionMenu_menu_labels_colorRipple, 0x66FFFFFF);
        mMenuShowShadow = attr.getBoolean(R.styleable.FloatingActionMenu_menu_showShadow, true);
        mMenuShadowColor = attr.getColor(R.styleable.FloatingActionMenu_menu_shadowColor, 0x66000000);
        mMenuShadowRadius = attr.getDimension(R.styleable.FloatingActionMenu_menu_shadowRadius, mMenuShadowRadius);
        mMenuShadowXOffset = attr.getDimension(R.styleable.FloatingActionMenu_menu_shadowXOffset, mMenuShadowXOffset);
        mMenuShadowYOffset = attr.getDimension(R.styleable.FloatingActionMenu_menu_shadowYOffset, mMenuShadowYOffset);
        mMenuColorNormal = attr.getColor(R.styleable.FloatingActionMenu_menu_colorNormal, 0x00FFFFFF);
        mMenuColorPressed = attr.getColor(R.styleable.FloatingActionMenu_menu_colorPressed, 0xFF555555);
        mMenuColorRipple = attr.getColor(R.styleable.FloatingActionMenu_menu_colorRipple, 0x99FFFFFF);
        mAnimationDelayPerItem = attr.getInt(R.styleable.FloatingActionMenu_menu_animationDelayPerItem, 50);
        mIcon = attr.getDrawable(R.styleable.FloatingActionMenu_menu_icon);
        if (mIcon == null) {
            mIcon = getResources().getDrawable(R.drawable.ic_edit);
        }
        mLabelsSingleLine = attr.getBoolean(R.styleable.FloatingActionMenu_menu_labels_singleLine, false);
        mLabelsEllipsize = attr.getInt(R.styleable.FloatingActionMenu_menu_labels_ellipsize, 0);
        mLabelsMaxLines = attr.getInt(R.styleable.FloatingActionMenu_menu_labels_maxLines, 1);
        mMenuFabSize = attr.getInt(R.styleable.FloatingActionMenu_menu_fab_size, FloatingActionButton.SIZE_NORMAL);
        mLabelsStyle = attr.getResourceId(R.styleable.FloatingActionMenu_menu_labels_style, 0);
        mOpenDirection = attr.getInt(R.styleable.FloatingActionMenu_menu_openDirection, OPEN_UP);
        mBackgroundColor = attr.getColor(R.styleable.FloatingActionMenu_menu_backgroundColor, Color.TRANSPARENT);

//        if (attr.hasValue(R.styleable.FloatingActionMenu_menu_fab_label)) {
            mUsingMenuLabel = true;
            mMenuLabelText = attr.getString(R.styleable.FloatingActionMenu_menu_fab_label);
            //Log.e("FLOWZR",mMenuLabelText.toString());
//        }

        if (attr.hasValue(R.styleable.FloatingActionMenu_menu_labels_padding)) {
            int padding = attr.getDimensionPixelSize(R.styleable.FloatingActionMenu_menu_labels_padding, 0);
            initPadding(padding);
        }

        mOpenInterpolator = new OvershootInterpolator();
        mCloseInterpolator = new AnticipateInterpolator();
        mLabelsContext = new ContextThemeWrapper(getContext(), mLabelsStyle);

        initBackgroundDimAnimation();
        createMenuButton();
        initMenuButtonAnimations(attr);
        attr.recycle();
    }
 
Example 55
Project: dailyJournal   File: PartyDetailFragment.java   Source Code and License 4 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.fragment_party_detail, container, false);

    //Wire up the widgets view
    rootView.findViewById(R.id.fragment_party_detail_party_card).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            startPartyActivity();
        }
    });
    picIV = (ImageView) rootView.findViewById(R.id.fragment_party_detail_circle_iv);
    nameTV = (TextView) rootView.findViewById(R.id.fragment_party_detail_name_tv);
    nameTV.setMovementMethod(new ScrollingMovementMethod());

    ledgerListView = (RecyclerView) rootView.findViewById(R.id.activity_party_lv);
    ledgerListView.setLayoutManager(new LinearLayoutManager(getContext()));
    ledgerListView.setItemAnimator(UtilsView.getDefaultItemAnimator());

    balanceTV = (TextView) rootView.findViewById(R.id.fragment_party_detail_balance_tv);
    headerRow = (TableRow)rootView.findViewById(R.id.fragment_party_detail_header_tr);
    footerViewContainer = (ViewGroup) rootView.findViewById(R.id.fragment_party_detail_footer);

    ((TextView)rootView.findViewById(R.id.activity_party_col_header_dr))
            .setText(getString(R.string.str_dr));

    ((TextView)rootView.findViewById(R.id.activity_party_col_header_cr))
            .setText(getString(R.string.str_cr));


    balanceTV.setSingleLine();

    setPartyViews(mParty);
    setLedgerListViews();
    setFooterView(mParty);

    //Animate the list view but wait until the view is laid out
    ledgerListView.addOnLayoutChangeListener(new View.OnLayoutChangeListener() {
        @Override
        public void onLayoutChange(View view, int i, int i1, int i2, int i3, int i4, int i5, int i6, int i7) {
            if (ViewCompat.isLaidOut(ledgerListView)) {
                DisplayMetrics metrics = new DisplayMetrics();
                getActivity().getWindowManager().getDefaultDisplay().getMetrics(metrics);
                ledgerListView.setTranslationY(metrics.heightPixels);
                AnticipateInterpolator interpolator = new AnticipateInterpolator();
                ledgerListView.animate().setInterpolator(interpolator)
                        .setDuration(500)
                        .setStartDelay(2)
                        .translationYBy(-metrics.heightPixels)
                        .start();
                // remove listener
                ledgerListView.removeOnLayoutChangeListener(this);
            }
        }
    });

    mServices.registerPartyObserver(this);

    return rootView;
}
 
Example 56
Project: itsnat_droid   File: ClassDescInterpolatorAnticipate.java   Source Code and License 4 votes vote down vote up
@Override
public Class<AnticipateInterpolator> getDeclaredClass()
{
    return AnticipateInterpolator.class;
}
 
Example 57
Project: itsnat_droid   File: ClassDescInterpolatorAnticipate.java   Source Code and License 4 votes vote down vote up
@Override
protected AnticipateInterpolator createResourceNative(Context ctx)
{
    return new AnticipateInterpolator(ctx,null);
}
 
Example 58
Project: OneNote   File: FloatingActionMenu.java   Source Code and License 4 votes vote down vote up
private void init(Context context, AttributeSet attrs) {
    TypedArray attr = context.obtainStyledAttributes(attrs, R.styleable.FloatingActionMenu, 0, 0);
    mButtonSpacing = attr.getDimensionPixelSize(R.styleable.FloatingActionMenu_menu_buttonSpacing, mButtonSpacing);
    mLabelsMargin = attr.getDimensionPixelSize(R.styleable.FloatingActionMenu_menu_labels_margin, mLabelsMargin);
    mLabelsPosition = attr.getInt(R.styleable.FloatingActionMenu_menu_labels_position, LABELS_POSITION_LEFT);
    mLabelsShowAnimation = attr.getResourceId(R.styleable.FloatingActionMenu_menu_labels_showAnimation,
            mLabelsPosition == LABELS_POSITION_LEFT ? R.anim.fab_slide_in_from_right : R.anim.fab_slide_in_from_left);
    mLabelsHideAnimation = attr.getResourceId(R.styleable.FloatingActionMenu_menu_labels_hideAnimation,
            mLabelsPosition == LABELS_POSITION_LEFT ? R.anim.fab_slide_out_to_right : R.anim.fab_slide_out_to_left);
    mLabelsPaddingTop = attr.getDimensionPixelSize(R.styleable.FloatingActionMenu_menu_labels_paddingTop, mLabelsPaddingTop);
    mLabelsPaddingRight = attr.getDimensionPixelSize(R.styleable.FloatingActionMenu_menu_labels_paddingRight, mLabelsPaddingRight);
    mLabelsPaddingBottom = attr.getDimensionPixelSize(R.styleable.FloatingActionMenu_menu_labels_paddingBottom, mLabelsPaddingBottom);
    mLabelsPaddingLeft = attr.getDimensionPixelSize(R.styleable.FloatingActionMenu_menu_labels_paddingLeft, mLabelsPaddingLeft);
    mLabelsTextColor = attr.getColorStateList(R.styleable.FloatingActionMenu_menu_labels_textColor);
    // set default value if null same as for textview
    if (mLabelsTextColor == null) {
        mLabelsTextColor = ColorStateList.valueOf(Color.WHITE);
    }
    mLabelsTextSize = attr.getDimension(R.styleable.FloatingActionMenu_menu_labels_textSize, getResources().getDimension(R.dimen.labels_text_size));
    mLabelsCornerRadius = attr.getDimensionPixelSize(R.styleable.FloatingActionMenu_menu_labels_cornerRadius, mLabelsCornerRadius);
    mLabelsShowShadow = attr.getBoolean(R.styleable.FloatingActionMenu_menu_labels_showShadow, true);
    mLabelsColorNormal = attr.getColor(R.styleable.FloatingActionMenu_menu_labels_colorNormal, 0xFF333333);
    mLabelsColorPressed = attr.getColor(R.styleable.FloatingActionMenu_menu_labels_colorPressed, 0xFF444444);
    mLabelsColorRipple = attr.getColor(R.styleable.FloatingActionMenu_menu_labels_colorRipple, 0x66FFFFFF);
    mMenuShowShadow = attr.getBoolean(R.styleable.FloatingActionMenu_menu_showShadow, true);
    mMenuShadowColor = attr.getColor(R.styleable.FloatingActionMenu_menu_shadowColor, 0x66000000);
    mMenuShadowRadius = attr.getDimension(R.styleable.FloatingActionMenu_menu_shadowRadius, mMenuShadowRadius);
    mMenuShadowXOffset = attr.getDimension(R.styleable.FloatingActionMenu_menu_shadowXOffset, mMenuShadowXOffset);
    mMenuShadowYOffset = attr.getDimension(R.styleable.FloatingActionMenu_menu_shadowYOffset, mMenuShadowYOffset);
    mMenuColorNormal = attr.getColor(R.styleable.FloatingActionMenu_menu_colorNormal, 0xFFDA4336);
    mMenuColorPressed = attr.getColor(R.styleable.FloatingActionMenu_menu_colorPressed, 0xFFE75043);
    mMenuColorRipple = attr.getColor(R.styleable.FloatingActionMenu_menu_colorRipple, 0x99FFFFFF);
    mAnimationDelayPerItem = attr.getInt(R.styleable.FloatingActionMenu_menu_animationDelayPerItem, 50);
    mIcon = attr.getDrawable(R.styleable.FloatingActionMenu_menu_icon);
    if (mIcon == null) {
        mIcon = getResources().getDrawable(R.drawable.fab_add);
    }
    mLabelsSingleLine = attr.getBoolean(R.styleable.FloatingActionMenu_menu_labels_singleLine, false);
    mLabelsEllipsize = attr.getInt(R.styleable.FloatingActionMenu_menu_labels_ellipsize, 0);
    mLabelsMaxLines = attr.getInt(R.styleable.FloatingActionMenu_menu_labels_maxLines, -1);
    mMenuFabSize = attr.getInt(R.styleable.FloatingActionMenu_menu_fab_size, FloatingActionButton.SIZE_NORMAL);
    mLabelsStyle = attr.getResourceId(R.styleable.FloatingActionMenu_menu_labels_style, 0);
    String customFont = attr.getString(R.styleable.FloatingActionMenu_menu_labels_customFont);
    try {
        if (!TextUtils.isEmpty(customFont)) {
            mCustomTypefaceFromFont = Typeface.createFromAsset(getContext().getAssets(), customFont);
        }
    } catch (RuntimeException ex) {
        throw new IllegalArgumentException("Unable to load specified custom font: " + customFont, ex);
    }
    mOpenDirection = attr.getInt(R.styleable.FloatingActionMenu_menu_openDirection, OPEN_UP);
    mBackgroundColor = attr.getColor(R.styleable.FloatingActionMenu_menu_backgroundColor, Color.TRANSPARENT);

    if (attr.hasValue(R.styleable.FloatingActionMenu_menu_fab_label)) {
        mUsingMenuLabel = true;
        mMenuLabelText = attr.getString(R.styleable.FloatingActionMenu_menu_fab_label);
    }

    if (attr.hasValue(R.styleable.FloatingActionMenu_menu_labels_padding)) {
        int padding = attr.getDimensionPixelSize(R.styleable.FloatingActionMenu_menu_labels_padding, 0);
        initPadding(padding);
    }

    mOpenInterpolator = new OvershootInterpolator();
    mCloseInterpolator = new AnticipateInterpolator();
    mLabelsContext = new ContextThemeWrapper(getContext(), mLabelsStyle);

    initBackgroundDimAnimation();
    createMenuButton();
    initMenuButtonAnimations(attr);

    attr.recycle();
}
 
Example 59
Project: PieChart3D_Android   File: CustomScroller.java   Source Code and License 4 votes vote down vote up
public FlingRunnable() {
	LinearInterpolator linearInterpolator = new LinearInterpolator();
	/*
	 * The accelerate interpolator starts slowly but arrives at the
	 * final position at full speed. The opposite effect can be achieved
	 * by using decelerate_interpolator. This will start at full speed
	 * but then slowly come to rest at the end position.
	 */
	AccelerateInterpolator ai = new AccelerateInterpolator(1.0f);
	DecelerateInterpolator di = new DecelerateInterpolator(1.0f);
	/*
	 * The interpolator that combines an acceleration phase and a
	 * deceleration phase is, you guessed it, the
	 * accelerate_decelerate_interpolator. The code for the XML file
	 * looks like follows.
	 */
	AccelerateDecelerateInterpolator adi = new AccelerateDecelerateInterpolator();

	/*
	 * The anticipate_interpolator starts by moving the view backwards
	 * before it accelerates forwards. This creates the effect of a
	 * slingshot. As with the accelerate interpolator, the final
	 * position is reached at full speed.
	 */
	AnticipateInterpolator ani = new AnticipateInterpolator(1.0f);
	/*
	 * The opposite of the anticipate interpolator is the
	 * overshoot_interpolator. Here the view starts with full speed but
	 * overshoots the target before it returns to the final position.
	 */
	OvershootInterpolator osi = new OvershootInterpolator(1.0f);
	/*
	 * Combining the effects of both the anticipate and the overshoot
	 * interpolator is the anticipate_overshoot_interpolator. The
	 * movement starts away from the target before it accelerates
	 * towards the target. It then overshoots and returns to the final
	 * position.
	 */
	AnticipateOvershootInterpolator anosi = new AnticipateOvershootInterpolator(1.0f);
	/* http://cogitolearning.co.uk/?p=952 */
	// Create scroller and assign a interpolator to it.
	mScroller = new Scroller(mContext, di);
}
 
Example 60
Project: Qiitanium   File: OverlayTopMenuView.java   Source Code and License 4 votes vote down vote up
public void turnOff() {

    final float homeX = ViewUtils.getCenterX(homeBtn);
    final float refreshX = ViewUtils.getCenterX(refreshBtn);
    final float settingX = ViewUtils.getCenterX(settingBtn);

    AnimatorSet animSet = new AnimatorSet();

    animSet.playSequentially(
        AnimatorUtils.together(
            new DecelerateInterpolator(),
            AnimatorUtils.fadeOut(homeLabel),
            AnimatorUtils.fadeOut(refreshLabel),
            AnimatorUtils.fadeOut(settingLabel)
        ).setDuration(50),
        AnimatorUtils.together(
            new AnticipateInterpolator(),
            AnimatorUtils.of(
                refreshBtn,
                AnimatorUtils.ofTranslationX(0f, homeX - refreshX),
                AnimatorUtils.ofAlpha(1f, 0f),
                AnimatorUtils.ofScaleX(1f, 0f),
                AnimatorUtils.ofScaleY(1f, 0f)
            ).setDuration(400),
            AnimatorUtils.of(
                homeBtn,
                AnimatorUtils.ofAlpha(1f, 0f),
                AnimatorUtils.ofScaleX(1f, 0f),
                AnimatorUtils.ofScaleY(1f, 0f)
            ).setDuration(300),
            AnimatorUtils.of(
                settingBtn,
                AnimatorUtils.ofTranslationX(0f, homeX - settingX),
                AnimatorUtils.ofAlpha(1f, 0f),
                AnimatorUtils.ofScaleX(1f, 0f),
                AnimatorUtils.ofScaleY(1f, 0f)
            ).setDuration(200)
        ),
        AnimatorUtils.fadeOut(layout).setDuration(50)
    );

    animSet.addListener(new AnimatorListenerAdapter() {
      @Override
      public void onAnimationEnd(Animator animation) {
        layoutToggle.setSelected(false);
        ViewUtils.setInvisible(layout);
        AnimatorUtils.reset(homeBtn);
        AnimatorUtils.reset(refreshBtn);
        AnimatorUtils.reset(settingBtn);
      }
    });

    animSet.start();

  }