Correctly display workout comment

This commit is contained in:
jannis 2020-03-11 12:24:24 +01:00
parent 16c42ec350
commit 4a89e95b41

View File

@ -67,12 +67,9 @@ public class ShowWorkoutActivity extends WorkoutActivity implements DialogUtils.
initAfterContent(); initAfterContent();
String commentStr = getString(R.string.comment) + ": " + workout.comment; commentView = addText("", true);
if (workout.edited) {
commentStr = getString(R.string.workoutEdited) + "\n" + commentStr;
}
commentView = addText(commentStr, true);
commentView.setOnClickListener(v -> openEditCommentDialog()); commentView.setOnClickListener(v -> openEditCommentDialog());
updateCommentText();
addTitle(getString(R.string.workoutTime)); addTitle(getString(R.string.workoutTime));
addKeyValue(getString(R.string.workoutDate), getDate()); addKeyValue(getString(R.string.workoutDate), getDate());
@ -136,14 +133,22 @@ public class ShowWorkoutActivity extends WorkoutActivity implements DialogUtils.
editText.setSingleLine(true); editText.setSingleLine(true);
new AlertDialog.Builder(this) new AlertDialog.Builder(this)
.setTitle(R.string.enterComment) .setTitle(R.string.enterComment)
.setPositiveButton(R.string.okay, (dialog, which) -> changeComment(editText.getText().toString(), commentView)) .setPositiveButton(R.string.okay, (dialog, which) -> changeComment(editText.getText().toString()))
.setView(editText).create().show(); .setView(editText).create().show();
} }
private void changeComment(String comment, TextView onChange) { private void changeComment(String comment) {
workout.comment= comment; workout.comment= comment;
Instance.getInstance(this).db.workoutDao().updateWorkout(workout); Instance.getInstance(this).db.workoutDao().updateWorkout(workout);
onChange.setText(getString(R.string.comment) + ": " + workout.comment); updateCommentText();
}
private void updateCommentText() {
String commentStr = getString(R.string.comment) + ": " + workout.comment;
if (workout.edited) {
commentStr = getString(R.string.workoutEdited) + "\n" + commentStr;
}
commentView.setText(commentStr);
} }
private String getDate() { private String getDate() {