Example usage for android.view.animation AnimationUtils loadInterpolator

List of usage examples for android.view.animation AnimationUtils loadInterpolator

Introduction

In this page you can find the example usage for android.view.animation AnimationUtils loadInterpolator.

Prototype

public static Interpolator loadInterpolator(Context context, @AnimRes @InterpolatorRes int id)
        throws NotFoundException 

Source Link

Document

Loads an Interpolator object from a resource

Usage

From source file:ticwear.design.widget.FloatingActionButtonAnimator.java

FloatingActionButtonAnimator(VisibilityAwareImageButton view) {

    mView = view;//www . java2  s .  c o  m

    if (!view.isInEditMode()) {
        mInterpolator = AnimationUtils.loadInterpolator(mView.getContext(),
                android.R.interpolator.fast_out_slow_in);
    }

}

From source file:com.example.android.unsplash.DetailActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    setContentView(R.layout.activity_detail);

    postponeEnterTransition();/*from  ww  w . j a v a  2  s .c  o m*/

    TransitionSet transitions = new TransitionSet();
    Slide slide = new Slide(Gravity.BOTTOM);
    slide.setInterpolator(AnimationUtils.loadInterpolator(this, android.R.interpolator.linear_out_slow_in));
    slide.setDuration(getResources().getInteger(android.R.integer.config_shortAnimTime));
    transitions.addTransition(slide);
    transitions.addTransition(new Fade());
    getWindow().setEnterTransition(transitions);

    Intent intent = getIntent();
    sharedElementCallback = new DetailSharedElementEnterCallback(intent);
    setEnterSharedElementCallback(sharedElementCallback);
    try {
        initialItem = Integer.parseInt(intent.getData().getLastPathSegment());
    } catch (NumberFormatException e) {
        initialItem = 0;
    }
    PhotoService.getInstance().getPhotosAsync(new PhotoService.PhotoCallback() {
        @Override
        public void success(ArrayList<Photo> photos) {
            setUpViewPager(photos);
            findViewById(android.R.id.empty).setVisibility(View.GONE);
        }

        @Override
        public void error() {
            finishAfterTransition();
        }
    });

    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    toolbar.setNavigationOnClickListener(navigationOnClickListener);

    super.onCreate(savedInstanceState);
}

From source file:com.pwned.steamfriends.views.TwitterStream.java

@Override
public void onCreate(Bundle savedInstanceState) {
    setMyTheme();/*from w  w w.  j  a v  a2 s.  c om*/
    super.onCreate(savedInstanceState);
    tracker = GoogleAnalyticsTracker.getInstance();
    tracker.start(Constants.UACODE, 20, this);
    tracker.trackPageView("/TwitterStream");

    mManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
    mManager.cancel(APP_ID);

    setContentView(R.layout.twitter);
    m_streams = new ArrayList<Stream>();
    this.m_adapter = new TwitterStreamAdapter(this, R.layout.row, m_streams);
    setListAdapter(this.m_adapter);

    viewStream = new Thread() {
        @Override
        public void run() {
            getStream();
        }
    };

    Animation a = new RotateAnimation(0.0f, 360.0f, Animation.RELATIVE_TO_SELF, 0.5f,
            Animation.RELATIVE_TO_SELF, 0.5f);
    a.setRepeatMode(Animation.RESTART);
    a.setRepeatCount(Animation.INFINITE);
    a.setDuration(750);

    a.setInterpolator(AnimationUtils.loadInterpolator(this, android.R.anim.linear_interpolator));
    ivLoad = (ImageView) findViewById(R.id.loading_spinner);
    ivLoad.startAnimation(a);

    Thread thread = new Thread(null, viewStream, "SpecialsBackground");
    thread.start();
    //m_ProgressDialog = ProgressDialog.show(TwitterStream.this,"","Loading Twitter Stream...", true);

    steamHeader = (ImageView) findViewById(R.id.headerimage);
    steamHeader.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            Intent myIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(Constants.HEADER_URL));
            startActivity(myIntent);
        }
    });
}

From source file:com.hannesdorfmann.home.filter.FilterAdapter.java

