From 609c1dfad3d58a3f696632d9cfeb5b679721c568 Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Tue, 2 Feb 2021 21:11:40 +0100 Subject: [PATCH] InsulinFragment -> jetpack --- .../plugins/insulin/InsulinFragment.kt | 27 +++++--- app/src/main/res/layout/insulin_fragment.xml | 62 +++++++++---------- 2 files changed, 48 insertions(+), 41 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/insulin/InsulinFragment.kt b/app/src/main/java/info/nightscout/androidaps/plugins/insulin/InsulinFragment.kt index c2b9aa1fca..6d5f2c6df8 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/insulin/InsulinFragment.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/insulin/InsulinFragment.kt @@ -6,25 +6,38 @@ import android.view.View import android.view.ViewGroup import dagger.android.support.DaggerFragment import info.nightscout.androidaps.R +import info.nightscout.androidaps.databinding.InsulinFragmentBinding import info.nightscout.androidaps.interfaces.ActivePluginProvider import info.nightscout.androidaps.utils.resources.ResourceHelper -import kotlinx.android.synthetic.main.insulin_fragment.* import javax.inject.Inject class InsulinFragment : DaggerFragment() { + @Inject lateinit var activePlugin: ActivePluginProvider @Inject lateinit var resourceHelper: ResourceHelper + private var _binding: InsulinFragmentBinding? = null + + // This property is only valid between onCreateView and + // onDestroyView. + private val binding get() = _binding!! + override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, - savedInstanceState: Bundle?): View? { - return inflater.inflate(R.layout.insulin_fragment, container, false) + savedInstanceState: Bundle?): View { + _binding = InsulinFragmentBinding.inflate(inflater, container, false) + return binding.root } override fun onResume() { super.onResume() - insulin_name?.text = activePlugin.activeInsulin.friendlyName - insulin_comment?.text = activePlugin.activeInsulin.comment - insulin_dia?.text = resourceHelper.gs(R.string.dia) + ": " + activePlugin.activeInsulin.dia + "h" - insulin_graph?.show(activePlugin.activeInsulin) + binding.name.text = activePlugin.activeInsulin.friendlyName + binding.comment.text = activePlugin.activeInsulin.comment + binding.dia.text = resourceHelper.gs(R.string.dia) + ": " + resourceHelper.gs(R.string.format_hours, activePlugin.activeInsulin.dia) + binding.graph.show(activePlugin.activeInsulin) + } + + override fun onDestroyView() { + super.onDestroyView() + _binding = null } } \ No newline at end of file diff --git a/app/src/main/res/layout/insulin_fragment.xml b/app/src/main/res/layout/insulin_fragment.xml index d1789ea80e..ef70d617c9 100644 --- a/app/src/main/res/layout/insulin_fragment.xml +++ b/app/src/main/res/layout/insulin_fragment.xml @@ -1,47 +1,41 @@ - - + android:layout_height="wrap_content" + android:orientation="vertical"> - + android:layout_height="wrap_content" + android:layout_margin="10dp" + android:textAppearance="?android:attr/textAppearanceLarge" /> - + - + - + - + - - - - - +