Search in sources :

Example 6 with RequestManager

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();
        }
    });
}
Also used : R(com.simplecity.amp_library.R) GridLayoutManager(android.support.v7.widget.GridLayoutManager) Bundle(android.os.Bundle) ViewModel(com.simplecityapps.recycler_adapter.model.ViewModel) SuggestedDividerDecoration(com.simplecity.amp_library.ui.views.SuggestedDividerDecoration) AndroidSchedulers(io.reactivex.android.schedulers.AndroidSchedulers) Song(com.simplecity.amp_library.model.Song) Optional(com.annimon.stream.Optional) RequestManager(com.bumptech.glide.RequestManager) MenuUtils(com.simplecity.amp_library.utils.MenuUtils) View(android.view.View) LogUtils(com.simplecity.amp_library.utils.LogUtils) Playlist(com.simplecity.amp_library.model.Playlist) PopupMenu(android.support.v7.widget.PopupMenu) ViewGroup(android.view.ViewGroup) SuggestedHeaderView(com.simplecity.amp_library.ui.modelviews.SuggestedHeaderView) MusicUtils(com.simplecity.amp_library.utils.MusicUtils) List(java.util.List) CompositeDisposable(io.reactivex.disposables.CompositeDisposable) Disposable(io.reactivex.disposables.Disposable) FragmentModule(com.simplecity.amp_library.dagger.module.FragmentModule) PermissionUtils(com.simplecity.amp_library.utils.PermissionUtils) Nullable(android.support.annotation.Nullable) Context(android.content.Context) SuggestedSongView(com.simplecity.amp_library.ui.modelviews.SuggestedSongView) Album(com.simplecity.amp_library.model.Album) Stream(com.annimon.stream.Stream) RecyclerListener(com.simplecityapps.recycler_adapter.recyclerview.RecyclerListener) EmptyView(com.simplecity.amp_library.ui.modelviews.EmptyView) ViewModelAdapter(com.simplecityapps.recycler_adapter.adapter.ViewModelAdapter) ViewType(com.simplecity.amp_library.ui.adapters.ViewType) ArrayList(java.util.ArrayList) Inject(javax.inject.Inject) SuppressLint(android.annotation.SuppressLint) SuggestedHeader(com.simplecity.amp_library.model.SuggestedHeader) Toast(android.widget.Toast) Observable(io.reactivex.Observable) UpgradeDialog(com.simplecity.amp_library.ui.dialog.UpgradeDialog) ShuttleUtils(com.simplecity.amp_library.utils.ShuttleUtils) LayoutInflater(android.view.LayoutInflater) AlbumView(com.simplecity.amp_library.ui.modelviews.AlbumView) TimeUnit(java.util.concurrent.TimeUnit) RecyclerView(android.support.v7.widget.RecyclerView) ShuttleApplication(com.simplecity.amp_library.ShuttleApplication) HorizontalRecyclerView(com.simplecity.amp_library.ui.modelviews.HorizontalRecyclerView) PlaylistDetailFragment(com.simplecity.amp_library.ui.detail.PlaylistDetailFragment) ComparisonUtils(com.simplecity.amp_library.utils.ComparisonUtils) DataManager(com.simplecity.amp_library.utils.DataManager) AlbumArtist(com.simplecity.amp_library.model.AlbumArtist) Operators(com.simplecity.amp_library.utils.Operators) Collections(java.util.Collections) SuggestedHeaderView(com.simplecity.amp_library.ui.modelviews.SuggestedHeaderView) AlbumView(com.simplecity.amp_library.ui.modelviews.AlbumView) ArrayList(java.util.ArrayList) ViewModel(com.simplecityapps.recycler_adapter.model.ViewModel) SuggestedHeader(com.simplecity.amp_library.model.SuggestedHeader)

