List of usage examples for android.animation ArgbEvaluator ArgbEvaluator
ArgbEvaluator
From source file:com.yoloo.android.util.AnimUtils.java
public static ArgbEvaluator getArgbEvaluator() { if (argbEvaluator == null) { argbEvaluator = new ArgbEvaluator(); }/* w ww . j av a 2s. c om*/ return argbEvaluator; }
From source file:com.runmit.sweedee.view.CirclePageIndicator.java
public CirclePageIndicator(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); if (isInEditMode()) return;//from w w w . j av a 2 s . c om final Resources res = getResources(); defaultFillColor = res.getColor(R.color.default_circle_indicator_fill_color); defaultCommonColor = res.getColor(R.color.default_circle_indicator_stroke_color); final float defaultRadius = res.getDimension(R.dimen.default_circle_indicator_radius); TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.CirclePageIndicator, defStyle, 0); mRadius = a.getDimension(R.styleable.CirclePageIndicator_radius, defaultRadius); a.recycle(); mColorEvaluator = new ArgbEvaluator(); }
From source file:org.catrobat.paintroid.ui.BottomBar.java
private void delayedAnimateSelectedTool(int startDelay) { ImageButton button = getToolButtonByToolType(mCurrentToolType); int color = ContextCompat.getColor(button.getContext(), R.color.bottom_bar_button_activated); int fadedColor = color & 0x00ffffff; ValueAnimator valueAnimator = ObjectAnimator.ofInt(button, "backgroundColor", color, fadedColor); valueAnimator.setEvaluator(new ArgbEvaluator()); valueAnimator.setInterpolator(new LinearInterpolator()); valueAnimator.setDuration(500);/*w w w .jav a 2s .c o m*/ valueAnimator.setRepeatCount(5); valueAnimator.setRepeatMode(ValueAnimator.REVERSE); valueAnimator.setStartDelay(startDelay); valueAnimator.addListener(new Animator.AnimatorListener() { @Override public void onAnimationStart(Animator animation) { } @Override public void onAnimationEnd(Animator animation) { if (PaintroidApplication.currentTool != null) { setActivatedToolButton(PaintroidApplication.currentTool.getToolType()); } } @Override public void onAnimationCancel(Animator animation) { } @Override public void onAnimationRepeat(Animator animation) { } }); valueAnimator.start(); }
From source file:com.redbooth.demo.MainActivity.java
private void initializeBackgroundTransitions() { final Resources resources = getResources(); final int colorPage1 = ResourcesCompat.getColor(resources, R.color.page1, getTheme()); final int colorPage2 = ResourcesCompat.getColor(resources, R.color.page2, getTheme()); final int colorPage3 = ResourcesCompat.getColor(resources, R.color.page3, getTheme()); final int colorPage4 = ResourcesCompat.getColor(resources, R.color.page4, getTheme()); backgroundAnimator = ValueAnimator.ofObject(new ArgbEvaluator(), colorPage1, colorPage2, colorPage3, colorPage4);/*w w w .ja va 2 s .c o m*/ backgroundAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { coordinatorLayout.setBackgroundColor((int) animation.getAnimatedValue()); } }); }
From source file:com.google.android.apps.forscience.whistlepunk.intro.TutorialActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_tutorial); mPager = (ViewPager) findViewById(R.id.tutorial_pager); mDots = (ViewGroup) findViewById(R.id.dot_holder); Resources res = getResources(); ArrayList<TutorialItem> items = new ArrayList<>(); items.add(new TutorialItem(R.string.tutorial_welcome_header, R.string.tutorial_welcome_body, R.raw.walkthrough_welcome, res.getColor(R.color.tutorial_background_welcome))); items.add(new TutorialItem(R.string.tutorial_setup_header, R.string.tutorial_setup_body, R.raw.walkthrough_setup, res.getColor(R.color.tutorial_background_setup))); items.add(new TutorialItem(R.string.tutorial_observe_record_header, R.string.tutorial_observe_record_body, R.raw.walkthrough_observe_record, res.getColor(R.color.tutorial_background_observe_record))); items.add(new TutorialItem(R.string.tutorial_take_notes_header, R.string.tutorial_take_notes_body, R.raw.walkthrough_take_notes, res.getColor(R.color.tutorial_background_take_notes))); items.add(new EndItem(res)); final TutorialAdapter adapter = new TutorialAdapter(getFragmentManager(), items); mBtnNext = (Button) findViewById(R.id.btn_next); mBtnPrev = (Button) findViewById(R.id.btn_prev); mBtnNext.setOnClickListener(new OnClickListener() { @Override/*ww w.j a va 2s . c o m*/ public void onClick(View v) { advance(); } }); mBtnPrev.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (mPager.getCurrentItem() > 0) { mPager.setCurrentItem(mPager.getCurrentItem() - 1, true); } } }); setupDots(items); // This prevents the video views from touching. mPager.setPageMargin(1); mPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() { private ArgbEvaluator mArgbEvaluator = new ArgbEvaluator(); @Override public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { int color1 = adapter.getTutorialItem(position).backgroundColor; if (position < adapter.getCount() - 1) { int color2 = adapter.getTutorialItem(position + 1).backgroundColor; setStatusBarColorIfPossible((int) mArgbEvaluator.evaluate(positionOffset, color1, color2)); } } @Override public void onPageSelected(int position) { mBtnPrev.setVisibility(position > 0 ? View.VISIBLE : View.INVISIBLE); final int count = mDots.getChildCount(); for (int index = 0; index < count; index++) { mDots.getChildAt(index).setSelected(index == position); } if (adapter.getTutorialItem(position).isEndItem()) { finishTutorial(); } } @Override public void onPageScrollStateChanged(int state) { } }); mPager.setAdapter(adapter); setStatusBarColorIfPossible(res.getColor(R.color.tutorial_background_welcome)); }
From source file:xyz.klinker.android.article.ArticleScrollListener.java
private void animateBackgroundColor(int from, int to, Interpolator interpolator) { final ValueAnimator anim = new ValueAnimator(); anim.setIntValues(from, to);/*from w w w . j a v a 2 s. c om*/ anim.setEvaluator(new ArgbEvaluator()); anim.setInterpolator(interpolator); anim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator valueAnimator) { toolbar.setBackgroundColor((Integer) valueAnimator.getAnimatedValue()); statusBar.setBackgroundColor((Integer) valueAnimator.getAnimatedValue()); } }); anim.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { super.onAnimationEnd(animation); isUpdatingBackground = false; } }); anim.setDuration(ANIMATION_DURATION); anim.start(); isUpdatingBackground = true; }
From source file:arun.com.chromer.browsing.article.util.ArticleScrollListener.java
private void animateBackgroundColor(int from, int to, Interpolator interpolator) { final ValueAnimator anim = new ValueAnimator(); anim.setIntValues(from, to);//from w w w . ja v a2 s . c om anim.setEvaluator(new ArgbEvaluator()); anim.setInterpolator(interpolator); anim.addUpdateListener(valueAnimator -> { toolbar.setBackgroundColor((Integer) valueAnimator.getAnimatedValue()); statusBar.setBackgroundColor((Integer) valueAnimator.getAnimatedValue()); }); anim.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { super.onAnimationEnd(animation); isUpdatingBackground = false; } }); anim.setDuration(ANIMATION_DURATION); anim.start(); isUpdatingBackground = true; }
From source file:com.musenkishi.atelier.Atelier.java
private static void applyColorToView(final TextView textView, int color, boolean fromCache) { if (fromCache) { textView.setTextColor(color);//w w w . j a v a2 s . c om } else { Integer colorFrom = textView.getCurrentTextColor(); Integer colorTo = color; ValueAnimator colorAnimation = ValueAnimator.ofObject(new ArgbEvaluator(), colorFrom, colorTo); colorAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animator) { textView.setTextColor((Integer) animator.getAnimatedValue()); } }); colorAnimation.start(); } }
From source file:com.zoffcc.applications.zanavi.ZANaviMainIntroActivityStatic.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); System.out.println("ZANaviMainIntroActivity:" + "onCreate"); if (Build.VERSION.SDK_INT >= 11) { argbEvaluator = new ArgbEvaluator(); }//w ww. ja va 2 s . co m // Making notification bar transparent if (Build.VERSION.SDK_INT >= 21) { getWindow().getDecorView().setSystemUiVisibility( View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN); } setContentView(R.layout.intro_slide_static); viewPager = (ViewPager) findViewById(R.id.view_pager); dotsLayout = (LinearLayout) findViewById(R.id.layoutDots); btnSkip = (Button) findViewById(R.id.btn_skip); btnNext = (Button) findViewById(R.id.btn_next); btnNext.setText(Navit.get_text("OK")); if (Navit.intro_flag_crash) { System.out.println("flags:" + "intro_flag_crash:true " + "starting crashlog screen"); layouts.add(R.layout.intro_slide_static_00); colors.add(ContextCompat.getColor(this, R.color.zanavi_yellowbrown)); id_.add(ID_CRASH); title_txt.add(""); desc_txt.add(Html.fromHtml(Navit.get_text("ZANavi has recently crashed, please submit the crashlog") + "\n<br>" + "<font color=\"#fe0000\">" + Navit.get_text("Log may contain private and sensitive data!") + "</font>")); icon_res.add(R.drawable.crash_icon); } try { if (EasyPermissions.hasPermissions(ZANaviMainIntroActivityStatic.this, Navit.perms)) { } else { layouts.add(R.layout.intro_slide_static_01); colors.add(ContextCompat.getColor(this, R.color.zanavi_yellowbrown)); id_.add(ID_PERM); title_txt.add(Navit.get_text("Grant Permissions")); desc_txt.add(Html.fromHtml("")); icon_res.add(R.drawable.app_intro_permissions_v1); } } catch (Exception e) { } if (Navit.intro_flag_firststart) { layouts.add(R.layout.intro_slide_static_02); colors.add(ContextCompat.getColor(this, R.color.zanavi_teal)); id_.add(ID_FIRST); title_txt.add(""); desc_txt.add(Html.fromHtml(Navit.get_text("Welcome to ZANavi offline Navigation"))); icon_res.add(R.drawable.icon_large); } if (!Navit.intro_flag_firststart) { if (Navit.intro_flag_update) { layouts.add(R.layout.intro_slide_static_03); colors.add(ContextCompat.getColor(this, R.color.zanavi_teal)); id_.add(ID_UPD); title_txt.add(""); desc_txt.add(Html.fromHtml(Navit.get_text("you have just updated ZANavi"))); icon_res.add(R.drawable.icon_large); // reset flag right now Navit.intro_flag_update = false; } } if (!Navit.intro_flag_firststart) { if (Navit.intro_flag_info) { final String ZANAVI_MSG_PLUGIN_MARKET_LINK = "https://play.google.com/store/apps/details?id=com.zoffcc.applications.zanavi_msg"; final String ZANAVI_MSG_PLUGIN_FD_LINK = "https://static.zanavi.cc/app/zanavi_plugin_latest.apk"; // final String ZANAVI_UDONATE_LINK = "http://more.zanavi.cc/donate/"; final String ZANAVI_HOWTO_DEBUG_LINK = "http://static.zanavi.cc/be-a-testdriver/be-a-testdriver.html"; final String ZANAVI_HOWTO_UDONTATE_FREE_LINK = "http://static.zanavi.cc/activate-udonate/activate-udonate.html"; layouts.add(R.layout.intro_slide_static_04); colors.add(ContextCompat.getColor(this, R.color.zanavi_teal)); title_txt.add(""); if (Navit.FDBL) { desc_txt.add(Html.fromHtml("<small>show " + (Navit.info_popup_seen_count_max - Navit.info_popup_seen_count + 1) + " more times<br>\n<br>\n</small>Help us to improve ZANavi, be a Testdriver and send in your route debug information.<br>\n<a href=\"" + ZANAVI_HOWTO_DEBUG_LINK + "\">HowTo be a Testdriver</a><br>\n<br>\n" + "And get the uDonate Version for free.<br>\n<a href=\"" + ZANAVI_HOWTO_UDONTATE_FREE_LINK + "\">get free uDonate version</a>\n" + "\n<br>\n<br>" + "Install the ZANavi Plugin and always know when updated maps are available.<br>\n<a href=\"" + ZANAVI_MSG_PLUGIN_FD_LINK + "\">download here</a><br>\n")); } else { desc_txt.add(Html.fromHtml("<small>show " + (Navit.info_popup_seen_count_max - Navit.info_popup_seen_count + 1) + " more times<br>\n<br>\n</small>Help us to improve ZANavi, be a Testdriver and send in your route debug information.<br>\n<a href=\"" + ZANAVI_HOWTO_DEBUG_LINK + "\">HowTo be a Testdriver</a><br>\n<br>\n" + "And get the uDonate Version for free.<br>\n<a href=\"" + ZANAVI_HOWTO_UDONTATE_FREE_LINK + "\">get free uDonate version</a>\n" + "\n<br>\n<br>" + "Install the ZANavi Plugin and always know when updated maps are available.<br>\n<a href=\"" + ZANAVI_MSG_PLUGIN_MARKET_LINK + "\">download here</a><br>\n")); } icon_res.add(R.drawable.icon); id_.add(ID_INFO); // reset flag Navit.intro_flag_info = false; } } if (Navit.intro_flag_nomaps) { layouts.add(R.layout.intro_slide_static_05); colors.add(ContextCompat.getColor(this, R.color.zanavi_purple)); title_txt.add(""); desc_txt.add(Html.fromHtml(Navit.get_text("select your storage and download a Map for your Area"))); icon_res.add(R.drawable.app_intro_mapdownload_v1); id_.add(ID_NOMAPS); } if (!Navit.intro_flag_nomaps) { if (Navit.intro_flag_indexmissing) { layouts.add(R.layout.intro_slide_static_06); colors.add(ContextCompat.getColor(this, R.color.zanavi_purple)); title_txt.add(""); desc_txt.add(Html.fromHtml( Navit.get_text("Index missing, please delete your maps and download them again"))); icon_res.add(R.drawable.app_intro_mapdownload_v1); id_.add(ID_INDEX); } } if (layouts.size() == 1) { btnNext.setText(Navit.get_text("OK")); } else { btnNext.setText(Navit.get_text("Next")); } // layouts of all sliders ------------------------------------------ // adding bottom dots addBottomDots(0); // making notification bar transparent changeStatusBarColor(); myViewPagerAdapter = new MyViewPagerAdapter(); viewPager.setAdapter(myViewPagerAdapter); viewPager.addOnPageChangeListener(viewPagerPageChangeListener); btnSkip.setVisibility(View.INVISIBLE); btnSkip.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { System.out.println("ZANaviMainIntroActivity:" + "finish2"); finish(); } }); btnNext.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // checking for last page // if last page home screen will be launched int current = getItem(+1); // System.out.println("current=" + current + " layouts.length=" + layouts.length); if ((current < layouts.size()) && (layouts.size() > 1)) { // move to next screen viewPager.setCurrentItem(current); } else { System.out.println("ZANaviMainIntroActivity:" + "finish3"); finish(); } } }); }
From source file:com.folioreader.view.ConfigView.java
private void toggleBlackTheme() { int day = getResources().getColor(R.color.white); int night = getResources().getColor(R.color.night); int darkNight = getResources().getColor(R.color.dark_night); final int diffNightDark = night - darkNight; ValueAnimator colorAnimation = ValueAnimator.ofObject(new ArgbEvaluator(), mIsNightMode ? night : day, mIsNightMode ? day : night); colorAnimation.setDuration(FADE_DAY_NIGHT_MODE); colorAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override//from ww w. j av a 2 s . c om public void onAnimationUpdate(ValueAnimator animator) { int value = (int) animator.getAnimatedValue(); mContainer.setBackgroundColor(value); if (mConfigViewCallback != null) { mConfigViewCallback.onBackgroundUpdate(value - diffNightDark); } } }); colorAnimation.addListener(new Animator.AnimatorListener() { @Override public void onAnimationStart(Animator animator) { } @Override public void onAnimationEnd(Animator animator) { mIsNightMode = !mIsNightMode; Config.getConfig().setNightMode(mIsNightMode); mConfigViewCallback.onConfigChange(); } @Override public void onAnimationCancel(Animator animator) { } @Override public void onAnimationRepeat(Animator animator) { } }); colorAnimation.setDuration(FADE_DAY_NIGHT_MODE); colorAnimation.start(); }