79 lines
2.5 KiB
Java
79 lines
2.5 KiB
Java
package com.xxpatx.os.adapter;
|
|
|
|
import android.content.ComponentName;
|
|
import android.content.Context;
|
|
import android.content.Intent;
|
|
import android.util.Log;
|
|
import android.view.LayoutInflater;
|
|
import android.view.View;
|
|
import android.view.ViewGroup;
|
|
|
|
import androidx.annotation.NonNull;
|
|
import androidx.recyclerview.widget.RecyclerView;
|
|
|
|
import com.bumptech.glide.Glide;
|
|
import com.shehuan.niv.NiceImageView;
|
|
import com.uiui.video.bean.VideoInfo;
|
|
import com.xxpatx.os.R;
|
|
|
|
import java.util.ArrayList;
|
|
|
|
public class LivenVideoAdapter extends RecyclerView.Adapter<LivenVideoAdapter.LivenVideoHolder> {
|
|
private static final String TAG = "LivenVideoAdapter";
|
|
|
|
private Context mContext;
|
|
private ArrayList<VideoInfo> mLivenVideoList;
|
|
|
|
public void setLivenVideoList(ArrayList<VideoInfo> livenVideoList) {
|
|
mLivenVideoList = livenVideoList;
|
|
notifyDataSetChanged();
|
|
}
|
|
|
|
@NonNull
|
|
@Override
|
|
public LivenVideoHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
|
mContext = parent.getContext();
|
|
return new LivenVideoAdapter.LivenVideoHolder(LayoutInflater.from(mContext).inflate(R.layout.item_liven_video, parent, false));
|
|
}
|
|
|
|
|
|
@Override
|
|
public void onBindViewHolder(@NonNull LivenVideoHolder holder, int position) {
|
|
VideoInfo videoInfo = mLivenVideoList.get(position);
|
|
Glide.with(holder.iv_cover).load(videoInfo.getVideo_cover()).into(holder.iv_cover);
|
|
holder.iv_cover.setOnClickListener(new View.OnClickListener() {
|
|
|
|
@Override
|
|
public void onClick(View v) {
|
|
Intent intent = new Intent(Intent.ACTION_MAIN);
|
|
intent.setComponent(new ComponentName("com.uiui.video", "com.uiui.video.activity.main.OldMainActivity"));
|
|
intent.putExtra("position", position);
|
|
intent.putExtra("switchId", 0);
|
|
intent.putParcelableArrayListExtra("list", mLivenVideoList);
|
|
try {
|
|
mContext.startActivity(intent);
|
|
} catch (Exception e) {
|
|
Log.e(TAG, "onClick: " + e.getMessage());
|
|
}
|
|
}
|
|
});
|
|
}
|
|
|
|
|
|
@Override
|
|
public int getItemCount() {
|
|
return mLivenVideoList == null ? 0 : mLivenVideoList.size();
|
|
}
|
|
|
|
class LivenVideoHolder extends RecyclerView.ViewHolder {
|
|
|
|
NiceImageView iv_cover;
|
|
|
|
public LivenVideoHolder(@NonNull View itemView) {
|
|
super(itemView);
|
|
iv_cover = itemView.findViewById(R.id.iv_cover);
|
|
}
|
|
}
|
|
|
|
}
|