Skip to content
Closed
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 @@ -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;
Expand Down Expand Up @@ -233,4 +234,23 @@ public void setThumbImage(final String uri) {
setThumb(getThumb());
}
}
@Override
public boolean onTouchEvent(MotionEvent event) {
//设置父容器不拦截事件
if (getParent() != null) {
try {
Copy link
Member

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 against null.

getParent().requestDisallowInterceptTouchEvent(true);
//SeekBar 放在其他视图中,手指放在 SeekBar 上面不会立即触发滑动操作
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code should always be self-explanatory.
If comments are required for the code to be more understandable they should be written in English.

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) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why leaving an empty exception here?


}
}
return super.onTouchEvent(event);
}
}