mirror of https://github.com/FongMi/TV.git
parent
f36e6b569c
commit
1ecff571ff
@ -0,0 +1,16 @@ |
||||
package com.fongmi.android.tv.ui.base; |
||||
|
||||
import android.view.View; |
||||
|
||||
import androidx.leanback.widget.Presenter; |
||||
|
||||
import com.fongmi.android.tv.bean.Vod; |
||||
|
||||
public abstract class BaseVodHolder extends Presenter.ViewHolder { |
||||
|
||||
public BaseVodHolder(View view) { |
||||
super(view); |
||||
} |
||||
|
||||
public abstract void initView(Vod item); |
||||
} |
||||
@ -0,0 +1,29 @@ |
||||
package com.fongmi.android.tv.ui.holder; |
||||
|
||||
import androidx.annotation.NonNull; |
||||
|
||||
import com.fongmi.android.tv.bean.Vod; |
||||
import com.fongmi.android.tv.databinding.AdapterVodFullBinding; |
||||
import com.fongmi.android.tv.ui.base.BaseVodHolder; |
||||
import com.fongmi.android.tv.utils.ImgUtil; |
||||
|
||||
public class VodFullHolder extends BaseVodHolder { |
||||
|
||||
public final AdapterVodFullBinding binding; |
||||
|
||||
public VodFullHolder(@NonNull AdapterVodFullBinding binding) { |
||||
super(binding.getRoot()); |
||||
this.binding = binding; |
||||
} |
||||
|
||||
public VodFullHolder size(int[] size) { |
||||
binding.getRoot().getLayoutParams().width = size[0]; |
||||
binding.getRoot().getLayoutParams().height = size[1]; |
||||
return this; |
||||
} |
||||
|
||||
@Override |
||||
public void initView(Vod item) { |
||||
ImgUtil.load(item.getVodPic(), binding.image); |
||||
} |
||||
} |
||||
@ -0,0 +1,35 @@ |
||||
package com.fongmi.android.tv.ui.holder; |
||||
|
||||
import androidx.annotation.NonNull; |
||||
|
||||
import com.fongmi.android.tv.bean.Vod; |
||||
import com.fongmi.android.tv.databinding.AdapterVodOvalBinding; |
||||
import com.fongmi.android.tv.ui.base.BaseVodHolder; |
||||
import com.fongmi.android.tv.ui.presenter.VodPresenter; |
||||
import com.fongmi.android.tv.utils.ImgUtil; |
||||
|
||||
public class VodOvalHolder extends BaseVodHolder { |
||||
|
||||
private final VodPresenter.OnClickListener listener; |
||||
public final AdapterVodOvalBinding binding; |
||||
|
||||
public VodOvalHolder(@NonNull AdapterVodOvalBinding binding, VodPresenter.OnClickListener listener) { |
||||
super(binding.getRoot()); |
||||
this.binding = binding; |
||||
this.listener = listener; |
||||
} |
||||
|
||||
public VodOvalHolder size(int[] size) { |
||||
binding.image.getLayoutParams().width = size[0]; |
||||
binding.image.getLayoutParams().height = size[1]; |
||||
return this; |
||||
} |
||||
|
||||
@Override |
||||
public void initView(Vod item) { |
||||
binding.name.setText(item.getVodName()); |
||||
binding.getRoot().setOnClickListener(v -> listener.onItemClick(item)); |
||||
binding.getRoot().setOnLongClickListener(v -> listener.onLongClick(item)); |
||||
ImgUtil.load(item.getVodPic(), binding.image); |
||||
} |
||||
} |
||||
@ -0,0 +1,4 @@ |
||||
<?xml version="1.0" encoding="utf-8"?> |
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android"> |
||||
<item android:drawable="@drawable/shape_vod_oval_focused" android:state_focused="true" /> |
||||
</selector> |
||||
@ -0,0 +1,9 @@ |
||||
<?xml version="1.0" encoding="utf-8"?> |
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android" |
||||
android:shape="oval"> |
||||
|
||||
<stroke |
||||
android:width="1.5dp" |
||||
android:color="@color/white" /> |
||||
|
||||
</shape> |
||||
@ -0,0 +1,25 @@ |
||||
<?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="200dp" |
||||
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" /> |
||||
|
||||
<View |
||||
android:layout_width="match_parent" |
||||
android:layout_height="match_parent" |
||||
android:background="@drawable/selector_vod" |
||||
android:duplicateParentState="true" /> |
||||
|
||||
</RelativeLayout> |
||||
@ -0,0 +1,45 @@ |
||||
<?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="wrap_content" |
||||
android:layout_height="wrap_content" |
||||
android:focusable="true" |
||||
android:focusableInTouchMode="true"> |
||||
|
||||
<com.google.android.material.imageview.ShapeableImageView |
||||
android:id="@+id/image" |
||||
android:layout_width="wrap_content" |
||||
android:layout_height="wrap_content" |
||||
android:background="@color/black_20" |
||||
android:scaleType="center" |
||||
app:shapeAppearanceOverlay="@style/Vod.Circle" |
||||
tools:src="@drawable/ic_img_loading" /> |
||||
|
||||
<TextView |
||||
android:id="@+id/name" |
||||
android:layout_width="wrap_content" |
||||
android:layout_height="wrap_content" |
||||
android:layout_below="@+id/image" |
||||
android:layout_alignStart="@+id/image" |
||||
android:layout_alignEnd="@+id/image" |
||||
android:layout_marginTop="12dp" |
||||
android:ellipsize="marquee" |
||||
android:gravity="center" |
||||
android:singleLine="true" |
||||
android:textColor="@color/white" |
||||
android:textSize="16sp" |
||||
tools:text="蜘蛛人" /> |
||||
|
||||
<FrameLayout |
||||
android:id="@+id/frame" |
||||
android:layout_width="wrap_content" |
||||
android:layout_height="wrap_content" |
||||
android:layout_alignStart="@+id/image" |
||||
android:layout_alignTop="@+id/image" |
||||
android:layout_alignEnd="@+id/image" |
||||
android:layout_alignBottom="@+id/image" |
||||
android:background="@drawable/selector_vod_oval" |
||||
android:duplicateParentState="true" /> |
||||
|
||||
</RelativeLayout> |
||||
Loading…
Reference in new issue