-
Notifications
You must be signed in to change notification settings - Fork 292
fix: android slider seek时与viewPager 滑动冲突 #268
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,6 +12,7 @@ | |
| import android.graphics.drawable.BitmapDrawable; | ||
| import android.os.Build; | ||
| import android.util.AttributeSet; | ||
| import android.view.MotionEvent; | ||
| import android.view.accessibility.AccessibilityEvent; | ||
| import android.view.accessibility.AccessibilityManager; | ||
| import androidx.appcompat.widget.AppCompatSeekBar; | ||
|
|
@@ -233,4 +234,23 @@ public void setThumbImage(final String uri) { | |
| setThumb(getThumb()); | ||
| } | ||
| } | ||
| @Override | ||
| public boolean onTouchEvent(MotionEvent event) { | ||
| //设置父容器不拦截事件 | ||
| if (getParent() != null) { | ||
| try { | ||
| getParent().requestDisallowInterceptTouchEvent(true); | ||
| //SeekBar 放在其他视图中,手指放在 SeekBar 上面不会立即触发滑动操作 | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The code should always be self-explanatory. Applies also to line 239. |
||
| if (event.getAction() == MotionEvent.ACTION_DOWN) { | ||
| MotionEvent evup = MotionEvent.obtain(event); | ||
| evup.setAction(MotionEvent.ACTION_MOVE); | ||
| dispatchTouchEvent(evup); | ||
| evup.recycle(); | ||
| } | ||
| } catch (Exception exception) { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why leaving an empty exception here? |
||
|
|
||
| } | ||
| } | ||
| return super.onTouchEvent(event); | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What exceptions do we expect here to be thrown by
MotionEvent?getParent()is already checked againstnull.