Scroll list on overscolling web view

This commit is contained in:
M66B 2020-08-22 10:00:11 +02:00
parent 983c74f2e9
commit 7acee1304b
3 changed files with 29 additions and 0 deletions

View File

@ -1907,6 +1907,14 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
properties.setPosition(message.id, new Pair<Integer, Integer>(scrollX, scrollY));
}
@Override
public void onOverScrolled(int scrollX, int scrollY, boolean clampedX, boolean clampedY) {
if (clampedY) {
int dy = context.getResources().getDisplayMetrics().heightPixels / 50;
properties.scrollBy(0, scrollY == 0 ? -dy : dy);
}
}
@Override
public boolean onOpenLink(String url) {
if (parentFragment == null)
@ -5760,6 +5768,8 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
void scrollTo(int pos, int y);
void scrollBy(int x, int y);
void move(long id, String type);
void reply(TupleMessageEx message, String selected, View anchor);

View File

@ -1700,6 +1700,16 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
});
}
@Override
public void scrollBy(int x, int y) {
new Handler().post(new Runnable() {
@Override
public void run() {
rvMessage.scrollBy(x, y);
}
});
}
@Override
public void move(long id, String type) {
Bundle args = new Bundle();

View File

@ -145,6 +145,13 @@ public class WebViewEx extends WebView implements DownloadListener, View.OnLongC
this.intf.onSizeChanged(w, h, ow, oh);
}
@Override
protected void onOverScrolled(int scrollX, int scrollY, boolean clampedX, boolean clampedY) {
super.onOverScrolled(scrollX, scrollY, clampedX, clampedY);
Log.i("Over scrolled=" + scrollX + "/" + scrollY + " clamped=" + clampedX + "/" + clampedY);
intf.onOverScrolled(scrollX, scrollY, clampedX, clampedY);
}
@Override
public void onDownloadStart(
String url, String userAgent, String contentDisposition, String mimetype, long contentLength) {
@ -208,6 +215,8 @@ public class WebViewEx extends WebView implements DownloadListener, View.OnLongC
void onScrollChange(int scrollX, int scrollY);
void onOverScrolled(int scrollX, int scrollY, boolean clampedX, boolean clampedY);
boolean onOpenLink(String url);
}
}