Example usage for android.view.animation AccelerateInterpolator AccelerateInterpolator

List of usage examples for android.view.animation AccelerateInterpolator AccelerateInterpolator

Introduction

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

Prototype

public AccelerateInterpolator() 

Source Link

Usage

From source file:com.phonemetra.turbo.launcher.AsyncTaskCallback.java

@Override
public void onClick(View v) {
    // When we have exited all apps or are in transition, disregard clicks
    if (!mLauncher.isAllAppsVisible() || mLauncher.getWorkspace().isSwitchingState())
        return;//from   w w w. ja v  a 2 s.  c om

    if (v instanceof PagedViewIcon) {
        // Animate some feedback to the click
        final AppInfo appInfo = (AppInfo) v.getTag();

        // Lock the drawable state to pressed until we return to Launcher
        if (mPressedIcon != null) {
            mPressedIcon.lockDrawableState();
        }
        mLauncher.startActivitySafely(v, appInfo.intent, appInfo);
        mLauncher.getStats().recordLaunch(appInfo.intent);
    } else if (v instanceof PagedViewWidget) {
        // Let the user know that they have to long press to add a widget
        if (mWidgetInstructionToast != null) {
            mWidgetInstructionToast.cancel();
        }
        mWidgetInstructionToast = Toast.makeText(getContext(), R.string.long_press_widget_to_add,
                Toast.LENGTH_SHORT);
        mWidgetInstructionToast.show();

        // Create a little animation to show that the widget can move
        float offsetY = getResources().getDimensionPixelSize(R.dimen.dragViewOffsetY);
        final ImageView p = (ImageView) v.findViewById(R.id.widget_preview);
        AnimatorSet bounce = LauncherAnimUtils.createAnimatorSet();
        ValueAnimator tyuAnim = LauncherAnimUtils.ofFloat(p, "translationY", offsetY);
        tyuAnim.setDuration(125);
        ValueAnimator tydAnim = LauncherAnimUtils.ofFloat(p, "translationY", 0f);
        tydAnim.setDuration(100);
        bounce.play(tyuAnim).before(tydAnim);
        bounce.setInterpolator(new AccelerateInterpolator());
        bounce.start();
    }
}

From source file:org.huxizhijian.hhcomicviewer.ui.entry.ComicDetailsActivity.java

