From 590c1cff46b105d774271f950caa9f65523f05c1 Mon Sep 17 00:00:00 2001 From: Linjiajia <319408893@qq.com> Date: 星期五, 29 十二月 2023 20:20:40 +0800 Subject: [PATCH] 1、增加护眼模式主题\n2、修复显示问题 --- app/src/main/java/com/application/zhangshi_app_android/adapter/ElectronicFileAdapter.java | 43 ++++++++++++++++++++++++------------------- 1 files changed, 24 insertions(+), 19 deletions(-) diff --git a/app/src/main/java/com/application/zhangshi_app_android/adapter/ElectronicFileAdapter.java b/app/src/main/java/com/application/zhangshi_app_android/adapter/ElectronicFileAdapter.java index bffa07a..b7e0147 100644 --- a/app/src/main/java/com/application/zhangshi_app_android/adapter/ElectronicFileAdapter.java +++ b/app/src/main/java/com/application/zhangshi_app_android/adapter/ElectronicFileAdapter.java @@ -2,6 +2,7 @@ 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; @@ -29,27 +30,31 @@ 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); } } -- Gitblit v1.9.1