Add pull to refresh to Downloads screen (#7230)
This commit is contained in:
parent
91f8ed055f
commit
2d2ec14e5d
|
@ -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();
|
||||
|
|
|
@ -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>
|
||||
|
||||
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
|
||||
android:id="@+id/swipeRefresh"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
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"
|
||||
android:layout_below="@id/appbar"
|
||||
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
|
||||
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>
|
||||
|
|
Loading…
Reference in New Issue