From 81a4dd06211ac3a2be1fdfc93edf630a5fc4fc14 Mon Sep 17 00:00:00 2001 From: tibbi Date: Sun, 16 Oct 2016 19:13:05 +0200 Subject: [PATCH] display a photo thumbnail at images --- app/build.gradle | 1 + .../filemanager/adapters/ItemsAdapter.kt | 11 +++++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 0a3bd976..65c40b56 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -38,6 +38,7 @@ dependencies { compile 'com.android.support:appcompat-v7:23.4.0' compile 'com.android.support:design:23.4.0' compile 'com.jakewharton:butterknife:8.0.1' + compile 'com.github.bumptech.glide:glide:3.7.0' compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" apt 'com.jakewharton:butterknife-compiler:8.0.1' 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 05d14122..5ec363a2 100644 --- a/app/src/main/kotlin/com/simplemobiletools/filemanager/adapters/ItemsAdapter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/filemanager/adapters/ItemsAdapter.kt @@ -9,6 +9,8 @@ import android.view.ViewGroup import android.widget.BaseAdapter import android.widget.ImageView import android.widget.TextView +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 @@ -20,10 +22,11 @@ class ItemsAdapter(context: Context, private val mItems: List) : Ba private val mFileBmp: Bitmap private val mDirectoryBmp: Bitmap private val mRes: Resources + private val mContext: Context init { 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) @@ -47,7 +50,11 @@ class ItemsAdapter(context: Context, private val mItems: List) : Ba viewHolder.icon.setImageBitmap(mDirectoryBmp) viewHolder.details.text = getChildrenCnt(item) } else { - viewHolder.icon.setImageBitmap(mFileBmp) + if (item.isImage()) { + Glide.with(mContext).load(item.path).diskCacheStrategy(DiskCacheStrategy.RESULT).centerCrop().crossFade().into(viewHolder.icon) + } else { + viewHolder.icon.setImageBitmap(mFileBmp) + } viewHolder.details.text = item.size.formatSize() }