mirror of
https://github.com/Aviortheking/Neo-Store.git
synced 2025-04-24 03:42:15 +00:00
Improve: Icon logic in App Detail Page (Again)
This commit is contained in:
parent
dfee171812
commit
c842b4574a
@ -22,6 +22,8 @@ import android.view.MotionEvent
|
|||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import android.widget.TextView
|
import android.widget.TextView
|
||||||
|
import androidx.annotation.DrawableRes
|
||||||
|
import androidx.annotation.StringRes
|
||||||
import androidx.appcompat.widget.LinearLayoutCompat
|
import androidx.appcompat.widget.LinearLayoutCompat
|
||||||
import androidx.core.content.res.ResourcesCompat
|
import androidx.core.content.res.ResourcesCompat
|
||||||
import androidx.core.net.toUri
|
import androidx.core.net.toUri
|
||||||
@ -73,14 +75,14 @@ class ProductAdapter(private val callbacks: Callbacks, private val columns: Int)
|
|||||||
fun onUriClick(uri: Uri, shouldConfirm: Boolean): Boolean
|
fun onUriClick(uri: Uri, shouldConfirm: Boolean): Boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
enum class Action(val titleResId: Int) {
|
enum class Action(@StringRes val titleResId: Int, @DrawableRes val iconResId: Int) {
|
||||||
INSTALL(R.string.install),
|
INSTALL(R.string.install, R.drawable.ic_download),
|
||||||
UPDATE(R.string.update),
|
UPDATE(R.string.update, R.drawable.ic_download),
|
||||||
LAUNCH(R.string.launch),
|
LAUNCH(R.string.launch, R.drawable.ic_launch),
|
||||||
DETAILS(R.string.details),
|
DETAILS(R.string.details, R.drawable.ic_tune),
|
||||||
UNINSTALL(R.string.uninstall),
|
UNINSTALL(R.string.uninstall, R.drawable.ic_delete),
|
||||||
CANCEL(R.string.cancel),
|
CANCEL(R.string.cancel, R.drawable.ic_cancel),
|
||||||
SHARE(R.string.share)
|
SHARE(R.string.share, R.drawable.ic_share)
|
||||||
}
|
}
|
||||||
|
|
||||||
sealed class Status {
|
sealed class Status {
|
||||||
@ -1065,6 +1067,7 @@ class ProductAdapter(private val callbacks: Callbacks, private val columns: Int)
|
|||||||
holder.action.apply {
|
holder.action.apply {
|
||||||
visibility = if (action == null) View.GONE else View.VISIBLE
|
visibility = if (action == null) View.GONE else View.VISIBLE
|
||||||
if (action != null) {
|
if (action != null) {
|
||||||
|
icon = context.getDrawable(action.iconResId)
|
||||||
setText(action.titleResId)
|
setText(action.titleResId)
|
||||||
setTextColor(
|
setTextColor(
|
||||||
if (action == Action.CANCEL) holder.actionTintOnCancel
|
if (action == Action.CANCEL) holder.actionTintOnCancel
|
||||||
@ -1075,13 +1078,6 @@ class ProductAdapter(private val callbacks: Callbacks, private val columns: Int)
|
|||||||
backgroundTintList = if (action == Action.CANCEL)
|
backgroundTintList = if (action == Action.CANCEL)
|
||||||
holder.actionTintCancel else holder.actionTintNormal
|
holder.actionTintCancel else holder.actionTintNormal
|
||||||
}
|
}
|
||||||
icon =
|
|
||||||
when (action) {
|
|
||||||
Action.CANCEL -> context.getDrawable(R.drawable.ic_cancel)
|
|
||||||
Action.LAUNCH -> context.getDrawable(R.drawable.ic_launch)
|
|
||||||
Action.DETAILS -> context.getDrawable(R.drawable.ic_tune)
|
|
||||||
else -> context.getDrawable(R.drawable.ic_download)
|
|
||||||
}
|
|
||||||
iconTint = if (action == Action.CANCEL) holder.actionTintOnCancel
|
iconTint = if (action == Action.CANCEL) holder.actionTintOnCancel
|
||||||
else holder.actionTintOnNormal
|
else holder.actionTintOnNormal
|
||||||
}
|
}
|
||||||
|
@ -94,7 +94,7 @@ class ProductFragment() : ScreenFragment(), ProductAdapter.Callbacks {
|
|||||||
toolbar.menu.apply {
|
toolbar.menu.apply {
|
||||||
for (action in Action.values()) {
|
for (action in Action.values()) {
|
||||||
add(0, action.id, 0, action.adapterAction.titleResId)
|
add(0, action.id, 0, action.adapterAction.titleResId)
|
||||||
.setIcon(Utils.getToolbarIcon(toolbar.context, action.adapterAction.iconsId))
|
.setIcon(Utils.getToolbarIcon(toolbar.context, action.adapterAction.iconResId))
|
||||||
.setVisible(false)
|
.setVisible(false)
|
||||||
.setShowAsActionFlags(MenuItem.SHOW_AS_ACTION_ALWAYS)
|
.setShowAsActionFlags(MenuItem.SHOW_AS_ACTION_ALWAYS)
|
||||||
.setOnMenuItemClickListener {
|
.setOnMenuItemClickListener {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user