Example 7 with RequestManager

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;
}
Also used : R(com.simplecity.amp_library.R) CompletionListUpdateCallbackAdapter(com.simplecityapps.recycler_adapter.adapter.CompletionListUpdateCallbackAdapter) Bundle(android.os.Bundle) SongView(com.simplecity.amp_library.ui.modelviews.SongView) PlaylistUtils(com.simplecity.amp_library.utils.PlaylistUtils) ImageView(android.widget.ImageView) ViewModel(com.simplecityapps.recycler_adapter.model.ViewModel) Random(java.util.Random) Drawable(android.graphics.drawable.Drawable) AndroidSchedulers(io.reactivex.android.schedulers.AndroidSchedulers) OnClick(butterknife.OnClick) BindView(butterknife.BindView) ColorStateList(android.content.res.ColorStateList) Song(com.simplecity.amp_library.model.Song) Aesthetic(com.afollestad.aesthetic.Aesthetic) Optional(com.annimon.stream.Optional) Priority(com.bumptech.glide.Priority) RequestManager(com.bumptech.glide.RequestManager) HorizontalAlbumView(com.simplecity.amp_library.ui.modelviews.HorizontalAlbumView) MenuUtils(com.simplecity.amp_library.utils.MenuUtils) View(android.view.View) ResourceUtils(com.simplecity.amp_library.utils.ResourceUtils) Schedulers(io.reactivex.schedulers.Schedulers) ViewCompat(android.support.v4.view.ViewCompat) Transition(android.transition.Transition) Unbinder(butterknife.Unbinder) ActionBarUtils(com.simplecity.amp_library.utils.ActionBarUtils) LogUtils(com.simplecity.amp_library.utils.LogUtils) ContextualToolbarHelper(com.simplecity.amp_library.utils.ContextualToolbarHelper) FloatingActionButton(android.support.design.widget.FloatingActionButton) SortManager(com.simplecity.amp_library.utils.SortManager) ObjectAnimator(android.animation.ObjectAnimator) PopupMenu(android.support.v7.widget.PopupMenu) SubMenu(android.view.SubMenu) ArtworkProvider(com.simplecity.amp_library.model.ArtworkProvider) ViewGroup(android.view.ViewGroup) MusicUtils(com.simplecity.amp_library.utils.MusicUtils) List(java.util.List) CompositeDisposable(io.reactivex.disposables.CompositeDisposable) Disposable(io.reactivex.disposables.Disposable) ContextualToolbarHost(com.simplecity.amp_library.ui.views.ContextualToolbarHost) Nullable(android.support.annotation.Nullable) MaterialDialog(com.afollestad.materialdialogs.MaterialDialog) Album(com.simplecity.amp_library.model.Album) TypefaceManager(com.simplecity.amp_library.utils.TypefaceManager) Stream(com.annimon.stream.Stream) ContextualToolbar(com.simplecity.amp_library.ui.views.ContextualToolbar) RecyclerListener(com.simplecityapps.recycler_adapter.recyclerview.RecyclerListener) ButterKnife(butterknife.ButterKnife) EmptyView(com.simplecity.amp_library.ui.modelviews.EmptyView) DrawerLockManager(com.simplecity.amp_library.ui.drawer.DrawerLockManager) TransitionListenerAdapter(com.simplecity.amp_library.ui.fragments.TransitionListenerAdapter) ViewModelAdapter(com.simplecityapps.recycler_adapter.adapter.ViewModelAdapter) NonNull(android.support.annotation.NonNull) StringUtils(com.simplecity.amp_library.utils.StringUtils) SelectableViewModel(com.simplecity.amp_library.ui.modelviews.SelectableViewModel) Single(io.reactivex.Single) MenuItem(android.view.MenuItem) ArrayList(java.util.ArrayList) AnimationUtils(android.view.animation.AnimationUtils) Toast(android.widget.Toast) DiskCacheStrategy(com.bumptech.glide.load.engine.DiskCacheStrategy) AnimatorSet(android.animation.AnimatorSet) Observable(io.reactivex.Observable) UpgradeDialog(com.simplecity.amp_library.ui.dialog.UpgradeDialog) PlaceholderProvider(com.simplecity.amp_library.utils.PlaceholderProvider) ShuttleUtils(com.simplecity.amp_library.utils.ShuttleUtils) Rx.distinctToMainThread(com.afollestad.aesthetic.Rx.distinctToMainThread) SharedElementCallback(android.support.v4.app.SharedElementCallback) AlwaysCrossFade(com.simplecity.amp_library.glide.utils.AlwaysCrossFade) TaggerDialog(com.simplecity.amp_library.tagger.TaggerDialog) Collectors(com.annimon.stream.Collectors) LayoutInflater(android.view.LayoutInflater) SubheaderView(com.simplecity.amp_library.ui.modelviews.SubheaderView) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) AlbumView(com.simplecity.amp_library.ui.modelviews.AlbumView) TimeUnit(java.util.concurrent.TimeUnit) RecyclerView(android.support.v7.widget.RecyclerView) CustomCollapsingToolbarLayout(android.support.design.widget.CustomCollapsingToolbarLayout) Glide(com.bumptech.glide.Glide) HorizontalRecyclerView(com.simplecity.amp_library.ui.modelviews.HorizontalRecyclerView) Toolbar(android.support.v7.widget.Toolbar) Pair(android.support.v4.util.Pair) TransitionInflater(android.transition.TransitionInflater) BaseFragment(com.simplecity.amp_library.ui.fragments.BaseFragment) Operators(com.simplecity.amp_library.utils.Operators) Collections(java.util.Collections) HorizontalAlbumView(com.simplecity.amp_library.ui.modelviews.HorizontalAlbumView) SubheaderView(com.simplecity.amp_library.ui.modelviews.SubheaderView) ArrayList(java.util.ArrayList) ViewModel(com.simplecityapps.recycler_adapter.model.ViewModel) SelectableViewModel(com.simplecity.amp_library.ui.modelviews.SelectableViewModel) NonNull(android.support.annotation.NonNull)

