mirror of
https://github.com/SimpleMobileTools/Simple-App-Launcher.git
synced 2025-04-24 22:58:45 +02:00
make sure always the right items are checked
This commit is contained in:
parent
2c14e0b5dc
commit
8c6062180f
@ -7,7 +7,6 @@ import android.view.View
|
|||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import com.simplemobiletools.applauncher.R
|
import com.simplemobiletools.applauncher.R
|
||||||
import com.simplemobiletools.applauncher.extensions.hide
|
import com.simplemobiletools.applauncher.extensions.hide
|
||||||
import com.simplemobiletools.applauncher.extensions.isVisible
|
|
||||||
import com.simplemobiletools.applauncher.extensions.show
|
import com.simplemobiletools.applauncher.extensions.show
|
||||||
import com.simplemobiletools.applauncher.models.AppLauncher
|
import com.simplemobiletools.applauncher.models.AppLauncher
|
||||||
import kotlinx.android.synthetic.main.app_launcher_dialog_item.view.*
|
import kotlinx.android.synthetic.main.app_launcher_dialog_item.view.*
|
||||||
@ -35,10 +34,13 @@ class RecyclerAdapter(val cxt: Context, val displayChecks: Boolean, val launcher
|
|||||||
itemView.setOnClickListener {
|
itemView.setOnClickListener {
|
||||||
itemClick(this)
|
itemClick(this)
|
||||||
|
|
||||||
if (displayChecks)
|
if (displayChecks) {
|
||||||
handleCheck(itemView.launcher_check)
|
launcher.isChecked = !launcher.isChecked
|
||||||
|
handleCheck(itemView.launcher_check, launcher)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
handleCheck(itemView.launcher_check, launcher)
|
||||||
if (launcher.iconId != 0) {
|
if (launcher.iconId != 0) {
|
||||||
val icon = context.resources.getDrawable(launcher.iconId)
|
val icon = context.resources.getDrawable(launcher.iconId)
|
||||||
itemView.launcher_icon.setImageDrawable(icon)
|
itemView.launcher_icon.setImageDrawable(icon)
|
||||||
@ -49,11 +51,12 @@ class RecyclerAdapter(val cxt: Context, val displayChecks: Boolean, val launcher
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun handleCheck(check: View) {
|
fun handleCheck(check: View, launcher: AppLauncher) {
|
||||||
if (check.isVisible)
|
if (launcher.isChecked) {
|
||||||
check.hide()
|
|
||||||
else
|
|
||||||
check.show()
|
check.show()
|
||||||
|
} else {
|
||||||
|
check.hide()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package com.simplemobiletools.applauncher.models
|
package com.simplemobiletools.applauncher.models
|
||||||
|
|
||||||
data class AppLauncher(val name: String, val pkgName: String, val iconId: Int) {
|
data class AppLauncher(val name: String, val pkgName: String, val iconId: Int, var isChecked: Boolean = false) {
|
||||||
override fun equals(other: Any?): Boolean {
|
override fun equals(other: Any?): Boolean {
|
||||||
return pkgName.equals((other as AppLauncher).pkgName)
|
return pkgName.equals((other as AppLauncher).pkgName)
|
||||||
}
|
}
|
||||||
|
@ -26,11 +26,11 @@
|
|||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/launcher_check"
|
android:id="@+id/launcher_check"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:gravity="top|right"
|
android:layout_alignParentRight="true"
|
||||||
android:scaleType="fitEnd"
|
android:layout_alignParentTop="true"
|
||||||
android:src="@mipmap/check"
|
android:background="@mipmap/check"
|
||||||
android:visibility="invisible"/>
|
android:visibility="invisible"/>
|
||||||
|
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user