@Override
public FilterViewHolder onCreateViewHolder(ViewGroup viewGroup, int viewType) {
    final FilterViewHolder holder = new FilterViewHolder(
            LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.filter_item, viewGroup, false));

    holder.itemView.setOnClickListener(new View.OnClickListener() {
        @Override/*from w  w w  .  j  a  va 2s .  co m*/
        public void onClick(View v) {
            final int position = holder.getAdapterPosition();
            if (position == RecyclerView.NO_POSITION)
                return;

            final SourceFilterPresentationModel filter = filters.get(position);
            holder.itemView.setHasTransientState(true);
            ObjectAnimator fade = ObjectAnimator.ofInt(holder.filterIcon, ViewUtils.IMAGE_ALPHA,
                    filter.getEnabled() ? FILTER_ICON_DISABLED_ALPHA : FILTER_ICON_ENABLED_ALPHA);
            fade.setDuration(300);
            fade.setInterpolator(AnimationUtils.loadInterpolator(holder.itemView.getContext(),
                    android.R.interpolator.fast_out_slow_in));
            fade.addListener(new AnimatorListenerAdapter() {
                @Override
                public void onAnimationEnd(Animator animation) {
                    holder.itemView.setHasTransientState(false);
                    clickedListener.onSourceFilterClicked(filter);
                }
            });
            fade.start();
        }
    });
    return holder;
}

From source file:ca.uwaterloo.sh6choi.czshopper.ui.FloatLabelLayout.java

public FloatLabelLayout(Context context, AttributeSet attrs) {
    super(context, attrs);
    setOrientation(VERTICAL);/* w  ww  . j  a v a2s .c o  m*/

    final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.FloatLabelLayout);

    int leftPadding = a.getDimensionPixelSize(R.styleable.FloatLabelLayout_floatLabelPaddingLeft,
            dipsToPix(DEFAULT_LABEL_PADDING_LEFT));
    int topPadding = a.getDimensionPixelSize(R.styleable.FloatLabelLayout_floatLabelPaddingTop,
            dipsToPix(DEFAULT_LABEL_PADDING_TOP));
    int rightPadding = a.getDimensionPixelSize(R.styleable.FloatLabelLayout_floatLabelPaddingRight,
            dipsToPix(DEFAULT_LABEL_PADDING_RIGHT));
    int bottomPadding = a.getDimensionPixelSize(R.styleable.FloatLabelLayout_floatLabelPaddingBottom,
            dipsToPix(DEFAULT_LABEL_PADDING_BOTTOM));
    mHint = a.getText(R.styleable.FloatLabelLayout_floatLabelHint);

    mLabel = new TextView(context);
    mLabel.setPadding(leftPadding, topPadding, rightPadding, bottomPadding);
    mLabel.setVisibility(INVISIBLE);
    mLabel.setText(mHint);
    ViewCompat.setPivotX(mLabel, 0f);
    ViewCompat.setPivotY(mLabel, 0f);

    mLabel.setTextAppearance(context, a.getResourceId(R.styleable.FloatLabelLayout_floatLabelTextAppearance,
            android.R.style.TextAppearance_Small));
    a.recycle();

    addView(mLabel, LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);

    mInterpolator = AnimationUtils.loadInterpolator(context,
            Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP ? android.R.interpolator.fast_out_slow_in
                    : android.R.anim.decelerate_interpolator);
}

From source file:com.hitherejoe.animate.util.MorphButtonToDialog.java

@Override
public Animator createAnimator(final ViewGroup sceneRoot, TransitionValues startValues,
        final TransitionValues endValues) {
    Animator changeBounds = super.createAnimator(sceneRoot, startValues, endValues);
    if (startValues == null || endValues == null || changeBounds == null)
        return null;

    Integer startColor = (Integer) startValues.values.get(PROPERTY_COLOR);
    Integer endColor = (Integer) endValues.values.get(PROPERTY_COLOR);

    if (startColor == null || endColor == null)
        return null;

    MorphDrawable background = new MorphDrawable(startColor, 0);
    endValues.view.setBackground(background);

    Animator color = ObjectAnimator.ofArgb(background, background.COLOR, endColor);

    // ease in the dialog's child views (slide up & fade_fast in)
    if (endValues.view instanceof ViewGroup) {
        ViewGroup vg = (ViewGroup) endValues.view;
        float offset = vg.getHeight() / 3;
        for (int i = 0; i < vg.getChildCount(); i++) {
            View v = vg.getChildAt(i);
            v.setTranslationY(offset);//from w  ww.jav a2 s  . c  om
            v.setAlpha(0f);
            v.animate().alpha(1f).translationY(0f).setDuration(150).setStartDelay(150).setInterpolator(
                    AnimationUtils.loadInterpolator(vg.getContext(), android.R.interpolator.fast_out_slow_in));
            offset *= 1.8f;
        }
    }

    AnimatorSet transition = new AnimatorSet();
    transition.playTogether(changeBounds, color);
    transition.setDuration(300);
    transition.setInterpolator(
            AnimationUtils.loadInterpolator(sceneRoot.getContext(), android.R.interpolator.fast_out_slow_in));
    return transition;
}

