mirror of https://github.com/FongMi/TV.git
parent
2e639cba6a
commit
dae14c33ff
@ -0,0 +1,20 @@ |
||||
package com.fongmi.bear.impl; |
||||
|
||||
public interface KeyDownImpl { |
||||
|
||||
void onSeek(boolean forward); |
||||
|
||||
void onKeyVertical(boolean up); |
||||
|
||||
void onKeyLeft(); |
||||
|
||||
void onKeyRight(); |
||||
|
||||
void onKeyCenter(); |
||||
|
||||
void onKeyMenu(); |
||||
|
||||
void onKeyBack(); |
||||
|
||||
void onLongPress(); |
||||
} |
||||
@ -0,0 +1,52 @@ |
||||
package com.fongmi.bear.utils; |
||||
|
||||
import android.view.KeyEvent; |
||||
|
||||
import com.fongmi.bear.impl.KeyDownImpl; |
||||
|
||||
public class KeyDown { |
||||
|
||||
private final KeyDownImpl mKeyDown; |
||||
private boolean mPress; |
||||
|
||||
public static KeyDown create(KeyDownImpl keyDown) { |
||||
return new KeyDown(keyDown); |
||||
} |
||||
|
||||
private KeyDown(KeyDownImpl keyDown) { |
||||
this.mKeyDown = keyDown; |
||||
} |
||||
|
||||
public boolean onKeyDown(KeyEvent event) { |
||||
if (event.getAction() == KeyEvent.ACTION_DOWN && Utils.isUpKey(event)) { |
||||
mKeyDown.onKeyVertical(true); |
||||
} else if (event.getAction() == KeyEvent.ACTION_DOWN && Utils.isDownKey(event)) { |
||||
mKeyDown.onKeyVertical(false); |
||||
} else if (event.getAction() == KeyEvent.ACTION_DOWN && Utils.isLeftKey(event)) { |
||||
mKeyDown.onSeek(false); |
||||
} else if (event.getAction() == KeyEvent.ACTION_DOWN && Utils.isRightKey(event)) { |
||||
mKeyDown.onSeek(true); |
||||
} else if (event.getAction() == KeyEvent.ACTION_UP && Utils.isLeftKey(event)) { |
||||
mKeyDown.onKeyLeft(); |
||||
} else if (event.getAction() == KeyEvent.ACTION_UP && Utils.isRightKey(event)) { |
||||
mKeyDown.onKeyRight(); |
||||
} else if (event.getAction() == KeyEvent.ACTION_UP && Utils.isBackKey(event)) { |
||||
mKeyDown.onKeyBack(); |
||||
} else if (event.getAction() == KeyEvent.ACTION_UP && Utils.isMenuKey(event)) { |
||||
mKeyDown.onKeyMenu(); |
||||
} else if (Utils.isEnterKey(event)) { |
||||
checkPress(event); |
||||
} |
||||
return true; |
||||
} |
||||
|
||||
private void checkPress(KeyEvent event) { |
||||
if (event.isLongPress()) { |
||||
mPress = true; |
||||
mKeyDown.onLongPress(); |
||||
} else if (event.getAction() == KeyEvent.ACTION_UP) { |
||||
if (mPress) mPress = false; |
||||
else mKeyDown.onKeyCenter(); |
||||
} |
||||
} |
||||
} |
||||
@ -1,6 +0,0 @@ |
||||
<?xml version="1.0" encoding="utf-8"?> |
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android"> |
||||
<item android:drawable="@drawable/shape_site_focused" android:state_focused="true" /> |
||||
<item android:drawable="@drawable/shape_site_activated" android:state_activated="true" /> |
||||
<item android:drawable="@drawable/shape_site_normal" /> |
||||
</selector> |
||||
@ -0,0 +1,6 @@ |
||||
<?xml version="1.0" encoding="utf-8"?> |
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android"> |
||||
<item android:drawable="@drawable/shape_text_focused" android:state_focused="true" /> |
||||
<item android:drawable="@drawable/shape_text_activated" android:state_activated="true" /> |
||||
<item android:drawable="@drawable/shape_text_normal" /> |
||||
</selector> |
||||
@ -0,0 +1,11 @@ |
||||
<?xml version="1.0" encoding="utf-8"?> |
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android" |
||||
android:shape="rectangle"> |
||||
|
||||
<solid android:color="@color/white_90" /> |
||||
|
||||
<corners |
||||
android:topLeftRadius="8dp" |
||||
android:topRightRadius="8dp" /> |
||||
|
||||
</shape> |
||||
@ -0,0 +1,124 @@ |
||||
<?xml version="1.0" encoding="utf-8"?> |
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" |
||||
xmlns:app="http://schemas.android.com/apk/res-auto" |
||||
xmlns:tools="http://schemas.android.com/tools" |
||||
android:id="@+id/exo_controller" |
||||
android:layout_width="match_parent" |
||||
android:layout_height="wrap_content" |
||||
android:layout_gravity="bottom" |
||||
android:background="@drawable/shape_controller" |
||||
android:orientation="vertical" |
||||
android:paddingStart="16dp" |
||||
android:paddingTop="16dp" |
||||
android:paddingEnd="16dp" |
||||
android:paddingBottom="8dp"> |
||||
|
||||
<LinearLayout |
||||
android:layout_width="match_parent" |
||||
android:layout_height="wrap_content" |
||||
android:orientation="horizontal"> |
||||
|
||||
<TextView |
||||
android:layout_width="wrap_content" |
||||
android:layout_height="wrap_content" |
||||
android:layout_marginEnd="16dp" |
||||
android:text="播放" |
||||
android:textColor="@color/grey_700" |
||||
android:textSize="16sp" /> |
||||
|
||||
<TextView |
||||
android:layout_width="wrap_content" |
||||
android:layout_height="wrap_content" |
||||
android:layout_marginEnd="8dp" |
||||
android:background="@drawable/selector_text" |
||||
android:text="下一集" |
||||
android:textColor="@color/white" /> |
||||
|
||||
<TextView |
||||
android:layout_width="wrap_content" |
||||
android:layout_height="wrap_content" |
||||
android:layout_marginEnd="8dp" |
||||
android:background="@drawable/selector_text" |
||||
android:text="上一集" |
||||
android:textColor="@color/white" /> |
||||
|
||||
<TextView |
||||
android:layout_width="wrap_content" |
||||
android:layout_height="wrap_content" |
||||
android:layout_marginEnd="16dp" |
||||
android:background="@drawable/selector_text" |
||||
android:text="重播本集" |
||||
android:textColor="@color/white" /> |
||||
|
||||
<TextView |
||||
android:layout_width="wrap_content" |
||||
android:layout_height="wrap_content" |
||||
android:layout_marginEnd="16dp" |
||||
android:text="倍速" |
||||
android:textColor="@color/grey_700" |
||||
android:textSize="16sp" /> |
||||
|
||||
<TextView |
||||
android:layout_width="wrap_content" |
||||
android:layout_height="wrap_content" |
||||
android:layout_marginEnd="16dp" |
||||
android:background="@drawable/selector_text" |
||||
android:text="x1.0" |
||||
android:textColor="@color/white" /> |
||||
|
||||
<TextView |
||||
android:layout_width="wrap_content" |
||||
android:layout_height="wrap_content" |
||||
android:layout_marginEnd="16dp" |
||||
android:text="縮放比例" |
||||
android:textColor="@color/grey_700" |
||||
android:textSize="16sp" /> |
||||
|
||||
<TextView |
||||
android:layout_width="wrap_content" |
||||
android:layout_height="wrap_content" |
||||
android:layout_marginEnd="16dp" |
||||
android:background="@drawable/selector_text" |
||||
android:text="預設" |
||||
android:textColor="@color/white" /> |
||||
|
||||
</LinearLayout> |
||||
|
||||
<LinearLayout |
||||
android:id="@id/exo_time" |
||||
android:layout_width="match_parent" |
||||
android:layout_height="wrap_content" |
||||
android:layout_marginTop="16dp" |
||||
android:gravity="center" |
||||
android:orientation="horizontal"> |
||||
|
||||
<TextView |
||||
android:id="@id/exo_position" |
||||
android:layout_width="wrap_content" |
||||
android:layout_height="wrap_content" |
||||
android:textColor="@color/grey_700" |
||||
android:textSize="16sp" |
||||
tools:text="00:00:00" /> |
||||
|
||||
<com.google.android.exoplayer2.ui.DefaultTimeBar |
||||
android:id="@id/exo_progress" |
||||
android:layout_width="0dp" |
||||
android:layout_height="26dp" |
||||
android:layout_marginStart="8dp" |
||||
android:layout_marginEnd="8dp" |
||||
android:layout_weight="1" |
||||
app:buffered_color="@color/grey_700" |
||||
app:played_color="@color/grey_900" |
||||
app:scrubber_color="@color/blue_500" |
||||
app:unplayed_color="@color/grey_500" /> |
||||
|
||||
<TextView |
||||
android:id="@id/exo_duration" |
||||
android:layout_width="wrap_content" |
||||
android:layout_height="wrap_content" |
||||
android:textColor="@color/grey_700" |
||||
android:textSize="16sp" |
||||
tools:text="00:00:00" /> |
||||
|
||||
</LinearLayout> |
||||
</LinearLayout> |
||||
Loading…
Reference in new issue