summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVishnu Sanal T <50027064+VishnuSanal@users.noreply.github.com>2024-06-09 22:36:02 +0530
committerGitHub <noreply@github.com>2024-06-09 19:06:02 +0200
commit2d2ec14e5d9417df1953dc2b3bfe17b247b2baac (patch)
tree4cf48882704c9c2dbbfe4546bf03c8f9253fae47
parent91f8ed055f552cdf32fd8bbcdd632534542257f8 (diff)
downloadAntennaPod-2d2ec14e5d9417df1953dc2b3bfe17b247b2baac.zip
Add pull to refresh to Downloads screen (#7230)
-rw-r--r--app/src/main/java/de/danoeh/antennapod/ui/screen/download/CompletedDownloadsFragment.java13
-rw-r--r--app/src/main/res/layout/simple_list_fragment.xml20
2 files changed, 26 insertions, 7 deletions
diff --git a/app/src/main/java/de/danoeh/antennapod/ui/screen/download/CompletedDownloadsFragment.java b/app/src/main/java/de/danoeh/antennapod/ui/screen/download/CompletedDownloadsFragment.java
index 0d82b7133..fa35b57ed 100644
--- a/app/src/main/java/de/danoeh/antennapod/ui/screen/download/CompletedDownloadsFragment.java
+++ b/app/src/main/java/de/danoeh/antennapod/ui/screen/download/CompletedDownloadsFragment.java
@@ -11,10 +11,13 @@ import android.widget.ProgressBar;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
+import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
+
import com.google.android.material.appbar.MaterialToolbar;
import com.google.android.material.snackbar.Snackbar;
import de.danoeh.antennapod.R;
import de.danoeh.antennapod.activity.MainActivity;
+import de.danoeh.antennapod.event.FeedUpdateRunningEvent;
import de.danoeh.antennapod.ui.episodeslist.EpisodeItemListAdapter;
import de.danoeh.antennapod.actionbutton.DeleteActionButton;
import de.danoeh.antennapod.event.DownloadLogEvent;
@@ -75,6 +78,7 @@ public class CompletedDownloadsFragment extends Fragment
private SwipeActions swipeActions;
private ProgressBar progressBar;
private MaterialToolbar toolbar;
+ private SwipeRefreshLayout swipeRefreshLayout;
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
@@ -95,6 +99,10 @@ public class CompletedDownloadsFragment extends Fragment
}
((MainActivity) getActivity()).setupToolbarToggle(toolbar, displayUpArrow);
+ swipeRefreshLayout = root.findViewById(R.id.swipeRefresh);
+ swipeRefreshLayout.setDistanceToTriggerSync(getResources().getInteger(R.integer.swipe_refresh_distance));
+ swipeRefreshLayout.setOnRefreshListener(() -> FeedUpdateManager.getInstance().runOnceOrAsk(requireContext()));
+
recyclerView = root.findViewById(R.id.recyclerView);
recyclerView.setRecycledViewPool(((MainActivity) getActivity()).getRecycledViewPool());
adapter = new CompletedDownloadsListAdapter((MainActivity) getActivity());
@@ -277,6 +285,11 @@ public class CompletedDownloadsFragment extends Fragment
loadItems();
}
+ @Subscribe(sticky = true, threadMode = ThreadMode.MAIN)
+ public void onEventMainThread(FeedUpdateRunningEvent event) {
+ swipeRefreshLayout.setRefreshing(event.isFeedUpdateRunning);
+ }
+
private void loadItems() {
if (disposable != null) {
disposable.dispose();
diff --git a/app/src/main/res/layout/simple_list_fragment.xml b/app/src/main/res/layout/simple_list_fragment.xml
index 3972e419e..63c418d17 100644
--- a/app/src/main/res/layout/simple_list_fragment.xml
+++ b/app/src/main/res/layout/simple_list_fragment.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
-<androidx.coordinatorlayout.widget.CoordinatorLayout
+<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
@@ -20,13 +20,19 @@
</com.google.android.material.appbar.AppBarLayout>
- <de.danoeh.antennapod.ui.episodeslist.EpisodeItemListRecyclerView
- android:id="@+id/recyclerView"
+ <androidx.swiperefreshlayout.widget.SwipeRefreshLayout
+ android:id="@+id/swipeRefresh"
android:layout_width="match_parent"
android:layout_height="match_parent"
- android:paddingHorizontal="@dimen/additional_horizontal_spacing"
- android:layout_below="@id/appbar"
- app:layout_behavior="@string/appbar_scrolling_view_behavior" />
+ android:layout_below="@id/appbar">
+
+ <de.danoeh.antennapod.ui.episodeslist.EpisodeItemListRecyclerView
+ android:id="@+id/recyclerView"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:paddingHorizontal="@dimen/additional_horizontal_spacing" />
+
+ </androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
<ProgressBar
android:id="@+id/progLoading"
@@ -42,4 +48,4 @@
android:layout_height="wrap_content"
android:layout_gravity="bottom" />
-</androidx.coordinatorlayout.widget.CoordinatorLayout>
+</RelativeLayout>