List of usage examples for android.content.res ColorStateList valueOf
@NonNull public static ColorStateList valueOf(@ColorInt int color)
From source file:supertoast.utils.SuperActivityToast.java
/** * Modify various attributes of the SuperActivityToast before being shown. *//*from w w w. j av a 2s . c om*/ @Override protected void onPrepareShow() { super.onPrepareShow(); // This will take care of many modifications final FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(this.mStyle.width, this.mStyle.height); // Make some type specific tweaks switch (this.mStyle.type) { case Style.TYPE_STANDARD: break; case Style.TYPE_BUTTON: // If NOT Lollipop frame, give padding on each side if (this.mStyle.frame != Style.FRAME_LOLLIPOP) { this.mStyle.width = FrameLayout.LayoutParams.MATCH_PARENT; this.mStyle.xOffset = BackgroundUtils.convertToDIP(24); this.mStyle.yOffset = BackgroundUtils.convertToDIP(24); } // On a big screen device, show the SuperActivityToast on the bottom left if ((this.mContext.getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) >= Configuration.SCREENLAYOUT_SIZE_LARGE) { this.mStyle.width = BackgroundUtils.convertToDIP(568); this.mStyle.gravity = Gravity.BOTTOM | Gravity.START; } // Set up the Button attributes final Button button = (Button) this.mView.findViewById(R.id.button); button.setBackgroundResource(BackgroundUtils.getButtonBackgroundResource(this.mStyle.frame)); button.setText(this.mStyle.buttonText != null ? this.mStyle.buttonText.toUpperCase() : ""); button.setTypeface(button.getTypeface(), this.mStyle.buttonTypefaceStyle); button.setTextColor(this.mStyle.buttonTextColor); button.setTextSize(this.mStyle.buttonTextSize); if (this.mStyle.frame != Style.FRAME_LOLLIPOP) { this.mView.findViewById(R.id.divider).setBackgroundColor(this.mStyle.buttonDividerColor); // Set an icon resource if desired if (this.mStyle.buttonIconResource > 0) { button.setCompoundDrawablesWithIntrinsicBounds( ResourcesCompat.getDrawable(mContext.getResources(), this.mStyle.buttonIconResource, mContext.getTheme()), null, null, null); } } if (this.mOnButtonClickListener != null) { button.setOnClickListener(new View.OnClickListener() { short clicked = 0; @Override public void onClick(View view) { // Prevent button spamming if (clicked > 0) return; clicked++; mOnButtonClickListener.onClick(view, getButtonToken()); SuperActivityToast.this.dismiss(); } }); } break; case Style.TYPE_PROGRESS_CIRCLE: if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { this.mProgressBar.setIndeterminateTintMode(PorterDuff.Mode.SRC_IN); this.mProgressBar.setIndeterminateTintList(ColorStateList.valueOf(this.mStyle.progressBarColor)); } break; case Style.TYPE_PROGRESS_BAR: if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { this.mProgressBar.setIndeterminateTintMode(PorterDuff.Mode.SRC_IN); this.mProgressBar.setIndeterminateTintList(ColorStateList.valueOf(this.mStyle.progressBarColor)); this.mProgressBar.setProgressTintMode(PorterDuff.Mode.SRC_IN); this.mProgressBar.setProgressTintList(ColorStateList.valueOf(this.mStyle.progressBarColor)); } this.mProgressBar.setProgress(this.mStyle.progress); this.mProgressBar.setMax(this.mStyle.progressMax); this.mProgressBar.setIndeterminate(this.mStyle.progressIndeterminate); break; } layoutParams.width = this.mStyle.width; layoutParams.height = this.mStyle.height; layoutParams.gravity = this.mStyle.gravity; layoutParams.bottomMargin = this.mStyle.yOffset; layoutParams.topMargin = this.mStyle.yOffset; layoutParams.leftMargin = this.mStyle.xOffset; layoutParams.rightMargin = this.mStyle.xOffset; this.mView.setLayoutParams(layoutParams); // Set up touch to dismiss if (this.mStyle.touchToDismiss) { mView.setOnTouchListener(new View.OnTouchListener() { int timesTouched; @Override public boolean onTouch(View v, MotionEvent motionEvent) { // Prevent repetitive touch events if (timesTouched == 0 && motionEvent.getAction() == MotionEvent.ACTION_DOWN) dismiss(); timesTouched++; return false; // Do not consume the event in case a Button listener is set } }); } else { // Make sure no listener is set mView.setOnTouchListener(null); } }
From source file:com.github.johnpersano.supertoasts.library.SuperActivityToast.java
/** * Modify various attributes of the SuperActivityToast before being shown. *//*from w ww .j a v a 2 s . c om*/ @Override protected void onPrepareShow() { super.onPrepareShow(); // This will take care of many modifications final FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(this.mStyle.width, this.mStyle.height); // Make some type specific tweaks switch (this.mStyle.type) { case Style.TYPE_STANDARD: break; case Style.TYPE_BUTTON: // If NOT Lollipop frame, give padding on each side if (this.mStyle.frame != Style.FRAME_LOLLIPOP) { this.mStyle.width = FrameLayout.LayoutParams.MATCH_PARENT; this.mStyle.xOffset = BackgroundUtils.convertToDIP(24); this.mStyle.yOffset = BackgroundUtils.convertToDIP(24); } // On a big screen device, show the SuperActivityToast on the bottom left if ((this.mContext.getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) >= Configuration.SCREENLAYOUT_SIZE_LARGE) { this.mStyle.width = BackgroundUtils.convertToDIP(568); this.mStyle.gravity = Gravity.BOTTOM | Gravity.START; } // Set up the Button attributes final Button button = (Button) this.mView.findViewById(R.id.button); button.setBackgroundResource(BackgroundUtils.getButtonBackgroundResource(this.mStyle.frame)); button.setText(this.mStyle.buttonText != null ? this.mStyle.buttonText.toUpperCase() : ""); button.setTypeface(button.getTypeface(), this.mStyle.buttonTypefaceStyle); button.setTextColor(this.mStyle.buttonTextColor); button.setTextSize(this.mStyle.buttonTextSize); if (this.mStyle.frame != Style.FRAME_LOLLIPOP) { this.mView.findViewById(R.id.divider).setBackgroundColor(this.mStyle.buttonDividerColor); // Set an icon resource if desired if (this.mStyle.buttonIconResource > 0) { button.setCompoundDrawablesWithIntrinsicBounds( ResourcesCompat.getDrawable(mContext.getResources(), this.mStyle.buttonIconResource, mContext.getTheme()), null, null, null); } } if (this.mOnButtonClickListener != null) { button.setOnClickListener(new View.OnClickListener() { short clicked = 0; @Override public void onClick(View view) { // Prevent button spamming if (clicked > 0) return; clicked++; mOnButtonClickListener.onClick(view, getButtonToken()); SuperActivityToast.this.dismiss(); } }); } break; case Style.TYPE_PROGRESS_CIRCLE: if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { this.mProgressBar.setIndeterminateTintMode(PorterDuff.Mode.SRC_IN); this.mProgressBar.setIndeterminateTintList(ColorStateList.valueOf(this.mStyle.progressBarColor)); } break; case Style.TYPE_PROGRESS_BAR: if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { this.mProgressBar.setIndeterminateTintMode(PorterDuff.Mode.SRC_IN); this.mProgressBar.setIndeterminateTintList(ColorStateList.valueOf(this.mStyle.progressBarColor)); this.mProgressBar.setProgressTintMode(PorterDuff.Mode.SRC_IN); this.mProgressBar.setProgressTintList(ColorStateList.valueOf(this.mStyle.progressBarColor)); } this.mProgressBar.setProgress(this.mStyle.progress); this.mProgressBar.setMax(this.mStyle.progressMax); this.mProgressBar.setIndeterminate(this.mStyle.progressIndeterminate); break; } layoutParams.width = this.mStyle.width; layoutParams.height = this.mStyle.height; layoutParams.gravity = this.mStyle.gravity; layoutParams.bottomMargin = this.mStyle.yOffset; layoutParams.topMargin = this.mStyle.yOffset; layoutParams.leftMargin = this.mStyle.xOffset; layoutParams.rightMargin = this.mStyle.xOffset; this.mView.setLayoutParams(layoutParams); // Set up touch to dismiss if (this.mStyle.touchToDismiss) { mView.setOnTouchListener(new View.OnTouchListener() { int timesTouched; @Override public boolean onTouch(View v, MotionEvent motionEvent) { // Prevent repetitive touch events if (timesTouched == 0 && motionEvent.getAction() == MotionEvent.ACTION_DOWN) dismiss(); timesTouched++; return false; // Do not consume the event in case a Button listener is set } }); } else { // Make sure no listener is set mView.setOnTouchListener(null); } }
From source file:com.heinrichreimersoftware.materialintro.app.IntroActivity.java
private void updateBackground() { @ColorInt/*from w w w . ja v a 2 s .c o m*/ int background; @ColorInt int backgroundNext; @ColorInt int backgroundDark; @ColorInt int backgroundDarkNext; if (position == getCount()) { background = Color.TRANSPARENT; backgroundNext = Color.TRANSPARENT; backgroundDark = Color.TRANSPARENT; backgroundDarkNext = Color.TRANSPARENT; } else { background = ContextCompat.getColor(IntroActivity.this, getBackground(position)); backgroundNext = ContextCompat.getColor(IntroActivity.this, getBackground(Math.min(position + 1, getCount() - 1))); background = ColorUtils.setAlphaComponent(background, 0xFF); backgroundNext = ColorUtils.setAlphaComponent(backgroundNext, 0xFF); try { backgroundDark = ContextCompat.getColor(IntroActivity.this, getBackgroundDark(position)); } catch (Resources.NotFoundException e) { backgroundDark = ContextCompat.getColor(IntroActivity.this, R.color.mi_status_bar_background); } try { backgroundDarkNext = ContextCompat.getColor(IntroActivity.this, getBackgroundDark(Math.min(position + 1, getCount() - 1))); } catch (Resources.NotFoundException e) { backgroundDarkNext = ContextCompat.getColor(IntroActivity.this, R.color.mi_status_bar_background); } } if (position + positionOffset >= adapter.getCount() - 1) { backgroundNext = ColorUtils.setAlphaComponent(background, 0x00); backgroundDarkNext = ColorUtils.setAlphaComponent(backgroundDark, 0x00); } background = (Integer) evaluator.evaluate(positionOffset, background, backgroundNext); backgroundDark = (Integer) evaluator.evaluate(positionOffset, backgroundDark, backgroundDarkNext); miFrame.setBackgroundColor(background); float[] backgroundDarkHsv = new float[3]; Color.colorToHSV(backgroundDark, backgroundDarkHsv); //Slightly darken the background color a bit for more contrast backgroundDarkHsv[2] *= 0.95; int backgroundDarker = Color.HSVToColor(backgroundDarkHsv); miPagerIndicator.setPageIndicatorColor(backgroundDarker); ViewCompat.setBackgroundTintList(miButtonNext, ColorStateList.valueOf(backgroundDarker)); ViewCompat.setBackgroundTintList(miButtonBack, ColorStateList.valueOf(backgroundDarker)); @ColorInt int backgroundButtonCta = buttonCtaTintMode == BUTTON_CTA_TINT_MODE_TEXT ? ContextCompat.getColor(this, android.R.color.white) : backgroundDarker; ViewCompat.setBackgroundTintList(miButtonCta.getChildAt(0), ColorStateList.valueOf(backgroundButtonCta)); ViewCompat.setBackgroundTintList(miButtonCta.getChildAt(1), ColorStateList.valueOf(backgroundButtonCta)); int iconColor; if (ColorUtils.calculateLuminance(backgroundDark) > 0.4) { //Light background iconColor = ContextCompat.getColor(this, R.color.mi_icon_color_light); } else { //Dark background iconColor = ContextCompat.getColor(this, R.color.mi_icon_color_dark); } miPagerIndicator.setCurrentPageIndicatorColor(iconColor); DrawableCompat.setTint(miButtonNext.getDrawable(), iconColor); DrawableCompat.setTint(miButtonBack.getDrawable(), iconColor); @ColorInt int textColorButtonCta = buttonCtaTintMode == BUTTON_CTA_TINT_MODE_TEXT ? backgroundDarker : iconColor; ((Button) miButtonCta.getChildAt(0)).setTextColor(textColorButtonCta); ((Button) miButtonCta.getChildAt(1)).setTextColor(textColorButtonCta); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { getWindow().setStatusBarColor(backgroundDark); if (position == adapter.getCount()) { getWindow().setNavigationBarColor(Color.TRANSPARENT); } else if (position + positionOffset >= adapter.getCount() - 1) { TypedValue typedValue = new TypedValue(); TypedArray a = obtainStyledAttributes(typedValue.data, new int[] { android.R.attr.navigationBarColor }); int defaultNavigationBarColor = a.getColor(0, Color.BLACK); a.recycle(); int navigationBarColor = (Integer) evaluator.evaluate(positionOffset, defaultNavigationBarColor, Color.TRANSPARENT); getWindow().setNavigationBarColor(navigationBarColor); } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { int systemUiVisibility = getWindow().getDecorView().getSystemUiVisibility(); int flagLightStatusBar = View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR; if (ColorUtils.calculateLuminance(backgroundDark) > 0.4) { //Light background systemUiVisibility |= flagLightStatusBar; } else { //Dark background systemUiVisibility &= ~flagLightStatusBar; } getWindow().getDecorView().setSystemUiVisibility(systemUiVisibility); } } }
From source file:org.gateshipone.odyssey.views.NowPlayingView.java
/** * Called after the layout inflater is finished. * Sets all global view variables to the ones inflatd. *//*from w w w . ja v a 2 s. c o m*/ @Override protected void onFinishInflate() { super.onFinishInflate(); // Get both main views (header and bottom part) mHeaderView = findViewById(R.id.now_playing_headerLayout); mMainView = findViewById(R.id.now_playing_bodyLayout); // header buttons mTopPlayPauseButton = (ImageButton) findViewById(R.id.now_playing_topPlayPauseButton); mTopPlaylistButton = (ImageButton) findViewById(R.id.now_playing_topPlaylistButton); ImageButton topMenuButton = (ImageButton) findViewById(R.id.now_playing_topMenuButton); // bottom buttons mBottomRepeatButton = (ImageButton) findViewById(R.id.now_playing_bottomRepeatButton); mBottomPlayPauseButton = (ImageButton) findViewById(R.id.now_playing_bottomPlayPauseButton); mBottomRandomButton = (ImageButton) findViewById(R.id.now_playing_bottomRandomButton); ImageButton bottomPreviousButton = (ImageButton) findViewById(R.id.now_playing_bottomPreviousButton); ImageButton bottomNextButton = (ImageButton) findViewById(R.id.now_playing_bottomNextButton); // Main cover image mCoverImage = (ImageView) findViewById(R.id.now_playing_cover); // Small header cover image mTopCoverImage = (ImageView) findViewById(R.id.now_playing_topCover); // View with the ListView of the playlist mPlaylistView = (CurrentPlaylistView) findViewById(R.id.now_playing_playlist); // view switcher for cover and playlist view mViewSwitcher = (ViewSwitcher) findViewById(R.id.now_playing_view_switcher); // Button container for the buttons shown if dragged up mDraggedUpButtons = (LinearLayout) findViewById(R.id.now_playing_layout_dragged_up); // Button container for the buttons shown if dragged down mDraggedDownButtons = (LinearLayout) findViewById(R.id.now_playing_layout_dragged_down); // textviews mTrackTitle = (TextView) findViewById(R.id.now_playing_track_title); // For marquee scrolling the TextView need selected == true mTrackTitle.setSelected(true); mTrackSubtitle = (TextView) findViewById(R.id.now_playing_track_subtitle); // For marquee scrolling the TextView need selected == true mTrackSubtitle.setSelected(true); // Textviews directly under the seekbar mElapsedTime = (TextView) findViewById(R.id.now_playing_elapsedTime); mDuration = (TextView) findViewById(R.id.now_playing_duration); mHeaderTextLayout = (LinearLayout) findViewById(R.id.now_playing_header_textLayout); // seekbar (position) mPositionSeekbar = (SeekBar) findViewById(R.id.now_playing_seekBar); mPositionSeekbar.setOnSeekBarChangeListener(this); // set dragging part default to bottom mDragOffset = 1.0f; mDraggedUpButtons.setVisibility(INVISIBLE); mDraggedDownButtons.setVisibility(VISIBLE); mDraggedUpButtons.setAlpha(0.0f); // add listener to top playpause button mTopPlayPauseButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { try { mServiceConnection.getPBS().togglePause(); } catch (RemoteException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }); // Add listeners to top playlist button mTopPlaylistButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // get color for playlist button int color; if (mViewSwitcher.getCurrentView() != mPlaylistView) { color = ThemeUtils.getThemeColor(getContext(), R.attr.colorAccent); } else { color = ThemeUtils.getThemeColor(getContext(), R.attr.odyssey_color_text_accent); } // tint the button mTopPlaylistButton.setImageTintList(ColorStateList.valueOf(color)); // toggle between cover and playlistview mViewSwitcher.showNext(); // report the change of the view if (mDragStatusReceiver != null) { // set view status if (mViewSwitcher.getCurrentView() == mCoverImage) { // cover image is shown mDragStatusReceiver .onSwitchedViews(NowPlayingDragStatusReceiver.VIEW_SWITCHER_STATUS.COVER_VIEW); } else { // playlist view is shown mDragStatusReceiver .onSwitchedViews(NowPlayingDragStatusReceiver.VIEW_SWITCHER_STATUS.PLAYLIST_VIEW); } } } }); // Add listener to top menu button topMenuButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { showAdditionalOptionsMenu(v); } }); // Add listener to bottom repeat button mBottomRepeatButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { try { mServiceConnection.getPBS().toggleRepeat(); } catch (RemoteException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }); // Add listener to bottom previous button bottomPreviousButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { try { mServiceConnection.getPBS().previous(); } catch (RemoteException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }); // Add listener to bottom playpause button mBottomPlayPauseButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { try { mServiceConnection.getPBS().togglePause(); } catch (RemoteException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }); // Add listener to bottom next button bottomNextButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { try { mServiceConnection.getPBS().next(); } catch (RemoteException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }); // Add listener to bottom random button mBottomRandomButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { try { mServiceConnection.getPBS().toggleRandom(); } catch (RemoteException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }); mCoverLoader = new CoverBitmapLoader(getContext(), new CoverReceiverClass()); invalidate(); }
From source file:com.rks.musicx.ui.activities.MainActivity.java
private void colorMode(int color) { playToggle.setBackgroundTintList(ColorStateList.valueOf(color)); songProgress.setProgressColor(color); songProgress.setDefaultProgressBackgroundColor(Color.TRANSPARENT); }
From source file:am.widget.indicatortabstrip.IndicatorTabStrip.java
/** * * * @param color */ public void setTextColor(@ColorInt int color) { setTextColor(ColorStateList.valueOf(color)); }
From source file:android.support.design.widget.CollapsingToolbarLayout.java
/** * Sets the text color of the collapsed title. * * @param color The new text color in ARGB format *///from w ww . j av a 2s .c o m public void setCollapsedTitleTextColor(@ColorInt int color) { setCollapsedTitleTextColor(ColorStateList.valueOf(color)); }
From source file:android.support.design.widget.CollapsingToolbarLayout.java
/** * Sets the text color of the expanded title. * * @param color The new text color in ARGB format *///from ww w.ja v a 2s . c o m public void setExpandedTitleColor(@ColorInt int color) { setExpandedTitleTextColor(ColorStateList.valueOf(color)); }
From source file:com.example.mego.adas.main.CarFragment.java
/** * method to get the data from the firebase and take action based on it *///from ww w .j a v a2 s . com private void actionResolver() { startStateEventListener = new ValueEventListener() { @Override public void onDataChange(DataSnapshot dataSnapshot) { if (dataSnapshot.exists()) { startState = (long) dataSnapshot.getValue(); if (startState == 1) { sendBluetoothCommand("p"); if (carFragments.isAdded()) { //change the button color to the accent color when it's on startButton.setBackgroundTintList( ColorStateList.valueOf(getResources().getColor(R.color.off))); } } else if (startState == 0) { sendBluetoothCommand("t"); if (carFragments.isAdded()) { //change the button color to the accent color when it's on startButton.setBackgroundTintList( ColorStateList.valueOf(getResources().getColor(R.color.colorPrimary))); } } } } @Override public void onCancelled(DatabaseError databaseError) { } }; lockStateEventListener = new ValueEventListener() { @Override public void onDataChange(DataSnapshot dataSnapshot) { if (dataSnapshot.exists()) { lockState = (long) dataSnapshot.getValue(); if (lockState == 1) { sendBluetoothCommand("r"); if (carFragments.isAdded()) { //change the button color to the accent color when it's on lockButton.setBackgroundTintList( ColorStateList.valueOf(getResources().getColor(R.color.off))); } } else if (lockState == 0) { sendBluetoothCommand("v"); if (carFragments.isAdded()) { //change the button color to the accent color when it's on lockButton.setBackgroundTintList( ColorStateList.valueOf(getResources().getColor(R.color.colorPrimary))); } } } } @Override public void onCancelled(DatabaseError databaseError) { } }; lightsStateEventListener = new ValueEventListener() { @Override public void onDataChange(DataSnapshot dataSnapshot) { if (dataSnapshot.exists()) { lightsState = (long) dataSnapshot.getValue(); if (lightsState == 1) { if (connected) { sendBluetoothCommand("o"); } //change the button color to the accent color when it's on if (carFragments.isAdded()) { lightsButton.setBackgroundTintList( ColorStateList.valueOf(getResources().getColor(R.color.off))); } } else if (lightsState == 0) { if (connected) { sendBluetoothCommand("f"); } if (carFragments.isAdded()) { //change the button color to the accent color when it's on lightsButton.setBackgroundTintList( ColorStateList.valueOf(getResources().getColor(R.color.colorPrimary))); } } } } @Override public void onCancelled(DatabaseError databaseError) { } }; //add a listener to the reference startStateStateDatabaseReference.addValueEventListener(startStateEventListener); lockStateDatabaseReference.addValueEventListener(lockStateEventListener); lightsStateDatabaseReference.addValueEventListener(lightsStateEventListener); }
From source file:com.github.chenxiaolong.dualbootpatcher.switcher.RomDetailActivity.java
private void onCachedWallpaper(CacheWallpaperResult result) { File wallpaperFile = new File(mRomInfo.getWallpaperPath()); RequestCreator creator;/* w w w. j a v a 2 s. co m*/ if (result == CacheWallpaperResult.USES_LIVE_WALLPAPER) { Toast.makeText(this, "Cannot preview live wallpaper", Toast.LENGTH_SHORT).show(); } if (result == CacheWallpaperResult.UP_TO_DATE || result == CacheWallpaperResult.UPDATED) { creator = Picasso.with(this).load(wallpaperFile).error(R.drawable.material); } else { creator = Picasso.with(this).load(R.drawable.material); } creator.transform(PaletteGeneratorTransformation.getInstance()).into(mWallpaper, new PaletteGeneratorCallback(mWallpaper) { @Override public void onObtainedPalette(Palette palette) { if (palette == null) { return; } Swatch swatch = palette.getMutedSwatch(); if (swatch == null) { swatch = palette.getDarkVibrantSwatch(); } if (swatch != null) { // Status bar should be slightly darker float[] hsl = swatch.getHsl(); hsl[2] -= 0.05; if (hsl[2] < 0) { hsl[2] = 0; } mCollapsing.setContentScrimColor(swatch.getRgb()); mCollapsing.setStatusBarScrimColor(ColorUtils.HSLToColor(hsl)); mFab.setBackgroundTintList(ColorStateList.valueOf(swatch.getRgb())); } //Swatch lightVibrant = palette.getLightVibrantSwatch(); //if (lightVibrant != null) { // collapsingToolbar.setCollapsedTitleTextColor(lightVibrant.getRgb()); // collapsingToolbar.setExpandedTitleColor(lightVibrant.getRgb()); //} } }); }