Scroll Up/Down
This commit is contained in:
parent
1985125472
commit
1db988d2b7
1 changed files with 25 additions and 11 deletions
|
@ -28,6 +28,7 @@ import androidx.appcompat.widget.PopupMenu;
|
||||||
import androidx.appcompat.widget.Toolbar;
|
import androidx.appcompat.widget.Toolbar;
|
||||||
import androidx.browser.customtabs.CustomTabsIntent;
|
import androidx.browser.customtabs.CustomTabsIntent;
|
||||||
import androidx.core.content.ContextCompat;
|
import androidx.core.content.ContextCompat;
|
||||||
|
import androidx.core.view.MotionEventCompat;
|
||||||
import androidx.fragment.app.FragmentActivity;
|
import androidx.fragment.app.FragmentActivity;
|
||||||
import androidx.fragment.app.FragmentManager;
|
import androidx.fragment.app.FragmentManager;
|
||||||
|
|
||||||
|
@ -123,19 +124,32 @@ public class WikipediaDialogFragment extends WikiArticleBaseDialogFragment {
|
||||||
|
|
||||||
contentWebView = mainView.findViewById(R.id.content_web_view);
|
contentWebView = mainView.findViewById(R.id.content_web_view);
|
||||||
contentWebView.setOnTouchListener(new View.OnTouchListener() {
|
contentWebView.setOnTouchListener(new View.OnTouchListener() {
|
||||||
|
float initialY, finalY;
|
||||||
|
boolean isScrollingUp;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onTouch(View v, MotionEvent event) {
|
public boolean onTouch(View v, MotionEvent event) {
|
||||||
switch (event.getAction()) {
|
int action = MotionEventCompat.getActionMasked(event);
|
||||||
case MotionEvent.ACTION_SCROLL:
|
|
||||||
case MotionEvent.ACTION_MOVE:
|
switch(action) {
|
||||||
readFullArticleButton.setVisibility(View.GONE);
|
case (MotionEvent.ACTION_DOWN):
|
||||||
break;
|
initialY = event.getY();
|
||||||
case MotionEvent.ACTION_CANCEL:
|
case (MotionEvent.ACTION_UP):
|
||||||
case MotionEvent.ACTION_DOWN:
|
finalY = event.getY();
|
||||||
case MotionEvent.ACTION_UP:
|
if (initialY < finalY) {
|
||||||
readFullArticleButton.setVisibility(View.VISIBLE);
|
isScrollingUp = true;
|
||||||
break;
|
} else if (initialY > finalY) {
|
||||||
|
isScrollingUp = false;
|
||||||
|
}
|
||||||
|
default:
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isScrollingUp) {
|
||||||
|
readFullArticleButton.setVisibility(View.VISIBLE);
|
||||||
|
} else {
|
||||||
|
readFullArticleButton.setVisibility(View.GONE);
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue