Merge pull request #6199 from ByteHamster/home-pull-refresh

Add pull-to-refresh to home screen
This commit is contained in:
ByteHamster 2022-11-30 19:54:28 +01:00 committed by GitHub
commit 1ee85b5bb0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 26 additions and 9 deletions

View File

@ -3,6 +3,8 @@ package de.danoeh.antennapod.ui.home;
import android.content.Context; import android.content.Context;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.os.Bundle; import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.text.TextUtils; import android.text.TextUtils;
import android.util.Log; import android.util.Log;
import android.view.LayoutInflater; import android.view.LayoutInflater;
@ -70,6 +72,14 @@ public class HomeFragment extends Fragment implements Toolbar.OnMenuItemClickLis
refreshToolbarState(); refreshToolbarState();
populateSectionList(); populateSectionList();
updateWelcomeScreenVisibility(); updateWelcomeScreenVisibility();
viewBinding.swipeRefresh.setDistanceToTriggerSync(getResources().getInteger(R.integer.swipe_refresh_distance));
viewBinding.swipeRefresh.setOnRefreshListener(() -> {
AutoUpdateManager.runImmediate(requireContext());
new Handler(Looper.getMainLooper()).postDelayed(() -> viewBinding.swipeRefresh.setRefreshing(false),
getResources().getInteger(R.integer.swipe_to_refresh_duration_in_ms));
});
return viewBinding.getRoot(); return viewBinding.getRoot();
} }

View File

@ -65,6 +65,11 @@
</LinearLayout> </LinearLayout>
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
android:id="@+id/swipeRefresh"
android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.core.widget.NestedScrollView <androidx.core.widget.NestedScrollView
android:id="@+id/homeScrollView" android:id="@+id/homeScrollView"
android:layout_width="match_parent" android:layout_width="match_parent"
@ -79,4 +84,6 @@
</androidx.core.widget.NestedScrollView> </androidx.core.widget.NestedScrollView>
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
</LinearLayout> </LinearLayout>