display a photo thumbnail at images

This commit is contained in:
tibbi 2016-10-16 19:13:05 +02:00
parent 4b80fbd26b
commit 81a4dd0621
2 changed files with 10 additions and 2 deletions

View File

@ -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'

View File

@ -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<FileDirItem>) : 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<FileDirItem>) : 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()
}