show PlaybackControlView when on key event for DPAD center or any direction
and consume event without moving the focus. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=171967057
This commit is contained in:
parent
a11c704d27
commit
333e745e7b
@ -218,8 +218,8 @@ public class PlayerActivity extends Activity implements OnClickListener,
|
||||
|
||||
@Override
|
||||
public boolean dispatchKeyEvent(KeyEvent event) {
|
||||
// If the event was not handled then see if the player view can handle it.
|
||||
return super.dispatchKeyEvent(event) || simpleExoPlayerView.dispatchKeyEvent(event);
|
||||
// See whether the player view wants to handle media or DPAD keys events.
|
||||
return simpleExoPlayerView.dispatchKeyEvent(event) || super.dispatchKeyEvent(event);
|
||||
}
|
||||
|
||||
// OnClickListener methods
|
||||
|
@ -15,6 +15,7 @@
|
||||
*/
|
||||
package com.google.android.exoplayer2.ui;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.annotation.TargetApi;
|
||||
import android.content.Context;
|
||||
import android.content.res.Resources;
|
||||
@ -521,8 +522,10 @@ public final class SimpleExoPlayerView extends FrameLayout {
|
||||
overlayFrameLayout.requestFocus();
|
||||
return super.dispatchKeyEvent(event);
|
||||
}
|
||||
boolean isDpadWhenControlHidden = isDpadKey(event.getKeyCode()) && useController
|
||||
&& !controller.isVisible();
|
||||
maybeShowController(true);
|
||||
return dispatchMediaKeyEvent(event) || super.dispatchKeyEvent(event);
|
||||
return isDpadWhenControlHidden || dispatchMediaKeyEvent(event) || super.dispatchKeyEvent(event);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -871,12 +874,20 @@ public final class SimpleExoPlayerView extends FrameLayout {
|
||||
logo.setBackgroundColor(resources.getColor(R.color.exo_edit_mode_background_color));
|
||||
}
|
||||
|
||||
|
||||
@SuppressWarnings("ResourceType")
|
||||
private static void setResizeModeRaw(AspectRatioFrameLayout aspectRatioFrame, int resizeMode) {
|
||||
aspectRatioFrame.setResizeMode(resizeMode);
|
||||
}
|
||||
|
||||
@SuppressLint("InlinedApi")
|
||||
private boolean isDpadKey(int keyCode) {
|
||||
return keyCode == KeyEvent.KEYCODE_DPAD_UP || keyCode == KeyEvent.KEYCODE_DPAD_UP_RIGHT
|
||||
|| keyCode == KeyEvent.KEYCODE_DPAD_RIGHT || keyCode == KeyEvent.KEYCODE_DPAD_DOWN_RIGHT
|
||||
|| keyCode == KeyEvent.KEYCODE_DPAD_DOWN || keyCode == KeyEvent.KEYCODE_DPAD_DOWN_LEFT
|
||||
|| keyCode == KeyEvent.KEYCODE_DPAD_LEFT || keyCode == KeyEvent.KEYCODE_DPAD_UP_LEFT
|
||||
|| keyCode == KeyEvent.KEYCODE_DPAD_CENTER;
|
||||
}
|
||||
|
||||
private final class ComponentListener extends Player.DefaultEventListener implements TextOutput,
|
||||
SimpleExoPlayer.VideoListener {
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user