diff --git a/app/src/main/java/com/cappielloantonio/play/ui/fragment/HomeTabPodcastFragment.java b/app/src/main/java/com/cappielloantonio/play/ui/fragment/HomeTabPodcastFragment.java
index b58e06e6..af0328c1 100644
--- a/app/src/main/java/com/cappielloantonio/play/ui/fragment/HomeTabPodcastFragment.java
+++ b/app/src/main/java/com/cappielloantonio/play/ui/fragment/HomeTabPodcastFragment.java
@@ -5,6 +5,7 @@ import android.content.res.TypedArray;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.InsetDrawable;
import android.os.Bundle;
+import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@@ -33,8 +34,11 @@ import com.cappielloantonio.play.ui.activity.MainActivity;
import com.cappielloantonio.play.ui.adapter.PodcastChannelHorizontalAdapter;
import com.cappielloantonio.play.ui.adapter.PodcastEpisodeAdapter;
import com.cappielloantonio.play.util.Constants;
+import com.cappielloantonio.play.util.Preferences;
import com.cappielloantonio.play.util.UIUtil;
import com.cappielloantonio.play.viewmodel.PodcastViewModel;
+import com.google.android.material.divider.MaterialDividerItemDecoration;
+import com.google.android.material.snackbar.Snackbar;
import com.google.common.util.concurrent.ListenableFuture;
import java.util.Objects;
@@ -62,8 +66,6 @@ public class HomeTabPodcastFragment extends Fragment implements ClickCallback {
View view = bind.getRoot();
podcastViewModel = new ViewModelProvider(requireActivity()).get(PodcastViewModel.class);
- init();
-
return view;
}
@@ -71,6 +73,8 @@ public class HomeTabPodcastFragment extends Fragment implements ClickCallback {
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
+ init();
+ initPodcastView();
initNewestPodcastsView();
initPodcastChannelsView();
}
@@ -96,6 +100,19 @@ public class HomeTabPodcastFragment extends Fragment implements ClickCallback {
private void init() {
bind.podcastChannelsTextViewClickable.setOnClickListener(v -> activity.navController.navigate(R.id.action_homeFragment_to_podcastChannelCatalogueFragment));
+ bind.hideSectionButton.setOnClickListener(v -> Preferences.setPodcastSectionHidden());
+ }
+
+ private void initPodcastView() {
+ podcastViewModel.getPodcastChannels(getViewLifecycleOwner()).observe(getViewLifecycleOwner(), podcastChannels -> {
+ if (podcastChannels == null) {
+ if (bind != null) bind.homePodcastChannelsSector.setVisibility(View.GONE);
+ if (bind != null) bind.emptyPodcastLayout.setVisibility(View.GONE);
+ } else {
+ if (bind != null) bind.homePodcastChannelsSector.setVisibility(!podcastChannels.isEmpty() ? View.VISIBLE : View.GONE);
+ if (bind != null) bind.emptyPodcastLayout.setVisibility(podcastChannels.isEmpty() ? View.VISIBLE : View.GONE);
+ }
+ });
}
private void initPodcastChannelsView() {
@@ -133,8 +150,6 @@ public class HomeTabPodcastFragment extends Fragment implements ClickCallback {
});
}
-
-
private void initializeMediaBrowser() {
mediaBrowserListenableFuture = new MediaBrowser.Builder(requireContext(), new SessionToken(requireContext(), new ComponentName(requireContext(), MediaService.class))).buildAsync();
}
diff --git a/app/src/main/java/com/cappielloantonio/play/ui/fragment/HomeTabRadioFragment.java b/app/src/main/java/com/cappielloantonio/play/ui/fragment/HomeTabRadioFragment.java
index eda055f0..6867be8f 100644
--- a/app/src/main/java/com/cappielloantonio/play/ui/fragment/HomeTabRadioFragment.java
+++ b/app/src/main/java/com/cappielloantonio/play/ui/fragment/HomeTabRadioFragment.java
@@ -23,6 +23,7 @@ import com.cappielloantonio.play.ui.activity.MainActivity;
import com.cappielloantonio.play.ui.adapter.InternetRadioStationAdapter;
import com.cappielloantonio.play.ui.dialog.RadioEditorDialog;
import com.cappielloantonio.play.util.Constants;
+import com.cappielloantonio.play.util.Preferences;
import com.cappielloantonio.play.viewmodel.RadioViewModel;
import com.google.common.util.concurrent.ListenableFuture;
@@ -87,6 +88,8 @@ public class HomeTabRadioFragment extends Fragment implements ClickCallback {
radioViewModel.getInternetRadioStations(getViewLifecycleOwner());
return true;
});
+
+ bind.hideSectionButton.setOnClickListener(v -> Preferences.setRadioSectionHidden());
}
private void initRadioStationView() {
@@ -97,14 +100,13 @@ public class HomeTabRadioFragment extends Fragment implements ClickCallback {
bind.internetRadioStationRecyclerView.setAdapter(internetRadioStationAdapter);
radioViewModel.getInternetRadioStations(getViewLifecycleOwner()).observe(getViewLifecycleOwner(), internetRadioStations -> {
if (internetRadioStations == null) {
- if (bind != null)
- bind.internetRadioStationPlaceholder.placeholder.setVisibility(View.VISIBLE);
- if (bind != null) bind.internetRadioStationSector.setVisibility(View.GONE);
+ if (bind != null) bind.homeRadioStationSector.setVisibility(View.GONE);
+ if (bind != null) bind.emptyRadioStationLayout.setVisibility(View.GONE);
} else {
if (bind != null)
- bind.internetRadioStationPlaceholder.placeholder.setVisibility(View.GONE);
+ bind.homeRadioStationSector.setVisibility(!internetRadioStations.isEmpty() ? View.VISIBLE : View.GONE);
if (bind != null)
- bind.internetRadioStationSector.setVisibility(!internetRadioStations.isEmpty() ? View.VISIBLE : View.GONE);
+ bind.emptyRadioStationLayout.setVisibility(internetRadioStations.isEmpty() ? View.VISIBLE : View.GONE);
internetRadioStationAdapter.setItems(internetRadioStations);
}
diff --git a/app/src/main/java/com/cappielloantonio/play/util/Preferences.kt b/app/src/main/java/com/cappielloantonio/play/util/Preferences.kt
index ec203c0a..c3f4ede9 100644
--- a/app/src/main/java/com/cappielloantonio/play/util/Preferences.kt
+++ b/app/src/main/java/com/cappielloantonio/play/util/Preferences.kt
@@ -215,8 +215,18 @@ object Preferences {
return App.getInstance().preferences.getBoolean(PODCAST_SECTION_VISIBILITY, true)
}
+ @JvmStatic
+ fun setPodcastSectionHidden() {
+ App.getInstance().preferences.edit().putBoolean(PODCAST_SECTION_VISIBILITY, false).apply()
+ }
+
@JvmStatic
fun isRadioSectionVisible(): Boolean {
return App.getInstance().preferences.getBoolean(RADIO_SECTION_VISIBILITY, true)
}
+
+ @JvmStatic
+ fun setRadioSectionHidden() {
+ App.getInstance().preferences.edit().putBoolean(RADIO_SECTION_VISIBILITY, false).apply()
+ }
}
\ No newline at end of file
diff --git a/app/src/main/res/drawable/ui_empty_podcast.xml b/app/src/main/res/drawable/ui_empty_podcast.xml
new file mode 100644
index 00000000..d85dce1c
--- /dev/null
+++ b/app/src/main/res/drawable/ui_empty_podcast.xml
@@ -0,0 +1,172 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/src/main/res/drawable/ui_empty_radio_station.xml b/app/src/main/res/drawable/ui_empty_radio_station.xml
new file mode 100644
index 00000000..d85dce1c
--- /dev/null
+++ b/app/src/main/res/drawable/ui_empty_radio_station.xml
@@ -0,0 +1,172 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/src/main/res/layout/fragment_home_tab_podcast.xml b/app/src/main/res/layout/fragment_home_tab_podcast.xml
index 45d757a9..31660b34 100644
--- a/app/src/main/res/layout/fragment_home_tab_podcast.xml
+++ b/app/src/main/res/layout/fragment_home_tab_podcast.xml
@@ -1,95 +1,163 @@
-
+ android:layout_height="match_parent">
-
+ app:layout_constraintBottom_toBottomOf="parent"
+ app:layout_constraintEnd_toEndOf="parent"
+ app:layout_constraintStart_toStartOf="parent"
+ app:layout_constraintTop_toTopOf="parent">
+ android:paddingBottom="@dimen/global_padding_bottom">
-
+ android:orientation="vertical"
+ android:paddingBottom="8dp">
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ android:text="@string/home_title_newest_podcasts" />
-
+
-
+
+
+
+
+
+
+
+
+
+
+
+ android:layout_width="64dp"
+ android:layout_marginTop="12dp"
+ android:layout_marginBottom="12dp" />
-
-
-
-
-
-
-
-
+ android:background="?attr/selectableItemBackground"
+ android:gravity="center"
+ android:text="@string/podcast_info_empty_button" />
-
\ No newline at end of file
+
diff --git a/app/src/main/res/layout/fragment_home_tab_radio.xml b/app/src/main/res/layout/fragment_home_tab_radio.xml
index 5ab6a9e9..254d537e 100644
--- a/app/src/main/res/layout/fragment_home_tab_radio.xml
+++ b/app/src/main/res/layout/fragment_home_tab_radio.xml
@@ -1,18 +1,21 @@
-
+ android:layout_height="match_parent">
-
+ app:layout_constraintBottom_toBottomOf="parent"
+ app:layout_constraintEnd_toEndOf="parent"
+ app:layout_constraintStart_toStartOf="parent"
+ app:layout_constraintTop_toTopOf="parent">
@@ -45,13 +48,64 @@
android:paddingTop="8dp"
android:paddingBottom="8dp" />
+
-
+
+
+
+
+
+
+
+
+
+
-
+
+
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index c1271cff..745ebf2a 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -125,6 +125,11 @@
Description
Episodes
%1$s • %2$s
+
+ Once you add a channel, you\'ll find it here
+ No podcasts found!
+ Click to hide the section\nThe effects will be visible on restart
+
Radio Name
Radio Stream URL
Radio Homepage URL
@@ -132,6 +137,12 @@
Delete
Save
Internet Radio Station
+
+ Once you add a radio station, you\'ll find it here
+ No stations found!
+ Click to hide the section\nThe effects will be visible on restart
+
+
Cancel
Save
Rate