diff --git a/app/src/main/java/info/nightscout/androidaps/MainActivity.kt b/app/src/main/java/info/nightscout/androidaps/MainActivity.kt index 0a4066dfa2..4e58a1f21f 100644 --- a/app/src/main/java/info/nightscout/androidaps/MainActivity.kt +++ b/app/src/main/java/info/nightscout/androidaps/MainActivity.kt @@ -47,7 +47,6 @@ import info.nightscout.androidaps.plugins.constraints.versionChecker.VersionChec import info.nightscout.androidaps.plugins.general.nsclient.data.NSSettingsStatus import info.nightscout.androidaps.plugins.general.smsCommunicator.SmsCommunicatorPlugin import info.nightscout.androidaps.setupwizard.SetupWizardActivity -import info.nightscout.androidaps.utils.tabs.TabPageAdapter import info.nightscout.androidaps.utils.AndroidPermission import info.nightscout.androidaps.utils.FabricPrivacy import info.nightscout.androidaps.utils.LocaleHelper @@ -58,6 +57,8 @@ import info.nightscout.androidaps.utils.protection.ProtectionCheck import info.nightscout.androidaps.utils.resources.IconsProvider import info.nightscout.androidaps.utils.resources.ResourceHelper import info.nightscout.androidaps.utils.sharedPreferences.SP +import info.nightscout.androidaps.utils.tabs.TabPageAdapter +import info.nightscout.androidaps.utils.ui.UIRunnable import io.reactivex.android.schedulers.AndroidSchedulers import io.reactivex.disposables.CompositeDisposable import kotlinx.android.synthetic.main.activity_main.* @@ -160,12 +161,9 @@ class MainActivity : NoSplashAppCompatActivity() { override fun onResume() { super.onResume() protectionCheck.queryProtection(this, ProtectionCheck.Protection.APPLICATION, null, - Runnable { - OKDialog.show(this, "", resourceHelper.gs(R.string.authorizationfailed), Runnable { finish() }) - }, - Runnable { - OKDialog.show(this, "", resourceHelper.gs(R.string.authorizationfailed), Runnable { finish() }) - }) + UIRunnable(Runnable { OKDialog.show(this, "", resourceHelper.gs(R.string.authorizationfailed), Runnable { finish() }) }), + UIRunnable(Runnable { OKDialog.show(this, "", resourceHelper.gs(R.string.authorizationfailed), Runnable { finish() }) }) + ) } private fun setWakeLock() { diff --git a/app/src/main/java/info/nightscout/androidaps/activities/MyPreferenceFragment.kt b/app/src/main/java/info/nightscout/androidaps/activities/MyPreferenceFragment.kt index b06276114d..78147d4108 100644 --- a/app/src/main/java/info/nightscout/androidaps/activities/MyPreferenceFragment.kt +++ b/app/src/main/java/info/nightscout/androidaps/activities/MyPreferenceFragment.kt @@ -279,7 +279,7 @@ class MyPreferenceFragment : PreferenceFragmentCompat(), OnSharedPreferenceChang } for (plugin in pluginStore.plugins) { - pref?.let { pref-> pref.getKey()?.let { plugin.updatePreferenceSummary(pref) }} + pref?.let { it.key?.let { plugin.updatePreferenceSummary(pref) }} } val hmacPasswords = arrayOf( diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/constraints/objectives/ObjectivesFragment.kt b/app/src/main/java/info/nightscout/androidaps/plugins/constraints/objectives/ObjectivesFragment.kt index d891a89dda..5fe20f2968 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/constraints/objectives/ObjectivesFragment.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/constraints/objectives/ObjectivesFragment.kt @@ -212,7 +212,7 @@ class ObjectivesFragment : DaggerFragment() { bundle.putInt("currentTask", taskPosition) dialog.arguments = bundle ObjectivesExamDialog.objective = objective - fragmentManager?.let { dialog.show(it, "ObjectivesFragment") } + dialog.show(childFragmentManager, "ObjectivesFragment") } } // horizontal line diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/constraints/phoneChecker/PhoneCheckerPlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/constraints/phoneChecker/PhoneCheckerPlugin.kt index 749f7f795c..4ea2d78989 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/constraints/phoneChecker/PhoneCheckerPlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/constraints/phoneChecker/PhoneCheckerPlugin.kt @@ -41,7 +41,7 @@ class PhoneCheckerPlugin @Inject constructor( override fun onStart() { super.onStart() - phoneRooted = RootBeer(context).isRootedWithoutBusyBoxCheck() + phoneRooted = RootBeer(context).isRooted() devMode = isDevModeEnabled() } } \ No newline at end of file diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/actions/ActionsFragment.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/actions/ActionsFragment.kt index 9e80d9d331..6a324d74cc 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/actions/ActionsFragment.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/actions/ActionsFragment.kt @@ -25,14 +25,15 @@ import info.nightscout.androidaps.plugins.general.actions.defs.CustomAction import info.nightscout.androidaps.plugins.general.overview.StatusLightHandler import info.nightscout.androidaps.queue.Callback import info.nightscout.androidaps.utils.FabricPrivacy -import info.nightscout.androidaps.utils.alertDialogs.OKDialog import info.nightscout.androidaps.utils.SingleClickButton +import info.nightscout.androidaps.utils.alertDialogs.OKDialog import info.nightscout.androidaps.utils.buildHelper.BuildHelper import info.nightscout.androidaps.utils.extensions.plusAssign -import info.nightscout.androidaps.utils.resources.ResourceHelper -import info.nightscout.androidaps.utils.sharedPreferences.SP import info.nightscout.androidaps.utils.extensions.toVisibility import info.nightscout.androidaps.utils.protection.ProtectionCheck +import info.nightscout.androidaps.utils.resources.ResourceHelper +import info.nightscout.androidaps.utils.sharedPreferences.SP +import info.nightscout.androidaps.utils.ui.UIRunnable import io.reactivex.android.schedulers.AndroidSchedulers import io.reactivex.disposables.CompositeDisposable import kotlinx.android.synthetic.main.actions_fragment.* @@ -68,19 +69,19 @@ class ActionsFragment : DaggerFragment() { super.onViewCreated(view, savedInstanceState) actions_profileswitch.setOnClickListener { - fragmentManager?.let { ProfileSwitchDialog().show(it, "Actions") } + ProfileSwitchDialog().show(childFragmentManager, "Actions") } actions_temptarget.setOnClickListener { - fragmentManager?.let { TempTargetDialog().show(it, "Actions") } + TempTargetDialog().show(childFragmentManager, "Actions") } actions_extendedbolus.setOnClickListener { activity?.let { activity -> - protectionCheck.queryProtection(activity, ProtectionCheck.Protection.BOLUS, Runnable { + protectionCheck.queryProtection(activity, ProtectionCheck.Protection.BOLUS, UIRunnable(Runnable { OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.extended_bolus), resourceHelper.gs(R.string.ebstopsloop), Runnable { - fragmentManager?.let { ExtendedBolusDialog().show(it, "Actions") } + ExtendedBolusDialog().show(childFragmentManager, "Actions") }, null) - }) + })) } } actions_extendedbolus_cancel.setOnClickListener { @@ -101,7 +102,7 @@ class ActionsFragment : DaggerFragment() { } } actions_settempbasal.setOnClickListener { - fragmentManager?.let { TempBasalDialog().show(it, "Actions") } + TempBasalDialog().show(childFragmentManager, "Actions") } actions_canceltempbasal.setOnClickListener { if (activePlugin.activeTreatments.isTempBasalInProgress) { @@ -122,25 +123,25 @@ class ActionsFragment : DaggerFragment() { } actions_fill.setOnClickListener { activity?.let { activity -> - protectionCheck.queryProtection(activity, ProtectionCheck.Protection.BOLUS, Runnable { fragmentManager?.let { FillDialog().show(it, "FillDialog") } }) + protectionCheck.queryProtection(activity, ProtectionCheck.Protection.BOLUS, UIRunnable(Runnable { FillDialog().show(childFragmentManager, "FillDialog") })) } } actions_historybrowser.setOnClickListener { startActivity(Intent(context, HistoryBrowseActivity::class.java)) } actions_tddstats.setOnClickListener { startActivity(Intent(context, TDDStatsActivity::class.java)) } actions_bgcheck.setOnClickListener { - fragmentManager?.let { CareDialog().setOptions(CareDialog.EventType.BGCHECK, R.string.careportal_bgcheck).show(it, "Actions") } + CareDialog().setOptions(CareDialog.EventType.BGCHECK, R.string.careportal_bgcheck).show(childFragmentManager, "Actions") } actions_cgmsensorinsert.setOnClickListener { - fragmentManager?.let { CareDialog().setOptions(CareDialog.EventType.SENSOR_INSERT, R.string.careportal_cgmsensorinsert).show(it, "Actions") } + CareDialog().setOptions(CareDialog.EventType.SENSOR_INSERT, R.string.careportal_cgmsensorinsert).show(childFragmentManager, "Actions") } actions_pumpbatterychange.setOnClickListener { - fragmentManager?.let { CareDialog().setOptions(CareDialog.EventType.BATTERY_CHANGE, R.string.careportal_pumpbatterychange).show(it, "Actions") } + CareDialog().setOptions(CareDialog.EventType.BATTERY_CHANGE, R.string.careportal_pumpbatterychange).show(childFragmentManager, "Actions") } actions_note.setOnClickListener { - fragmentManager?.let { CareDialog().setOptions(CareDialog.EventType.NOTE, R.string.careportal_note).show(it, "Actions") } + CareDialog().setOptions(CareDialog.EventType.NOTE, R.string.careportal_note).show(childFragmentManager, "Actions") } actions_exercise.setOnClickListener { - fragmentManager?.let { CareDialog().setOptions(CareDialog.EventType.EXERCISE, R.string.careportal_exercise).show(it, "Actions") } + CareDialog().setOptions(CareDialog.EventType.EXERCISE, R.string.careportal_exercise).show(childFragmentManager, "Actions") } sp.putBoolean(R.string.key_objectiveuseactions, true) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/AutomationFragment.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/AutomationFragment.kt index 4cf73af02f..3e472a9ce9 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/AutomationFragment.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/AutomationFragment.kt @@ -72,7 +72,7 @@ class AutomationFragment : DaggerFragment(), OnStartDragListener { args.putString("event", AutomationEvent(mainApp).toJSON()) args.putInt("position", -1) // New event dialog.arguments = args - fragmentManager?.let { dialog.show(it, "EditEventDialog") } + dialog.show(childFragmentManager, "EditEventDialog") } val callback: ItemTouchHelper.Callback = SimpleItemTouchHelperCallback(eventListAdapter) @@ -182,7 +182,7 @@ class AutomationFragment : DaggerFragment(), OnStartDragListener { args.putString("event", event.toJSON()) args.putInt("position", position) dialog.arguments = args - fragmentManager?.let { dialog.show(it, "EditEventDialog") } + dialog.show(childFragmentManager, "EditEventDialog") } // Start a drag whenever the handle view it touched holder.iconSort.setOnTouchListener { v: View, motionEvent: MotionEvent -> diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/dialogs/EditEventDialog.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/dialogs/EditEventDialog.kt index 21a62bc0a5..44929a9dee 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/dialogs/EditEventDialog.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/dialogs/EditEventDialog.kt @@ -66,15 +66,15 @@ class EditEventDialog : DialogFragmentWithDate() { args.putString("trigger", event.trigger.toJSON()) val dialog = EditTriggerDialog() dialog.arguments = args - fragmentManager?.let { dialog.show(it, "EditTriggerDialog") } + dialog.show(childFragmentManager, "EditTriggerDialog") } // setup action list view - fragmentManager?.let { actionListAdapter = ActionListAdapter() } + actionListAdapter = ActionListAdapter() automation_actionListView.layoutManager = LinearLayoutManager(context) automation_actionListView.adapter = actionListAdapter - automation_addAction.setOnClickListener { fragmentManager?.let { ChooseActionDialog().show(it, "ChooseActionDialog") } } + automation_addAction.setOnClickListener { ChooseActionDialog().show(childFragmentManager, "ChooseActionDialog") } showPreconditions() @@ -187,9 +187,7 @@ class EditEventDialog : DialogFragmentWithDate() { args.putString("action", action.toJSON()) val dialog = EditActionDialog() dialog.arguments = args - fragmentManager?.let { - dialog.show(it, "EditActionDialog") - } + dialog.show(childFragmentManager, "EditActionDialog") } } view.findViewById(R.id.automation_iconTrash).setOnClickListener { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/careportal/CareportalFragment.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/careportal/CareportalFragment.kt index 613dfeab32..4007e43b45 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/careportal/CareportalFragment.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/careportal/CareportalFragment.kt @@ -125,9 +125,7 @@ class CareportalFragment : DaggerFragment(), View.OnClickListener { R.id.careportal_openapsoffline -> newDialog.setOptions(OPENAPSOFFLINE, R.string.careportal_openapsoffline) R.id.careportal_temporarytarget -> newDialog.setOptions(TEMPTARGET, R.string.careportal_temporarytarget) } - fragmentManager?.let { - NewNSTreatmentDialog().show(it, "CareportalFragment") - } + NewNSTreatmentDialog().show(childFragmentManager, "CareportalFragment") } private fun updateGUI() { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/maintenance/activities/PrefImportListActivity.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/maintenance/activities/PrefImportListActivity.kt index af19414794..7703166d04 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/maintenance/activities/PrefImportListActivity.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/maintenance/activities/PrefImportListActivity.kt @@ -58,7 +58,7 @@ class PrefImportListActivity : DaggerAppCompatActivity() { init { itemView.isClickable = true - itemView.setOnClickListener { v: View -> + itemView.setOnClickListener { val prefFile = fileName.tag as PrefsFile val i = Intent() diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/OverviewFragment.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/OverviewFragment.kt index 354e07c28f..4a6455e41c 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/OverviewFragment.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/OverviewFragment.kt @@ -65,6 +65,7 @@ import info.nightscout.androidaps.utils.extensions.toVisibility import info.nightscout.androidaps.utils.protection.ProtectionCheck import info.nightscout.androidaps.utils.resources.ResourceHelper import info.nightscout.androidaps.utils.sharedPreferences.SP +import info.nightscout.androidaps.utils.ui.UIRunnable import info.nightscout.androidaps.utils.wizard.QuickWizard import io.reactivex.android.schedulers.AndroidSchedulers import io.reactivex.disposables.CompositeDisposable @@ -293,22 +294,20 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList } override fun onContextItemSelected(item: MenuItem): Boolean { - val manager = fragmentManager - return if (manager != null && overviewMenus.onContextItemSelected(item, manager)) true else super.onContextItemSelected(item) + return if (overviewMenus.onContextItemSelected(item, childFragmentManager)) true else super.onContextItemSelected(item) } override fun onClick(v: View) { - val manager = fragmentManager ?: return // try to fix https://fabric.io/nightscout3/android/apps/info.nightscout.androidaps/issues/5aca7a1536c7b23527eb4be7?time=last-seven-days // https://stackoverflow.com/questions/14860239/checking-if-state-is-saved-before-committing-a-fragmenttransaction - if (manager.isStateSaved) return + if (childFragmentManager.isStateSaved) return activity?.let { activity -> when (v.id) { - R.id.overview_treatmentbutton -> protectionCheck.queryProtection(activity, ProtectionCheck.Protection.BOLUS, Runnable { TreatmentDialog().show(manager, "Overview") }) - R.id.overview_wizardbutton -> protectionCheck.queryProtection(activity, ProtectionCheck.Protection.BOLUS, Runnable { WizardDialog().show(manager, "Overview") }) - R.id.overview_insulinbutton -> protectionCheck.queryProtection(activity, ProtectionCheck.Protection.BOLUS, Runnable { InsulinDialog().show(manager, "Overview") }) - R.id.overview_quickwizardbutton -> protectionCheck.queryProtection(activity, ProtectionCheck.Protection.BOLUS, Runnable { onClickQuickWizard() }) - R.id.overview_carbsbutton -> protectionCheck.queryProtection(activity, ProtectionCheck.Protection.BOLUS, Runnable { CarbsDialog().show(manager, "Overview") }) + R.id.overview_treatmentbutton -> protectionCheck.queryProtection(activity, ProtectionCheck.Protection.BOLUS, UIRunnable(Runnable { TreatmentDialog().show(childFragmentManager, "Overview") })) + R.id.overview_wizardbutton -> protectionCheck.queryProtection(activity, ProtectionCheck.Protection.BOLUS, UIRunnable(Runnable { WizardDialog().show(childFragmentManager, "Overview") })) + R.id.overview_insulinbutton -> protectionCheck.queryProtection(activity, ProtectionCheck.Protection.BOLUS, UIRunnable(Runnable { InsulinDialog().show(childFragmentManager, "Overview") })) + R.id.overview_quickwizardbutton -> protectionCheck.queryProtection(activity, ProtectionCheck.Protection.BOLUS, UIRunnable(Runnable { onClickQuickWizard() })) + R.id.overview_carbsbutton -> protectionCheck.queryProtection(activity, ProtectionCheck.Protection.BOLUS, UIRunnable(Runnable { CarbsDialog().show(childFragmentManager, "Overview") })) R.id.overview_cgmbutton -> { if (xdripPlugin.isEnabled(PluginType.BGSOURCE)) @@ -323,7 +322,7 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList R.id.overview_calibrationbutton -> { if (xdripPlugin.isEnabled(PluginType.BGSOURCE)) { - CalibrationDialog().show(manager, "CalibrationDialog") + CalibrationDialog().show(childFragmentManager, "CalibrationDialog") } else if (dexcomPlugin.isEnabled(PluginType.BGSOURCE)) { try { dexcomPlugin.findDexcomPackageName()?.let { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/profile/local/LocalProfileFragment.kt b/app/src/main/java/info/nightscout/androidaps/plugins/profile/local/LocalProfileFragment.kt index 3acf960195..f26bacf8ec 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/profile/local/LocalProfileFragment.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/profile/local/LocalProfileFragment.kt @@ -178,7 +178,7 @@ class LocalProfileFragment : DaggerFragment() { localprofile_profileswitch.setOnClickListener { // TODO: select in dialog localProfilePlugin.currentProfileIndex - fragmentManager?.let { ProfileSwitchDialog().show(it, "NewNSTreatmentDialog") } + ProfileSwitchDialog().show(childFragmentManager, "NewNSTreatmentDialog") } localprofile_reset.setOnClickListener { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/DanaRFragment.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/DanaRFragment.kt index 60420d6d70..9a8477ae2d 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/DanaRFragment.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/DanaRFragment.kt @@ -71,21 +71,19 @@ class DanaRFragment : DaggerFragment() { danar_history.setOnClickListener { startActivity(Intent(context, DanaRHistoryActivity::class.java)) } danar_viewprofile.setOnClickListener { - fragmentManager?.let { fragmentManager -> - val profile = danaRPump.createConvertedProfile()?.getDefaultProfile() - ?: return@let - val profileName = danaRPump.createConvertedProfile()?.getDefaultProfileName() - ?: return@let - val args = Bundle() - args.putLong("time", DateUtil.now()) - args.putInt("mode", ProfileViewerDialog.Mode.CUSTOM_PROFILE.ordinal) - args.putString("customProfile", profile.data.toString()) - args.putString("customProfileUnits", profile.units) - args.putString("customProfileName", profileName) - val pvd = ProfileViewerDialog() - pvd.arguments = args - pvd.show(fragmentManager, "ProfileViewDialog") - } + val profile = danaRPump.createConvertedProfile()?.getDefaultProfile() + ?: return@setOnClickListener + val profileName = danaRPump.createConvertedProfile()?.getDefaultProfileName() + ?: return@setOnClickListener + val args = Bundle() + args.putLong("time", DateUtil.now()) + args.putInt("mode", ProfileViewerDialog.Mode.CUSTOM_PROFILE.ordinal) + args.putString("customProfile", profile.data.toString()) + args.putString("customProfileUnits", profile.units) + args.putString("customProfileName", profileName) + val pvd = ProfileViewerDialog() + pvd.arguments = args + pvd.show(childFragmentManager, "ProfileViewDialog") } danar_stats.setOnClickListener { startActivity(Intent(context, TDDStatsActivity::class.java)) } danar_user_options.setOnClickListener { startActivity(Intent(context, DanaRUserOptionsActivity::class.java)) } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/OmnipodFragment.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/OmnipodFragment.kt index fce29225d4..6dba697009 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/OmnipodFragment.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/OmnipodFragment.kt @@ -176,7 +176,7 @@ class OmnipodFragment : DaggerFragment() { disposable += rxBus .toObservable(EventPreferenceChange::class.java) .observeOn(Schedulers.io()) - .subscribe({ event -> + .subscribe({ setVisibilityOfPodDebugButton() }, { fabricPrivacy.logException(it) }) } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsBolusFragment.kt b/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsBolusFragment.kt index a6b1cdf296..7e130ceab9 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsBolusFragment.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsBolusFragment.kt @@ -145,12 +145,10 @@ class TreatmentsBolusFragment : DaggerFragment() { init { calculation.setOnClickListener { val treatment = it.tag as Treatment - fragmentManager?.let { fragmentManager -> - if (treatment.getBoluscalc() != null) { - val wizardDialog = WizardInfoDialog() - wizardDialog.setData(treatment.getBoluscalc()!!) - wizardDialog.show(fragmentManager, "WizardInfoDialog") - } + if (treatment.getBoluscalc() != null) { + val wizardDialog = WizardInfoDialog() + wizardDialog.setData(treatment.getBoluscalc()!!) + wizardDialog.show(childFragmentManager, "WizardInfoDialog") } } calculation.paintFlags = calculation.paintFlags or Paint.UNDERLINE_TEXT_FLAG diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsProfileSwitchFragment.kt b/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsProfileSwitchFragment.kt index 10bdf42de5..d45d547ef0 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsProfileSwitchFragment.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsProfileSwitchFragment.kt @@ -156,7 +156,7 @@ class TreatmentsProfileSwitchFragment : DaggerFragment() { args.putInt("mode", ProfileViewerDialog.Mode.RUNNING_PROFILE.ordinal) val pvd = ProfileViewerDialog() pvd.arguments = args - fragmentManager?.let { pvd.show(it, "ProfileViewDialog") } + pvd.show(childFragmentManager, "ProfileViewDialog") } } } diff --git a/core/src/main/java/info/nightscout/androidaps/utils/ui/UIRunnable.kt b/core/src/main/java/info/nightscout/androidaps/utils/ui/UIRunnable.kt new file mode 100644 index 0000000000..d3860ac53b --- /dev/null +++ b/core/src/main/java/info/nightscout/androidaps/utils/ui/UIRunnable.kt @@ -0,0 +1,9 @@ +package info.nightscout.androidaps.utils.ui + +import info.nightscout.androidaps.utils.extensions.runOnUiThread + +class UIRunnable (val runnable: Runnable) : Runnable { + override fun run() { + runOnUiThread(runnable) + } +} \ No newline at end of file