Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Solve the problem of multiple quick clicks and the view doesn't dismiss #83

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,11 @@ public class MaterialIntroView extends RelativeLayout {
*/
private boolean usesCustomShape = false;

/**
* status of dismiss
*/
private boolean isDismiss = false;

public MaterialIntroView(Context context) {
super(context);
init(context);
Expand Down Expand Up @@ -372,16 +377,17 @@ public boolean onTouchEvent(MotionEvent event) {

return true;
case MotionEvent.ACTION_UP:

if (isTouchOnFocus || dismissOnTouch)
dismiss();

if (isTouchOnFocus && isPerformClick) {
targetView.getView().performClick();
targetView.getView().setPressed(true);
targetView.getView().invalidate();
targetView.getView().setPressed(false);
targetView.getView().invalidate();
if(!isDismiss){
if (isTouchOnFocus || dismissOnTouch)
dismiss();

if (isTouchOnFocus && isPerformClick) {
targetView.getView().performClick();
targetView.getView().setPressed(true);
targetView.getView().invalidate();
targetView.getView().setPressed(false);
targetView.getView().invalidate();
}
}

return true;
Expand Down Expand Up @@ -425,12 +431,14 @@ public void onAnimationStart() {
if(isIdempotent) {
preferencesManager.setDisplayed(materialIntroViewId);
}
isDismiss = false;
}

/**
* Dismiss Material Intro View
*/
public void dismiss() {
isDismiss = true;
if(!isIdempotent) {
preferencesManager.setDisplayed(materialIntroViewId);
}
Expand Down