Fix view binding for Omnipod wizard progress indication
This commit is contained in:
parent
34891f3fda
commit
524a297b22
2 changed files with 13 additions and 13 deletions
|
@ -12,6 +12,7 @@ import androidx.navigation.fragment.findNavController
|
||||||
import dagger.android.support.DaggerFragment
|
import dagger.android.support.DaggerFragment
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.common.R
|
import info.nightscout.androidaps.plugins.pump.omnipod.common.R
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.common.databinding.OmnipodCommonWizardBaseFragmentBinding
|
import info.nightscout.androidaps.plugins.pump.omnipod.common.databinding.OmnipodCommonWizardBaseFragmentBinding
|
||||||
|
import info.nightscout.androidaps.plugins.pump.omnipod.common.databinding.OmnipodCommonWizardProgressIndicationBinding
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.common.ui.wizard.common.activity.OmnipodWizardActivityBase
|
import info.nightscout.androidaps.plugins.pump.omnipod.common.ui.wizard.common.activity.OmnipodWizardActivityBase
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.common.ui.wizard.common.viewmodel.ViewModelBase
|
import info.nightscout.androidaps.plugins.pump.omnipod.common.ui.wizard.common.viewmodel.ViewModelBase
|
||||||
import kotlin.math.roundToInt
|
import kotlin.math.roundToInt
|
||||||
|
@ -21,20 +22,21 @@ abstract class WizardFragmentBase : DaggerFragment() {
|
||||||
protected lateinit var viewModel: ViewModelBase
|
protected lateinit var viewModel: ViewModelBase
|
||||||
|
|
||||||
var _binding: OmnipodCommonWizardBaseFragmentBinding? = null
|
var _binding: OmnipodCommonWizardBaseFragmentBinding? = null
|
||||||
|
var _progressIndicationBinding: OmnipodCommonWizardProgressIndicationBinding? = null
|
||||||
|
|
||||||
// This property is only valid between onCreateView and
|
// These properties are only valid between onCreateView and
|
||||||
// onDestroyView.
|
// onDestroyView.
|
||||||
val binding get() = _binding!!
|
val binding get() = _binding!!
|
||||||
|
val progressIndicationBinding get() = _progressIndicationBinding!!
|
||||||
|
|
||||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
|
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View =
|
||||||
_binding = OmnipodCommonWizardBaseFragmentBinding.inflate(inflater, container, false)
|
OmnipodCommonWizardBaseFragmentBinding.inflate(inflater, container, false).also {
|
||||||
|
_binding = it
|
||||||
|
_progressIndicationBinding = OmnipodCommonWizardProgressIndicationBinding.bind(it.root)
|
||||||
|
|
||||||
binding.fragmentContent.let {
|
it.fragmentContent.layoutResource = getLayoutId()
|
||||||
it.layoutResource = getLayoutId()
|
it.fragmentContent.inflate()
|
||||||
it.inflate()
|
}.root
|
||||||
}
|
|
||||||
return binding.root
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
super.onViewCreated(view, savedInstanceState)
|
super.onViewCreated(view, savedInstanceState)
|
||||||
|
@ -76,7 +78,7 @@ abstract class WizardFragmentBase : DaggerFragment() {
|
||||||
val currentFragment = getIndex() - (it.getTotalDefinedNumberOfSteps() - numberOfSteps)
|
val currentFragment = getIndex() - (it.getTotalDefinedNumberOfSteps() - numberOfSteps)
|
||||||
val progressPercentage = (currentFragment / numberOfSteps.toDouble() * 100).roundToInt()
|
val progressPercentage = (currentFragment / numberOfSteps.toDouble() * 100).roundToInt()
|
||||||
|
|
||||||
binding.progressIndicationLayout.progressIndication.progress = progressPercentage
|
progressIndicationBinding.progressIndication.progress = progressPercentage
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,9 +5,7 @@
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
||||||
<include
|
<include layout="@layout/omnipod_common_wizard_progress_indication" />
|
||||||
android:id="@+id/progress_indication_layout"
|
|
||||||
layout="@layout/omnipod_common_wizard_progress_indication" />
|
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/fragment_title"
|
android:id="@+id/fragment_title"
|
||||||
|
|
Loading…
Reference in a new issue