From source file:com.advaitaworld.widgets.FloatLabelLayout.java

public FloatLabelLayout(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);

    setOrientation(VERTICAL);/*ww  w  . ja  va2  s .  co  m*/

    final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.FloatLabelLayout);

    int leftPadding = a.getDimensionPixelSize(R.styleable.FloatLabelLayout_floatLabelPaddingLeft,
            dipsToPix(DEFAULT_LABEL_PADDING_LEFT));
    int topPadding = a.getDimensionPixelSize(R.styleable.FloatLabelLayout_floatLabelPaddingTop,
            dipsToPix(DEFAULT_LABEL_PADDING_TOP));
    int rightPadding = a.getDimensionPixelSize(R.styleable.FloatLabelLayout_floatLabelPaddingRight,
            dipsToPix(DEFAULT_LABEL_PADDING_RIGHT));
    int bottomPadding = a.getDimensionPixelSize(R.styleable.FloatLabelLayout_floatLabelPaddingBottom,
            dipsToPix(DEFAULT_LABEL_PADDING_BOTTOM));
    mHint = a.getText(R.styleable.FloatLabelLayout_floatLabelHint);

    mLabel = new TextView(context);
    mLabel.setPadding(leftPadding, topPadding, rightPadding, bottomPadding);
    mLabel.setVisibility(INVISIBLE);
    mLabel.setText(mHint);
    ViewCompat.setPivotX(mLabel, 0f);
    ViewCompat.setPivotY(mLabel, 0f);

    mLabel.setTextAppearance(context, a.getResourceId(R.styleable.FloatLabelLayout_floatLabelTextAppearance,
            android.R.style.TextAppearance_Small));
    a.recycle();

    addView(mLabel, LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);

    mInterpolator = AnimationUtils.loadInterpolator(context,
            Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP ? android.R.interpolator.fast_out_slow_in
                    : android.R.anim.decelerate_interpolator);
}

From source file:io.geeteshk.papierr.FloatLabelLayout.java

@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public FloatLabelLayout(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);

    setOrientation(VERTICAL);//from   w w  w .jav  a 2s.c o m

    final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.FloatLabelLayout);

    int leftPadding = a.getDimensionPixelSize(R.styleable.FloatLabelLayout_floatLabelPaddingLeft,
            dipsToPix(DEFAULT_LABEL_PADDING_LEFT));
    int topPadding = a.getDimensionPixelSize(R.styleable.FloatLabelLayout_floatLabelPaddingTop,
            dipsToPix(DEFAULT_LABEL_PADDING_TOP));
    int rightPadding = a.getDimensionPixelSize(R.styleable.FloatLabelLayout_floatLabelPaddingRight,
            dipsToPix(DEFAULT_LABEL_PADDING_RIGHT));
    int bottomPadding = a.getDimensionPixelSize(R.styleable.FloatLabelLayout_floatLabelPaddingBottom,
            dipsToPix(DEFAULT_LABEL_PADDING_BOTTOM));
    mHint = a.getText(R.styleable.FloatLabelLayout_floatLabelHint);

    mLabel = new TextView(context);
    mLabel.setPadding(leftPadding, topPadding, rightPadding, bottomPadding);
    mLabel.setVisibility(INVISIBLE);
    mLabel.setText(mHint);
    ViewCompat.setPivotX(mLabel, 0f);
    ViewCompat.setPivotY(mLabel, 0f);

    mLabel.setTextAppearance(context, a.getResourceId(R.styleable.FloatLabelLayout_floatLabelTextAppearance,
            android.R.style.TextAppearance_Small));
    a.recycle();

    addView(mLabel, LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);

    mInterpolator = AnimationUtils.loadInterpolator(context,
            Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP ? android.R.interpolator.fast_out_slow_in
                    : android.R.anim.decelerate_interpolator);
}

From source file:ch.heigvd.wordhunt.Interaction.FloatLabelLayout.java

