Example usage for android.view.animation Animation setInterpolator

List of usage examples for android.view.animation Animation setInterpolator

Introduction

In this page you can find the example usage for android.view.animation Animation setInterpolator.

Prototype

public void setInterpolator(Interpolator i) 

Source Link

Document

Sets the acceleration curve for this animation.

Usage

From source file:org.fs.publication.views.ReadActivity.java

@Override
public void hideNavigation() {
    clearAnimations();/*  w w  w.  ja  v  a2 s .  c  o  m*/
    // toolbar
    Animation hideToolbarAnim = AnimationUtils.loadAnimation(getContext(), R.anim.top_out);
    hideToolbarAnim.setDuration(300L);
    hideToolbarAnim.setInterpolator(new FancyInterpolator());
    hideToolbarAnim.setAnimationListener(new SimpleAnimationListener() {
        @Override
        public void onAnimationEnd(Animation animation) {
            if (isAvailable()) {
                toolbar.setVisibility(View.INVISIBLE);
            }
        }
    });
    toolbar.setAnimation(hideToolbarAnim);
    // navigation
    Animation hideMenuAnim = AnimationUtils.loadAnimation(getContext(), R.anim.bottom_out);
    hideMenuAnim.setDuration(300L);
    hideMenuAnim.setInterpolator(new FancyInterpolator());
    hideMenuAnim.setAnimationListener(new SimpleAnimationListener() {
        @Override
        public void onAnimationEnd(Animation animation) {
            if (isAvailable()) {
                layout.setVisibility(View.INVISIBLE);
            }
        }
    });
    layout.setAnimation(hideMenuAnim);
    // start
    hideToolbarAnim.start();
    hideMenuAnim.start();
}

From source file:com.heinrichreimersoftware.singleinputform.SingleInputFormActivity.java

private Animation getAnimation(int animationResId, boolean isInAnimation) {
    final Interpolator interpolator;

    if (isInAnimation) {
        interpolator = new DecelerateInterpolator(1.0f);
    } else {//  w  w w . j a v  a  2  s  .  c om
        interpolator = new AccelerateInterpolator(1.0f);
    }

    Animation animation = AnimationUtils.loadAnimation(activity, animationResId);
    animation.setInterpolator(interpolator);

    return animation;
}

From source file:android.support.design.widget.FloatingActionButtonGingerbread.java

@Override
void show(@Nullable final InternalVisibilityChangedListener listener, final boolean fromUser) {
    if (isOrWillBeShown()) {
        // We either are or will soon be visible, skip the call
        return;/*from w  w w.  jav a  2 s .c o m*/
    }

    mAnimState = ANIM_STATE_SHOWING;

    mView.internalSetVisibility(View.VISIBLE, fromUser);
    Animation anim = android.view.animation.AnimationUtils.loadAnimation(mView.getContext(),
            R.anim.design_fab_in);
    anim.setDuration(SHOW_HIDE_ANIM_DURATION);
    anim.setInterpolator(AnimationUtils.LINEAR_OUT_SLOW_IN_INTERPOLATOR);
    anim.setAnimationListener(new AnimationListenerAdapter() {
        @Override
        public void onAnimationEnd(Animation animation) {
            mAnimState = ANIM_STATE_NONE;
            if (listener != null) {
                listener.onShown();
            }
        }
    });
    mView.startAnimation(anim);
}

From source file:android.support.design.widget.FloatingActionButtonEclairMr1.java

@Override
void show(@Nullable final InternalVisibilityChangedListener listener, final boolean fromUser) {
    if (mView.getVisibility() != View.VISIBLE || mIsHiding) {
        // If the view is not visible, or is visible and currently being hidden, run
        // the show animation
        mView.clearAnimation();/* ww  w.  j  av a 2  s  . c  o m*/
        mView.internalSetVisibility(View.VISIBLE, fromUser);
        Animation anim = android.view.animation.AnimationUtils.loadAnimation(mView.getContext(),
                R.anim.design_fab_in);
        anim.setDuration(SHOW_HIDE_ANIM_DURATION);
        anim.setInterpolator(AnimationUtils.LINEAR_OUT_SLOW_IN_INTERPOLATOR);
        anim.setAnimationListener(new AnimationListenerAdapter() {
            @Override
            public void onAnimationEnd(Animation animation) {
                if (listener != null) {
                    listener.onShown();
                }
            }
        });
        mView.startAnimation(anim);
    } else {
        if (listener != null) {
            listener.onShown();
        }
    }
}

