mirror of https://github.com/FongMi/TV.git
commit
8ba0e3b0f2
@ -0,0 +1,64 @@ |
||||
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.bean.Vod; |
||||
import com.fongmi.android.tv.databinding.AdapterSearchBinding; |
||||
import com.fongmi.android.tv.utils.ResUtil; |
||||
|
||||
public class SearchPresenter extends Presenter { |
||||
|
||||
private final OnClickListener mListener; |
||||
private int width; |
||||
|
||||
public SearchPresenter(OnClickListener listener) { |
||||
this.mListener = listener; |
||||
setLayoutSize(); |
||||
} |
||||
|
||||
private void setLayoutSize() { |
||||
int space = ResUtil.dp2px(24) + ResUtil.dp2px(8 * 5); |
||||
int base = ResUtil.getScreenWidthPx() - space; |
||||
width = base / 5; |
||||
} |
||||
|
||||
public interface OnClickListener { |
||||
|
||||
void onItemClick(Vod item); |
||||
} |
||||
|
||||
@Override |
||||
public Presenter.ViewHolder onCreateViewHolder(ViewGroup parent) { |
||||
ViewHolder holder = new ViewHolder(AdapterSearchBinding.inflate(LayoutInflater.from(parent.getContext()), parent, false)); |
||||
holder.binding.getRoot().getLayoutParams().width = width; |
||||
return holder; |
||||
} |
||||
|
||||
@Override |
||||
public void onBindViewHolder(Presenter.ViewHolder viewHolder, Object object) { |
||||
Vod item = (Vod) object; |
||||
ViewHolder holder = (ViewHolder) viewHolder; |
||||
holder.binding.name.setText(item.getVodName()); |
||||
holder.binding.site.setText(item.getSiteName()); |
||||
holder.binding.remark.setText(item.getVodRemarks()); |
||||
setOnClickListener(holder, view -> mListener.onItemClick(item)); |
||||
} |
||||
|
||||
@Override |
||||
public void onUnbindViewHolder(Presenter.ViewHolder viewHolder) { |
||||
} |
||||
|
||||
public static class ViewHolder extends Presenter.ViewHolder { |
||||
|
||||
private final AdapterSearchBinding binding; |
||||
|
||||
public ViewHolder(@NonNull AdapterSearchBinding binding) { |
||||
super(binding.getRoot()); |
||||
this.binding = binding; |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,42 @@ |
||||
<?xml version="1.0" encoding="utf-8"?> |
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" |
||||
xmlns:tools="http://schemas.android.com/tools" |
||||
android:layout_width="150dp" |
||||
android:layout_height="wrap_content" |
||||
android:background="@drawable/selector_item" |
||||
android:focusable="true" |
||||
android:focusableInTouchMode="true" |
||||
android:nextFocusUp="@id/part" |
||||
android:orientation="vertical"> |
||||
|
||||
<TextView |
||||
android:id="@+id/name" |
||||
android:layout_width="wrap_content" |
||||
android:layout_height="wrap_content" |
||||
android:singleLine="true" |
||||
android:textColor="@color/white" |
||||
android:textSize="16sp" |
||||
tools:text="蜘蛛人" /> |
||||
|
||||
<TextView |
||||
android:id="@+id/site" |
||||
android:layout_width="wrap_content" |
||||
android:layout_height="wrap_content" |
||||
android:layout_marginTop="2dp" |
||||
android:singleLine="true" |
||||
android:textColor="@color/green_a_400" |
||||
android:textSize="14sp" |
||||
tools:text="泥巴" |
||||
tools:visibility="visible" /> |
||||
|
||||
<TextView |
||||
android:id="@+id/remark" |
||||
android:layout_width="wrap_content" |
||||
android:layout_height="wrap_content" |
||||
android:layout_marginTop="2dp" |
||||
android:singleLine="true" |
||||
android:textColor="@color/yellow_500" |
||||
android:textSize="14sp" |
||||
tools:text="1080p" /> |
||||
|
||||
</LinearLayout> |
||||
@ -0,0 +1,18 @@ |
||||
package com.fongmi.android.tv; |
||||
|
||||
public class Constant { |
||||
|
||||
public static final String PROXY = "https://ghproxy.com/"; |
||||
public static final String REPO = "https://raw.githubusercontent.com/FongMi/TV/"; |
||||
public static final String RELEASE = "release"; |
||||
public static final String KITKAT = "kitkat"; |
||||
public static final String DEV = "dev"; |
||||
|
||||
public static String getReleasePath(String path) { |
||||
return PROXY + REPO + RELEASE + path; |
||||
} |
||||
|
||||
public static String getBranchPath(String branch, String path) { |
||||
return PROXY + REPO + branch + path; |
||||
} |
||||
} |
||||
Loading…
Reference in new issue