I have an app where I am using different players for playing different types of streams e.g. I am using MediaPlayer
and YoutubePlayerSupportFragment
through the YouTube player API. So for this I have made a separate controller for Play/Pause/etc, also a user may click a float button (which causes the player to shrink and drag). For this I am using a dialog (YouTube Player API doesn't allow any views on top of the player).
So the problem I am facing is this: while the Dialog
is active (showing) no touch events pass through to the MainActivity
. I overcame this issue by sending MotionEvent
s via dispatchTouchEvent()
of the said Activity
from the Dialog
's dispatchTouchEvent()
. It works well as I want it and I can now switch between different sections of app, but I can't get any Click Events on ListView
and GridView
only everything else works fine.
I checked the ListView
's dispatchTouchEvent()
and I am getting all of the MotionEvent
s.
Here's the code I use to send events to the MainActivity
.
@Override
public boolean dispatchTouchEvent(MotionEvent event) {
if (isPlayerMinimized) {
if (playerDraggableView != null) {
playerDraggableView.dispatchTouchEvent(event);
}
return ((MainActivity) mContext).dispatchTouchEvent(event);
}
else if (!onControlViews(event)) {
detector.onTouchEvent(event);
}
return super.dispatchTouchEvent(event);
}
I can scroll the ListView
and GridView
but can't get OnItemClickListener
or OnItemLongClickListener
events to fire.
My question is, is this the correct/intended behavior? If so is there any way to send MotionEvent
s to the MainActivity
. Or am I missing something? If that is the case then kindly point out.
I know there isn't enough code here to properly provide a solution but if I am missing something obvious here then please tell. Thanks!