mirror of
https://github.com/russok/FitoTrack.git
synced 2025-10-29 00:32:11 -07:00
Data Import up to 5 times faster and more secure if it fails
This commit is contained in:
parent
99182791f9
commit
82e383e953
@ -95,21 +95,25 @@ public class Exporter {
|
|||||||
.commit();
|
.commit();
|
||||||
|
|
||||||
AppDatabase database= Instance.getInstance(context).db;
|
AppDatabase database= Instance.getInstance(context).db;
|
||||||
database.clearAllTables();
|
|
||||||
|
|
||||||
listener.onStatusChanged(60, context.getString(R.string.workouts));
|
database.runInTransaction(() -> {
|
||||||
if(container.workouts != null){
|
database.clearAllTables();
|
||||||
for(Workout workout : container.workouts){
|
|
||||||
database.workoutDao().insertWorkout(workout);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
listener.onStatusChanged(80, context.getString(R.string.locationData));
|
listener.onStatusChanged(60, context.getString(R.string.workouts));
|
||||||
if(container.samples != null){
|
if(container.workouts != null){
|
||||||
for(WorkoutSample sample : container.samples){
|
for(Workout workout : container.workouts){
|
||||||
database.workoutDao().insertSample(sample);
|
database.workoutDao().insertWorkout(workout);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
listener.onStatusChanged(80, context.getString(R.string.locationData));
|
||||||
|
if(container.samples != null){
|
||||||
|
for(WorkoutSample sample : container.samples){
|
||||||
|
database.workoutDao().insertSample(sample);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
listener.onStatusChanged(100, context.getString(R.string.finished));
|
listener.onStatusChanged(100, context.getString(R.string.finished));
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user