Compare commits
2 Commits
e820c11e68
...
6f69b581e4
| Author | SHA1 | Date | |
|---|---|---|---|
| 6f69b581e4 | |||
| ec80f78baf |
@@ -420,17 +420,6 @@ class MainActivity : AppCompatActivity() {
|
|||||||
return dateTime
|
return dateTime
|
||||||
}
|
}
|
||||||
|
|
||||||
fun saveEvent(event: LunaEvent) {
|
|
||||||
if (!allEvents.contains(event)) {
|
|
||||||
// new event
|
|
||||||
logEvent(event)
|
|
||||||
}
|
|
||||||
|
|
||||||
logbook?.sort()
|
|
||||||
recyclerView.adapter?.notifyDataSetChanged()
|
|
||||||
saveLogbook()
|
|
||||||
}
|
|
||||||
|
|
||||||
fun addSleepEvent(event: LunaEvent) {
|
fun addSleepEvent(event: LunaEvent) {
|
||||||
askSleepValue(event) { saveEvent(event) }
|
askSleepValue(event) { saveEvent(event) }
|
||||||
}
|
}
|
||||||
@@ -1116,23 +1105,6 @@ class MainActivity : AppCompatActivity() {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
fun logEvent(event: LunaEvent) {
|
|
||||||
savingEvent(true)
|
|
||||||
|
|
||||||
event.signature = signature
|
|
||||||
|
|
||||||
setLoading(true)
|
|
||||||
logbook?.logs?.add(0, event)
|
|
||||||
recyclerView.adapter?.notifyItemInserted(0)
|
|
||||||
recyclerView.smoothScrollToPosition(0)
|
|
||||||
saveLogbook(event)
|
|
||||||
|
|
||||||
// Check logbook size to avoid OOM errors
|
|
||||||
if (logbook?.isTooBig() == true) {
|
|
||||||
askToTrimLogbook()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fun deleteEvent(event: LunaEvent) {
|
fun deleteEvent(event: LunaEvent) {
|
||||||
// Update view
|
// Update view
|
||||||
savingEvent(true)
|
savingEvent(true)
|
||||||
@@ -1144,6 +1116,32 @@ class MainActivity : AppCompatActivity() {
|
|||||||
saveLogbook()
|
saveLogbook()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun saveEvent(event: LunaEvent) {
|
||||||
|
if (allEvents.contains(event)) {
|
||||||
|
// event was modified
|
||||||
|
logbook?.sort()
|
||||||
|
recyclerView.adapter?.notifyDataSetChanged()
|
||||||
|
saveLogbook()
|
||||||
|
} else {
|
||||||
|
// add new event
|
||||||
|
savingEvent(true)
|
||||||
|
setLoading(true)
|
||||||
|
if (signature.isNotEmpty()) {
|
||||||
|
event.signature = signature
|
||||||
|
}
|
||||||
|
logbook?.logs?.add(0, event)
|
||||||
|
logbook?.sort()
|
||||||
|
recyclerView.adapter?.notifyItemInserted(0)
|
||||||
|
recyclerView.smoothScrollToPosition(0)
|
||||||
|
saveLogbook(event)
|
||||||
|
|
||||||
|
// Check logbook size to avoid OOM errors
|
||||||
|
if (logbook?.isTooBig() == true) {
|
||||||
|
askToTrimLogbook()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Saves the logbook. If saving while adding an event, please specify the event so in case
|
* Saves the logbook. If saving while adding an event, please specify the event so in case
|
||||||
* of error can be removed from the list.
|
* of error can be removed from the list.
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -32,25 +32,18 @@
|
|||||||
android:orientation="horizontal">
|
android:orientation="horizontal">
|
||||||
|
|
||||||
<Spinner
|
<Spinner
|
||||||
android:id="@+id/type_selection"
|
android:id="@+id/graph_type_selection"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:gravity="center"
|
android:layout_weight="1"
|
||||||
android:layout_weight="1" />
|
android:gravity="center"/>
|
||||||
|
|
||||||
<Spinner
|
<Spinner
|
||||||
android:id="@+id/data_selection"
|
android:id="@+id/time_range_selection"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:gravity="center"
|
android:layout_weight="1"
|
||||||
android:layout_weight="1"/>
|
android:gravity="center"/>
|
||||||
|
|
||||||
<Spinner
|
|
||||||
android:id="@+id/time_selection"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:gravity="center"
|
|
||||||
android:layout_weight="1"/>
|
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
|||||||
@@ -8,23 +8,21 @@
|
|||||||
</string-array>
|
</string-array>
|
||||||
|
|
||||||
<string-array name="StatisticsTypeLabels">
|
<string-array name="StatisticsTypeLabels">
|
||||||
<item>Bottle</item>
|
<item>@string/statistics_bottle_sum</item>
|
||||||
<item>Sleep</item>
|
<item>@string/statistics_bottle_events</item>
|
||||||
|
<item>@string/statistics_sleep_sum</item>
|
||||||
|
<item>@string/statistics_sleep_events</item>
|
||||||
|
<item>@string/statistics_sleep_pattern</item>
|
||||||
|
<item>@string/statistics_medicine_events</item>
|
||||||
</string-array>
|
</string-array>
|
||||||
|
|
||||||
<string-array name="StatisticsTypeValues">
|
<string-array name="StatisticsTypeValues">
|
||||||
<item>BOTTLE</item>
|
<item>BOTTLE_SUM</item>
|
||||||
<item>SLEEP</item>
|
<item>BOTTLE_EVENTS</item>
|
||||||
</string-array>
|
<item>SLEEP_SUM</item>
|
||||||
|
<item>SLEEP_EVENTS</item>
|
||||||
<string-array name="StatisticsDataLabels">
|
<item>SLEEP_PATTERN</item>
|
||||||
<item>Event</item>
|
<item>MEDICINE_EVENTS</item>
|
||||||
<item>Amount</item>
|
|
||||||
</string-array>
|
|
||||||
|
|
||||||
<string-array name="StatisticsDataValues">
|
|
||||||
<item>EVENT</item>
|
|
||||||
<item>AMOUNT</item>
|
|
||||||
</string-array>
|
</string-array>
|
||||||
|
|
||||||
<string-array name="StatisticsTimeLabels">
|
<string-array name="StatisticsTimeLabels">
|
||||||
@@ -38,5 +36,4 @@
|
|||||||
<item>WEEK</item>
|
<item>WEEK</item>
|
||||||
<item>MONTH</item>
|
<item>MONTH</item>
|
||||||
</string-array>
|
</string-array>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
@@ -140,6 +140,13 @@
|
|||||||
<string name="measurement_unit_temperature_base_imperial" translatable="false">°F</string>
|
<string name="measurement_unit_temperature_base_imperial" translatable="false">°F</string>
|
||||||
<string name="measurement_unit_temperature_base_metric" translatable="false">°C</string>
|
<string name="measurement_unit_temperature_base_metric" translatable="false">°C</string>
|
||||||
|
|
||||||
|
<string name="statistics_bottle_events">Bottle Events</string>
|
||||||
|
<string name="statistics_bottle_sum">Bottle Per Day</string>
|
||||||
|
<string name="statistics_medicine_events">Medicine Events</string>
|
||||||
|
<string name="statistics_sleep_sum">Sleep Per Day</string>
|
||||||
|
<string name="statistics_sleep_events">Sleep Events</string>
|
||||||
|
<string name="statistics_sleep_pattern">Sleep Pattern</string>
|
||||||
|
|
||||||
<string name="row_luna_event_description">Description</string>
|
<string name="row_luna_event_description">Description</string>
|
||||||
<string name="row_luna_event_quantity">Qty</string>
|
<string name="row_luna_event_quantity">Qty</string>
|
||||||
<string name="row_luna_event_time">Time</string>
|
<string name="row_luna_event_time">Time</string>
|
||||||
|
|||||||
Reference in New Issue
Block a user