Skip to content

Commit

Permalink
Skipping interception of some gestures
Browse files Browse the repository at this point in the history
  • Loading branch information
avently committed Aug 17, 2020
1 parent b7f50c3 commit 24c24d6
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,14 @@ public boolean onInterceptTouchEvent(final CoordinatorLayout parent, final AppBa
return false;
}
}
final View seekBar = child.findViewById(R.id.playbackSeekBar);
if (seekBar != null) {
final boolean visible = seekBar.getGlobalVisibleRect(globalRect);
if (visible && globalRect.contains((int) ev.getRawX(), (int) ev.getRawY())) {
allowScroll = false;
return false;
}
}
allowScroll = true;
switch (ev.getActionMasked()) {
case MotionEvent.ACTION_DOWN:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import android.graphics.Rect;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;
import androidx.annotation.NonNull;
Expand All @@ -25,7 +26,7 @@ public CustomBottomSheetBehavior(final Context context, final AttributeSet attrs
private boolean skippingInterception = false;
private final List<Integer> skipInterceptionOfElements = Arrays.asList(
R.id.detail_content_root_layout, R.id.relatedStreamsLayout,
R.id.playQueuePanel, R.id.viewpager);
R.id.playQueuePanel, R.id.viewpager, R.id.bottomControls);

@Override
public boolean onInterceptTouchEvent(@NonNull final CoordinatorLayout parent,
Expand All @@ -51,6 +52,13 @@ public boolean onInterceptTouchEvent(@NonNull final CoordinatorLayout parent,
visible = viewGroup.getGlobalVisibleRect(globalRect);
if (visible
&& globalRect.contains((int) event.getRawX(), (int) event.getRawY())) {
// Makes bottom part of the player draggable in portrait when
// playbackControlRoot is hidden
if (element == R.id.bottomControls
&& child.findViewById(R.id.playbackControlRoot)
.getVisibility() != View.VISIBLE) {
return super.onInterceptTouchEvent(parent, child, event);
}
skippingInterception = true;
return false;
}
Expand Down

0 comments on commit 24c24d6

Please sign in to comment.