Skip to content

Commit

Permalink
Merge pull request #139 from AdamGuidarini/history-crash-as-needed
Browse files Browse the repository at this point in the history
History crash as needed
  • Loading branch information
AdamGuidarini authored Dec 11, 2024
2 parents 91ca4f5 + 893bef5 commit 6963b49
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 12 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ android {
targetSdkVersion 34
compileSdk 34

versionCode 33
versionName "0.13.4"
versionCode 34
versionName "0.13.5"
resourceConfigurations += ['en', 'de', 'es', 'it', 'tr']

ndk {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ void DatabaseController::exportCsv(const string &exportPath, map<string, vector<

Medication DatabaseController::getMedication(long medicationId) {
string query = "SELECT * FROM " + MEDICATION_TABLE + " m "
+ " INNER JOIN " + MEDICATION_TIMES + " mt "
+ " LEFT JOIN " + MEDICATION_TIMES + " mt "
+ " ON " + "m." + MED_ID + "= mt." + MED_ID
+ " WHERE m." + MED_ID + "=" + to_string(medicationId);
Medication medication;
Expand Down Expand Up @@ -393,7 +393,11 @@ Medication DatabaseController::getMedication(long medicationId) {
}

while (!table->isAfterLast()) {
times.push_back(table->getItem(DRUG_TIME));
string t = table->getItem(DRUG_TIME);

if (!t.empty()) {
times.push_back(table->getItem(DRUG_TIME));
}

table->moveToNext();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,18 @@ public void onBindViewHolder(@NonNull HistoryAdapter.ViewHolder holder, int posi
LocalDateTime scheduledDateTime = doses[position].getDoseTime();
LocalDateTime takenDateTime = doses[position].getTimeTaken();

String scheduleDate = DateTimeFormatter.ofPattern(
dateFormat, Locale.getDefault()
).format(scheduledDateTime.toLocalDate());
String scheduleTime = DateTimeFormatter.ofPattern(
timeFormat, Locale.getDefault()
).format(scheduledDateTime.toLocalTime());
if (currentMed.getFrequency() == 0) {
holder.scheduledDateLabel.setText("N/A");
} else {
String scheduleDate = DateTimeFormatter.ofPattern(
dateFormat, Locale.getDefault()
).format(scheduledDateTime.toLocalDate());
String scheduleTime = DateTimeFormatter.ofPattern(
timeFormat, Locale.getDefault()
).format(scheduledDateTime.toLocalTime());

holder.scheduledDateLabel.setText(scheduleDate + "\n" + scheduleTime);
}

String takenDate = DateTimeFormatter.ofPattern(
dateFormat, Locale.getDefault()
Expand All @@ -93,7 +99,6 @@ public void onBindViewHolder(@NonNull HistoryAdapter.ViewHolder holder, int posi
doseLbl += currentMed.getDosageUnits();
}

holder.scheduledDateLabel.setText(scheduleDate + "\n" + scheduleTime);
holder.takenDateLabel.setText(takenDate + "\n" + takenTime);
holder.dosageAmount.setText(doseLbl);

Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ buildscript {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:8.7.2'
classpath 'com.android.tools.build:gradle:8.7.3'

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
Expand Down

0 comments on commit 6963b49

Please sign in to comment.