mirror of https://github.com/FongMi/TV.git
parent
9f1a20270c
commit
e0baef51c9
@ -0,0 +1,7 @@ |
||||
package com.fongmi.android.tv.ui.base; |
||||
|
||||
public class ViewType { |
||||
|
||||
public static final int GRID = 0; |
||||
public static final int FOLDER = 1; |
||||
} |
||||
@ -0,0 +1,32 @@ |
||||
package com.fongmi.android.tv.ui.holder; |
||||
|
||||
import android.widget.ImageView; |
||||
|
||||
import androidx.annotation.NonNull; |
||||
import androidx.leanback.widget.Presenter; |
||||
|
||||
import com.fongmi.android.tv.bean.Vod; |
||||
import com.fongmi.android.tv.databinding.AdapterVodFolderBinding; |
||||
import com.fongmi.android.tv.ui.presenter.VodPresenter; |
||||
import com.fongmi.android.tv.utils.ImgUtil; |
||||
|
||||
public class VodFolderHolder extends Presenter.ViewHolder { |
||||
|
||||
private final VodPresenter.OnClickListener listener; |
||||
public final AdapterVodFolderBinding binding; |
||||
|
||||
public VodFolderHolder(@NonNull AdapterVodFolderBinding binding, VodPresenter.OnClickListener listener) { |
||||
super(binding.getRoot()); |
||||
this.binding = binding; |
||||
this.listener = listener; |
||||
} |
||||
|
||||
public void initView(Vod item) { |
||||
binding.name.setText(item.getVodName()); |
||||
binding.remark.setText(item.getVodRemarks()); |
||||
binding.remark.setVisibility(item.getRemarkVisible()); |
||||
binding.getRoot().setOnClickListener(v -> listener.onItemClick(item)); |
||||
binding.getRoot().setOnLongClickListener(v -> listener.onLongClick(item)); |
||||
ImgUtil.load(item.getVodPic(), binding.image, ImageView.ScaleType.FIT_CENTER); |
||||
} |
||||
} |
||||
@ -0,0 +1,34 @@ |
||||
package com.fongmi.android.tv.ui.holder; |
||||
|
||||
import androidx.annotation.NonNull; |
||||
import androidx.leanback.widget.Presenter; |
||||
|
||||
import com.fongmi.android.tv.bean.Vod; |
||||
import com.fongmi.android.tv.databinding.AdapterVodGridBinding; |
||||
import com.fongmi.android.tv.ui.presenter.VodPresenter; |
||||
import com.fongmi.android.tv.utils.ImgUtil; |
||||
|
||||
public class VodGridHolder extends Presenter.ViewHolder { |
||||
|
||||
private final VodPresenter.OnClickListener listener; |
||||
public final AdapterVodGridBinding binding; |
||||
|
||||
public VodGridHolder(@NonNull AdapterVodGridBinding binding, VodPresenter.OnClickListener listener) { |
||||
super(binding.getRoot()); |
||||
this.binding = binding; |
||||
this.listener = listener; |
||||
} |
||||
|
||||
public void initView(Vod item) { |
||||
binding.name.setText(item.getVodName()); |
||||
binding.year.setText(item.getVodYear()); |
||||
binding.site.setText(item.getSiteName()); |
||||
binding.remark.setText(item.getVodRemarks()); |
||||
binding.site.setVisibility(item.getSiteVisible()); |
||||
binding.year.setVisibility(item.getYearVisible()); |
||||
binding.remark.setVisibility(item.getRemarkVisible()); |
||||
binding.getRoot().setOnClickListener(v -> listener.onItemClick(item)); |
||||
binding.getRoot().setOnLongClickListener(v -> listener.onLongClick(item)); |
||||
ImgUtil.load(item.getVodPic(), binding.image); |
||||
} |
||||
} |
||||
@ -0,0 +1,9 @@ |
||||
<?xml version="1.0" encoding="utf-8"?> |
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android" |
||||
android:shape="rectangle"> |
||||
|
||||
<corners android:radius="8dp" /> |
||||
|
||||
<solid android:color="@color/black_20" /> |
||||
|
||||
</shape> |
||||
@ -0,0 +1,55 @@ |
||||
<?xml version="1.0" encoding="utf-8"?> |
||||
<FrameLayout 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:layout_width="match_parent" |
||||
android:layout_height="wrap_content" |
||||
android:background="@drawable/shape_vod_list" |
||||
android:focusable="true" |
||||
android:focusableInTouchMode="true" |
||||
android:foreground="@drawable/selector_vod"> |
||||
|
||||
<LinearLayout |
||||
android:layout_width="match_parent" |
||||
android:layout_height="wrap_content" |
||||
android:gravity="center_vertical" |
||||
android:orientation="horizontal"> |
||||
|
||||
<com.google.android.material.imageview.ShapeableImageView |
||||
android:id="@+id/image" |
||||
android:layout_width="48dp" |
||||
android:layout_height="48dp" |
||||
android:layout_margin="16dp" |
||||
android:scaleType="fitCenter" |
||||
app:shapeAppearanceOverlay="@style/Vod.Grid" |
||||
tools:src="@drawable/ic_img_error" /> |
||||
|
||||
<LinearLayout |
||||
android:layout_width="match_parent" |
||||
android:layout_height="wrap_content" |
||||
android:layout_marginEnd="16dp" |
||||
android:gravity="center_vertical" |
||||
android:orientation="vertical"> |
||||
|
||||
<TextView |
||||
android:id="@+id/name" |
||||
android:layout_width="match_parent" |
||||
android:layout_height="wrap_content" |
||||
android:singleLine="true" |
||||
android:textColor="@color/white" |
||||
android:textSize="16sp" |
||||
tools:text="蜘蛛人" /> |
||||
|
||||
<TextView |
||||
android:id="@+id/remark" |
||||
android:layout_width="match_parent" |
||||
android:layout_height="wrap_content" |
||||
android:layout_marginTop="2dp" |
||||
android:singleLine="true" |
||||
android:textColor="@color/white" |
||||
android:textSize="14sp" |
||||
tools:text="1080p" /> |
||||
|
||||
</LinearLayout> |
||||
</LinearLayout> |
||||
</FrameLayout> |
||||
@ -0,0 +1,82 @@ |
||||
<?xml version="1.0" encoding="utf-8"?> |
||||
<RelativeLayout 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:layout_width="150dp" |
||||
android:layout_height="200dp" |
||||
android:focusable="true" |
||||
android:focusableInTouchMode="true"> |
||||
|
||||
<com.google.android.material.imageview.ShapeableImageView |
||||
android:id="@+id/image" |
||||
android:layout_width="match_parent" |
||||
android:layout_height="match_parent" |
||||
android:background="@color/black_20" |
||||
android:scaleType="center" |
||||
app:shapeAppearanceOverlay="@style/Vod.Grid" |
||||
tools:src="@drawable/ic_img_loading" /> |
||||
|
||||
<TextView |
||||
android:id="@+id/year" |
||||
android:layout_width="wrap_content" |
||||
android:layout_height="wrap_content" |
||||
android:layout_marginTop="8dp" |
||||
android:background="#CC2196F3" |
||||
android:ellipsize="end" |
||||
android:padding="4dp" |
||||
android:singleLine="true" |
||||
android:textColor="@color/white" |
||||
android:textSize="14sp" |
||||
android:visibility="gone" |
||||
tools:text="2022" |
||||
tools:visibility="visible" /> |
||||
|
||||
<TextView |
||||
android:id="@+id/site" |
||||
android:layout_width="wrap_content" |
||||
android:layout_height="wrap_content" |
||||
android:layout_marginTop="8dp" |
||||
android:background="#CCF44336" |
||||
android:ellipsize="end" |
||||
android:padding="4dp" |
||||
android:singleLine="true" |
||||
android:textColor="@color/white" |
||||
android:textSize="14sp" |
||||
android:visibility="gone" |
||||
tools:text="泥巴" |
||||
tools:visibility="visible" /> |
||||
|
||||
<TextView |
||||
android:id="@+id/remark" |
||||
android:layout_width="wrap_content" |
||||
android:layout_height="wrap_content" |
||||
android:layout_above="@+id/name" |
||||
android:background="#CC177535" |
||||
android:ellipsize="end" |
||||
android:padding="4dp" |
||||
android:singleLine="true" |
||||
android:textColor="@color/white" |
||||
android:textSize="14sp" |
||||
tools:text="1080p" /> |
||||
|
||||
<TextView |
||||
android:id="@+id/name" |
||||
android:layout_width="match_parent" |
||||
android:layout_height="wrap_content" |
||||
android:layout_alignParentBottom="true" |
||||
android:background="@drawable/shape_vod_name" |
||||
android:ellipsize="marquee" |
||||
android:gravity="center" |
||||
android:padding="6dp" |
||||
android:singleLine="true" |
||||
android:textColor="@color/white" |
||||
android:textSize="16sp" |
||||
tools:text="蜘蛛人" /> |
||||
|
||||
<View |
||||
android:layout_width="match_parent" |
||||
android:layout_height="match_parent" |
||||
android:background="@drawable/selector_vod" |
||||
android:duplicateParentState="true" /> |
||||
|
||||
</RelativeLayout> |
||||
Loading…
Reference in new issue