mirror of https://github.com/FongMi/TV.git
parent
deafd6e7b9
commit
54aebc441d
@ -0,0 +1,55 @@ |
||||
package com.fongmi.android.tv.ui.presenter; |
||||
|
||||
import android.view.LayoutInflater; |
||||
import android.view.ViewGroup; |
||||
|
||||
import androidx.annotation.NonNull; |
||||
import androidx.leanback.widget.Presenter; |
||||
|
||||
import com.fongmi.android.tv.databinding.AdapterPartBinding; |
||||
|
||||
public class PartPresenter extends Presenter { |
||||
|
||||
private final OnClickListener mListener; |
||||
private int nextFocus; |
||||
|
||||
public PartPresenter(OnClickListener listener) { |
||||
this.mListener = listener; |
||||
} |
||||
|
||||
public interface OnClickListener { |
||||
void onItemClick(String item); |
||||
} |
||||
|
||||
public void setNextFocusUp(int nextFocus) { |
||||
this.nextFocus = nextFocus; |
||||
} |
||||
|
||||
@Override |
||||
public Presenter.ViewHolder onCreateViewHolder(ViewGroup parent) { |
||||
return new ViewHolder(AdapterPartBinding.inflate(LayoutInflater.from(parent.getContext()), parent, false)); |
||||
} |
||||
|
||||
@Override |
||||
public void onBindViewHolder(Presenter.ViewHolder viewHolder, Object object) { |
||||
String text = object.toString(); |
||||
ViewHolder holder = (ViewHolder) viewHolder; |
||||
holder.binding.text.setText(text); |
||||
holder.binding.text.setNextFocusUpId(nextFocus); |
||||
setOnClickListener(holder, view -> mListener.onItemClick(text)); |
||||
} |
||||
|
||||
@Override |
||||
public void onUnbindViewHolder(Presenter.ViewHolder viewHolder) { |
||||
} |
||||
|
||||
public static class ViewHolder extends Presenter.ViewHolder { |
||||
|
||||
private final AdapterPartBinding binding; |
||||
|
||||
public ViewHolder(@NonNull AdapterPartBinding binding) { |
||||
super(binding.getRoot()); |
||||
this.binding = binding; |
||||
} |
||||
} |
||||
} |
||||
@ -1,216 +1,235 @@ |
||||
<?xml version="1.0" encoding="utf-8"?> |
||||
<com.fongmi.android.tv.ui.custom.ProgressLayout xmlns:android="http://schemas.android.com/apk/res/android" |
||||
<androidx.core.widget.NestedScrollView 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/progressLayout" |
||||
android:layout_width="match_parent" |
||||
android:layout_height="match_parent" |
||||
android:fillViewport="true" |
||||
android:keepScreenOn="true"> |
||||
|
||||
<FrameLayout |
||||
android:id="@+id/video" |
||||
android:layout_width="360dp" |
||||
android:layout_height="200dp" |
||||
android:layout_marginStart="24dp" |
||||
android:layout_marginTop="24dp" |
||||
android:background="@color/black" |
||||
android:focusable="true" |
||||
android:focusableInTouchMode="true" |
||||
android:foreground="@drawable/selector_video"> |
||||
|
||||
<com.google.android.exoplayer2.ui.StyledPlayerView |
||||
android:id="@+id/surface" |
||||
android:layout_width="match_parent" |
||||
android:layout_height="match_parent" |
||||
android:visibility="gone" |
||||
app:animation_enabled="false" |
||||
app:auto_show="false" |
||||
app:controller_layout_id="@layout/view_controller_bottom" |
||||
app:resize_mode="fit" |
||||
app:surface_type="surface_view" |
||||
app:use_controller="false" /> |
||||
|
||||
<com.google.android.exoplayer2.ui.StyledPlayerView |
||||
android:id="@+id/texture" |
||||
android:layout_width="match_parent" |
||||
android:layout_height="match_parent" |
||||
android:visibility="gone" |
||||
app:animation_enabled="false" |
||||
app:auto_show="false" |
||||
app:controller_layout_id="@layout/view_controller_bottom" |
||||
app:resize_mode="fit" |
||||
app:surface_type="texture_view" |
||||
app:use_controller="false" /> |
||||
|
||||
<include |
||||
android:id="@+id/progress" |
||||
layout="@layout/view_progress" |
||||
android:visibility="gone" /> |
||||
|
||||
<include |
||||
android:id="@+id/error" |
||||
layout="@layout/view_error" |
||||
android:layout_width="wrap_content" |
||||
android:layout_height="wrap_content" |
||||
android:layout_gravity="center" |
||||
android:visibility="gone" /> |
||||
|
||||
<include |
||||
android:id="@+id/center" |
||||
layout="@layout/view_controller_center" |
||||
android:layout_width="wrap_content" |
||||
android:layout_height="wrap_content" |
||||
android:layout_gravity="center" |
||||
android:visibility="gone" /> |
||||
|
||||
</FrameLayout> |
||||
|
||||
<TextView |
||||
android:id="@+id/name" |
||||
android:layout_width="wrap_content" |
||||
android:layout_height="wrap_content" |
||||
android:layout_marginStart="24dp" |
||||
android:layout_marginTop="24dp" |
||||
android:layout_marginEnd="24dp" |
||||
android:layout_toEndOf="@+id/video" |
||||
android:singleLine="true" |
||||
android:textColor="@color/white" |
||||
android:textSize="24sp" |
||||
android:textStyle="bold" |
||||
tools:text="慶餘年第二季" /> |
||||
|
||||
<LinearLayout |
||||
android:id="@+id/row" |
||||
<com.fongmi.android.tv.ui.custom.ProgressLayout |
||||
android:id="@+id/progressLayout" |
||||
android:layout_width="match_parent" |
||||
android:layout_height="wrap_content" |
||||
android:layout_below="@+id/name" |
||||
android:layout_alignStart="@+id/name" |
||||
android:layout_marginEnd="24dp" |
||||
android:orientation="horizontal"> |
||||
android:layout_height="match_parent"> |
||||
|
||||
<FrameLayout |
||||
android:id="@+id/video" |
||||
android:layout_width="360dp" |
||||
android:layout_height="200dp" |
||||
android:layout_marginStart="24dp" |
||||
android:layout_marginTop="24dp" |
||||
android:background="@color/black" |
||||
android:focusable="true" |
||||
android:focusableInTouchMode="true" |
||||
android:foreground="@drawable/selector_video"> |
||||
|
||||
<com.google.android.exoplayer2.ui.StyledPlayerView |
||||
android:id="@+id/surface" |
||||
android:layout_width="match_parent" |
||||
android:layout_height="match_parent" |
||||
android:visibility="gone" |
||||
app:animation_enabled="false" |
||||
app:auto_show="false" |
||||
app:controller_layout_id="@layout/view_controller_bottom" |
||||
app:resize_mode="fit" |
||||
app:surface_type="surface_view" |
||||
app:use_controller="false" /> |
||||
|
||||
<com.google.android.exoplayer2.ui.StyledPlayerView |
||||
android:id="@+id/texture" |
||||
android:layout_width="match_parent" |
||||
android:layout_height="match_parent" |
||||
android:visibility="gone" |
||||
app:animation_enabled="false" |
||||
app:auto_show="false" |
||||
app:controller_layout_id="@layout/view_controller_bottom" |
||||
app:resize_mode="fit" |
||||
app:surface_type="texture_view" |
||||
app:use_controller="false" /> |
||||
|
||||
<include |
||||
android:id="@+id/progress" |
||||
layout="@layout/view_progress" |
||||
android:visibility="gone" /> |
||||
|
||||
<include |
||||
android:id="@+id/error" |
||||
layout="@layout/view_error" |
||||
android:layout_width="wrap_content" |
||||
android:layout_height="wrap_content" |
||||
android:layout_gravity="center" |
||||
android:visibility="gone" /> |
||||
|
||||
<include |
||||
android:id="@+id/center" |
||||
layout="@layout/view_controller_center" |
||||
android:layout_width="wrap_content" |
||||
android:layout_height="wrap_content" |
||||
android:layout_gravity="center" |
||||
android:visibility="gone" /> |
||||
|
||||
</FrameLayout> |
||||
|
||||
<TextView |
||||
android:id="@+id/site" |
||||
android:id="@+id/name" |
||||
android:layout_width="wrap_content" |
||||
android:layout_height="wrap_content" |
||||
android:layout_marginTop="8dp" |
||||
android:layout_marginEnd="12dp" |
||||
android:layout_marginStart="24dp" |
||||
android:layout_marginTop="24dp" |
||||
android:layout_marginEnd="24dp" |
||||
android:layout_toEndOf="@+id/video" |
||||
android:singleLine="true" |
||||
android:textColor="@color/white" |
||||
android:textSize="16sp" |
||||
tools:text="站源:泥巴" /> |
||||
android:textSize="24sp" |
||||
android:textStyle="bold" |
||||
tools:text="慶餘年第二季" /> |
||||
|
||||
<LinearLayout |
||||
android:id="@+id/row" |
||||
android:layout_width="match_parent" |
||||
android:layout_height="wrap_content" |
||||
android:layout_below="@+id/name" |
||||
android:layout_alignStart="@+id/name" |
||||
android:layout_marginEnd="24dp" |
||||
android:orientation="horizontal"> |
||||
|
||||
<TextView |
||||
android:id="@+id/site" |
||||
android:layout_width="wrap_content" |
||||
android:layout_height="wrap_content" |
||||
android:layout_marginTop="8dp" |
||||
android:layout_marginEnd="12dp" |
||||
android:singleLine="true" |
||||
android:textColor="@color/white" |
||||
android:textSize="16sp" |
||||
tools:text="站源:泥巴" /> |
||||
|
||||
<TextView |
||||
android:id="@+id/year" |
||||
android:layout_width="wrap_content" |
||||
android:layout_height="wrap_content" |
||||
android:layout_marginTop="8dp" |
||||
android:layout_marginEnd="12dp" |
||||
android:singleLine="true" |
||||
android:textColor="@color/white" |
||||
android:textSize="16sp" |
||||
tools:text="年份:2022" /> |
||||
|
||||
<TextView |
||||
android:id="@+id/area" |
||||
android:layout_width="wrap_content" |
||||
android:layout_height="wrap_content" |
||||
android:layout_marginTop="8dp" |
||||
android:layout_marginEnd="12dp" |
||||
android:singleLine="true" |
||||
android:textColor="@color/white" |
||||
android:textSize="16sp" |
||||
tools:text="地區:台灣" /> |
||||
|
||||
<TextView |
||||
android:id="@+id/type" |
||||
android:layout_width="wrap_content" |
||||
android:layout_height="wrap_content" |
||||
android:layout_marginTop="8dp" |
||||
android:singleLine="true" |
||||
android:textColor="@color/white" |
||||
android:textSize="16sp" |
||||
tools:text="類型:科幻" /> |
||||
|
||||
</LinearLayout> |
||||
|
||||
<TextView |
||||
android:id="@+id/year" |
||||
android:id="@+id/director" |
||||
android:layout_width="wrap_content" |
||||
android:layout_height="wrap_content" |
||||
android:layout_below="@+id/row" |
||||
android:layout_alignStart="@+id/name" |
||||
android:layout_marginTop="8dp" |
||||
android:layout_marginEnd="12dp" |
||||
android:layout_marginEnd="24dp" |
||||
android:singleLine="true" |
||||
android:textColor="@color/white" |
||||
android:textSize="16sp" |
||||
tools:text="年份:2022" /> |
||||
tools:text="導演:FongMi" /> |
||||
|
||||
<TextView |
||||
android:id="@+id/area" |
||||
android:id="@+id/actor" |
||||
android:layout_width="wrap_content" |
||||
android:layout_height="wrap_content" |
||||
android:layout_below="@+id/director" |
||||
android:layout_alignStart="@+id/name" |
||||
android:layout_marginTop="8dp" |
||||
android:layout_marginEnd="12dp" |
||||
android:layout_marginEnd="24dp" |
||||
android:singleLine="true" |
||||
android:textColor="@color/white" |
||||
android:textSize="16sp" |
||||
tools:text="地區:台灣" /> |
||||
tools:text="演員:FongMi" /> |
||||
|
||||
<TextView |
||||
android:id="@+id/type" |
||||
android:layout_width="wrap_content" |
||||
android:id="@+id/content" |
||||
android:layout_width="match_parent" |
||||
android:layout_height="wrap_content" |
||||
android:layout_below="@+id/actor" |
||||
android:layout_alignStart="@+id/name" |
||||
android:layout_marginTop="8dp" |
||||
android:singleLine="true" |
||||
android:layout_marginEnd="24dp" |
||||
android:ellipsize="end" |
||||
android:lineSpacingExtra="4dp" |
||||
android:maxLines="3" |
||||
android:textColor="@color/white" |
||||
android:textSize="16sp" |
||||
tools:text="類型:科幻" /> |
||||
|
||||
</LinearLayout> |
||||
|
||||
<TextView |
||||
android:id="@+id/director" |
||||
android:layout_width="wrap_content" |
||||
android:layout_height="wrap_content" |
||||
android:layout_below="@+id/row" |
||||
android:layout_alignStart="@+id/name" |
||||
android:layout_marginTop="8dp" |
||||
android:layout_marginEnd="24dp" |
||||
android:singleLine="true" |
||||
android:textColor="@color/white" |
||||
android:textSize="16sp" |
||||
tools:text="導演:FongMi" /> |
||||
|
||||
<TextView |
||||
android:id="@+id/actor" |
||||
android:layout_width="wrap_content" |
||||
android:layout_height="wrap_content" |
||||
android:layout_below="@+id/director" |
||||
android:layout_alignStart="@+id/name" |
||||
android:layout_marginTop="8dp" |
||||
android:layout_marginEnd="24dp" |
||||
android:singleLine="true" |
||||
android:textColor="@color/white" |
||||
android:textSize="16sp" |
||||
tools:text="演員:FongMi" /> |
||||
|
||||
<TextView |
||||
android:id="@+id/content" |
||||
android:layout_width="match_parent" |
||||
android:layout_height="wrap_content" |
||||
android:layout_below="@+id/actor" |
||||
android:layout_alignStart="@+id/name" |
||||
android:layout_marginTop="8dp" |
||||
android:layout_marginEnd="24dp" |
||||
android:ellipsize="end" |
||||
android:lineSpacingExtra="4dp" |
||||
android:maxLines="3" |
||||
android:textColor="@color/white" |
||||
android:textSize="16sp" |
||||
tools:text="簡介:" /> |
||||
|
||||
<com.fongmi.android.tv.ui.custom.CustomHorizontalGridView |
||||
android:id="@+id/flag" |
||||
android:layout_width="match_parent" |
||||
android:layout_height="wrap_content" |
||||
android:layout_below="@+id/video" |
||||
android:layout_marginTop="12dp" |
||||
android:clipChildren="false" |
||||
android:clipToPadding="false" |
||||
android:paddingStart="24dp" |
||||
android:paddingTop="12dp" |
||||
android:paddingEnd="24dp" |
||||
android:paddingBottom="8dp" /> |
||||
|
||||
<com.fongmi.android.tv.ui.custom.CustomHorizontalGridView |
||||
android:id="@+id/episode" |
||||
android:layout_width="match_parent" |
||||
android:layout_height="wrap_content" |
||||
android:layout_below="@+id/flag" |
||||
android:clipChildren="false" |
||||
android:clipToPadding="false" |
||||
android:paddingStart="24dp" |
||||
android:paddingTop="8dp" |
||||
android:paddingEnd="24dp" |
||||
android:paddingBottom="8dp" /> |
||||
|
||||
<com.fongmi.android.tv.ui.custom.CustomHorizontalGridView |
||||
android:id="@+id/group" |
||||
android:layout_width="match_parent" |
||||
android:layout_height="wrap_content" |
||||
android:layout_below="@+id/episode" |
||||
android:clipChildren="false" |
||||
android:clipToPadding="false" |
||||
android:paddingStart="24dp" |
||||
android:paddingTop="8dp" |
||||
android:paddingEnd="24dp" |
||||
android:paddingBottom="8dp" |
||||
android:visibility="gone" |
||||
tools:visibility="visible" /> |
||||
|
||||
</com.fongmi.android.tv.ui.custom.ProgressLayout> |
||||
tools:text="簡介:" /> |
||||
|
||||
<com.fongmi.android.tv.ui.custom.CustomHorizontalGridView |
||||
android:id="@+id/flag" |
||||
android:layout_width="match_parent" |
||||
android:layout_height="wrap_content" |
||||
android:layout_below="@+id/video" |
||||
android:layout_marginTop="12dp" |
||||
android:clipChildren="false" |
||||
android:clipToPadding="false" |
||||
android:paddingStart="24dp" |
||||
android:paddingTop="12dp" |
||||
android:paddingEnd="24dp" |
||||
android:paddingBottom="8dp" /> |
||||
|
||||
<com.fongmi.android.tv.ui.custom.CustomHorizontalGridView |
||||
android:id="@+id/episode" |
||||
android:layout_width="match_parent" |
||||
android:layout_height="wrap_content" |
||||
android:layout_below="@+id/flag" |
||||
android:clipChildren="false" |
||||
android:clipToPadding="false" |
||||
android:paddingStart="24dp" |
||||
android:paddingTop="8dp" |
||||
android:paddingEnd="24dp" |
||||
android:paddingBottom="8dp" /> |
||||
|
||||
<com.fongmi.android.tv.ui.custom.CustomHorizontalGridView |
||||
android:id="@+id/group" |
||||
android:layout_width="match_parent" |
||||
android:layout_height="wrap_content" |
||||
android:layout_below="@+id/episode" |
||||
android:clipChildren="false" |
||||
android:clipToPadding="false" |
||||
android:paddingStart="24dp" |
||||
android:paddingTop="8dp" |
||||
android:paddingEnd="24dp" |
||||
android:paddingBottom="8dp" |
||||
android:visibility="gone" |
||||
tools:visibility="visible" /> |
||||
|
||||
<com.fongmi.android.tv.ui.custom.CustomHorizontalGridView |
||||
android:id="@+id/part" |
||||
android:layout_width="match_parent" |
||||
android:layout_height="wrap_content" |
||||
android:layout_below="@+id/group" |
||||
android:layout_marginBottom="8dp" |
||||
android:clipChildren="false" |
||||
android:clipToPadding="false" |
||||
android:paddingStart="24dp" |
||||
android:paddingTop="8dp" |
||||
android:paddingEnd="24dp" |
||||
android:paddingBottom="8dp" /> |
||||
|
||||
</com.fongmi.android.tv.ui.custom.ProgressLayout> |
||||
</androidx.core.widget.NestedScrollView> |
||||
@ -0,0 +1,14 @@ |
||||
<?xml version="1.0" encoding="utf-8"?> |
||||
<TextView xmlns:android="http://schemas.android.com/apk/res/android" |
||||
xmlns:tools="http://schemas.android.com/tools" |
||||
android:id="@+id/text" |
||||
android:layout_width="wrap_content" |
||||
android:layout_height="wrap_content" |
||||
android:background="@drawable/selector_item" |
||||
android:focusable="true" |
||||
android:focusableInTouchMode="true" |
||||
android:gravity="center" |
||||
android:nextFocusUp="@id/group" |
||||
android:textColor="@color/white" |
||||
android:textSize="16sp" |
||||
tools:text="分詞" /> |
||||
@ -0,0 +1,30 @@ |
||||
package com.fongmi.android.tv.bean; |
||||
|
||||
import com.google.gson.Gson; |
||||
import com.google.gson.annotations.SerializedName; |
||||
import com.google.gson.reflect.TypeToken; |
||||
|
||||
import java.lang.reflect.Type; |
||||
import java.util.ArrayList; |
||||
import java.util.List; |
||||
|
||||
public class Part { |
||||
|
||||
@SerializedName("t") |
||||
private String t; |
||||
|
||||
private static List<Part> arrayFrom(String str) { |
||||
Type listType = new TypeToken<ArrayList<Part>>() {}.getType(); |
||||
return new Gson().fromJson(str, listType); |
||||
} |
||||
|
||||
public static List<String> get(String str) { |
||||
List<String> items = new ArrayList<>(); |
||||
for (Part item : arrayFrom(str)) items.add(item.getT()); |
||||
return items; |
||||
} |
||||
|
||||
public String getT() { |
||||
return t; |
||||
} |
||||
} |
||||
Loading…
Reference in new issue