use of android.support.v7.graphics.Palette in project PhotoNoter by yydcdut.
the class Utils method getPaletteColor.
public static int getPaletteColor(Bitmap bitmap) {
Palette.Builder builder = Palette.from(bitmap);
Palette palette = builder.generate();
Palette.Swatch vibrantSwatch = palette.getVibrantSwatch();
if (vibrantSwatch == null) {
Palette.Swatch lightVibrant = palette.getLightVibrantSwatch();
if (lightVibrant == null) {
Palette.Swatch darkVibrant = palette.getDarkVibrantSwatch();
if (darkVibrant == null) {
Palette.Swatch mutedSwatch = palette.getMutedSwatch();
if (mutedSwatch == null) {
Palette.Swatch lightMuted = palette.getMutedSwatch();
if (lightMuted == null) {
Palette.Swatch darkMuted = palette.getDarkMutedSwatch();
if (darkMuted == null) {
return Color.WHITE;
} else {
return darkMuted.getRgb();
}
} else {
return lightMuted.getRgb();
}
} else {
return mutedSwatch.getRgb();
}
} else {
return darkVibrant.getRgb();
}
} else {
return lightVibrant.getRgb();
}
} else {
return vibrantSwatch.getRgb();
}
}
use of android.support.v7.graphics.Palette in project apps-android-wikipedia by wikimedia.
the class FacePostprocessor method process.
@Override
public void process(Bitmap destBitmap, Bitmap sourceBitmap) {
if (listener.get() == null) {
return;
}
if (isBitmapEligibleForImageProcessing(sourceBitmap)) {
copyWithWhiteBackground(destBitmap, sourceBitmap);
Bitmap testBmp = new565ScaledBitmap(sourceBitmap);
Palette colorPalette = Palette.from(testBmp).generate();
PointF facePos = null;
try {
facePos = detectFace(testBmp);
} catch (OutOfMemoryError e) {
L.logRemoteErrorIfProd(e);
}
int defaultColor = ContextCompat.getColor(WikipediaApp.getInstance(), R.color.base30);
listener.get().onImageLoaded(destBitmap.getHeight(), facePos, extractMainColor(colorPalette, defaultColor));
} else {
listener.get().onImageFailed();
}
}
use of android.support.v7.graphics.Palette in project TicktockMusic by Lauzy.
the class TickNotification method buildNotification.
private Notification buildNotification(MusicService musicService) {
PendingIntent playIntent = createAction(musicService, MusicService.ACTION_PLAY);
PendingIntent pauseIntent = createAction(musicService, MusicService.ACTION_PAUSE);
PendingIntent previousIntent = createAction(musicService, MusicService.ACTION_LAST);
PendingIntent nextIntent = createAction(musicService, MusicService.ACTION_NEXT);
PendingIntent contentIntent = PendingIntent.getActivity(musicService, 0, new Intent(musicService, MainActivity.class), PendingIntent.FLAG_UPDATE_CURRENT);
boolean isPlaying = musicService.getPlaybackState().getState() == PlaybackState.STATE_PLAYING;
MediaSession session = musicService.getMediaSession();
MediaController controller = session.getController();
if (controller.getMetadata() != null) {
MediaDescription description = controller.getMetadata().getDescription();
NotificationCompat.Builder builder = new NotificationCompat.Builder(musicService);
builder.setContentTitle(description.getTitle()).setSmallIcon(R.drawable.ic_notification).setShowWhen(false).setOngoing(isPlaying).setContentIntent(contentIntent).setLargeIcon(description.getIconBitmap()).setContentTitle(description.getTitle()).setContentText(description.getSubtitle()).addAction(R.drawable.ic_skip_previous_notify, "", previousIntent).addAction(isPlaying ? R.drawable.ic_pause : R.drawable.ic_play, "", isPlaying ? pauseIntent : playIntent).addAction(R.drawable.ic_skip_next_notify, "", nextIntent).setVisibility(NotificationCompat.VISIBILITY_PUBLIC).setStyle(new NotificationCompat.MediaStyle().setShowActionsInCompactView(0, 1, 2));
if (description.getIconBitmap() != null) {
Palette palette = Palette.from(description.getIconBitmap()).generate();
int color = palette.getDominantColor(ThemeHelper.getThemeColorResId(musicService.getApplicationContext()));
builder.setColor(color);
}
return builder.build();
}
return null;
}
use of android.support.v7.graphics.Palette in project MusicLake by caiyonglong.
the class PlayControlsPresenter method updateNowPlayingCard.
@Override
public void updateNowPlayingCard() {
Log.d(TAG, "updateNowPlayingCard" + mProgress);
Music music = PlayManager.getPlayingMusic();
if (music == null || PlayManager.getPlayList().size() == 0) {
Bitmap bitmap = BitmapFactory.decodeResource(mContext.getResources(), R.drawable.default_cover);
mView.setAlbumArt(bitmap);
mView.setTitle(mContext.getResources().getString(R.string.app_name));
mView.setArtist("");
mView.updatePanelLayout(false);
return;
} else {
mView.updatePanelLayout(true);
}
final String title = PlayManager.getSongName();
final String artist = PlayManager.getSongArtist();
if (TextUtils.isEmpty(title) && TextUtils.isEmpty(artist)) {
mView.setTitle(mContext.getResources().getString(R.string.app_name));
mView.setArtist("");
} else {
mView.setTitle(title);
mView.setArtist(artist);
}
String picUrl = CoverLoader.getInstance().getCoverUriByMusic(music);
// 设置音乐来源
mView.setOtherInfo(music.getTypeName(false));
// 获取当前歌曲状态
AppRepository.getMusicInfo(mContext, music).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(music1 -> mView.updateFavorite(music1.isLove()));
if (!isPlayPauseClick && !activity.isFinishing()) {
loadLyric();
GlideApp.with(mContext).asBitmap().load(picUrl != null ? picUrl : CoverLoader.getInstance().getCoverUriByRandom()).error(CoverLoader.getInstance().getCoverUriByRandom()).diskCacheStrategy(DiskCacheStrategy.ALL).into(new SimpleTarget<Bitmap>() {
@Override
public void onResourceReady(Bitmap resource, Transition<? super Bitmap> transition) {
mView.setAlbumArt(resource);
mView.setAlbumArt(ImageUtils.createBlurredImageFromBitmap(resource, mContext, 12));
new Palette.Builder(resource).generate(palette -> mView.setPalette(palette));
}
});
}
isPlayPauseClick = false;
mHandler.post(updateProgress);
}
Aggregations