mirror of
https://github.com/gsantner/dandelion
synced 2024-11-05 12:06:01 +01:00
pull to refresh page (#219)
This commit is contained in:
parent
1f8babd708
commit
5854075080
2 changed files with 15 additions and 2 deletions
|
@ -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.ui.theme.ThemedFragment;
|
||||||
import com.github.dfa.diaspora_android.util.AppLog;
|
import com.github.dfa.diaspora_android.util.AppLog;
|
||||||
import com.github.dfa.diaspora_android.util.AppSettings;
|
import com.github.dfa.diaspora_android.util.AppSettings;
|
||||||
|
import android.support.v4.widget.SwipeRefreshLayout;//pull to refresh
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fragment with a webView and a ProgressBar.
|
* Fragment with a webView and a ProgressBar.
|
||||||
|
@ -50,6 +51,7 @@ public class BrowserFragment extends ThemedFragment {
|
||||||
protected WebSettings webSettings;
|
protected WebSettings webSettings;
|
||||||
|
|
||||||
protected String pendingUrl;
|
protected String pendingUrl;
|
||||||
|
protected SwipeRefreshLayout swipe;//pull to refresh
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected int getLayoutResId() {
|
protected int getLayoutResId() {
|
||||||
|
@ -90,6 +92,11 @@ public class BrowserFragment extends ThemedFragment {
|
||||||
webView.setParentActivity(getActivity());
|
webView.setParentActivity(getActivity());
|
||||||
|
|
||||||
this.setRetainInstance(true);
|
this.setRetainInstance(true);
|
||||||
|
|
||||||
|
//pull to refresh
|
||||||
|
swipe = view.findViewById(R.id.swipe);
|
||||||
|
swipe.setOnRefreshListener(() -> reloadUrl());
|
||||||
|
swipe.setDistanceToTriggerSync(20000);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -192,6 +199,7 @@ public class BrowserFragment extends ThemedFragment {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
getWebView().reload();
|
getWebView().reload();
|
||||||
|
swipe.setRefreshing(false);//pull to refresh
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -5,10 +5,15 @@
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
tools:context="com.github.dfa.diaspora_android.activity.MainActivity">
|
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
|
<com.github.dfa.diaspora_android.web.ContextMenuWebView
|
||||||
android:id="@+id/webView"
|
android:id="@+id/webView"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent" />
|
android:layout_height="match_parent" />
|
||||||
|
</android.support.v4.widget.SwipeRefreshLayout>
|
||||||
|
|
||||||
<ProgressBar
|
<ProgressBar
|
||||||
android:id="@+id/progressBar"
|
android:id="@+id/progressBar"
|
||||||
|
|
Loading…
Reference in a new issue