use glide for loading app icons with placeholders
This commit is contained in:
parent
df2f816102
commit
3a64c8ede4
|
@ -1,12 +1,15 @@
|
||||||
package com.simplemobiletools.launcher.adapters
|
package com.simplemobiletools.launcher.adapters
|
||||||
|
|
||||||
import android.graphics.drawable.ColorDrawable
|
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import android.view.ViewTreeObserver
|
import android.view.ViewTreeObserver
|
||||||
import androidx.recyclerview.widget.RecyclerView
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
|
import com.bumptech.glide.Glide
|
||||||
|
import com.bumptech.glide.load.resource.drawable.DrawableTransitionOptions
|
||||||
|
import com.bumptech.glide.request.transition.DrawableCrossFadeFactory
|
||||||
import com.qtalk.recyclerviewfastscroller.RecyclerViewFastScroller
|
import com.qtalk.recyclerviewfastscroller.RecyclerViewFastScroller
|
||||||
|
import com.simplemobiletools.commons.extensions.getColoredDrawableWithColor
|
||||||
import com.simplemobiletools.commons.extensions.getProperTextColor
|
import com.simplemobiletools.commons.extensions.getProperTextColor
|
||||||
import com.simplemobiletools.commons.extensions.portrait
|
import com.simplemobiletools.commons.extensions.portrait
|
||||||
import com.simplemobiletools.commons.extensions.realScreenSize
|
import com.simplemobiletools.commons.extensions.realScreenSize
|
||||||
|
@ -62,9 +65,14 @@ class LaunchersAdapter(
|
||||||
launcher_label.setTextColor(textColor)
|
launcher_label.setTextColor(textColor)
|
||||||
launcher_icon.setPadding(iconPadding, iconPadding, iconPadding, 0)
|
launcher_icon.setPadding(iconPadding, iconPadding, iconPadding, 0)
|
||||||
|
|
||||||
if (launcher.drawable != null) {
|
val factory = DrawableCrossFadeFactory.Builder(150).setCrossFadeEnabled(true).build()
|
||||||
launcher_icon.setImageDrawable(launcher.drawable!!)
|
val placeholderDrawable = activity.resources.getColoredDrawableWithColor(R.drawable.placeholder_drawable, launcher.thumbnailColor)
|
||||||
}
|
|
||||||
|
Glide.with(activity)
|
||||||
|
.load(launcher.drawable)
|
||||||
|
.placeholder(placeholderDrawable)
|
||||||
|
.transition(DrawableTransitionOptions.withCrossFade(factory))
|
||||||
|
.into(launcher_icon)
|
||||||
|
|
||||||
setOnClickListener { itemClick(launcher) }
|
setOnClickListener { itemClick(launcher) }
|
||||||
setOnLongClickListener { view ->
|
setOnLongClickListener { view ->
|
||||||
|
|
|
@ -0,0 +1,9 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:shape="oval">
|
||||||
|
<size
|
||||||
|
android:width="@dimen/launcher_icon_size"
|
||||||
|
android:height="@dimen/launcher_icon_size" />
|
||||||
|
|
||||||
|
<solid android:color="@color/md_grey_white" />
|
||||||
|
</shape>
|
Loading…
Reference in New Issue