mirror of
https://github.com/russok/FitoTrack.git
synced 2025-10-29 00:32:11 -07:00
Merge branch 'master' into feature-unit_systems
# Conflicts: # app/src/main/java/de/tadris/fitness/WorkoutAdapter.java
This commit is contained in:
commit
eea30747cd
@ -27,8 +27,12 @@ import android.widget.TextView;
|
|||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
import de.tadris.fitness.data.Workout;
|
import de.tadris.fitness.data.Workout;
|
||||||
import de.tadris.fitness.util.unit.UnitUtils;
|
import de.tadris.fitness.util.unit.UnitUtils;
|
||||||
|
import de.tadris.fitness.util.WorkoutTypeCalculator;
|
||||||
|
|
||||||
public class WorkoutAdapter extends RecyclerView.Adapter<WorkoutAdapter.WorkoutViewHolder>{
|
public class WorkoutAdapter extends RecyclerView.Adapter<WorkoutAdapter.WorkoutViewHolder>{
|
||||||
|
|
||||||
@ -36,13 +40,16 @@ public class WorkoutAdapter extends RecyclerView.Adapter<WorkoutAdapter.WorkoutV
|
|||||||
public static class WorkoutViewHolder extends RecyclerView.ViewHolder{
|
public static class WorkoutViewHolder extends RecyclerView.ViewHolder{
|
||||||
|
|
||||||
View root;
|
View root;
|
||||||
TextView lengthText, timeText;
|
TextView lengthText, timeText, dateText, typeText, commentText;
|
||||||
|
|
||||||
public WorkoutViewHolder(@NonNull View itemView) {
|
public WorkoutViewHolder(@NonNull View itemView) {
|
||||||
super(itemView);
|
super(itemView);
|
||||||
this.root= itemView;
|
this.root= itemView;
|
||||||
lengthText= itemView.findViewById(R.id.workoutLength);
|
lengthText= itemView.findViewById(R.id.workoutLength);
|
||||||
timeText= itemView.findViewById(R.id.workoutTime);
|
timeText= itemView.findViewById(R.id.workoutTime);
|
||||||
|
dateText= itemView.findViewById(R.id.workoutDate);
|
||||||
|
typeText= itemView.findViewById(R.id.workoutType);
|
||||||
|
commentText=itemView.findViewById(R.id.workoutComment);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -64,14 +71,17 @@ public class WorkoutAdapter extends RecyclerView.Adapter<WorkoutAdapter.WorkoutV
|
|||||||
// Replace the contents of a view (invoked by the layout manager)
|
// Replace the contents of a view (invoked by the layout manager)
|
||||||
@Override
|
@Override
|
||||||
public void onBindViewHolder(WorkoutViewHolder holder, final int position) {
|
public void onBindViewHolder(WorkoutViewHolder holder, final int position) {
|
||||||
holder.lengthText.setText(UnitUtils.getDistance(workouts[position].length));
|
Workout workout= workouts[position];
|
||||||
holder.timeText.setText(UnitUtils.getHourMinuteTime(workouts[position].duration));
|
holder.dateText.setText(SimpleDateFormat.getDateTimeInstance().format(new Date(workout.start)));
|
||||||
holder.root.setOnClickListener(new View.OnClickListener() {
|
holder.typeText.setText(WorkoutTypeCalculator.getType(workout));
|
||||||
@Override
|
if(workout.comment.length() > 33){
|
||||||
public void onClick(View v) {
|
holder.commentText.setText(workout.comment.substring(0, 30) + "...");
|
||||||
listener.onItemClick(workouts[position]);
|
}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)
|
// Return the size of your dataset (invoked by the layout manager)
|
||||||
|
|||||||
@ -171,6 +171,7 @@ public class RecordWorkoutActivity extends FitoTrackActivity implements Location
|
|||||||
|
|
||||||
private void showEnterDescriptionDialog(){
|
private void showEnterDescriptionDialog(){
|
||||||
final EditText editText= new EditText(this);
|
final EditText editText= new EditText(this);
|
||||||
|
editText.setSingleLine(true);
|
||||||
new AlertDialog.Builder(this).setTitle(R.string.enterComment).setPositiveButton(R.string.okay, (dialog, which) -> {
|
new AlertDialog.Builder(this).setTitle(R.string.enterComment).setPositiveButton(R.string.okay, (dialog, which) -> {
|
||||||
dialog.cancel();
|
dialog.cancel();
|
||||||
recorder.setComment(editText.getText().toString());
|
recorder.setComment(editText.getText().toString());
|
||||||
|
|||||||
@ -129,6 +129,7 @@ public class ShowWorkoutActivity extends FitoTrackActivity {
|
|||||||
void openEditCommentDialog(final TextView change){
|
void openEditCommentDialog(final TextView change){
|
||||||
final EditText editText= new EditText(this);
|
final EditText editText= new EditText(this);
|
||||||
editText.setText(workout.comment);
|
editText.setText(workout.comment);
|
||||||
|
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(), change))
|
.setPositiveButton(R.string.okay, (dialog, which) -> changeComment(editText.getText().toString(), change))
|
||||||
|
|||||||
@ -27,18 +27,52 @@
|
|||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
|
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">
|
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
|
<LinearLayout
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="vertical"
|
android:orientation="horizontal">
|
||||||
android:layout_margin="15dp">
|
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/workoutLength"
|
android:id="@+id/workoutLength"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginRight="15dp"
|
||||||
android:text="8km"
|
android:text="8km"
|
||||||
android:textSize="36sp" />
|
android:textSize="36sp" />
|
||||||
|
|
||||||
@ -51,14 +85,6 @@
|
|||||||
android:textSize="30sp" />
|
android:textSize="30sp" />
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:id="@+id/workoutPreviewRoot"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:orientation="vertical">
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<View
|
<View
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user