| | |
| | | |
| | | 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; |
| | |
| | | protected void onBind(BaseViewHolder<ItemElectronicFileBinding> holder, int position) { |
| | | String item = mDataList.get(position); |
| | | if (item != null) { |
| | | if (item.endsWith(".pdf")) { |
| | | holder.getBinding().ivImage.setImageResource(R.drawable.ic_pdf); |
| | | } else if (item.endsWith(".zip") || item.endsWith(".aar") || item.endsWith(".7z")) { |
| | | holder.getBinding().ivImage.setImageResource(R.drawable.ic_zip); |
| | | } else if (item.endsWith(".doc") || item.endsWith(".docx")) { |
| | | holder.getBinding().ivImage.setImageResource(R.drawable.ic_word); |
| | | } else if (item.endsWith(".xls") || item.endsWith(".xlsx")) { |
| | | holder.getBinding().ivImage.setImageResource(R.drawable.ic_excel); |
| | | } else if (item.endsWith(".ppt") || item.endsWith(".pptx")) { |
| | | holder.getBinding().ivImage.setImageResource(R.drawable.ic_ppt); |
| | | } else if (item.endsWith(".txt")) { |
| | | holder.getBinding().ivImage.setImageResource(R.drawable.ic_txt); |
| | | } else if (item.endsWith(".jpg") || item.endsWith(".jpeg") || item.endsWith(".png") || item.endsWith(".gif")) { |
| | | holder.getBinding().ivImage.setImageResource(R.drawable.ic_img); |
| | | } else if (item.endsWith(".mp4")) { |
| | | holder.getBinding().ivImage.setImageResource(R.drawable.ic_video); |
| | | } else if (item.endsWith(".mp3") || item.endsWith(".m4a")) { |
| | | holder.getBinding().ivImage.setImageResource(R.drawable.ic_audio); |
| | | 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 { |
| | | holder.getBinding().ivImage.setImageResource(R.drawable.ic_others); |
| | | resid = R.attr.icOther; |
| | | } |
| | | TypedValue typedValue = new TypedValue(); |
| | | mContext.getTheme().resolveAttribute(resid, typedValue, true); |
| | | holder.getBinding().ivImage.setImageResource(typedValue.resourceId); |
| | | } |
| | | } |
| | | |