fix displaying profile switches
This commit is contained in:
parent
6783c78d32
commit
3305a5979d
4 changed files with 19 additions and 7 deletions
|
@ -69,4 +69,8 @@ public class DatabaseHelperProvider implements DatabaseHelperInterface {
|
|||
@Override public long roundDateToSec(long date) {
|
||||
return MainApp.getDbHelper().roundDateToSec(date);
|
||||
}
|
||||
|
||||
@NotNull @Override public List<ProfileSwitch> getProfileSwitchData(long from, boolean ascending) {
|
||||
return MainApp.getDbHelper().getProfileSwitchData(from, ascending);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -156,7 +156,7 @@ class TreatmentsProfileSwitchFragment : DaggerFragment() {
|
|||
R.id.profileswitch_date, R.id.profileswitch_name -> {
|
||||
val args = Bundle()
|
||||
args.putLong("time", (v.tag as ProfileSwitch).date)
|
||||
args.putInt("mode", ProfileViewerDialog.Mode.RUNNING_PROFILE.ordinal)
|
||||
args.putInt("mode", ProfileViewerDialog.Mode.DB_PROFILE.ordinal)
|
||||
val pvd = ProfileViewerDialog()
|
||||
pvd.arguments = args
|
||||
pvd.show(childFragmentManager, "ProfileViewDialog")
|
||||
|
|
|
@ -12,6 +12,7 @@ import info.nightscout.androidaps.Constants
|
|||
import info.nightscout.androidaps.core.R
|
||||
import info.nightscout.androidaps.data.Profile
|
||||
import info.nightscout.androidaps.interfaces.ActivePluginProvider
|
||||
import info.nightscout.androidaps.interfaces.DatabaseHelperInterface
|
||||
import info.nightscout.androidaps.utils.DateUtil
|
||||
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||
import kotlinx.android.synthetic.main.close.*
|
||||
|
@ -24,12 +25,14 @@ class ProfileViewerDialog : DaggerDialogFragment() {
|
|||
@Inject lateinit var resourceHelper: ResourceHelper
|
||||
@Inject lateinit var activePlugin: ActivePluginProvider
|
||||
@Inject lateinit var dateUtil: DateUtil
|
||||
@Inject lateinit var databaseHelper: DatabaseHelperInterface
|
||||
|
||||
private var time: Long = 0
|
||||
|
||||
enum class Mode(val i: Int) {
|
||||
RUNNING_PROFILE(1),
|
||||
CUSTOM_PROFILE(2)
|
||||
CUSTOM_PROFILE(2),
|
||||
DB_PROFILE(3)
|
||||
}
|
||||
|
||||
private var mode: Mode = Mode.RUNNING_PROFILE
|
||||
|
@ -79,6 +82,14 @@ class ProfileViewerDialog : DaggerDialogFragment() {
|
|||
date = ""
|
||||
profileview_datelayout.visibility = View.GONE
|
||||
}
|
||||
|
||||
Mode.DB_PROFILE -> {
|
||||
val profileList = databaseHelper.getProfileSwitchData(time, true)
|
||||
profile = if (profileList.isNotEmpty()) profileList[0].profileObject else null
|
||||
profileName = if (profileList.isNotEmpty()) profileList[0].customizedName else null
|
||||
date = if (profileList.isNotEmpty()) dateUtil.dateAndTimeString(profileList[0].date) else null
|
||||
profileview_datelayout.visibility = View.VISIBLE
|
||||
}
|
||||
}
|
||||
profileview_noprofile.visibility = View.VISIBLE
|
||||
|
||||
|
|
|
@ -1,11 +1,7 @@
|
|||
package info.nightscout.androidaps.interfaces
|
||||
|
||||
import com.j256.ormlite.dao.CloseableIterator
|
||||
import info.nightscout.androidaps.db.BgReading
|
||||
import info.nightscout.androidaps.db.CareportalEvent
|
||||
import info.nightscout.androidaps.db.DanaRHistoryRecord
|
||||
import info.nightscout.androidaps.db.DbRequest
|
||||
import info.nightscout.androidaps.db.TDD
|
||||
import info.nightscout.androidaps.db.*
|
||||
|
||||
interface DatabaseHelperInterface {
|
||||
|
||||
|
@ -21,4 +17,5 @@ interface DatabaseHelperInterface {
|
|||
fun deleteDbRequestbyMongoId(action: String, _id: String)
|
||||
fun getDbRequestInterator(): CloseableIterator<DbRequest>
|
||||
fun roundDateToSec(date: Long): Long
|
||||
fun getProfileSwitchData(from: Long, ascending: Boolean): List<ProfileSwitch>
|
||||
}
|
Loading…
Reference in a new issue