Add swipe-to-refresh to home screen
This commit is contained in:
parent
3973f450be
commit
6e9325b549
@ -3,6 +3,8 @@ package de.danoeh.antennapod.ui.home;
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
@ -70,6 +72,14 @@ public class HomeFragment extends Fragment implements Toolbar.OnMenuItemClickLis
|
||||
refreshToolbarState();
|
||||
populateSectionList();
|
||||
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();
|
||||
}
|
||||
|
||||
|
@ -65,18 +65,25 @@
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<androidx.core.widget.NestedScrollView
|
||||
android:id="@+id/homeScrollView"
|
||||
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
|
||||
android:id="@+id/swipeRefresh"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/homeContainer"
|
||||
<androidx.core.widget.NestedScrollView
|
||||
android:id="@+id/homeScrollView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:paddingBottom="12dp" />
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
</androidx.core.widget.NestedScrollView>
|
||||
<LinearLayout
|
||||
android:id="@+id/homeContainer"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:paddingBottom="12dp" />
|
||||
|
||||
</androidx.core.widget.NestedScrollView>
|
||||
|
||||
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
Loading…
x
Reference in New Issue
Block a user