private void updateViews() {
    //?//w  w w.j  a v a  2s . c o  m
    mBinding.comicAuthorComicDetails.setVisibility(View.VISIBLE);
    mBinding.comicAuthorComicDetails.setText(mComic.getAuthor());
    mBinding.comicVolStatusComicDetails.setText(mComic.getComicStatus());
    mBinding.comicFavoriteNumberComicDetails.setText(mComic.getComicFavorite());
    mBinding.comicUpdateTimeComicDetails.setText(mComic.getComicUpdateTime());

    //
    mBinding.comicDescriptionComicDetails.setText(mComic.getDescription());
    //?
    mBinding.comicDescriptionComicDetailsBack.setVisibility(View.VISIBLE);
    mBinding.comicDescriptionComicDetailsBack.setText(mComic.getDescription());
    final ViewTreeObserver vto1 = mBinding.comicDescriptionComicDetails.getViewTreeObserver();
    vto1.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
        @Override
        public void onGlobalLayout() {
            mDetailsHeight = mBinding.comicDescriptionComicDetails.getHeight();
            //??
            mBinding.comicDescriptionComicDetails.getViewTreeObserver().removeGlobalOnLayoutListener(this);
        }
    });
    //?tv_back 
    ViewTreeObserver vto = mBinding.comicDescriptionComicDetailsBack.getViewTreeObserver();
    vto.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {

        @Override
        public void onGlobalLayout() {
            mBackHeight = mBinding.comicDescriptionComicDetailsBack.getHeight();
            mBinding.comicDescriptionComicDetailsBack.getViewTreeObserver().removeGlobalOnLayoutListener(this);

            //
            if (mBackHeight > mDetailsHeight) {
                //
                mBinding.ivArrow.setVisibility(View.VISIBLE);
                //?
                mBinding.comicDescriptionComicDetails.setTag(true);
                isDescriptionCanOpen = true;
            } else {
                mBinding.ivArrow.setVisibility(View.GONE);
                isDescriptionCanOpen = false;
            }

            mBinding.comicDescriptionComicDetailsBack.setVisibility(View.GONE);
        }
    });

    //?
    mBinding.ratingBarComicDetails.setRating((mComic.getRatingNumber() / 10.0f) * 5.0f);
    mBinding.ratingBarDescriptionComicDetails.setText(mComic.getRatingNumber() + "(10), " + ""
            + mComic.getRatingPeopleNum() + "");

    //
    if (mComic.isMark() || mComic.isDownload()) {
        mVolAdapter = new VolRecyclerViewAdapter(ComicDetailsActivity.this, mComic.getChapterName(),
                mComic.getReadChapter(), mFinishedComicChapters);
    } else {
        mVolAdapter = new VolRecyclerViewAdapter(ComicDetailsActivity.this, mComic.getChapterName(),
                mFinishedComicChapters);
    }

    //?RecyclerView
    mBinding.recyclerViewComicDetails
            .setLayoutManager(new FullyGridLayoutManager(ComicDetailsActivity.this, 4));
    mBinding.recyclerViewComicDetails.setItemAnimator(new DefaultItemAnimator());
    mBinding.recyclerViewComicDetails.setHasFixedSize(true);
    mBinding.recyclerViewComicDetails.setNestedScrollingEnabled(false);
    mVolAdapter.setOnItemClickListener(new VolRecyclerViewAdapter.OnItemClickListener() {
        @Override
        public void onItemClick(View view, int position) {
            Intent intent = new Intent(ComicDetailsActivity.this, GalleryActivity.class);
            intent.putExtra("comic", mComic);
            intent.putExtra("position", position);
            startActivityForResult(intent, 0);
        }

        @Override
        public void onItemLongClick(View view, int position) {
        }
    });
    mBinding.recyclerViewComicDetails.setAdapter(mVolAdapter);
    mBinding.recyclerViewComicDetails.setFocusable(false);
    mBinding.nestScrollViewComicDetails.setFocusable(true);
    mBinding.nestScrollViewComicDetails.smoothScrollBy(0, 0);

    //??
    if (mComic.isMark()) {
        mBinding.btnFavoriteComicDetails.setImageResource(R.mipmap.my_favorite);
        mBinding.buttonTextFavoriteComicDetails.setText("?");
    }

    //?
    mBinding.FABComicDetails.setOnClickListener(this);
    mBinding.readButton.setOnClickListener(this);
    //
    mBinding.btnFavorite.setOnClickListener(this);
    mBinding.btnShare.setOnClickListener(this);
    mBinding.btnFind.setOnClickListener(this);
    mBinding.btnDownload.setOnClickListener(this);
    //
    mBinding.comicAuthorComicDetails.setOnClickListener(this);
    mBinding.comicDescriptionComicDetailsLl.setOnClickListener(this);

    //??
    mBinding.FABComicDetails
            .setBackgroundTintList(ColorStateList.valueOf(getResources().getColor(R.color.colorAccent)));
    mBinding.linearLayoutComicDetails.setVisibility(View.VISIBLE);
    Animation alpha = AnimationUtils.loadAnimation(this, R.anim.alpha_in);
    //?
    alpha.setInterpolator(new AccelerateInterpolator());
    mBinding.linearLayoutComicDetails.startAnimation(alpha);
}

From source file:com.android.deskclock.timer.TimerFullScreenFragment.java

private void gotoSetupView() {
    if (mLastVisibleView == null || mLastVisibleView.getId() == R.id.timer_setup) {
        mTimerSetup.setVisibility(View.VISIBLE);
        mTimerSetup.setScaleX(1f);/*w ww .  jav  a  2s . com*/
        mTimersListPage.setVisibility(View.GONE);
    } else {
        // Animate
        ObjectAnimator a = ObjectAnimator.ofFloat(mTimersListPage, View.SCALE_X, 1f, 0f);
        a.setInterpolator(new AccelerateInterpolator());
        a.setDuration(125);
        a.addListener(new AnimatorListenerAdapter() {
            @Override
            public void onAnimationEnd(Animator animation) {
                mTimersListPage.setVisibility(View.GONE);
                mTimerSetup.setScaleX(0);
                mTimerSetup.setVisibility(View.VISIBLE);
                ObjectAnimator b = ObjectAnimator.ofFloat(mTimerSetup, View.SCALE_X, 0f, 1f);
                b.setInterpolator(new DecelerateInterpolator());
                b.setDuration(225);
                b.start();
            }
        });
        a.start();

    }
    stopClockTicks();
    mTimerSetup.updateDeleteButtonAndDivider();
    mLastVisibleView = mTimerSetup;
}