Example 8 with RequestManager

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;
            }
        }
    }));
}
Also used : QueuePagerItemView(com.simplecity.amp_library.ui.modelviews.QueuePagerItemView) BackpressureStrategy(io.reactivex.BackpressureStrategy) Collectors(com.annimon.stream.Collectors) Stream(com.annimon.stream.Stream) QueuePagerView(com.simplecity.amp_library.ui.views.QueuePagerView) IntentFilter(android.content.IntentFilter) Intent(android.content.Intent) ViewModel(com.simplecityapps.recycler_adapter.model.ViewModel) NonNull(android.support.annotation.NonNull) RxBroadcast(com.cantrowitz.rxbroadcast.RxBroadcast) AndroidSchedulers(io.reactivex.android.schedulers.AndroidSchedulers) MusicUtils(com.simplecity.amp_library.utils.MusicUtils) Inject(javax.inject.Inject) ShuttleApplication(com.simplecity.amp_library.ShuttleApplication) List(java.util.List) RequestManager(com.bumptech.glide.RequestManager) MusicService(com.simplecity.amp_library.playback.MusicService) IntentFilter(android.content.IntentFilter) QueuePagerView(com.simplecity.amp_library.ui.views.QueuePagerView) QueuePagerItemView(com.simplecity.amp_library.ui.modelviews.QueuePagerItemView) Intent(android.content.Intent) List(java.util.List)

Example 9 with RequestManager

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();
}
Also used : Bitmap(android.graphics.Bitmap) RequestManager(com.bumptech.glide.RequestManager) CropCircleTransformation(com.toshi.view.custom.CropCircleTransformation) DrawableTypeRequest(com.bumptech.glide.DrawableTypeRequest)

Example 10 with RequestManager

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;
}
Also used : RequestManager(com.bumptech.glide.RequestManager) Glide(com.bumptech.glide.Glide) NonNull(android.support.annotation.NonNull)

Aggregations

RequestManager (com.bumptech.glide.RequestManager)41 Context (android.content.Context)15 View (android.view.View)15 Bundle (android.os.Bundle)14 Glide (com.bumptech.glide.Glide)14 Test (org.junit.Test)14 Stream (com.annimon.stream.Stream)13 MusicUtils (com.simplecity.amp_library.utils.MusicUtils)13 List (java.util.List)13 PopupMenu (android.support.v7.widget.PopupMenu)11 MenuItem (android.view.MenuItem)11 Toast (android.widget.Toast)11 R (com.simplecity.amp_library.R)11 MenuUtils (com.simplecity.amp_library.utils.MenuUtils)11 Intent (android.content.Intent)10 LayoutInflater (android.view.LayoutInflater)10 ViewGroup (android.view.ViewGroup)10 Song (com.simplecity.amp_library.model.Song)10 ViewModel (com.simplecityapps.recycler_adapter.model.ViewModel)10 AndroidSchedulers (io.reactivex.android.schedulers.AndroidSchedulers)10