List of usage examples for android.animation ArgbEvaluator evaluate
public Object evaluate(float fraction, Object startValue, Object endValue)
From source file:com.geecko.QuickLyric.utils.ScreenSlidePagerAdapter.java
@Override public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { View tutorialLayout = mActivity.findViewById(R.id.tutorial_layout); ArgbEvaluator evaluator = new ArgbEvaluator(); Object background = position < getCount() - 1 ? evaluator.evaluate(positionOffset, mActivity.getResources().getColor(colors[position]), mActivity.getResources().getColor(colors[position + 1])) : mActivity.getResources().getColor(colors[position]); tutorialLayout.setBackgroundColor((int) background); ((MainActivity) mActivity).setNavBarColor( (int) evaluator.evaluate(0.5f, mActivity.getResources().getColor(R.color.action_dark), background)); ((MainActivity) mActivity).setStatusBarColor( (int) evaluator.evaluate(0.5f, mActivity.getResources().getColor(R.color.action_dark), background)); }
From source file:pl.kodujdlapolski.na4lapy.ui.introduction.IntroductionActivity.java
private void initPageChangeListener() { final ArgbEvaluator evaluator = new ArgbEvaluator(); viewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() { @Override/*from ww w.j ava 2 s.co m*/ public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { int fromColor = introductionPages.get(position).getBgColor(); int toColor = introductionPages.get(position + 1).getBgColor(); int colorUpdate = (Integer) evaluator.evaluate(positionOffset, fromColor, toColor); introductionContainer.setBackgroundColor(colorUpdate); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { getWindow().setNavigationBarColor(colorUpdate); } } @Override public void onPageSelected(int position) { currentPage = position; updateIndicators(currentPage); if (position == LAST_INTRO) { introductionContainer.setBackgroundColor( ContextCompat.getColor(IntroductionActivity.this, android.R.color.transparent)); nextBtn.setVisibility(View.GONE); finishBtn.setVisibility(View.GONE); skipBtn.setVisibility(View.GONE); onFinish(); } else { boolean lastPage = position == LAST_INTRO - 1; nextBtn.setVisibility(lastPage ? View.GONE : View.VISIBLE); finishBtn.setVisibility(lastPage ? View.VISIBLE : View.GONE); } } @Override public void onPageScrollStateChanged(int state) { } }); }
From source file:com.geecko.QuickLyric.adapter.IntroScreenSlidePagerAdapter.java
@SuppressWarnings({ "deprecation", "ResourceAsColor" }) @Override//from w w w .jav a 2 s . c o m public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { View tutorialLayout = mActivity.findViewById(R.id.tutorial_layout); ArgbEvaluator evaluator = new ArgbEvaluator(); Object background = position < getCount() - 1 ? evaluator.evaluate(positionOffset, mActivity.getResources().getColor(colors[position]), mActivity.getResources().getColor(colors[position + 1])) : mActivity.getResources().getColor(colors[position]); tutorialLayout.setBackgroundColor((int) background); MainActivity.setNavBarColor(mActivity.getWindow(), mActivity.getTheme(), (int) evaluator.evaluate(0.5f, mActivity.getResources().getColor(R.color.action_dark), background)); MainActivity.setStatusBarColor(mActivity.getWindow(), mActivity.getTheme(), (int) evaluator.evaluate(0.5f, mActivity.getResources().getColor(R.color.action_dark), background)); View bigFab = tutorialLayout.findViewById(R.id.big_fab); View handImage = tutorialLayout.findViewById(R.id.musicid_demo_hand_image); View soundImage = tutorialLayout.findViewById(R.id.musicid_demo_sound_image); View redKey = tutorialLayout.findViewById(R.id.intro_4_red_key); View yellowKey = tutorialLayout.findViewById(R.id.intro_4_yellow_key); View gearA = tutorialLayout.findViewById(R.id.redGear); View gearB = tutorialLayout.findViewById(R.id.blueGear); BubblePopImageView tableImageView = (BubblePopImageView) tutorialLayout.findViewById(R.id.table); position = rightToLeft ? getCount() - 1 - position : position; if (rightToLeft && positionOffset > 0.0) { position -= 1; positionOffset = 1f - positionOffset; positionOffsetPixels = (int) (positionOffset * mPager.getWidth()); } switch (position) { case 0: if (tableImageView != null) { tableImageView.setProgress(positionOffset); tableImageView.setTranslationX((rightToLeft ? -1f : 1f) * (1f - positionOffset) * (tableImageView.getMeasuredWidth() / 3f)); } break; case 1: if (tableImageView != null) { tableImageView.setProgress(1f); tableImageView.setTranslationX((rightToLeft ? 0.15f : -0.4f) * positionOffsetPixels); } if (bigFab != null) { bigFab.setTranslationX( (rightToLeft ? -1f : 1f) * (1f - positionOffset) * (bigFab.getMeasuredWidth() / 3f)); if (mCurrentPage == 1 ^ rightToLeft) bigFab.setRotation(positionOffset * 360f); else bigFab.setRotation((1f - positionOffset) * 360f); } break; case 2: if (bigFab != null) ((View) bigFab.getParent()).setTranslationX((!rightToLeft ? -0.4f : 0.4f) * positionOffsetPixels); if (soundImage != null && handImage != null) { soundImage.setTranslationX(300f - 300f * positionOffset); handImage.setTranslationX(-400f + 400f * positionOffset); } break; case 3: if (redKey != null && yellowKey != null) { if (redKey.getMeasuredHeight() < redKey.getResources().getDimensionPixelSize(R.dimen.dp) * 15) { redKey.setVisibility(View.INVISIBLE); yellowKey.setVisibility(View.INVISIBLE); break; } else { redKey.setVisibility(View.VISIBLE); yellowKey.setVisibility(View.VISIBLE); } redKey.setTranslationY(330f * (1 - positionOffset)); yellowKey.setTranslationY(290f * Math.min(1.3f * (1 - positionOffset), 1.0f)); yellowKey.setTranslationX(105f * Math.min(1.3f * (1 - positionOffset), 1.0f)); } if (3 == count - 2 && gearA != null && gearB != null) { gearA.setRotation(-180f * positionOffset); gearB.setRotation(180f * positionOffset); } break; case 4: if (gearA != null && gearB != null) { gearA.setRotation(-180f * positionOffset); gearB.setRotation(180f * positionOffset); } break; } }