From source file:fiskinfoo.no.sintef.fiskinfoo.CardViewFragment.java

public Animation getBlinkAnimation() {
    Animation animation = new AlphaAnimation(1, 0);
    animation.setDuration(600);/*from ww  w  . ja v a2  s.  c  om*/
    animation.setInterpolator(new LinearInterpolator());
    animation.setRepeatCount(1);
    animation.setRepeatMode(Animation.REVERSE);

    return animation;
}

From source file:android.support.designox.widget.FloatingActionButtonEclairMr1.java

@Override
void show(@Nullable final InternalVisibilityChangedListener listener, final boolean fromUser) {
    if (mView.getVisibility() != View.VISIBLE || mIsHiding) {
        // If the view is not visible, or is visible and currently being hidden, run
        // the show animation
        mView.clearAnimation();//ww  w  .  j av a2  s .c o  m
        mView.internalSetVisibility(View.VISIBLE, fromUser);
        Animation anim = android.view.animation.AnimationUtils.loadAnimation(mView.getContext(),
                R.anim.design_fab_in_ox);
        anim.setDuration(SHOW_HIDE_ANIM_DURATION);
        anim.setInterpolator(AnimationUtils.LINEAR_OUT_SLOW_IN_INTERPOLATOR);
        anim.setAnimationListener(new AnimationUtils.AnimationListenerAdapter() {
            @Override
            public void onAnimationEnd(Animation animation) {
                if (listener != null) {
                    listener.onShown();
                }
            }
        });
        mView.startAnimation(anim);
    } else {
        if (listener != null) {
            listener.onShown();
        }
    }
}

From source file:com.zzisoo.toylibrary.adapter.ToyListAdapter.java

@Override
public void onBindViewHolder(ViewHolder viewHolder, final int position) {
    Log.e(TAG, "onBindViewHolder #" + position);

    // Get element from your dataset at this position and replace the contents of the view
    // with that element
    View v = viewHolder.getVh();// w  w  w .j  av a2s . c o m
    final ImageView ivToyImage = viewHolder.getIvToyImage();
    final TextView textView = viewHolder.getTvTitle();
    final FlipImageView flipImageView = viewHolder.getFlipImageView();

    View.OnClickListener l = new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            String strPid = mDataSet.get(position).getStrPid();

            if (mPref.getStringArrayList(SharedPref.PREF_FAVORITE_LIST).contains(strPid)) {
                mPref.removeStringArrayListItem(SharedPref.PREF_FAVORITE_LIST, strPid);
            } else {
                mPref.addStringArrayListItem(SharedPref.PREF_FAVORITE_LIST, strPid);
            }
            flipImageView.toggleFlip();
        }
    };
    textView.setOnClickListener(l);
    flipImageView.setOnClickListener(l);

    viewHolder.getTvLoadingBackground().setBackgroundColor(getPastelRBG());
    viewHolder.getTvLoading().setText("ToyToI");
    if (-1 < position && position < mDataSet.size()) {
        setItemSize(v);

        mFavList = mPref.getStringArrayList(SharedPref.PREF_FAVORITE_LIST);
        if (mFavList.contains(mDataSet.get(position).getStrPid())) {
            flipImageView.setFlipped(true);
        } else {
            flipImageView.setFlipped(false);
        }

        final Toy toy = mDataSet.get(position);

        String bgImage = Config.HOST_SERVER_URL + toy.getImage().replace("..", "");
        String strTitle = toy.getTitle();
        textView.setText(strTitle);//

        ImageLoadingListener fadeImageLoadingListener = new ImageLoadingListener() {

            long ANIM_DURATION = 500;

            @Override
            public void onLoadingStarted(String s, View view) {
                view.clearAnimation();
                ((ImageView) view).setImageResource(R.drawable.alpha_zero);
            }

            @Override
            public void onLoadingFailed(String s, View view, FailReason failReason) {
                Toast.makeText(view.getContext(), "Network Error : " + failReason.getType().toString(),
                        Toast.LENGTH_LONG).show();
                ((TextView) ((FrameLayout) view.getParent()).findViewById(R.id.tvLoading)).setText("Error");
                Log.e(TAG, "onLoadingFailed :" + s);
            }

            @Override
            public void onLoadingComplete(String s, View view, Bitmap bitmap) {
                ((ImageView) view).setImageBitmap(bitmap);
                Animation fadeIn = new AlphaAnimation(0, 1);
                fadeIn.setInterpolator(new DecelerateInterpolator()); // add this
                fadeIn.setDuration(ANIM_DURATION);
                view.clearAnimation();
                view.startAnimation(fadeIn);
            }

            @Override
            public void onLoadingCancelled(String s, View view) {
                if (view != null) {
                    ((TextView) ((FrameLayout) view.getParent()).findViewById(R.id.tvLoading)).setText("Error");
                    Log.e(TAG, "onLoadingCancelled :" + s);
                }
            }
        };

        App.getImageLoader(v.getContext()).displayImage(bgImage, ivToyImage, fadeImageLoadingListener);
        ivToyImage.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(final View v) {
                AsyncHttpClient asyncHttpClient = new AsyncHttpClient();

                asyncHttpClient.get(v.getContext(), Config.URL_DETAIL + mDataSet.get(position).getStrPid(),
                        new AsyncHttpResponseHandler() {

                            @Override
                            public void onSuccess(int i, Header[] headers, byte[] bytes) {
                                String responseStr = new String(bytes);
                                Context context = v.getContext();

                                Bundle bundle = new Bundle();
                                Gson gson = new Gson();
                                Product[] products = gson.fromJson(responseStr, Product[].class);

                                Intent intent = new Intent(context,
                                        FlexibleSpaceWithImageRecyclerViewActivity.class);
                                intent.putExtra("Products", gson.toJson(products));
                                intent.putExtra("title", toy.getTitle());
                                intent.putExtra("image", toy.getImage());
                                intent.putExtra("favorite",
                                        mPref.getStringArrayList(SharedPref.PREF_FAVORITE_LIST)
                                                .contains(toy.getStrPid()));
                                context.startActivity(intent);

                                //changeFragment
                            }

                            private void changeFragment(Bundle bundle) {
                                Fragment fragment = new ProductListViewFragment();
                                fragment.setArguments(bundle);

                                FragmentTransaction transaction = ((FragmentActivity) v.getContext())
                                        .getSupportFragmentManager().beginTransaction();
                                transaction.setCustomAnimations(R.anim.enter, R.anim.exit, R.anim.popenter,
                                        R.anim.popexit);
                                transaction.addToBackStack(getClass().getSimpleName());
                                transaction.replace(R.id.toyListViewWraper, fragment);
                                transaction.commit();
                            }

                            @Override
                            public void onFailure(int i, Header[] headers, byte[] bytes, Throwable throwable) {

                            }
                        });

                Log.d(TAG, "Element " + position + " clicked.");
                mClickedPostion = position;
                //
            }
        });
    }

}

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

