forked from github/wulkanowy-mirror
impr: code improvements
This commit is contained in:
parent
a1203b360e
commit
47ff549d4b
@ -3,9 +3,9 @@ package io.github.wulkanowy.ui.modules.about
|
|||||||
import android.graphics.drawable.Drawable
|
import android.graphics.drawable.Drawable
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
|
import android.widget.Toast
|
||||||
import androidx.core.content.res.ResourcesCompat
|
import androidx.core.content.res.ResourcesCompat
|
||||||
import androidx.recyclerview.widget.RecyclerView
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
import com.google.android.material.snackbar.Snackbar
|
|
||||||
import io.github.wulkanowy.data.repositories.PreferencesRepository
|
import io.github.wulkanowy.data.repositories.PreferencesRepository
|
||||||
import io.github.wulkanowy.databinding.ItemAboutBinding
|
import io.github.wulkanowy.databinding.ItemAboutBinding
|
||||||
import io.github.wulkanowy.databinding.ScrollableHeaderAboutBinding
|
import io.github.wulkanowy.databinding.ScrollableHeaderAboutBinding
|
||||||
@ -15,6 +15,7 @@ class AboutAdapter @Inject constructor(
|
|||||||
private val preferencesRepository: PreferencesRepository
|
private val preferencesRepository: PreferencesRepository
|
||||||
) : RecyclerView.Adapter<RecyclerView.ViewHolder>() {
|
) : RecyclerView.Adapter<RecyclerView.ViewHolder>() {
|
||||||
|
|
||||||
|
private var developerModeClicks = 0
|
||||||
private enum class ViewType(val id: Int) {
|
private enum class ViewType(val id: Int) {
|
||||||
ITEM_HEADER(1),
|
ITEM_HEADER(1),
|
||||||
ITEM_ELEMENT(2)
|
ITEM_ELEMENT(2)
|
||||||
@ -22,7 +23,6 @@ class AboutAdapter @Inject constructor(
|
|||||||
|
|
||||||
var items = emptyList<Triple<String, String, Drawable?>>()
|
var items = emptyList<Triple<String, String, Drawable?>>()
|
||||||
|
|
||||||
var developerModeClicks = 0
|
|
||||||
var onClickListener: (name: String) -> Unit = {}
|
var onClickListener: (name: String) -> Unit = {}
|
||||||
|
|
||||||
override fun getItemCount() = items.size + 1
|
override fun getItemCount() = items.size + 1
|
||||||
@ -52,14 +52,14 @@ class AboutAdapter @Inject constructor(
|
|||||||
private fun bindHeaderViewHolder(binding: ScrollableHeaderAboutBinding) {
|
private fun bindHeaderViewHolder(binding: ScrollableHeaderAboutBinding) {
|
||||||
with(binding.aboutScrollableHeaderIcon) {
|
with(binding.aboutScrollableHeaderIcon) {
|
||||||
setOnClickListener {
|
setOnClickListener {
|
||||||
if (++developerModeClicks == 5) {
|
if (++developerModeClicks == 5 && !preferencesRepository.developerMode) {
|
||||||
preferencesRepository.developerMode = true
|
preferencesRepository.developerMode = true
|
||||||
developerModeClicks = 0
|
developerModeClicks = 0
|
||||||
|
|
||||||
Snackbar.make(
|
Toast.makeText(
|
||||||
binding.root,
|
context,
|
||||||
"👍🏻",
|
"done!",
|
||||||
Snackbar.LENGTH_SHORT
|
Toast.LENGTH_SHORT
|
||||||
).show()
|
).show()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user