From source file:com.smc.tw.waltz.MainActivity.java

private void hideToolbar() {
    getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
    mToolbar.animate().translationY(-mToolbar.getBottom()).setInterpolator(new AccelerateInterpolator())
            .start();/*ww w  . j av a2  s . c om*/

    mToolbar.setVisibility(View.GONE);

    mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED);
}

From source file:com.android.launcher2.AsyncTaskCallback.java

@Override
public void onClick(View v) {
    // When we have exited all apps or are in transition, disregard clicks
    if (!mLauncher.isAllAppsVisible() || mLauncher.getWorkspace().isSwitchingState())
        return;//from www .  ja va2s  .c  o  m

    if (v instanceof PagedViewIcon) {
        // Animate some feedback to the click
        final ApplicationInfo appInfo = (ApplicationInfo) v.getTag();

        // Lock the drawable state to pressed until we return to Launcher
        if (mPressedIcon != null) {
            mPressedIcon.lockDrawableState();
        }

        // NOTE: We want all transitions from launcher to act as if the wallpaper were enabled
        // to be consistent.  So re-enable the flag here, and we will re-disable it as necessary
        // when Launcher resumes and we are still in AllApps.
        mLauncher.updateWallpaperVisibility(true);
        mLauncher.startActivitySafely(v, appInfo.intent, appInfo);

    } else if (v instanceof PagedViewWidget) {
        // Let the user know that they have to long press to add a widget
        if (mWidgetInstructionToast != null) {
            mWidgetInstructionToast.cancel();
        }
        mWidgetInstructionToast = Toast.makeText(getContext(), R.string.long_press_widget_to_add,
                Toast.LENGTH_SHORT);
        mWidgetInstructionToast.show();

        // Create a little animation to show that the widget can move
        float offsetY = getResources().getDimensionPixelSize(R.dimen.dragViewOffsetY);
        final ImageView p = (ImageView) v.findViewById(R.id.widget_preview);
        AnimatorSet bounce = LauncherAnimUtils.createAnimatorSet();
        ValueAnimator tyuAnim = LauncherAnimUtils.ofFloat(p, "translationY", offsetY);
        tyuAnim.setDuration(125);
        ValueAnimator tydAnim = LauncherAnimUtils.ofFloat(p, "translationY", 0f);
        tydAnim.setDuration(100);
        bounce.play(tyuAnim).before(tydAnim);
        bounce.setInterpolator(new AccelerateInterpolator());
        bounce.start();
    }
}

From source file:com.google.android.apps.santatracker.village.Village.java

private void easterEggInteraction() {
    mCallback.playSoundOnce(R.raw.easter_egg);

    // Fade into the distance
    ObjectAnimator anim = ObjectAnimator.ofFloat(mImageUfo, "size", 1.0f, 0f);
    anim.setInterpolator(new AccelerateInterpolator());
    anim.setDuration(ImageWithAlphaAndSize.ANIM_DURATION);
    anim.addListener(new Animator.AnimatorListener() {
        @Override//from   w ww  .  j ava  2s .  c o  m
        public void onAnimationStart(Animator animation) {
        }

        @Override
        public void onAnimationEnd(Animator animation) {
            mImageUfo.setAlpha(ImageWithAlphaAndSize.INVISIBLE);
        }

        @Override
        public void onAnimationCancel(Animator animation) {
        }

        @Override
        public void onAnimationRepeat(Animator animation) {
        }
    });
    anim.start();
}

From source file:org.mozilla.gecko.home.BrowserSearch.java

