94 lines
2.3 KiB
Java
94 lines
2.3 KiB
Java
package com.keypalette.theme;
|
|
|
|
|
|
import android.content.Context;
|
|
import android.content.Intent;
|
|
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.keypalette.theme.activity.PageApply;
|
|
import com.keypalette.theme.dataabout.resource.Data;
|
|
import com.keypalette.theme.databinding.AdapterChildBinding;
|
|
import com.keypalette.theme.other.Helper;
|
|
|
|
import java.util.List;
|
|
|
|
public class ChildAdapter extends RecyclerView.Adapter<ChildAdapter.ChildViewHolder> {
|
|
|
|
private Context mContext;
|
|
private List<Data> mList;
|
|
|
|
public ChildAdapter(Context context, List<Data> list) {
|
|
mContext = context;
|
|
this.mList = list;
|
|
}
|
|
|
|
|
|
|
|
|
|
@NonNull
|
|
@Override
|
|
public ChildViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
|
AdapterChildBinding inflate = AdapterChildBinding.inflate(LayoutInflater.from(parent.getContext()));
|
|
|
|
|
|
return new ChildViewHolder(inflate);
|
|
}
|
|
|
|
@Override
|
|
public void onBindViewHolder(@NonNull ChildViewHolder holder, int position) {
|
|
Data data = mList.get(position);
|
|
|
|
|
|
String thumbGif = data.getThumbGif();
|
|
String thumb = data.getThumbUrl();
|
|
if (!thumbGif.isEmpty()) {
|
|
Helper.INSTANCE.loadWepJif(mContext, thumbGif, holder.binding.imageView);
|
|
} else {
|
|
Glide.with(mContext).load(thumb)
|
|
.placeholder(R.drawable.default_placeholder)
|
|
.into(holder.binding.imageView);
|
|
}
|
|
|
|
|
|
holder.binding.imageView.setOnClickListener(new View.OnClickListener() {
|
|
@Override
|
|
public void onClick(View v) {
|
|
Intent intentApply = new Intent(mContext, PageApply.class);
|
|
intentApply.putExtra(PageApply.SOURCE_KEY, data);
|
|
mContext.startActivity(intentApply);
|
|
|
|
|
|
}
|
|
});
|
|
|
|
|
|
}
|
|
|
|
@Override
|
|
public int getItemCount() {
|
|
return mList.size();
|
|
}
|
|
|
|
public static class ChildViewHolder extends RecyclerView.ViewHolder {
|
|
|
|
private AdapterChildBinding binding;
|
|
|
|
|
|
public ChildViewHolder(@NonNull AdapterChildBinding itemView) {
|
|
super(itemView.getRoot());
|
|
binding = itemView;
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
}
|