Merge branch 'master' into develop

# Conflicts:
#	app/src/main/java/de/tadris/fitness/view/WorkoutAdapter.java
This commit is contained in:
jannis 2019-08-20 17:53:28 +02:00
commit 1a074b33f8
4 changed files with 59 additions and 22 deletions

View File

@ -171,6 +171,7 @@ public class RecordWorkoutActivity extends FitoTrackActivity implements Location
private void showEnterDescriptionDialog(){
final EditText editText= new EditText(this);
editText.setSingleLine(true);
new AlertDialog.Builder(this).setTitle(R.string.enterComment).setPositiveButton(R.string.okay, (dialog, which) -> {
dialog.cancel();
recorder.setComment(editText.getText().toString());

View File

@ -144,6 +144,7 @@ public class ShowWorkoutActivity extends FitoTrackActivity {
void openEditCommentDialog(final TextView change){
final EditText editText= new EditText(this);
editText.setText(workout.comment);
editText.setSingleLine(true);
new AlertDialog.Builder(this)
.setTitle(R.string.enterComment)
.setPositiveButton(R.string.okay, (dialog, which) -> changeComment(editText.getText().toString(), change))

View File

@ -17,7 +17,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package de.tadris.fitness.view;
package de.tadris.fitness;
import android.view.LayoutInflater;
import android.view.View;
@ -27,9 +27,12 @@ import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import de.tadris.fitness.R;
import java.text.SimpleDateFormat;
import java.util.Date;
import de.tadris.fitness.data.Workout;
import de.tadris.fitness.util.UnitUtils;
import de.tadris.fitness.util.WorkoutTypeCalculator;
public class WorkoutAdapter extends RecyclerView.Adapter<WorkoutAdapter.WorkoutViewHolder>{
@ -37,13 +40,16 @@ public class WorkoutAdapter extends RecyclerView.Adapter<WorkoutAdapter.WorkoutV
public static class WorkoutViewHolder extends RecyclerView.ViewHolder{
View root;
TextView lengthText, timeText;
TextView lengthText, timeText, dateText, typeText, commentText;
public WorkoutViewHolder(@NonNull View itemView) {
super(itemView);
this.root= itemView;
lengthText= itemView.findViewById(R.id.workoutLength);
timeText= itemView.findViewById(R.id.workoutTime);
dateText= itemView.findViewById(R.id.workoutDate);
typeText= itemView.findViewById(R.id.workoutType);
commentText=itemView.findViewById(R.id.workoutComment);
}
}
@ -65,14 +71,17 @@ public class WorkoutAdapter extends RecyclerView.Adapter<WorkoutAdapter.WorkoutV
// Replace the contents of a view (invoked by the layout manager)
@Override
public void onBindViewHolder(WorkoutViewHolder holder, final int position) {
holder.lengthText.setText(UnitUtils.getDistance(workouts[position].length));
holder.timeText.setText(UnitUtils.getHourMinuteTime(workouts[position].duration));
holder.root.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
listener.onItemClick(workouts[position]);
}
});
Workout workout= workouts[position];
holder.dateText.setText(SimpleDateFormat.getDateTimeInstance().format(new Date(workout.start)));
holder.typeText.setText(WorkoutTypeCalculator.getType(workout));
if(workout.comment.length() > 33){
holder.commentText.setText(workout.comment.substring(0, 30) + "...");
}else{
holder.commentText.setText(workout.comment);
}
holder.lengthText.setText(UnitUtils.getDistance(workout.length));
holder.timeText.setText(UnitUtils.getHourMinuteTime(workout.duration));
holder.root.setOnClickListener(v -> listener.onItemClick(workout));
}
// Return the size of your dataset (invoked by the layout manager)

View File

@ -27,18 +27,52 @@
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
android:layout_margin="15dp"
android:orientation="vertical">
<TextView
android:id="@+id/workoutDate"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Aug 19, 2019 20:15"
android:textAllCaps="true"
android:textColor="@color/textLighterBlack"
android:textSize="18sp"
android:textStyle="bold" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="horizontal">
<TextView
android:id="@+id/workoutType"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Running" />
<TextView
android:id="@+id/workoutComment"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="my custom comment"
android:textAlignment="textEnd" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_margin="15dp">
android:orientation="horizontal">
<TextView
android:id="@+id/workoutLength"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginRight="15dp"
android:text="8km"
android:textSize="36sp" />
@ -51,14 +85,6 @@
android:textSize="30sp" />
</LinearLayout>
<LinearLayout
android:id="@+id/workoutPreviewRoot"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
</LinearLayout>
</LinearLayout>
<View