|
|
@ -22,12 +22,16 @@ import androidx.core.graphics.drawable.toBitmap |
|
|
import androidx.core.graphics.drawable.toDrawable |
|
|
import androidx.core.graphics.drawable.toDrawable |
|
|
import androidx.documentfile.provider.DocumentFile |
|
|
import androidx.documentfile.provider.DocumentFile |
|
|
import androidx.lifecycle.ViewModelProvider |
|
|
import androidx.lifecycle.ViewModelProvider |
|
|
|
|
|
import androidx.lifecycle.lifecycleScope |
|
|
import androidx.navigation.findNavController |
|
|
import androidx.navigation.findNavController |
|
|
import androidx.preference.PreferenceManager |
|
|
import androidx.preference.PreferenceManager |
|
|
import androidx.recyclerview.widget.AsyncDifferConfig |
|
|
import androidx.recyclerview.widget.AsyncDifferConfig |
|
|
import androidx.recyclerview.widget.DiffUtil |
|
|
import androidx.recyclerview.widget.DiffUtil |
|
|
import androidx.recyclerview.widget.ListAdapter |
|
|
import androidx.recyclerview.widget.ListAdapter |
|
|
import androidx.recyclerview.widget.RecyclerView |
|
|
import androidx.recyclerview.widget.RecyclerView |
|
|
|
|
|
import kotlinx.coroutines.Dispatchers |
|
|
|
|
|
import kotlinx.coroutines.launch |
|
|
|
|
|
import kotlinx.coroutines.withContext |
|
|
import org.yuzu.yuzu_emu.HomeNavigationDirections |
|
|
import org.yuzu.yuzu_emu.HomeNavigationDirections |
|
|
import org.yuzu.yuzu_emu.R |
|
|
import org.yuzu.yuzu_emu.R |
|
|
import org.yuzu.yuzu_emu.YuzuApplication |
|
|
import org.yuzu.yuzu_emu.YuzuApplication |
|
|
@ -92,6 +96,8 @@ class GameAdapter(private val activity: AppCompatActivity) : |
|
|
data = Uri.parse(holder.game.path) |
|
|
data = Uri.parse(holder.game.path) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
activity.lifecycleScope.launch { |
|
|
|
|
|
withContext(Dispatchers.IO) { |
|
|
val layerDrawable = ResourcesCompat.getDrawable( |
|
|
val layerDrawable = ResourcesCompat.getDrawable( |
|
|
YuzuApplication.appContext.resources, |
|
|
YuzuApplication.appContext.resources, |
|
|
R.drawable.shortcut, |
|
|
R.drawable.shortcut, |
|
|
@ -99,12 +105,14 @@ class GameAdapter(private val activity: AppCompatActivity) : |
|
|
) as LayerDrawable |
|
|
) as LayerDrawable |
|
|
layerDrawable.setDrawableByLayerId( |
|
|
layerDrawable.setDrawableByLayerId( |
|
|
R.id.shortcut_foreground, |
|
|
R.id.shortcut_foreground, |
|
|
GameIconUtils.getGameIcon(holder.game).toDrawable(YuzuApplication.appContext.resources) |
|
|
|
|
|
|
|
|
GameIconUtils.getGameIcon(activity, holder.game) |
|
|
|
|
|
.toDrawable(YuzuApplication.appContext.resources) |
|
|
) |
|
|
) |
|
|
val inset = YuzuApplication.appContext.resources |
|
|
val inset = YuzuApplication.appContext.resources |
|
|
.getDimensionPixelSize(R.dimen.icon_inset) |
|
|
.getDimensionPixelSize(R.dimen.icon_inset) |
|
|
layerDrawable.setLayerInset(1, inset, inset, inset, inset) |
|
|
layerDrawable.setLayerInset(1, inset, inset, inset, inset) |
|
|
val shortcut = ShortcutInfoCompat.Builder(YuzuApplication.appContext, holder.game.path) |
|
|
|
|
|
|
|
|
val shortcut = |
|
|
|
|
|
ShortcutInfoCompat.Builder(YuzuApplication.appContext, holder.game.path) |
|
|
.setShortLabel(holder.game.title) |
|
|
.setShortLabel(holder.game.title) |
|
|
.setIcon( |
|
|
.setIcon( |
|
|
IconCompat.createWithAdaptiveBitmap( |
|
|
IconCompat.createWithAdaptiveBitmap( |
|
|
@ -114,6 +122,8 @@ class GameAdapter(private val activity: AppCompatActivity) : |
|
|
.setIntent(openIntent) |
|
|
.setIntent(openIntent) |
|
|
.build() |
|
|
.build() |
|
|
ShortcutManagerCompat.pushDynamicShortcut(YuzuApplication.appContext, shortcut) |
|
|
ShortcutManagerCompat.pushDynamicShortcut(YuzuApplication.appContext, shortcut) |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
val action = HomeNavigationDirections.actionGlobalEmulationActivity(holder.game) |
|
|
val action = HomeNavigationDirections.actionGlobalEmulationActivity(holder.game) |
|
|
view.findNavController().navigate(action) |
|
|
view.findNavController().navigate(action) |
|
|
|