From 8d89ccb792d765741ede183d23b07e3577e63e22 Mon Sep 17 00:00:00 2001 From: Andrey Stoyan Date: Sun, 25 Aug 2024 10:42:18 +0300 Subject: [PATCH] Fix dots inflation --- .../learnbraille/ui/views/BrailleDotsView.kt | 37 ++++++++++++------- 1 file changed, 23 insertions(+), 14 deletions(-) diff --git a/app/src/main/java/com/github/braillesystems/learnbraille/ui/views/BrailleDotsView.kt b/app/src/main/java/com/github/braillesystems/learnbraille/ui/views/BrailleDotsView.kt index dac2c666..b76e8f9c 100644 --- a/app/src/main/java/com/github/braillesystems/learnbraille/ui/views/BrailleDotsView.kt +++ b/app/src/main/java/com/github/braillesystems/learnbraille/ui/views/BrailleDotsView.kt @@ -10,7 +10,6 @@ import android.view.accessibility.AccessibilityNodeInfo import android.widget.CheckBox import androidx.annotation.RequiresApi import androidx.constraintlayout.widget.ConstraintLayout -import androidx.databinding.DataBindingUtil import com.github.braillesystems.learnbraille.R import com.github.braillesystems.learnbraille.data.entities.BrailleDot import com.github.braillesystems.learnbraille.data.entities.BrailleDots @@ -20,7 +19,10 @@ import com.github.braillesystems.learnbraille.data.repository.PreferenceReposito import com.github.braillesystems.learnbraille.databinding.BrailleDotsViewBinding import com.github.braillesystems.learnbraille.ui.views.BrailleDotsViewMode.Reading import com.github.braillesystems.learnbraille.ui.views.BrailleDotsViewMode.Writing -import com.github.braillesystems.learnbraille.utils.* +import com.github.braillesystems.learnbraille.utils.announce +import com.github.braillesystems.learnbraille.utils.chainify +import com.github.braillesystems.learnbraille.utils.forEach +import com.github.braillesystems.learnbraille.utils.unreachable import org.koin.core.component.KoinComponent import org.koin.core.component.inject import timber.log.Timber @@ -63,25 +65,32 @@ val BrailleDotsViewMode.reflected: BrailleDotsViewMode class BrailleDotsView : ConstraintLayout, KoinComponent { private val preferenceRepository: PreferenceRepository by inject() - val dotButton1: BrailleDotView - val dotButton2: BrailleDotView - val dotButton3: BrailleDotView - val dotButton4: BrailleDotView - val dotButton5: BrailleDotView - val dotButton6: BrailleDotView - - constructor(context: Context) : super(context) + lateinit var dotButton1: BrailleDotView + lateinit var dotButton2: BrailleDotView + lateinit var dotButton3: BrailleDotView + lateinit var dotButton4: BrailleDotView + lateinit var dotButton5: BrailleDotView + lateinit var dotButton6: BrailleDotView + + constructor(context: Context) : super(context) { + init() + } - constructor(context: Context, attrSet: AttributeSet) : super(context, attrSet) + constructor(context: Context, attrSet: AttributeSet) : super(context, attrSet) { + init() + } constructor( context: Context, attrSet: AttributeSet, defStyleAttr: Int ) : super( context, attrSet, defStyleAttr - ) + ) { + init() + } - init { - val binding = BrailleDotsViewBinding.inflate(LayoutInflater.from(context), this, false) + private fun init() { + Timber.d("Inflating dots") + val binding = BrailleDotsViewBinding.inflate(LayoutInflater.from(context), this, true) dotButton1 = binding.dotButton1 dotButton2 = binding.dotButton2 dotButton3 = binding.dotButton3