diff --git a/app/src/main/java/be/scri/activities/MainActivity.kt b/app/src/main/java/be/scri/activities/MainActivity.kt index 94609f13..f65c0e00 100644 --- a/app/src/main/java/be/scri/activities/MainActivity.kt +++ b/app/src/main/java/be/scri/activities/MainActivity.kt @@ -24,8 +24,6 @@ class MainActivity : AppCompatActivity() { private lateinit var binding: ActivityMainBinding private var englishKeyboardIME: EnglishKeyboardIME? = null - fun getEnglishKeyboardIME(): EnglishKeyboardIME? = englishKeyboardIME - override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) supportActionBar?.displayOptions = androidx.appcompat.app.ActionBar.DISPLAY_SHOW_CUSTOM diff --git a/app/src/main/java/be/scri/fragments/AboutFragment.kt b/app/src/main/java/be/scri/fragments/AboutFragment.kt index 09733f0a..cd785dcd 100644 --- a/app/src/main/java/be/scri/fragments/AboutFragment.kt +++ b/app/src/main/java/be/scri/fragments/AboutFragment.kt @@ -133,9 +133,8 @@ class AboutFragment : Fragment() { ), ) - private fun getSecondRecyclerViewData(): List { - val context = requireContext() - return listOf( + private fun getSecondRecyclerViewData(): List = + listOf( ItemsViewModel( image = R.drawable.star, text = ItemsViewModel.Text(R.string.app_about_feedback_rate_scribe), @@ -177,7 +176,6 @@ class AboutFragment : Fragment() { action = ::resetHints, ), ) - } private fun getThirdRecyclerViewData(): List = listOf( diff --git a/app/src/main/java/be/scri/fragments/SettingsFragment.kt b/app/src/main/java/be/scri/fragments/SettingsFragment.kt index bb1bd915..012d83e9 100644 --- a/app/src/main/java/be/scri/fragments/SettingsFragment.kt +++ b/app/src/main/java/be/scri/fragments/SettingsFragment.kt @@ -20,6 +20,7 @@ import androidx.appcompat.app.AppCompatDelegate import androidx.appcompat.content.res.AppCompatResources.getDrawable import androidx.fragment.app.Fragment import androidx.recyclerview.widget.LinearLayoutManager +import androidx.recyclerview.widget.RecyclerView import be.scri.R import be.scri.activities.MainActivity import be.scri.databinding.FragmentSettingsBinding @@ -30,6 +31,7 @@ import be.scri.models.TextItem class SettingsFragment : Fragment() { private lateinit var binding: FragmentSettingsBinding + private var isDecorationSet: Boolean = false override fun onCreateView( inflater: LayoutInflater, @@ -141,24 +143,31 @@ class SettingsFragment : Fragment() { setupItemVisibility() } } - val recyclerView = binding.recyclerView2 val adapter = CustomAdapter(getRecyclerViewElements(), requireContext()) recyclerView.layoutManager = LinearLayoutManager(requireContext()) recyclerView.adapter = adapter recyclerView.suppressLayout(true) - recyclerView.apply { - val itemDecoration = - CustomDividerItemDecoration( - drawable = getDrawable(requireContext(), R.drawable.rv_divider)!!, - width = 1, - marginLeft = 50, - marginRight = 50, - ) - addItemDecoration(itemDecoration) + + if (!isDecorationSet) { + isDecorationSet = true + recyclerView.apply { + addCustomItemDecoration() + } } } + private fun RecyclerView.addCustomItemDecoration() { + val itemDecoration = + CustomDividerItemDecoration( + drawable = getDrawable(requireContext(), R.drawable.rv_divider)!!, + width = 1, + marginLeft = 50, + marginRight = 50, + ) + addItemDecoration(itemDecoration) + } + private fun getRecyclerViewElements(): MutableList { val languages = setupKeyboardLanguage() val list = mutableListOf() diff --git a/app/src/main/java/be/scri/views/CustomDividerItemDecoration.kt b/app/src/main/java/be/scri/views/CustomDividerItemDecoration.kt index 35c80c9a..d0ec2f73 100644 --- a/app/src/main/java/be/scri/views/CustomDividerItemDecoration.kt +++ b/app/src/main/java/be/scri/views/CustomDividerItemDecoration.kt @@ -20,7 +20,7 @@ class CustomDividerItemDecoration( val right = parent.width - parent.paddingRight - marginRight val childCount = parent.childCount - for (i in 0 until childCount - 1) { // Exclude the last item + for (i in 0 until childCount - 1) { val child = parent.getChildAt(i) val params = child.layoutParams as RecyclerView.LayoutParams val top = child.bottom + params.bottomMargin diff --git a/app/src/main/res/drawable/rv_divider.xml b/app/src/main/res/drawable/rv_divider.xml index 68649987..23bbfd39 100644 --- a/app/src/main/res/drawable/rv_divider.xml +++ b/app/src/main/res/drawable/rv_divider.xml @@ -1,7 +1,10 @@ - - - - - - + + +