1
0
Fork 0
mirror of https://github.com/gsantner/dandelion synced 2024-11-21 20:02:07 +01:00

pull to refresh page (#219)

This commit is contained in:
massimilianoLe 2018-11-23 10:28:37 +01:00 committed by Gregor Santner
parent 1f8babd708
commit 5854075080
2 changed files with 15 additions and 2 deletions

View file

@ -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
}
});

View file

@ -5,11 +5,16 @@
xmlns:tools="http://schemas.android.com/tools"
tools:context="com.github.dfa.diaspora_android.activity.MainActivity">
<android.support.v4.widget.SwipeRefreshLayout
android:id="@+id/swipe"
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.github.dfa.diaspora_android.web.ContextMenuWebView
android:id="@+id/webView"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</android.support.v4.widget.SwipeRefreshLayout>
<ProgressBar
android:id="@+id/progressBar"
style="@style/Widget.AppCompat.ProgressBar.Horizontal"
@ -18,4 +23,4 @@
android:indeterminate="false"
android:progressDrawable="@drawable/progressbar" />
</RelativeLayout>
</RelativeLayout>