diff options
author | flofriday <flohacksfriday@gmail.com> | 2024-09-08 16:05:36 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-09-08 16:05:36 +0200 |
commit | 60f6e175a8dc3a6b67655c920a9f70aceeb5b7db (patch) | |
tree | 10efa073867b0427f057854f6a8b5949d28248c8 /app | |
parent | 5ac3185605bb6bf3dd709513bd4ac84994aab386 (diff) | |
download | AntennaPod-60f6e175a8dc3a6b67655c920a9f70aceeb5b7db.zip |
Show message for empty home sections (#7221)
Diffstat (limited to 'app')
5 files changed, 65 insertions, 34 deletions
diff --git a/app/src/main/java/de/danoeh/antennapod/ui/screen/home/sections/DownloadsSection.java b/app/src/main/java/de/danoeh/antennapod/ui/screen/home/sections/DownloadsSection.java index 06de7803a..af497bbe8 100644 --- a/app/src/main/java/de/danoeh/antennapod/ui/screen/home/sections/DownloadsSection.java +++ b/app/src/main/java/de/danoeh/antennapod/ui/screen/home/sections/DownloadsSection.java @@ -6,35 +6,38 @@ import android.view.ContextMenu; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; + import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.RecyclerView; + +import org.greenrobot.eventbus.Subscribe; +import org.greenrobot.eventbus.ThreadMode; + +import java.util.List; + import de.danoeh.antennapod.R; import de.danoeh.antennapod.activity.MainActivity; -import de.danoeh.antennapod.ui.episodeslist.EpisodeItemListAdapter; import de.danoeh.antennapod.event.DownloadLogEvent; -import de.danoeh.antennapod.ui.MenuItemUtils; -import de.danoeh.antennapod.storage.database.DBReader; import de.danoeh.antennapod.event.FeedItemEvent; import de.danoeh.antennapod.event.PlayerStatusEvent; import de.danoeh.antennapod.event.playback.PlaybackPositionEvent; -import de.danoeh.antennapod.ui.screen.download.CompletedDownloadsFragment; -import de.danoeh.antennapod.ui.swipeactions.SwipeActions; import de.danoeh.antennapod.model.feed.FeedItem; import de.danoeh.antennapod.model.feed.FeedItemFilter; import de.danoeh.antennapod.model.feed.SortOrder; +import de.danoeh.antennapod.storage.database.DBReader; import de.danoeh.antennapod.storage.preferences.UserPreferences; -import de.danoeh.antennapod.ui.screen.home.HomeSection; +import de.danoeh.antennapod.ui.MenuItemUtils; +import de.danoeh.antennapod.ui.episodeslist.EpisodeItemListAdapter; import de.danoeh.antennapod.ui.episodeslist.EpisodeItemViewHolder; +import de.danoeh.antennapod.ui.screen.download.CompletedDownloadsFragment; +import de.danoeh.antennapod.ui.screen.home.HomeSection; +import de.danoeh.antennapod.ui.swipeactions.SwipeActions; import io.reactivex.Observable; import io.reactivex.android.schedulers.AndroidSchedulers; import io.reactivex.disposables.Disposable; import io.reactivex.schedulers.Schedulers; -import org.greenrobot.eventbus.Subscribe; -import org.greenrobot.eventbus.ThreadMode; - -import java.util.List; public class DownloadsSection extends HomeSection { public static final String TAG = "DownloadsSection"; @@ -63,6 +66,7 @@ public class DownloadsSection extends HomeSection { }; adapter.setDummyViews(NUM_EPISODES); viewBinding.recyclerView.setAdapter(adapter); + viewBinding.emptyLabel.setText(R.string.home_downloads_empty_text); SwipeActions swipeActions = new SwipeActions(this, CompletedDownloadsFragment.TAG); swipeActions.attachTo(viewBinding.recyclerView); @@ -133,6 +137,7 @@ public class DownloadsSection extends HomeSection { items = downloads; adapter.setDummyViews(0); adapter.updateItems(items); + viewBinding.emptyLabel.setVisibility(items.isEmpty() ? View.VISIBLE : View.GONE); }, error -> Log.e(TAG, Log.getStackTraceString(error))); } } diff --git a/app/src/main/java/de/danoeh/antennapod/ui/screen/home/sections/EpisodesSurpriseSection.java b/app/src/main/java/de/danoeh/antennapod/ui/screen/home/sections/EpisodesSurpriseSection.java index 09f060f81..1f1a633c7 100644 --- a/app/src/main/java/de/danoeh/antennapod/ui/screen/home/sections/EpisodesSurpriseSection.java +++ b/app/src/main/java/de/danoeh/antennapod/ui/screen/home/sections/EpisodesSurpriseSection.java @@ -6,33 +6,36 @@ import android.view.ContextMenu; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; + import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.RecyclerView; + +import org.greenrobot.eventbus.Subscribe; +import org.greenrobot.eventbus.ThreadMode; + +import java.util.ArrayList; +import java.util.List; +import java.util.Random; + import de.danoeh.antennapod.R; import de.danoeh.antennapod.activity.MainActivity; -import de.danoeh.antennapod.ui.episodeslist.HorizontalItemListAdapter; -import de.danoeh.antennapod.ui.MenuItemUtils; -import de.danoeh.antennapod.storage.database.DBReader; import de.danoeh.antennapod.event.EpisodeDownloadEvent; import de.danoeh.antennapod.event.FeedItemEvent; import de.danoeh.antennapod.event.PlayerStatusEvent; import de.danoeh.antennapod.event.playback.PlaybackPositionEvent; -import de.danoeh.antennapod.ui.screen.AllEpisodesFragment; import de.danoeh.antennapod.model.feed.FeedItem; -import de.danoeh.antennapod.ui.screen.home.HomeSection; +import de.danoeh.antennapod.storage.database.DBReader; +import de.danoeh.antennapod.ui.MenuItemUtils; +import de.danoeh.antennapod.ui.episodeslist.HorizontalItemListAdapter; import de.danoeh.antennapod.ui.episodeslist.HorizontalItemViewHolder; +import de.danoeh.antennapod.ui.screen.AllEpisodesFragment; +import de.danoeh.antennapod.ui.screen.home.HomeSection; import io.reactivex.Observable; import io.reactivex.android.schedulers.AndroidSchedulers; import io.reactivex.disposables.Disposable; import io.reactivex.schedulers.Schedulers; -import org.greenrobot.eventbus.Subscribe; -import org.greenrobot.eventbus.ThreadMode; - -import java.util.ArrayList; -import java.util.List; -import java.util.Random; public class EpisodesSurpriseSection extends HomeSection { public static final String TAG = "EpisodesSurpriseSection"; @@ -69,6 +72,7 @@ public class EpisodesSurpriseSection extends HomeSection { if (seed == 0) { seed = new Random().nextInt(); } + viewBinding.emptyLabel.setText(R.string.home_no_recent_unplayed_episodes_text); return view; } @@ -149,6 +153,11 @@ public class EpisodesSurpriseSection extends HomeSection { this.episodes = episodes; listAdapter.setDummyViews(0); listAdapter.updateData(episodes); + + boolean isShuffleable = !episodes.isEmpty(); + viewBinding.shuffleButton.setVisibility(isShuffleable ? View.VISIBLE : View.GONE); + viewBinding.recyclerView.setVisibility(isShuffleable ? View.VISIBLE : View.GONE); + viewBinding.emptyLabel.setVisibility(!isShuffleable ? View.VISIBLE : View.GONE); }, error -> Log.e(TAG, Log.getStackTraceString(error))); } } diff --git a/app/src/main/java/de/danoeh/antennapod/ui/screen/home/sections/InboxSection.java b/app/src/main/java/de/danoeh/antennapod/ui/screen/home/sections/InboxSection.java index d30fa85bc..7bb791746 100644 --- a/app/src/main/java/de/danoeh/antennapod/ui/screen/home/sections/InboxSection.java +++ b/app/src/main/java/de/danoeh/antennapod/ui/screen/home/sections/InboxSection.java @@ -6,36 +6,39 @@ import android.view.ContextMenu; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; + import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.core.util.Pair; import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.RecyclerView; + +import org.greenrobot.eventbus.Subscribe; +import org.greenrobot.eventbus.ThreadMode; + +import java.util.ArrayList; +import java.util.List; +import java.util.Locale; + import de.danoeh.antennapod.R; import de.danoeh.antennapod.activity.MainActivity; -import de.danoeh.antennapod.ui.episodeslist.EpisodeItemListAdapter; -import de.danoeh.antennapod.ui.MenuItemUtils; -import de.danoeh.antennapod.storage.database.DBReader; import de.danoeh.antennapod.event.EpisodeDownloadEvent; import de.danoeh.antennapod.event.FeedItemEvent; import de.danoeh.antennapod.event.FeedListUpdateEvent; import de.danoeh.antennapod.event.UnreadItemsUpdateEvent; -import de.danoeh.antennapod.ui.screen.InboxFragment; -import de.danoeh.antennapod.ui.swipeactions.SwipeActions; import de.danoeh.antennapod.model.feed.FeedItem; import de.danoeh.antennapod.model.feed.FeedItemFilter; +import de.danoeh.antennapod.storage.database.DBReader; import de.danoeh.antennapod.storage.preferences.UserPreferences; +import de.danoeh.antennapod.ui.MenuItemUtils; +import de.danoeh.antennapod.ui.episodeslist.EpisodeItemListAdapter; +import de.danoeh.antennapod.ui.screen.InboxFragment; import de.danoeh.antennapod.ui.screen.home.HomeSection; +import de.danoeh.antennapod.ui.swipeactions.SwipeActions; import io.reactivex.Observable; import io.reactivex.android.schedulers.AndroidSchedulers; import io.reactivex.disposables.Disposable; import io.reactivex.schedulers.Schedulers; -import org.greenrobot.eventbus.Subscribe; -import org.greenrobot.eventbus.ThreadMode; - -import java.util.ArrayList; -import java.util.List; -import java.util.Locale; public class InboxSection extends HomeSection { public static final String TAG = "InboxSection"; @@ -53,7 +56,7 @@ public class InboxSection extends HomeSection { viewBinding.recyclerView.setOverScrollMode(RecyclerView.OVER_SCROLL_NEVER); viewBinding.recyclerView.setLayoutManager(new LinearLayoutManager(getContext(), RecyclerView.VERTICAL, false)); viewBinding.recyclerView.setRecycledViewPool(((MainActivity) requireActivity()).getRecycledViewPool()); - adapter = new EpisodeItemListAdapter((MainActivity) requireActivity()) { + adapter = new EpisodeItemListAdapter(requireActivity()) { @Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) { super.onCreateContextMenu(menu, v, menuInfo); @@ -62,6 +65,7 @@ public class InboxSection extends HomeSection { }; adapter.setDummyViews(NUM_EPISODES); viewBinding.recyclerView.setAdapter(adapter); + viewBinding.emptyLabel.setText(R.string.home_new_empty_text); SwipeActions swipeActions = new SwipeActions(this, InboxFragment.TAG); swipeActions.attachTo(viewBinding.recyclerView); @@ -129,7 +133,8 @@ public class InboxSection extends HomeSection { items = data.first; adapter.setDummyViews(0); adapter.updateItems(items); - viewBinding.numNewItemsLabel.setVisibility(View.VISIBLE); + viewBinding.emptyLabel.setVisibility(items.isEmpty() ? View.VISIBLE : View.GONE); + viewBinding.numNewItemsLabel.setVisibility(!items.isEmpty() ? View.VISIBLE : View.GONE); if (data.second >= 100) { viewBinding.numNewItemsLabel.setText(String.format(Locale.getDefault(), "%d+", 99)); } else { diff --git a/app/src/main/java/de/danoeh/antennapod/ui/screen/home/sections/QueueSection.java b/app/src/main/java/de/danoeh/antennapod/ui/screen/home/sections/QueueSection.java index 790992420..a06f4baba 100644 --- a/app/src/main/java/de/danoeh/antennapod/ui/screen/home/sections/QueueSection.java +++ b/app/src/main/java/de/danoeh/antennapod/ui/screen/home/sections/QueueSection.java @@ -59,6 +59,7 @@ public class QueueSection extends HomeSection { viewBinding.recyclerView.setAdapter(listAdapter); int paddingHorizontal = (int) (12 * getResources().getDisplayMetrics().density); viewBinding.recyclerView.setPadding(paddingHorizontal, 0, paddingHorizontal, 0); + viewBinding.emptyLabel.setText(R.string.home_continue_empty_text); return view; } @@ -156,6 +157,7 @@ public class QueueSection extends HomeSection { this.queue = queue; listAdapter.setDummyViews(0); listAdapter.updateData(queue); + viewBinding.emptyLabel.setVisibility(queue.isEmpty() ? View.VISIBLE : View.GONE); }, error -> Log.e(TAG, Log.getStackTraceString(error))); } diff --git a/app/src/main/res/layout/home_section.xml b/app/src/main/res/layout/home_section.xml index f8379b0ff..3064b7d44 100644 --- a/app/src/main/res/layout/home_section.xml +++ b/app/src/main/res/layout/home_section.xml @@ -106,4 +106,14 @@ tools:listitem="@layout/horizontal_itemlist_item" tools:itemCount="1" /> + <TextView + android:id="@+id/emptyLabel" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:visibility="gone" + android:paddingHorizontal="32dp" + android:paddingVertical="8dp" + android:textAlignment="center" + app:layout_constraintTop_toBottomOf="@id/barrier" /> + </androidx.constraintlayout.widget.ConstraintLayout> |