use of com.bumptech.glide.RequestManager in project Shuttle by timusus.
the class SuggestedFragment method getRecentlyAddedViewModels.
Observable<List<ViewModel>> getRecentlyAddedViewModels() {
return Playlist.recentlyAddedPlaylist.getSongsObservable().flatMap(songs -> Observable.just(Operators.songsToAlbums(songs))).flatMapSingle(source -> Observable.fromIterable(source).sorted((a, b) -> ComparisonUtils.compareLong(b.songPlayCount, a.songPlayCount)).take(20).toList()).map(albums -> {
if (!albums.isEmpty()) {
List<ViewModel> viewModels = new ArrayList<>();
SuggestedHeader recentlyAddedHeader = new SuggestedHeader(getString(R.string.recentlyadded), getString(R.string.suggested_recently_added_subtitle), Playlist.recentlyAddedPlaylist);
SuggestedHeaderView recentlyAddedHeaderView = new SuggestedHeaderView(recentlyAddedHeader);
recentlyAddedHeaderView.setClickListener(this);
viewModels.add(recentlyAddedHeaderView);
viewModels.addAll(Stream.of(albums).map(album -> {
AlbumView albumView = new AlbumView(album, ViewType.ALBUM_CARD, requestManager);
albumView.setClickListener(this);
return albumView;
}).toList());
return viewModels;
} else {
return Collections.emptyList();
}
});
}
use of com.bumptech.glide.RequestManager in project Shuttle by timusus.
the class BaseDetailFragment method getAlbumViewModels.
@NonNull
@Override
public List<ViewModel> getAlbumViewModels(List<Album> albums) {
if (albums.isEmpty()) {
return Collections.emptyList();
}
List<ViewModel> items = new ArrayList<>();
if (setHorizontalItemsDisposable != null) {
setHorizontalItemsDisposable.dispose();
}
setHorizontalItemsDisposable = horizontalRecyclerView.setItems(Stream.of(albums).map(album -> {
HorizontalAlbumView horizontalAlbumView = new HorizontalAlbumView(album, requestManager);
horizontalAlbumView.setClickListener(BaseDetailFragment.this);
horizontalAlbumView.showYear(true);
return horizontalAlbumView;
}).collect(Collectors.toList()));
items.add(new SubheaderView(StringUtils.makeAlbumsLabel(getContext(), albums.size())));
items.add(horizontalRecyclerView);
return items;
}
use of com.bumptech.glide.RequestManager in project Shuttle by timusus.
the class QueuePagerPresenter method bindView.
@Override
public void bindView(@NonNull QueuePagerView view) {
super.bindView(view);
IntentFilter filter = new IntentFilter();
filter.addAction(MusicService.InternalIntents.META_CHANGED);
filter.addAction(MusicService.InternalIntents.REPEAT_CHANGED);
filter.addAction(MusicService.InternalIntents.SHUFFLE_CHANGED);
filter.addAction(MusicService.InternalIntents.QUEUE_CHANGED);
filter.addAction(MusicService.InternalIntents.SERVICE_CONNECTED);
addDisposable(RxBroadcast.fromBroadcast(ShuttleApplication.getInstance(), filter).startWith(new Intent(MusicService.InternalIntents.QUEUE_CHANGED)).toFlowable(BackpressureStrategy.LATEST).observeOn(AndroidSchedulers.mainThread()).subscribe(intent -> {
final String action = intent.getAction();
QueuePagerView queuePagerView = getView();
if (queuePagerView == null) {
return;
}
if (action != null) {
switch(action) {
case MusicService.InternalIntents.META_CHANGED:
queuePagerView.updateQueuePosition(MusicUtils.getQueuePosition());
break;
case MusicService.InternalIntents.REPEAT_CHANGED:
case MusicService.InternalIntents.SHUFFLE_CHANGED:
case MusicService.InternalIntents.QUEUE_CHANGED:
case MusicService.InternalIntents.SERVICE_CONNECTED:
List<ViewModel> items = Stream.of(MusicUtils.getQueue()).map(song -> new QueuePagerItemView(song, requestManager)).collect(Collectors.toList());
queuePagerView.loadData(items, MusicUtils.getQueuePosition());
break;
}
}
}));
}
use of com.bumptech.glide.RequestManager in project toshi-android-client by toshiapp.
the class ImageUtil method loadNotificationIcon.
public static Bitmap loadNotificationIcon(final Recipient recipient) throws ExecutionException, InterruptedException {
final RequestManager requestManager = Glide.with(BaseApplication.get());
final DrawableTypeRequest typeRequest = recipient.isGroup() ? requestManager.load(recipient.getGroupAvatar().getBytes()) : requestManager.load(recipient.getUserAvatar());
return (Bitmap) typeRequest.asBitmap().transform(new CropCircleTransformation(BaseApplication.get())).into(200, 200).get();
}
use of com.bumptech.glide.RequestManager in project glide by bumptech.
the class RequestManagerRetriever method fragmentGet.
@SuppressWarnings({ "deprecation", "DeprecatedIsStillUsed" })
@Deprecated
@NonNull
private RequestManager fragmentGet(@NonNull Context context, @NonNull android.app.FragmentManager fm, @Nullable android.app.Fragment parentHint, boolean isParentVisible) {
RequestManagerFragment current = getRequestManagerFragment(fm, parentHint, isParentVisible);
RequestManager requestManager = current.getRequestManager();
if (requestManager == null) {
// TODO(b/27524013): Factor out this Glide.get() call.
Glide glide = Glide.get(context);
requestManager = factory.build(glide, current.getGlideLifecycle(), current.getRequestManagerTreeNode(), context);
current.setRequestManager(requestManager);
}
return requestManager;
}
Aggregations