From 895ca435026de96d6064cdb974025bc42094bbbe Mon Sep 17 00:00:00 2001 From: tibbi Date: Fri, 28 Oct 2016 23:51:27 +0200 Subject: [PATCH] let Glide handle filetype and icon, to improve the scroll performance --- .../filemanager/adapters/ItemsAdapter.kt | 14 ++------------ app/src/main/res/mipmap-hdpi/directory.png | Bin 135 -> 265 bytes app/src/main/res/mipmap-hdpi/file.png | Bin 153 -> 311 bytes app/src/main/res/mipmap-mdpi/directory.png | Bin 122 -> 209 bytes app/src/main/res/mipmap-mdpi/file.png | Bin 133 -> 217 bytes app/src/main/res/mipmap-xhdpi/directory.png | Bin 181 -> 317 bytes app/src/main/res/mipmap-xhdpi/file.png | Bin 206 -> 355 bytes app/src/main/res/mipmap-xxhdpi/directory.png | Bin 245 -> 486 bytes app/src/main/res/mipmap-xxhdpi/file.png | Bin 283 -> 584 bytes app/src/main/res/mipmap-xxxhdpi/directory.png | Bin 325 -> 427 bytes app/src/main/res/mipmap-xxxhdpi/file.png | Bin 372 -> 452 bytes 11 files changed, 2 insertions(+), 12 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/filemanager/adapters/ItemsAdapter.kt b/app/src/main/kotlin/com/simplemobiletools/filemanager/adapters/ItemsAdapter.kt index ee75ffb7..7a6fe922 100644 --- a/app/src/main/kotlin/com/simplemobiletools/filemanager/adapters/ItemsAdapter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/filemanager/adapters/ItemsAdapter.kt @@ -2,7 +2,6 @@ package com.simplemobiletools.filemanager.adapters import android.content.Context import android.content.res.Resources -import android.graphics.Bitmap import android.view.LayoutInflater import android.view.View import android.view.ViewGroup @@ -13,14 +12,11 @@ import com.bumptech.glide.Glide import com.bumptech.glide.load.engine.DiskCacheStrategy import com.simplemobiletools.filemanager.R import com.simplemobiletools.filemanager.extensions.formatSize -import com.simplemobiletools.filemanager.extensions.getColoredIcon import com.simplemobiletools.filepicker.models.FileDirItem import kotlinx.android.synthetic.main.list_item.view.* class ItemsAdapter(context: Context, private val mItems: List) : BaseAdapter() { private val mInflater: LayoutInflater - private val mFileBmp: Bitmap - private val mDirectoryBmp: Bitmap private val mRes: Resources private val mContext: Context @@ -28,8 +24,6 @@ class ItemsAdapter(context: Context, private val mItems: List) : Ba mInflater = context.getSystemService(Context.LAYOUT_INFLATER_SERVICE) as LayoutInflater mContext = context mRes = context.resources - mDirectoryBmp = mRes.getColoredIcon(R.color.lightGrey, R.mipmap.directory) - mFileBmp = mRes.getColoredIcon(R.color.lightGrey, R.mipmap.file) } override fun getView(position: Int, convertView: View?, parent: ViewGroup): View { @@ -47,14 +41,10 @@ class ItemsAdapter(context: Context, private val mItems: List) : Ba viewHolder.name.text = item.name if (item.isDirectory) { - viewHolder.icon.setImageBitmap(mDirectoryBmp) + Glide.with(mContext).load(R.mipmap.directory).diskCacheStrategy(getCacheStrategy(item)).centerCrop().crossFade().into(viewHolder.icon) viewHolder.details.text = getChildrenCnt(item) } else { - if (item.isImage() || item.isVideo()) { - Glide.with(mContext).load(item.path).diskCacheStrategy(getCacheStrategy(item)).centerCrop().crossFade().into(viewHolder.icon) - } else { - viewHolder.icon.setImageBitmap(mFileBmp) - } + Glide.with(mContext).load(item.path).diskCacheStrategy(getCacheStrategy(item)).error(R.mipmap.file).centerCrop().crossFade().into(viewHolder.icon) viewHolder.details.text = item.size.formatSize() } diff --git a/app/src/main/res/mipmap-hdpi/directory.png b/app/src/main/res/mipmap-hdpi/directory.png index 02ea533a8d662e512843bf218e372653e95d843b..e03b652db9cb202a928877775bf46a198cd3f44e 100644 GIT binary patch delta 248 zcmVT8Gi-<007|tn3wP6o+(MxK<`RTvm{1543Q@dJs#|)I;yaWb6AEEMA&M7r860LcwNM8P y>0B7bnqTyTzDFeY#2=>vp2(XzWfKfz&@zNm2K+vNg1PKx(C>$D3PFtaT`N)wWnfka1 X&s)j;)peX!00000NkvXXu0mjfoaZgt diff --git a/app/src/main/res/mipmap-hdpi/file.png b/app/src/main/res/mipmap-hdpi/file.png index 84755e48817d86d61d09e70489b6c94b5c1f4d38..eb356c2211f693f980896a44298c4120a33fd3eb 100644 GIT binary patch delta 295 zcmV+?0oeYT0k;B>8Gi-<007|tn3wyO90&A?5{7Jh$ zbz&i;Nr{YA*LnW11N zNMgTQq1*sxwlwT$@SI9?A;MP}Q6p4%{KrhF;z+2nh_3R8teA+ZxQM9OD6Q~9QqjL6 qQAHJ1G&{Pbr}@!=&NtX>X&-}3|Lp(a)PBG+aFyL{W z@8y0__{B5EJ^xd8z0k4H(Br!mq$RdUSFhGvnB%{oM&p_LB7S!nbQj2_xhG8G(pvtG z`60vCuX;j_yAMA2ntzj#_Y6a7i-SCC$udtxgGoy)nY_h1SPb`N1Wahr5#apRvD57I r-eua)kFLpk{HcI9N50r-q6I^<4v*I!M;>3Gdl)=j{an^LB{Ts5OG!j_ delta 103 zcmV-t0GR*L0eX-bVFUmG07`!Ka{vGUK}keGR5;6HU>GLgf8hU@|B*ohAq}X?32XUJ z40!e5pEM2s|Gy+v!~anYLteuxqSU`YXz<69UNMya_Z=?T833hePg@{T$NK;P002ov JPDHLkV1kZXD{cS) diff --git a/app/src/main/res/mipmap-mdpi/file.png b/app/src/main/res/mipmap-mdpi/file.png index b51ce3ed95a437af48d672cb4b8494807587c080..47495956936e088bf49b4b9c069bc5b2f850b448 100644 GIT binary patch delta 200 zcmZo=yvaC0vYw5Bf#E^9?GGTuS>O>_%)r1c48n{Iv*t(u1-m_6978-h-(Iy9axf5R zdw4xQvu%>oOQv`Af^*xrGcIIYlJK6k)8KNJ*d z?e;LmeP)(t6>G2D9rv=|jPd0`Jp00i_>zopr0I8`> AXaE2J delta 115 zcmcb~*vdFTGKYnMfx)ZpYcY`W@pN$vu{izq{6#6)6_FZ?vxhE-16}&DbansRY Txt#n(pt%g5u6{1-oD!M<)=?|L diff --git a/app/src/main/res/mipmap-xhdpi/directory.png b/app/src/main/res/mipmap-xhdpi/directory.png index 71a5a137c463dfd97dfad592c86b7eac773664c5..103d5baa0e15607ec63167960118b9981fb90525 100644 GIT binary patch delta 301 zcmV+|0n+}p0lfl{8Gi-<00374`G)`i010qNS#tmY3ljhU3ljkVnw%H_008evL_t(& zf$iAM3W7iwM&VOdNFcOt(XxH_e=V)D*8MCB6k6C1jU%O&UsLb15k`>jC?g_>h{!+d zRjkLr6i9%m<~7&Arp-`w_=bytIWPwL4X&A7j)$g0)!_@6QGX2IMrRRK0Zs0_tCI-d z9#~YYTgibvkOD{du_69|d|tSP{n0<0;(nlB*le2UkVX7dH?I~b&?(rmtf6v#e5OKlmj zauhQLCYsX+aX7g&`Q? zno2YVRXyR|1-z5gq&v%$Ql}_rn7FI7&gTp~XCtV1&qB~cQi2tq7CJ%<*zjwN5Uv2U zsew5)z!!mCfB-Xq009C7yaP+>N569g>MIZ!-R67p*xxSDG9BBGLmi!0>c<_7iZ@Zq S(|`*A0000GN#hJ%}@xLyo6zfg5$KC zjxcTnOo0UG1@4&vd0>t^l43@{92f&#g*}todQiwE5|~jGuYZY}gruWMeTazc<$D68 zp-CkZm>@qZRV;7ob3=kBArVN?5y*KIswVMk0Z^8(5CBC9D*;fFuoM6V32OlelxTtg z1W0H+4YbH9zw9b$k^q!TRML-BNEwS5Nt-r-k8uHOT)>)E2x#2G(P+g48jTBB;{w*W zfHf{)jSE=g0!-FO1TN95c+a^mKq9bHDCArAbpaBA4T4TY-~_Def+YV&Prw!!0t4co ln={4KSHLmyUXJtkTmiE1E=oQ4<#+%9002ovPDHLkV1nTDg4_TA delta 189 zcmV;u07C!c0?q-D8Gi%-008|9F$@3z0F_BZK~z}7?bbmGgHQ~F;ddI#yQK#zDD_^7 z)urupsk@Ja!l r4OGnZ{D{W$omLFQp%!$md3AX|=!NWvut4xc00000NkvXXu0mjfr#wh^ diff --git a/app/src/main/res/mipmap-xxhdpi/directory.png b/app/src/main/res/mipmap-xxhdpi/directory.png index b93d5a1e4a48fb9cddfa530aacfc84e5ea4ad9c9..89a7ae643cbbe2c7e77a64fcbec52e1093481ba3 100644 GIT binary patch literal 486 zcmeAS@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YkJsxB_y0|P(e~!Q{;o-~TkGWiKgub+xHJFl gqz(|cx80uUhj#ADue+Wza04y!boFyt=akR{05brifB*mh delta 299 zcmZ3@e3WT|ay=uDr;B4q#jUru&iWp95O8>S$3vf^Rp>I4SCej606DALEyLG_YxkTKihKK9$vQz+_5e9@5lIvuvn&ko%M2! zw^`fOnH$;vt+HZ?TbRj|f5D`2VvH|ONzS8&&K}XKYr4$!41J1DNem@xnY|w9Enz#b zu=GHs+=qEm2HW@?8W=D`wK;Y@>=d#Wzp$Py_L3)+| diff --git a/app/src/main/res/mipmap-xxxhdpi/file.png b/app/src/main/res/mipmap-xxxhdpi/file.png index 5bd56903d032fc7e43b8067aea0728ccefd67161..0f6f656843a9892f5ad24f88ecb0af0d8016c6f7 100644 GIT binary patch delta 427 zcmeyubcA_=ayvz~dpzWc)ru`xf?j?B+tBy2D7yRE`5-#TA z^lnC9M}F@f#Q%bkbzr@MJD%az7I{b8W=MUp%6@2>sspPw-9Fl2i3 zTA-@AE5J$re2BsiCM|(IjL%r=8w?eh61+MXC4?3+q_tQy2r3FCICZc}2rObe+EU@5 zxRBLBa3QY)<3iE;12LYz|Zodu45>Hn@mvv4FO#r9U Bq5c2> delta 346 zcmX@Y{DoNg1%1TPVT&=E74ZF2sd*sm{&UZ5cLX7|aVL$pz^+nLf zpBz?vHuJce^rlR0U$A_|PFI$_N8a4GUD>vvRAfPiz=zkrn5GESCo!_NWHihb;5QI9 zVhD5MJK%AG=>|t7gRtZJN(OF4@dSkw=1ZJE8&aB>CwP5e5aQHxkUGdNq5g&WUQL7H zp?QpTLf`m4%>9th@Uwt{fuV66 l1jc5stUU2nSnwjtF9yNq{T?#uyJv$8^>p=fS?83{1OV)riSqye