use of com.jp.wasabeef.glide.transformations.BlurTransformation in project Shuttle by timusus.
the class PlayerActivity method updateTrackInfo.
public void updateTrackInfo() {
String totalTime = StringUtils.makeTimeString(this, MusicUtils.getDuration() / 1000);
String trackName = MusicUtils.getSongName();
String albumName = MusicUtils.getAlbumName();
String artistName = MusicUtils.getAlbumArtistName();
String currentQueuePos = String.valueOf(MusicUtils.getQueuePosition() + 1);
String queueLength = String.valueOf(MusicUtils.getQueue().size());
if (totalTime != null && totalTime.length() != 0) {
mTotalTime.setText(" / " + totalTime);
}
if (trackName != null && trackName.length() != 0) {
mTrack.setText(trackName);
mTrack.setSelected(true);
}
if (albumName != null && artistName != null && albumName.length() != 0 && artistName.length() != 0) {
if (mArtist == null) {
mAlbum.setText(artistName + " - " + albumName);
} else {
mAlbum.setText(albumName);
mArtist.setText(artistName);
}
}
mQueuePosition.setText(currentQueuePos + " / " + queueLength);
queueNextRefresh(1);
supportInvalidateOptionsMenu();
Fragment fragment = getSupportFragmentManager().findFragmentById(R.id.main_container);
if (fragment != null && fragment instanceof LyricsFragment) {
((LyricsFragment) fragment).updateLyrics();
}
Glide.with(this).load(MusicUtils.getAlbumArtist()).diskCacheStrategy(DiskCacheStrategy.ALL).bitmapTransform(new BlurTransformation(this)).override(500, 500).into(mBackgroundImage);
}
use of com.jp.wasabeef.glide.transformations.BlurTransformation in project Shuttle by timusus.
the class PlayerFragment method trackInfoChanged.
@Override
public void trackInfoChanged(@Nullable Song song) {
if (song == null)
return;
if (isExpanded && !snowfallView.isSnowing()) {
snowfallView.letItSnow();
} else {
snowfallView.removeSnow();
}
String totalTimeString = StringUtils.makeTimeString(this.getActivity(), song.duration / 1000);
if (!TextUtils.isEmpty(totalTimeString)) {
if (totalTime != null) {
totalTime.setText(totalTimeString);
}
}
if (track != null) {
track.setText(song.name);
track.setSelected(true);
}
if (album != null) {
album.setText(String.format("%s | %s", song.artistName, song.albumName));
}
if (isLandscape) {
toolbar.setTitle(song.name);
toolbar.setSubtitle(String.format("%s | %s", song.artistName, song.albumName));
target = Glide.with(this).load(song).diskCacheStrategy(DiskCacheStrategy.SOURCE).bitmapTransform(new BlurTransformation(getContext(), 15, 4)).error(PlaceholderProvider.getInstance().getPlaceHolderDrawable(song.name, true)).thumbnail(Glide.with(this).load(this.song).bitmapTransform(new BlurTransformation(getContext(), 15, 4))).crossFade(600).into(backgroundView);
this.song = song;
} else {
backgroundView.setImageDrawable(null);
toolbar.setTitle(null);
toolbar.setSubtitle(null);
}
if (SettingsManager.getInstance().getUsePalette()) {
// noinspection unchecked
Glide.with(this).load(song).asBitmap().transcode(new PaletteBitmapTranscoder(getContext()), PaletteBitmap.class).override(250, 250).diskCacheStrategy(DiskCacheStrategy.ALL).into(new SimpleTarget<PaletteBitmap>() {
@Override
public void onResourceReady(PaletteBitmap resource, GlideAnimation<? super PaletteBitmap> glideAnimation) {
if (!isAdded() || getContext() == null) {
return;
}
Palette.Swatch swatch = resource.palette.getDarkMutedSwatch();
if (swatch != null) {
if (SettingsManager.getInstance().getUsePalette()) {
if (SettingsManager.getInstance().getUsePaletteNowPlayingOnly()) {
animateColors(currentColor, swatch.getRgb(), color -> invalidateColors(color));
} else {
// Set Aesthetic colors globally, based on the current Palette swatch
disposables.add(Aesthetic.get(getContext()).colorPrimary().take(1).subscribe(integer -> animateColors(integer, swatch.getRgb(), color -> {
if (getContext() != null && isAdded()) {
Aesthetic aesthetic = Aesthetic.get(getContext()).colorPrimary(color).colorStatusBarAuto();
if (SettingsManager.getInstance().getTintNavBar()) {
aesthetic = aesthetic.colorNavigationBar(color);
}
aesthetic.apply();
}
})));
}
}
} else {
// Failed to generate the dark muted swatch, fall back to the primary theme colour.
Aesthetic.get(getContext()).colorPrimary().take(1).subscribe(primaryColor -> animateColors(currentColor, primaryColor, color -> invalidateColors(color)));
}
}
@Override
public void onLoadFailed(Exception e, Drawable errorDrawable) {
super.onLoadFailed(e, errorDrawable);
Aesthetic.get(getContext()).colorPrimary().take(1).subscribe(primaryColor -> animateColors(currentColor, primaryColor, color -> invalidateColors(color)));
}
});
}
}
use of com.jp.wasabeef.glide.transformations.BlurTransformation in project Shuttle by timusus.
the class PlayerActivity method onCreate.
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
@Override
public void onCreate(Bundle savedInstanceState) {
ThemeUtils.setTheme(this);
if (!ShuttleUtils.hasLollipop() && ShuttleUtils.hasKitKat()) {
getWindow().setFlags(FLAG_TRANSLUCENT_STATUS, FLAG_TRANSLUCENT_STATUS);
}
if (ShuttleUtils.hasLollipop()) {
if (!ShuttleUtils.hasKitKat()) {
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
} else {
getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
getWindow().setStatusBarColor(Color.TRANSPARENT);
}
}
if (SettingsManager.getInstance().canTintNavBar()) {
getWindow().setNavigationBarColor(ColorUtils.getPrimaryColorDark(this));
}
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_player);
mToolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(mToolbar);
getSupportActionBar().setTitle(null);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
ThemeUtils.themeActionBar(this);
ThemeUtils.themeStatusBar(this, null);
if (!ShuttleUtils.isTablet() && ShuttleUtils.isLandscape()) {
getSupportActionBar().setBackgroundDrawable(new ColorDrawable(ColorUtils.getPrimaryColor()));
} else {
getSupportActionBar().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.parseColor("#20000000")));
}
mTimeHandler = new TimeHandler(this);
mTrack = (TextView) findViewById(R.id.text1);
mAlbum = (TextView) findViewById(R.id.text2);
mArtist = (TextView) findViewById(R.id.text3);
mCurrentTime = (TextView) findViewById(R.id.current_time);
mTotalTime = (TextView) findViewById(R.id.total_time);
mQueuePosition = (TextView) findViewById(R.id.queue_position);
mQueuePosition = (TextView) findViewById(R.id.queue_position);
mPauseButton = (ImageButton) findViewById(R.id.play);
mPauseButton.setOnClickListener(this);
mNextButton = (RepeatingImageButton) findViewById(R.id.next);
mNextButton.setOnClickListener(this);
mNextButton.setRepeatListener(mFastForwardListener);
mPrevButton = (RepeatingImageButton) findViewById(R.id.prev);
mPrevButton.setOnClickListener(this);
mPrevButton.setRepeatListener(mRewindListener);
mRepeatButton = (ImageButton) findViewById(R.id.repeat);
mRepeatButton.setOnClickListener(this);
mShuffleButton = (ImageButton) findViewById(R.id.shuffle);
mShuffleButton.setOnClickListener(this);
mTextViewContainer = findViewById(R.id.textContainer);
mButtonContainer = findViewById(R.id.button_container);
mSeekBar = (SizableSeekBar) findViewById(R.id.seekbar);
mSeekBar.setMax(1000);
mSeekBar.setOnSeekBarChangeListener(this);
mBackgroundImage = (ImageView) findViewById(R.id.background);
themeUIComponents();
if (savedInstanceState == null) {
FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
ft.setCustomAnimations(R.anim.abc_fade_in, R.anim.abc_fade_out);
ft.replace(R.id.main_container, new QueuePagerFragment(), QUEUE_PAGER_FRAGMENT);
if (ShuttleUtils.isTablet()) {
ft.replace(R.id.queue_container, QueueFragment.newInstance(), QUEUE_FRAGMENT);
}
ft.commit();
}
Glide.with(this).load(MusicUtils.getAlbumArtist()).diskCacheStrategy(DiskCacheStrategy.ALL).bitmapTransform(new BlurTransformation(this)).override(500, 500).into(mBackgroundImage);
}
Aggregations