Example usage for android.animation ObjectAnimator ObjectAnimator

List of usage examples for android.animation ObjectAnimator ObjectAnimator

Introduction

In this page you can find the example usage for android.animation ObjectAnimator ObjectAnimator.

Prototype

public ObjectAnimator() 

Source Link

Document

Creates a new ObjectAnimator object.

Usage

From source file:Main.java

private static ObjectAnimator getAnimator(Object target) {
    ObjectAnimator animator = new ObjectAnimator();
    animator.setTarget(target);//from w ww  .j  ava  2s .c o m
    return animator;
}

From source file:Main.java

public static void animation3(View view) {
    ObjectAnimator animator = new ObjectAnimator().ofFloat(view, "rotationY", 0.0f, 360f);
    animator.setDuration(4000);//from w w  w  .j av  a2s.  c  om
    animator.setRepeatCount(2);
    animator.setInterpolator(new AccelerateInterpolator());
    animator.start();
}

From source file:Main.java

public static ObjectAnimator ofInt(Object target, String propertyName, int... values) {
    ObjectAnimator anim = new ObjectAnimator();
    anim.setTarget(target);//w  w  w  .jav  a2  s  .  c om
    anim.setPropertyName(propertyName);
    anim.setIntValues(values);
    cancelOnDestroyActivity(anim);
    return anim;
}

From source file:Main.java

public static ObjectAnimator ofPropertyValuesHolder(Object target, PropertyValuesHolder... values) {
    ObjectAnimator anim = new ObjectAnimator();
    anim.setTarget(target);/*from   w ww  . j  av  a2  s . c  o m*/
    anim.setValues(values);
    cancelOnDestroyActivity(anim);
    return anim;
}

From source file:Main.java

public static ObjectAnimator ofFloat(Object target, String propertyName, float... values) {
    ObjectAnimator anim = new ObjectAnimator();
    anim.setTarget(target);//from   www .  j a va2s.  c  o m
    anim.setPropertyName(propertyName);
    anim.setFloatValues(values);
    cancelOnDestroyActivity(anim);
    return anim;
}

From source file:org.centum.android.play.PlayCardView.java

private void init() {
    titleTextView = (TextView) findViewById(R.id.title_textView);
    detailsTextView = (TextView) findViewById(R.id.details_textView);
    imageView = (ImageView) findViewById(R.id.imageView);
    correctBtn = (ImageButton) findViewById(R.id.correct_imageButton);
    wrongBtn = (ImageButton) findViewById(R.id.wrong_imageButton);
    playRelativeLayout = (RelativeLayout) findViewById(R.id.play_relativelayout);
    detailsScrollView = (ScrollView) findViewById(R.id.details_scrollView);

    int titleTextSize = 30;
    int detailsTextSize = 22;
    try {/*  ww  w.j  a  v a 2s .  c  o  m*/
        titleTextSize = Integer.parseInt(PreferenceManager.getDefaultSharedPreferences(getContext())
                .getString(SettingsActivity.KEY_PREF_PLAY_TITLE_SIZE, "30"));
    } catch (Exception e) {
        PreferenceManager.getDefaultSharedPreferences(getContext()).edit()
                .putString(SettingsActivity.KEY_PREF_PLAY_TITLE_SIZE, "30").commit();
    }
    try {
        detailsTextSize = Integer.parseInt(PreferenceManager.getDefaultSharedPreferences(getContext())
                .getString(SettingsActivity.KEY_PREF_PLAY_DETAILS_SIZE, "22"));
    } catch (Exception e) {
        PreferenceManager.getDefaultSharedPreferences(getContext()).edit()
                .putString(SettingsActivity.KEY_PREF_PLAY_DETAILS_SIZE, "22").commit();
    }

    titleTextView.setTextSize(TypedValue.COMPLEX_UNIT_SP, titleTextSize);
    detailsTextView.setTextSize(TypedValue.COMPLEX_UNIT_SP, detailsTextSize);

    autoAdvance = PreferenceManager.getDefaultSharedPreferences(getContext())
            .getBoolean(SettingsActivity.KEY_PREF_PLAY_AUTO_ADVANCE, false);

    detailsAnimator = new ObjectAnimator();
    detailsAnimator.setTarget(detailsTextView);
    detailsAnimator.setPropertyName("alpha");
    detailsAnimator.setDuration(100);
    detailsAnimator.setInterpolator(new LinearInterpolator());

    correctAnimator = new ObjectAnimator();
    correctAnimator.setTarget(correctBtn);
    correctAnimator.setPropertyName("alpha");
    correctAnimator.setDuration(100);
    correctAnimator.setInterpolator(new LinearInterpolator());

    wrongAnimator = new ObjectAnimator();
    wrongAnimator.setTarget(wrongBtn);
    wrongAnimator.setPropertyName("alpha");
    wrongAnimator.setDuration(100);
    wrongAnimator.setInterpolator(new LinearInterpolator());

    setThemeParams();

    detailsScrollView.setOnClickListener(this);
    detailsTextView.setOnClickListener(this);
    playRelativeLayout.setOnClickListener(this);
    correctBtn.setOnClickListener(this);
    wrongBtn.setOnClickListener(this);
    imageView.setOnClickListener(this);
    setOnClickListener(this);
}

