mirror of
https://github.com/russok/FitoTrack.git
synced 2025-10-28 16:22:12 -07:00
ListWorkoutActivity
This commit is contained in:
parent
93054f821e
commit
cc39f89a77
@ -21,10 +21,9 @@ android {
|
||||
|
||||
dependencies {
|
||||
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
||||
implementation 'com.android.support:appcompat-v7:28.0.0'
|
||||
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
|
||||
implementation "androidx.room:room-runtime:2.2.0-alpha02"
|
||||
implementation 'androidx.recyclerview:recyclerview:1.0.0'
|
||||
testImplementation 'junit:junit:4.12'
|
||||
androidTestImplementation 'com.android.support.test:runner:1.0.2'
|
||||
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
|
||||
}
|
||||
|
||||
@ -31,7 +31,7 @@ public class Instance {
|
||||
|
||||
private static Instance instance;
|
||||
|
||||
public Instance getInstance(Context context){
|
||||
public static Instance getInstance(Context context){
|
||||
if(instance == null){
|
||||
instance= new Instance(context);
|
||||
}
|
||||
|
||||
@ -21,14 +21,37 @@ package de.tadris.fitness;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.os.Bundle;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import de.tadris.fitness.data.Workout;
|
||||
|
||||
public class ListWorkoutsActivity extends Activity {
|
||||
|
||||
private RecyclerView listView;
|
||||
private RecyclerView.Adapter mAdapter;
|
||||
private RecyclerView.LayoutManager layoutManager;
|
||||
Workout[] workouts;
|
||||
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_list_workouts);
|
||||
|
||||
listView= findViewById(R.id.workoutList);
|
||||
listView.setHasFixedSize(true);
|
||||
|
||||
layoutManager= new LinearLayoutManager(this);
|
||||
listView.setLayoutManager(layoutManager);
|
||||
|
||||
Instance.getInstance(this).db.workoutDao().getWorkouts();
|
||||
listView.setAdapter(new WorkoutAdapter());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
17
app/src/main/java/de/tadris/fitness/WorkoutAdapter.java
Normal file
17
app/src/main/java/de/tadris/fitness/WorkoutAdapter.java
Normal file
@ -0,0 +1,17 @@
|
||||
package de.tadris.fitness;
|
||||
|
||||
import android.view.View;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
public class WorkoutAdapter {
|
||||
|
||||
|
||||
public static class WorkoutViewHolder extends RecyclerView.ViewHolder{
|
||||
public WorkoutViewHolder(@NonNull View itemView) {
|
||||
super(itemView);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -28,4 +28,7 @@ public interface WorkoutDao {
|
||||
@Query("SELECT * FROM workout_sample WHERE workout_id = :workout_id")
|
||||
WorkoutSample[] getAllSamplesOfWorkout(long workout_id);
|
||||
|
||||
@Query("SELECT * FROM workout")
|
||||
Workout[] getWorkouts();
|
||||
|
||||
}
|
||||
|
||||
@ -1,9 +1,14 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context=".ListWorkoutsActivity">
|
||||
|
||||
</android.support.constraint.ConstraintLayout>
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/workoutList"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
</ScrollView>
|
||||
3
app/src/main/res/layout/view_workout.xml
Normal file
3
app/src/main/res/layout/view_workout.xml
Normal file
@ -0,0 +1,3 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent" android:layout_height="match_parent"/>
|
||||
Loading…
x
Reference in New Issue
Block a user