public void init(Context context, AttributeSet attrs) {

    setOrientation(VERTICAL);/*from w ww. j  a v a 2s.c o  m*/

    final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.FloatLabelLayout);

    int leftPadding = a.getDimensionPixelSize(R.styleable.FloatLabelLayout_floatLabelPaddingLeft,
            dipsToPix(DEFAULT_LABEL_PADDING_LEFT));
    int topPadding = a.getDimensionPixelSize(R.styleable.FloatLabelLayout_floatLabelPaddingTop,
            dipsToPix(DEFAULT_LABEL_PADDING_TOP));
    int rightPadding = a.getDimensionPixelSize(R.styleable.FloatLabelLayout_floatLabelPaddingRight,
            dipsToPix(DEFAULT_LABEL_PADDING_RIGHT));
    int bottomPadding = a.getDimensionPixelSize(R.styleable.FloatLabelLayout_floatLabelPaddingBottom,
            dipsToPix(DEFAULT_LABEL_PADDING_BOTTOM));
    mHint = a.getText(R.styleable.FloatLabelLayout_floatLabelHint);

    mLabel = new TextView(context);
    mLabel.setPadding(leftPadding, topPadding, rightPadding, bottomPadding);
    mLabel.setVisibility(INVISIBLE);
    mLabel.setText(mHint);
    ViewCompat.setPivotX(mLabel, 0f);
    ViewCompat.setPivotY(mLabel, 0f);

    mLabel.setTextAppearance(context, a.getResourceId(R.styleable.FloatLabelLayout_floatLabelTextAppearance,
            android.R.style.TextAppearance_Small));
    a.recycle();

    addView(mLabel, LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);

    mInterpolator = AnimationUtils.loadInterpolator(context,
            Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP ? android.R.interpolator.fast_out_slow_in
                    : android.R.anim.decelerate_interpolator);
}

From source file:io.plaidapp.ui.PostNewDesignerNewsStory.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_post_new_designer_news_story);
    ButterKnife.bind(this);
    FabDialogMorphSetup.setupSharedEelementTransitions(this, bottomSheetContent, 0);

    bottomSheet.addListener(new BottomSheet.Listener() {
        @Override/*from   w ww  . j  a  v  a 2 s .  c o  m*/
        public void onDragDismissed() {
            // After a drag dismiss, finish without the shared element return transition as
            // it no longer makes sense.  Let the launching window know it's a drag dismiss so
            // that it can restore any UI used as an entering shared element
            setResult(RESULT_DRAG_DISMISSED);
            finish();
        }

        @Override
        public void onDrag(int top) {
            /* no-op */ }
    });

    scrollContainer.setListener(new ObservableScrollView.OnScrollListener() {
        @Override
        public void onScrolled(int scrollY) {
            if (scrollY != 0 && sheetTitle.getTranslationZ() != appBarElevation) {
                sheetTitle.animate().translationZ(appBarElevation).setStartDelay(0L).setDuration(80L)
                        .setInterpolator(AnimationUtils.loadInterpolator(PostNewDesignerNewsStory.this,
                                android.R.interpolator.fast_out_slow_in))
                        .start();
            } else if (scrollY == 0 && sheetTitle.getTranslationZ() == appBarElevation) {
                sheetTitle.animate().translationZ(0f).setStartDelay(0L).setDuration(80L)
                        .setInterpolator(AnimationUtils.loadInterpolator(PostNewDesignerNewsStory.this,
                                android.R.interpolator.fast_out_slow_in))
                        .start();
            }
        }
    });

    // check for share intent
    if (isShareIntent()) {
        ShareCompat.IntentReader intentReader = ShareCompat.IntentReader.from(this);
        url.setText(intentReader.getText());
        title.setText(intentReader.getSubject());

        // when receiving a share there is no shared element transition so animate up the
        // bottom sheet to establish the spatial model i.e. that it can be dismissed downward
        overridePendingTransition(R.anim.post_story_enter, R.anim.fade_out_rapidly);
        bottomSheetContent.getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() {
            @Override
            public boolean onPreDraw() {
                bottomSheetContent.getViewTreeObserver().removeOnPreDrawListener(this);
                bottomSheetContent.setTranslationY(bottomSheetContent.getHeight());
                bottomSheetContent.animate().translationY(0f).setStartDelay(120L).setDuration(240L)
                        .setInterpolator(AnimationUtils.loadInterpolator(PostNewDesignerNewsStory.this,
                                android.R.interpolator.linear_out_slow_in));
                return false;
            }
        });
    }
}