From source file:com.google.android.apps.gutenberg.ScannerActivity.java

private void showCheckinAnimation(Checkin checkin) {
    if (mLastAnimator != null) {
        mLastAnimator.cancel();//from   ww w . jav  a 2  s . com
    }
    final FrameLayout cover = (FrameLayout) findViewById(R.id.item_cover);
    cover.setVisibility(View.VISIBLE);
    final FrameLayout layer = (FrameLayout) findViewById(R.id.animation_layer);
    final CheckinHolder holder = new CheckinHolder(getLayoutInflater(), layer);
    FrameLayout.LayoutParams lp = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT,
            FrameLayout.LayoutParams.WRAP_CONTENT);
    lp.gravity = Gravity.CENTER_VERTICAL;
    holder.setWillAnimate(true);
    holder.bind(checkin, mImageLoader);
    holder.itemView.setBackgroundColor(Color.rgb(0xf0, 0xf0, 0xf0));
    float elevation = getResources().getDimension(R.dimen.popup_elevation);
    ViewCompat.setTranslationZ(holder.itemView, elevation);
    holder.setLines(false, false);
    layer.addView(holder.itemView, lp);
    // Interpolator for animators
    FastOutSlowInInterpolator interpolator = new FastOutSlowInInterpolator();
    // Pop-up
    Animator popUpAnim = AnimatorInflater.loadAnimator(this, R.animator.pop_up);
    popUpAnim.setTarget(holder.itemView);
    popUpAnim.setInterpolator(interpolator);
    popUpAnim.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
            holder.animateCheckin();
        }
    });
    // Wait
    ObjectAnimator waitAnim = new ObjectAnimator();
    waitAnim.setTarget(holder.itemView);
    waitAnim.setPropertyName("translationY");
    waitAnim.setFloatValues(0.f, 0.f);
    waitAnim.setDuration(2000);
    // Slide-down
    ObjectAnimator slideDownAnim = new ObjectAnimator();
    slideDownAnim.setTarget(holder.itemView);
    slideDownAnim.setPropertyName("translationY");
    slideDownAnim.setFloatValues(0.f, calcSlideDistance());
    slideDownAnim.setInterpolator(interpolator);
    // Landing anim
    ObjectAnimator landingAnim = new ObjectAnimator();
    landingAnim.setTarget(holder.itemView);
    landingAnim.setPropertyName("translationZ");
    landingAnim.setFloatValues(elevation, 0.f);
    landingAnim.setInterpolator(interpolator);
    landingAnim.setDuration(500);
    // Play the animators
    AnimatorSet set = new AnimatorSet();
    set.setInterpolator(interpolator);
    set.playSequentially(popUpAnim, waitAnim, slideDownAnim, landingAnim);
    set.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
            clean();
        }

        @Override
        public void onAnimationCancel(Animator animation) {
            clean();
        }

        private void clean() {
            mLastAnimator = null;
            layer.removeAllViews();
            cover.setVisibility(View.INVISIBLE);
        }
    });
    mLastAnimator = set;
    set.start();
}

From source file:com.betterAlarm.deskclock.timer.TimerFragment.java

private Animator getRotateFromAnimator(View view) {
    final Animator animator = new ObjectAnimator().ofFloat(view, View.SCALE_X, 1.0f, 0.0f);
    animator.setDuration(ROTATE_ANIM_DURATION_MILIS);
    animator.setInterpolator(DECELERATE_INTERPOLATOR);
    return animator;
}

From source file:cc.solart.turbo.TurboRecyclerView.java

private void animateOffsetToEnd(final String propertyName, final Interpolator interpolator, float... value) {
    if (mResetAnimator == null) {
        mResetAnimator = new ObjectAnimator();
        mResetAnimator.setTarget(this);
    }/*from w  w w. j  av  a 2  s  .com*/
    mResetAnimator.cancel();
    mResetAnimator.setPropertyName(propertyName);
    mResetAnimator.setFloatValues(value);
    mResetAnimator.setInterpolator(interpolator);
    mResetAnimator.start();
}

From source file:com.betterAlarm.deskclock.timer.TimerFragment.java

private Animator getRotateToAnimator(View view) {
    final Animator animator = new ObjectAnimator().ofFloat(view, View.SCALE_X, 0.0f, 1.0f);
    animator.setDuration(ROTATE_ANIM_DURATION_MILIS);
    animator.setInterpolator(ACCELERATE_INTERPOLATOR);
    return animator;
}