Search in sources :

Example 1 with NavDrawerData

use of de.danoeh.antennapod.core.storage.NavDrawerData in project AntennaPod by AntennaPod.

the class SubscriptionFragment method loadSubscriptions.

private void loadSubscriptions() {
    if (disposable != null) {
        disposable.dispose();
    }
    emptyView.hide();
    disposable = Observable.fromCallable(() -> {
        NavDrawerData data = DBReader.getNavDrawerData();
        List<NavDrawerData.DrawerItem> items = data.items;
        for (NavDrawerData.DrawerItem item : items) {
            if (item.type == NavDrawerData.DrawerItem.Type.TAG && item.getTitle().equals(displayedFolder)) {
                return ((NavDrawerData.TagDrawerItem) item).children;
            }
        }
        return items;
    }).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(result -> {
        if (listItems != null && listItems.size() > result.size()) {
            // We have fewer items. This can result in items being selected that are no longer visible.
            subscriptionAdapter.endSelectMode();
        }
        listItems = result;
        subscriptionAdapter.setItems(result);
        subscriptionAdapter.notifyDataSetChanged();
        emptyView.updateVisibility();
        // Keep hidden to avoid flickering while refreshing
        progressBar.setVisibility(View.GONE);
    }, error -> {
        Log.e(TAG, Log.getStackTraceString(error));
        progressBar.setVisibility(View.GONE);
    });
    if (UserPreferences.getSubscriptionsFilter().isEnabled()) {
        feedsFilteredMsg.setText("{md-info-outline} " + getString(R.string.subscriptions_are_filtered));
        Iconify.addIcons(feedsFilteredMsg);
        feedsFilteredMsg.setVisibility(View.VISIBLE);
    } else {
        feedsFilteredMsg.setVisibility(View.GONE);
    }
}
Also used : RemoveFeedDialog(de.danoeh.antennapod.dialog.RemoveFeedDialog) SpeedDialView(com.leinardi.android.speeddial.SpeedDialView) Bundle(android.os.Bundle) ProgressBar(android.widget.ProgressBar) NonNull(androidx.annotation.NonNull) FeedListUpdateEvent(de.danoeh.antennapod.event.FeedListUpdateEvent) AndroidSchedulers(io.reactivex.android.schedulers.AndroidSchedulers) UserPreferences(de.danoeh.antennapod.core.preferences.UserPreferences) SubscriptionsRecyclerAdapter(de.danoeh.antennapod.adapter.SubscriptionsRecyclerAdapter) Locale(java.util.Locale) Handler(android.os.Handler) Looper(android.os.Looper) FloatingActionButton(com.google.android.material.floatingactionbutton.FloatingActionButton) Fragment(androidx.fragment.app.Fragment) View(android.view.View) Schedulers(io.reactivex.schedulers.Schedulers) RecyclerView(androidx.recyclerview.widget.RecyclerView) RenameItemDialog(de.danoeh.antennapod.dialog.RenameItemDialog) Log(android.util.Log) EmptyViewHandler(de.danoeh.antennapod.view.EmptyViewHandler) ThreadMode(org.greenrobot.eventbus.ThreadMode) FeedMultiSelectActionHandler(de.danoeh.antennapod.fragment.actions.FeedMultiSelectActionHandler) ViewGroup(android.view.ViewGroup) StringRes(androidx.annotation.StringRes) List(java.util.List) MainActivity(de.danoeh.antennapod.activity.MainActivity) Disposable(io.reactivex.disposables.Disposable) TextView(android.widget.TextView) DownloadEvent(de.danoeh.antennapod.core.event.DownloadEvent) Toolbar(androidx.appcompat.widget.Toolbar) UnreadItemsUpdateEvent(de.danoeh.antennapod.event.UnreadItemsUpdateEvent) Context(android.content.Context) GridLayoutManager(androidx.recyclerview.widget.GridLayoutManager) AutoUpdateManager(de.danoeh.antennapod.core.util.download.AutoUpdateManager) ConfirmationDialog(de.danoeh.antennapod.core.dialog.ConfirmationDialog) Callable(java.util.concurrent.Callable) MenuItem(android.view.MenuItem) ArrayList(java.util.ArrayList) SubscriptionsFilterDialog(de.danoeh.antennapod.dialog.SubscriptionsFilterDialog) SuppressLint(android.annotation.SuppressLint) EventBus(org.greenrobot.eventbus.EventBus) Observable(io.reactivex.Observable) TagSettingsDialog(de.danoeh.antennapod.dialog.TagSettingsDialog) Feed(de.danoeh.antennapod.model.feed.Feed) DialogInterface(android.content.DialogInterface) NavDrawerData(de.danoeh.antennapod.core.storage.NavDrawerData) FeedSortDialog(de.danoeh.antennapod.dialog.FeedSortDialog) LayoutInflater(android.view.LayoutInflater) SwipeRefreshLayout(androidx.swiperefreshlayout.widget.SwipeRefreshLayout) R(de.danoeh.antennapod.R) MenuItemUtils(de.danoeh.antennapod.core.menuhandler.MenuItemUtils) Subscribe(org.greenrobot.eventbus.Subscribe) SharedPreferences(android.content.SharedPreferences) DBWriter(de.danoeh.antennapod.core.storage.DBWriter) Iconify(com.joanzapata.iconify.Iconify) DBReader(de.danoeh.antennapod.core.storage.DBReader) Collections(java.util.Collections) DownloadService(de.danoeh.antennapod.core.service.download.DownloadService) NavDrawerData(de.danoeh.antennapod.core.storage.NavDrawerData)

Aggregations

SuppressLint (android.annotation.SuppressLint)1 Context (android.content.Context)1 DialogInterface (android.content.DialogInterface)1 SharedPreferences (android.content.SharedPreferences)1 Bundle (android.os.Bundle)1 Handler (android.os.Handler)1 Looper (android.os.Looper)1 Log (android.util.Log)1 LayoutInflater (android.view.LayoutInflater)1 MenuItem (android.view.MenuItem)1 View (android.view.View)1 ViewGroup (android.view.ViewGroup)1 ProgressBar (android.widget.ProgressBar)1 TextView (android.widget.TextView)1 NonNull (androidx.annotation.NonNull)1 StringRes (androidx.annotation.StringRes)1 Toolbar (androidx.appcompat.widget.Toolbar)1 Fragment (androidx.fragment.app.Fragment)1 GridLayoutManager (androidx.recyclerview.widget.GridLayoutManager)1 RecyclerView (androidx.recyclerview.widget.RecyclerView)1