stopping toolbar from scrolling while scrolling code.

This commit is contained in:
Kosh 2017-06-13 22:29:12 +08:00
parent 6afca0235f
commit faab22bc92
3 changed files with 14 additions and 4 deletions

View File

@ -48,7 +48,7 @@ class WikiActivity : BaseActivity<WikiMvp.View, WikiPresenter>(), WikiMvp.View {
loadMenu()
}
if (wiki.content != null) {
webView.setGithubContent(wiki.content, null)
webView.setGithubContent(wiki.content, null, true)
}
}

View File

@ -161,7 +161,11 @@ public class PrettifyWebView extends NestedWebView {
}
public void setGithubContent(@NonNull String source, @Nullable String baseUrl) {
addJavascriptInterface(new MarkDownInterceptorInterface(this), "Android");
setGithubContent(source, baseUrl, false);
}
public void setGithubContent(@NonNull String source, @Nullable String baseUrl, boolean toggleNestScrolling) {
addJavascriptInterface(new MarkDownInterceptorInterface(this, toggleNestScrolling), "Android");
String page = GithubHelper.generateContent(getContext(), source, baseUrl, AppHelper.isNightMode(getResources()));
post(() -> loadDataWithBaseURL("file:///android_asset/md/", page, "text/html", "utf-8", null));
}

View File

@ -10,22 +10,28 @@ import com.prettifier.pretty.PrettifyWebView;
public class MarkDownInterceptorInterface {
private PrettifyWebView prettifyWebView;
private boolean toggleNestScrolling;
public MarkDownInterceptorInterface(PrettifyWebView prettifyWebView) {
this(prettifyWebView, false);
}
public MarkDownInterceptorInterface(PrettifyWebView prettifyWebView, boolean toggleNestScrolling) {
this.prettifyWebView = prettifyWebView;
this.toggleNestScrolling = toggleNestScrolling;
}
@JavascriptInterface public void startIntercept() {
if (prettifyWebView != null) {
prettifyWebView.setInterceptTouch(true);
// prettifyWebView.setEnableNestedScrolling(false);
if (toggleNestScrolling) prettifyWebView.setEnableNestedScrolling(false);
}
}
@JavascriptInterface public void stopIntercept() {
if (prettifyWebView != null) {
prettifyWebView.setInterceptTouch(false);
// prettifyWebView.setEnableNestedScrolling(true);
if (toggleNestScrolling) prettifyWebView.setEnableNestedScrolling(true);
}
}
}