Skip to content
This repository has been archived by the owner on Jul 22, 2024. It is now read-only.

Commit

Permalink
Fix missed clicks in menu items (#2165)
Browse files Browse the repository at this point in the history
  • Loading branch information
MortimerGoro authored and bluemarvin committed Nov 5, 2019
1 parent 8e2ab5a commit 5cff5e3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

import org.mozilla.vrbrowser.R;
import org.mozilla.vrbrowser.ui.widgets.UIWidget;
import org.mozilla.vrbrowser.utils.ViewUtils;

import java.util.ArrayList;

Expand Down Expand Up @@ -130,7 +131,7 @@ public View getView(int position, View convertView, ViewGroup parent) {
if (view == null) {
view = mInflater.inflate(layoutId, parent, false);
view.setOnHoverListener(this);
view.setOnClickListener(v -> {
ViewUtils.setStickyClickListener(view, v -> {
setSelectedItem(position);
MenuItem item = mItems.get(position);
if (item.mCallback != null) {
Expand Down
11 changes: 8 additions & 3 deletions app/src/common/shared/org/mozilla/vrbrowser/utils/ViewUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -185,8 +185,9 @@ public boolean onTouch(View view, MotionEvent event) {
view.getParent().requestDisallowInterceptTouchEvent(true);
switch (event.getAction()) {
case MotionEvent.ACTION_DOWN:
view.setPressed(true);
mTouched = true;
break;
return true;
case MotionEvent.ACTION_UP:
if (mTouched && ViewUtils.isInsideView(view, (int)event.getRawX(), (int)event.getRawY())) {
view.requestFocus();
Expand All @@ -195,11 +196,15 @@ public boolean onTouch(View view, MotionEvent event) {
mClickListener.onClick(view);
}
}
view.setPressed(false);
mTouched = false;
break;
return true;
case MotionEvent.ACTION_MOVE:
return true;
case MotionEvent.ACTION_CANCEL:
view.setPressed(false);
mTouched = false;
break;
return true;
}
return false;
}
Expand Down

0 comments on commit 5cff5e3

Please sign in to comment.