Skip to content

Commit 9705636

Browse files
committed
fixed "click on a menu button will not trigger it" bug
1 parent b392c2d commit 9705636

File tree

1 file changed

+19
-20
lines changed

1 file changed

+19
-20
lines changed

library/src/main/java/com/hackplan/androidarcmenu/ArcMenuLayout.java

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -120,26 +120,6 @@ public boolean onTouchEvent(MotionEvent event) {
120120
switch (event.getAction()) {
121121
case MotionEvent.ACTION_DOWN:
122122
hideOnTouchUp = true;
123-
break;
124-
case MotionEvent.ACTION_UP:
125-
case MotionEvent.ACTION_CANCEL:
126-
if (!show) break;
127-
if (lastFocusIndex != -1) {
128-
show = false;
129-
AnimatorUtils.openMenu(this, lastFocusIndex, animListener);
130-
if (onClickMenuListener != null) {
131-
View clickedView = getChildAt(lastFocusIndex);
132-
onClickMenuListener.onClickArcMenu(arcMenu, viewForListener, (int) clickedView.getTag());
133-
}
134-
} else if (hideOnTouchUp) {
135-
if (showAnimSet != null && showAnimSet.isRunning()) showAnimSet.cancel();
136-
AnimatorUtils.hideMenu(this, touchPoint);
137-
show = false;
138-
} else {
139-
hideOnTouchUp = true;
140-
}
141-
lastFocusIndex = -1;
142-
break;
143123
case MotionEvent.ACTION_MOVE:
144124
if (!animFinished) break;
145125
tempRect = new Rect();
@@ -161,6 +141,25 @@ public boolean onTouchEvent(MotionEvent event) {
161141
lastFocusIndex = -1;
162142
}
163143
break;
144+
case MotionEvent.ACTION_UP:
145+
case MotionEvent.ACTION_CANCEL:
146+
if (!show) break;
147+
if (lastFocusIndex != -1) {
148+
show = false;
149+
AnimatorUtils.openMenu(this, lastFocusIndex, animListener);
150+
if (onClickMenuListener != null) {
151+
View clickedView = getChildAt(lastFocusIndex);
152+
onClickMenuListener.onClickArcMenu(arcMenu, viewForListener, (int) clickedView.getTag());
153+
}
154+
} else if (hideOnTouchUp) {
155+
if (showAnimSet != null && showAnimSet.isRunning()) showAnimSet.cancel();
156+
AnimatorUtils.hideMenu(this, touchPoint);
157+
show = false;
158+
} else {
159+
hideOnTouchUp = true;
160+
}
161+
lastFocusIndex = -1;
162+
break;
164163
}
165164

166165
return show;

0 commit comments

Comments
 (0)