package com.application.zhangshi_app_android.adapter;
|
|
import android.content.Context;
|
import android.content.pm.ActivityInfo;
|
import android.util.TypedValue;
|
import android.view.View;
|
|
import com.android.app_base.base.adapter.BaseRVAdapter;
|
import com.application.zhangshi_app_android.R;
|
import com.application.zhangshi_app_android.databinding.ItemElectronicFileBinding;
|
import com.application.zhangshi_app_android.ui.ImagePreviewActivity;
|
import com.application.zhangshi_app_android.ui.VideoPlayActivity;
|
|
/**
|
* @author Ljj
|
* @date 2023.05.15. 21:46
|
* @desc 卡片里的 电子文件 适配器
|
*/
|
public class ElectronicFileAdapter extends BaseRVAdapter<String,ItemElectronicFileBinding,BaseRVAdapter.BaseViewHolder<ItemElectronicFileBinding>> {
|
public ElectronicFileAdapter(Context context) {
|
super(context);
|
}
|
|
@Override
|
protected int getLayoutId() {
|
return R.layout.item_electronic_file;
|
}
|
|
@Override
|
protected void onBind(BaseViewHolder<ItemElectronicFileBinding> holder, int position) {
|
String item = mDataList.get(position);
|
if (item != null) {
|
int resid;
|
if (item.endsWith(".pdf") || item.endsWith(".PDF")) {
|
resid = R.attr.icPdf;
|
} else if (item.endsWith(".zip") || item.endsWith(".ZIP") || item.endsWith(".aar") || item.endsWith(".AAR") || item.endsWith(".7z")) {
|
resid = R.attr.icZip;
|
} else if (item.endsWith(".doc") || item.endsWith(".docx") || item.endsWith(".DOC") || item.endsWith(".DOCX") || item.endsWith(".wps") || item.endsWith(".WPS")) {
|
resid = R.attr.icWord;
|
} else if (item.endsWith(".xls") || item.endsWith(".xlsx") || item.endsWith(".XLS") || item.endsWith(".XLSX")) {
|
resid = R.attr.icExcel;
|
} else if (item.endsWith(".ppt") || item.endsWith(".PPT") || item.endsWith(".pptx") || item.endsWith(".PPTX")) {
|
resid = R.attr.icPpt;
|
} else if (item.endsWith(".txt") || item.endsWith(".TXT")) {
|
resid = R.attr.icTxt;
|
} else if (item.endsWith(".jpg") || item.endsWith(".JPG") || item.endsWith(".jpeg") || item.endsWith(".JPEG") || item.endsWith(".png") || item.endsWith(".PNG") || item.endsWith(".gif") || item.endsWith(".GIF") || item.endsWith(".bmp") || item.endsWith(".BMP")) {
|
resid = R.attr.icImage;
|
} else if (item.endsWith(".mp4") || item.endsWith(".MP4") ) {
|
resid = R.attr.icVideo;
|
} else if (item.endsWith(".mp3") || item.endsWith(".m4a") || item.endsWith(".MP3") || item.endsWith(".M4A")) {
|
resid = R.attr.icAudio;
|
} else {
|
resid = R.attr.icOther;
|
}
|
TypedValue typedValue = new TypedValue();
|
mContext.getTheme().resolveAttribute(resid, typedValue, true);
|
holder.getBinding().ivImage.setImageResource(typedValue.resourceId);
|
}
|
}
|
|
@Override
|
protected BaseViewHolder<ItemElectronicFileBinding> getViewHolder(ItemElectronicFileBinding itemBind, int viewType) {
|
return new BaseViewHolder<>(itemBind);
|
}
|
}
|