private void setSuggestionsEnabled(final boolean enabled) {
    // Clicking the yes/no buttons quickly can cause the click events be
    // queued before the listeners are removed above, so it's possible
    // setSuggestionsEnabled() can be called twice. mSuggestionsOptInPrompt
    // can be null if this happens (bug 828480).
    if (mSuggestionsOptInPrompt == null) {
        return;/* ww  w.  jav a2 s. com*/
    }

    // Make suggestions appear immediately after the user opts in
    ThreadUtils.postToBackgroundThread(new Runnable() {
        @Override
        public void run() {
            SuggestClient client = mSuggestClient;
            if (client != null) {
                client.query(mSearchTerm);
            }
        }
    });

    // Pref observer in gecko will also set prompted = true
    PrefsHelper.setPref("browser.search.suggest.enabled", enabled);

    TranslateAnimation slideAnimation = new TranslateAnimation(0, mSuggestionsOptInPrompt.getWidth(), 0, 0);
    slideAnimation.setDuration(ANIMATION_DURATION);
    slideAnimation.setInterpolator(new AccelerateInterpolator());
    slideAnimation.setFillAfter(true);
    final View prompt = mSuggestionsOptInPrompt.findViewById(R.id.prompt);

    TranslateAnimation shrinkAnimation = new TranslateAnimation(0, 0, 0,
            -1 * mSuggestionsOptInPrompt.getHeight());
    shrinkAnimation.setDuration(ANIMATION_DURATION);
    shrinkAnimation.setFillAfter(true);
    shrinkAnimation.setStartOffset(slideAnimation.getDuration());
    shrinkAnimation.setAnimationListener(new Animation.AnimationListener() {
        @Override
        public void onAnimationStart(Animation a) {
            // Increase the height of the view so a gap isn't shown during animation
            mView.getLayoutParams().height = mView.getHeight() + mSuggestionsOptInPrompt.getHeight();
            mView.requestLayout();
        }

        @Override
        public void onAnimationRepeat(Animation a) {
        }

        @Override
        public void onAnimationEnd(Animation a) {
            // Removing the view immediately results in a NPE in
            // dispatchDraw(), possibly because this callback executes
            // before drawing is finished. Posting this as a Runnable fixes
            // the issue.
            mView.post(new Runnable() {
                @Override
                public void run() {
                    mView.removeView(mSuggestionsOptInPrompt);
                    mList.clearAnimation();
                    mSuggestionsOptInPrompt = null;

                    if (enabled) {
                        // Reset the view height
                        mView.getLayoutParams().height = LayoutParams.MATCH_PARENT;

                        mSuggestionsEnabled = enabled;
                        mAnimateSuggestions = true;
                        mAdapter.notifyDataSetChanged();
                        filterSuggestions();
                    }
                }
            });
        }
    });

    prompt.startAnimation(slideAnimation);
    mSuggestionsOptInPrompt.startAnimation(shrinkAnimation);
    mList.startAnimation(shrinkAnimation);
}

From source file:com.android.deskclock.timer.TimerFullScreenFragment.java

private void gotoTimersView() {
    if (mLastVisibleView == null || mLastVisibleView.getId() == R.id.timers_list_page) {
        mTimerSetup.setVisibility(View.GONE);
        mTimersListPage.setVisibility(View.VISIBLE);
        mTimersListPage.setScaleX(1f);/*from  w  w  w .j a v  a  2s  .  c om*/
    } else {
        // Animate
        ObjectAnimator a = ObjectAnimator.ofFloat(mTimerSetup, View.SCALE_X, 1f, 0f);
        a.setInterpolator(new AccelerateInterpolator());
        a.setDuration(125);
        a.addListener(new AnimatorListenerAdapter() {
            @Override
            public void onAnimationEnd(Animator animation) {
                mTimerSetup.setVisibility(View.GONE);
                mTimersListPage.setScaleX(0);
                mTimersListPage.setVisibility(View.VISIBLE);
                ObjectAnimator b = ObjectAnimator.ofFloat(mTimersListPage, View.SCALE_X, 0f, 1f);
                b.setInterpolator(new DecelerateInterpolator());
                b.setDuration(225);
                b.start();
            }
        });
        a.start();
    }
    startClockTicks();
    mLastVisibleView = mTimersListPage;
}

From source file:com.alivenet.dmvtaxi.Activity_ConfirmMybooking.java

private Animation inFromRightAnimation() {

    Animation inFromRight = new TranslateAnimation(Animation.RELATIVE_TO_PARENT, +1.0f,
            Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT, 0.0f,
            Animation.RELATIVE_TO_PARENT, 0.0f);
    inFromRight.setDuration(2000);//from  w w  w.  j a  v  a  2  s .com
    inFromRight.setInterpolator(new AccelerateInterpolator());
    return inFromRight;
}

From source file:pl.motyczko.scrollheader.PagerSlidingTabStrip.java

public void setActionBar(ActionBar actionBar) {
    if (mIcon == null)
        return;//from  w  ww .ja  va  2  s  . c  om

    mActionBar = actionBar;
    if (mActionBar == null)
        return;

    mActionBar.setIcon(R.drawable.transparent_actionbar_icon);
    mActionBar.setLogo(R.drawable.transparent_actionbar_icon);
    mAlphaForegroundColorSpan = new AlphaForegroundColorSpan(0xffffffff);
    mActionBarTitleInterpolator = new AccelerateInterpolator();
}