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