-
Notifications
You must be signed in to change notification settings - Fork 91
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
1.[ADD]support intercept touch event
- Loading branch information
Showing
3 changed files
with
46 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
curtain/src/main/java/com/qw/curtain/lib/NoInterceptAlertDialog.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package com.qw.curtain.lib; | ||
|
||
import android.app.Activity; | ||
import android.app.Dialog; | ||
import android.content.Context; | ||
import android.view.MotionEvent; | ||
|
||
import androidx.annotation.NonNull; | ||
|
||
public class NoInterceptAlertDialog extends Dialog { | ||
|
||
protected NoInterceptAlertDialog(@NonNull Context context, int themeResId) { | ||
super(context, themeResId); | ||
} | ||
|
||
@Override | ||
public boolean onTouchEvent(@NonNull MotionEvent event) { | ||
return super.onTouchEvent(event) || tryHandleByActivity(event); | ||
} | ||
|
||
private boolean tryHandleByActivity(MotionEvent ev) { | ||
Activity activity = getOwnerActivity(); | ||
if (activity != null) { | ||
return activity.dispatchTouchEvent(ev); | ||
} | ||
return false; | ||
} | ||
|
||
} |