activate correct profile
This commit is contained in:
parent
500de5fa2d
commit
6a1394b7b9
2 changed files with 14 additions and 4 deletions
|
@ -28,6 +28,8 @@ class ProfileSwitchDialog : DialogFragmentWithDate() {
|
|||
@Inject lateinit var treatmentsPlugin: TreatmentsPlugin
|
||||
@Inject lateinit var activePlugin: ActivePluginProvider
|
||||
|
||||
var profileIndex: Int? = null
|
||||
|
||||
override fun onSaveInstanceState(savedInstanceState: Bundle) {
|
||||
super.onSaveInstanceState(savedInstanceState)
|
||||
savedInstanceState.putDouble("overview_profileswitch_duration", overview_profileswitch_duration.value)
|
||||
|
@ -38,6 +40,9 @@ class ProfileSwitchDialog : DialogFragmentWithDate() {
|
|||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,
|
||||
savedInstanceState: Bundle?): View? {
|
||||
onCreateViewGeneral()
|
||||
arguments?.let { bundle ->
|
||||
profileIndex = bundle.getInt("profileIndex", 0)
|
||||
}
|
||||
return inflater.inflate(R.layout.dialog_profileswitch, container, false)
|
||||
}
|
||||
|
||||
|
@ -59,9 +64,12 @@ class ProfileSwitchDialog : DialogFragmentWithDate() {
|
|||
val adapter = ArrayAdapter(context, R.layout.spinner_centered, profileList)
|
||||
overview_profileswitch_profile.adapter = adapter
|
||||
// set selected to actual profile
|
||||
for (p in profileList.indices)
|
||||
if (profileList[p] == profileFunction.getProfileName(false))
|
||||
overview_profileswitch_profile.setSelection(p)
|
||||
if (profileIndex != null)
|
||||
overview_profileswitch_profile.setSelection(profileIndex as Int)
|
||||
else
|
||||
for (p in profileList.indices)
|
||||
if (profileList[p] == profileFunction.getProfileName(false))
|
||||
overview_profileswitch_profile.setSelection(p)
|
||||
} ?: return
|
||||
|
||||
treatmentsPlugin.getProfileSwitchFromHistory(DateUtil.now())?.let { ps ->
|
||||
|
|
|
@ -181,7 +181,9 @@ class LocalProfileFragment : DaggerFragment() {
|
|||
|
||||
localprofile_profileswitch.setOnClickListener {
|
||||
// TODO: select in dialog localProfilePlugin.currentProfileIndex
|
||||
ProfileSwitchDialog().show(childFragmentManager, "NewNSTreatmentDialog")
|
||||
ProfileSwitchDialog()
|
||||
.also { it.arguments = Bundle().also { bundle -> bundle.putInt("profileIndex", localProfilePlugin.currentProfileIndex) }}
|
||||
.show(childFragmentManager, "NewNSTreatmentDialog")
|
||||
}
|
||||
|
||||
localprofile_reset.setOnClickListener {
|
||||
|
|
Loading…
Add table
Reference in a new issue