@Override
public void onCreate(Bundle savedInstanceState) {
    setMyTheme();/*w w  w.  j a  va2s  .  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:de.wikilab.android.friendica01.activity.HomeActivity.java

protected void setMenuBarVisible(boolean v) {
    View leftBar = findViewById(R.id.left_bar);
    if (v) {//  w ww .j  a  v  a2  s  .com
        Animation anim1 = AnimationUtils.loadAnimation(HomeActivity.this, android.R.anim.slide_in_left);
        anim1.setInterpolator((new AccelerateDecelerateInterpolator()));
        //anim1.setFillAfter(true);
        leftBar.setAnimation(anim1);

        leftBar.setVisibility(View.VISIBLE);
    } else {
        Animation anim1 = AnimationUtils.loadAnimation(HomeActivity.this, R.anim.slide_out_left);
        anim1.setInterpolator((new AccelerateDecelerateInterpolator()));
        anim1.setFillAfter(true);
        leftBar.setAnimation(anim1);

        leftBar.setVisibility(View.GONE);
    }
}

From source file:com.glabs.homegenie.StartActivity.java

public void showLogo() {
    _islogovisible = true;//from  w  w w  .  j a va2  s  .c  o m
    runOnUiThread(new Runnable() {
        @Override
        public void run() {
            Animation fadeIn = new AlphaAnimation(0, 0.8f);
            fadeIn.setInterpolator(new AccelerateInterpolator()); //and this
            fadeIn.setStartOffset(0);
            fadeIn.setDuration(500);
            //
            AnimationSet animation = new AnimationSet(false); //change to false
            animation.addAnimation(fadeIn);
            animation.setFillAfter(true);
            RelativeLayout ivlogo = (RelativeLayout) findViewById(R.id.logo);
            ivlogo.startAnimation(animation);
        }
    });
}