package com.colorful.keyboard.theme.config_adpter;

import android.content.Context;
import android.view.ViewGroup;
import android.widget.ImageView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.bumptech.glide.Glide;
import com.chad.library.adapter4.BaseQuickAdapter;
import com.chad.library.adapter4.viewholder.QuickViewHolder;
import com.colorful.keyboard.theme.App;
import com.colorful.keyboard.theme.R;
import com.colorful.keyboard.theme.model.ThemePhotoListBean;

public class PhotoListAdapter extends BaseQuickAdapter<ThemePhotoListBean.DataBean.SectionsBean.ItemsBean, QuickViewHolder> {

    @Override
    protected void onBindViewHolder(@NonNull QuickViewHolder quickViewHolder, int i, @Nullable ThemePhotoListBean.DataBean.SectionsBean.ItemsBean itemsBean) {
        ImageView imageView = quickViewHolder.getView(R.id.iv_photo);

        String url = itemsBean.getThumbUrlGif();
        if(url.isEmpty()){
            url = itemsBean.getThumbUrl();
        }

        Glide.with(App.Companion.getApp())
                .load(url)
                .placeholder(R.drawable.placeholder)
                .into(imageView);
    }

    @NonNull
    @Override
    protected QuickViewHolder onCreateViewHolder(@NonNull Context context, @NonNull ViewGroup viewGroup, int i) {
        return new QuickViewHolder(R.layout.item_info, viewGroup);
    }
}
