From 58540750806724af108bee67eb260c89f3c82ec8 Mon Sep 17 00:00:00 2001 From: massimilianoLe <44651815+massimilianoLe@users.noreply.github.com> Date: Fri, 23 Nov 2018 10:28:37 +0100 Subject: [PATCH] pull to refresh page (#219) --- .../github/dfa/diaspora_android/web/BrowserFragment.java | 8 ++++++++ app/src/main/res/layout/browser__fragment.xml | 9 +++++++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/com/github/dfa/diaspora_android/web/BrowserFragment.java b/app/src/main/java/com/github/dfa/diaspora_android/web/BrowserFragment.java index 28db279b..32a1e83a 100644 --- a/app/src/main/java/com/github/dfa/diaspora_android/web/BrowserFragment.java +++ b/app/src/main/java/com/github/dfa/diaspora_android/web/BrowserFragment.java @@ -33,6 +33,7 @@ import com.github.dfa.diaspora_android.ui.theme.ThemeHelper; import com.github.dfa.diaspora_android.ui.theme.ThemedFragment; import com.github.dfa.diaspora_android.util.AppLog; import com.github.dfa.diaspora_android.util.AppSettings; +import android.support.v4.widget.SwipeRefreshLayout;//pull to refresh /** * Fragment with a webView and a ProgressBar. @@ -50,6 +51,7 @@ public class BrowserFragment extends ThemedFragment { protected WebSettings webSettings; protected String pendingUrl; + protected SwipeRefreshLayout swipe;//pull to refresh @Override protected int getLayoutResId() { @@ -90,6 +92,11 @@ public class BrowserFragment extends ThemedFragment { webView.setParentActivity(getActivity()); this.setRetainInstance(true); + + //pull to refresh + swipe = view.findViewById(R.id.swipe); + swipe.setOnRefreshListener(() -> reloadUrl()); + swipe.setDistanceToTriggerSync(20000); } @Override @@ -192,6 +199,7 @@ public class BrowserFragment extends ThemedFragment { @Override public void run() { getWebView().reload(); + swipe.setRefreshing(false);//pull to refresh } }); diff --git a/app/src/main/res/layout/browser__fragment.xml b/app/src/main/res/layout/browser__fragment.xml index 96daf8b1..9f534a0a 100644 --- a/app/src/main/res/layout/browser__fragment.xml +++ b/app/src/main/res/layout/browser__fragment.xml @@ -5,11 +5,16 @@ xmlns:tools="http://schemas.android.com/tools" tools:context="com.github.dfa.diaspora_android.activity.MainActivity"> + - + + - \ No newline at end of file +