mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge.git
synced 2025-01-10 17:11:56 +01:00
Huawei: fix pace update when more than one packets received
This commit is contained in:
parent
0e6a3e13cc
commit
80967ce42b
@ -32,7 +32,7 @@ public class GadgetbridgeUpdate_83 implements DBUpdateScript {
|
||||
+ HuaweiWorkoutPaceSampleDao.Properties.Pace.columnName + ","
|
||||
+ HuaweiWorkoutPaceSampleDao.Properties.PointIndex.columnName + ","
|
||||
+ HuaweiWorkoutPaceSampleDao.Properties.Correction.columnName + ") "
|
||||
+ " SELECT WORKOUT_ID, 0, DISTANCE, TYPE, PACE, 0, CORRECTION FROM " +HuaweiWorkoutPaceSampleDao.TABLENAME + "_temp;";
|
||||
+ " SELECT WORKOUT_ID, -1, DISTANCE, TYPE, PACE, 0, CORRECTION FROM " +HuaweiWorkoutPaceSampleDao.TABLENAME + "_temp;";
|
||||
|
||||
db.execSQL(MIGATE_DATA);
|
||||
|
||||
|
@ -1672,19 +1672,21 @@ public class HuaweiSupportProvider {
|
||||
}
|
||||
}
|
||||
|
||||
public void addWorkoutPaceData(Long workoutId, List<Workout.WorkoutPace.Response.Block> paceList) {
|
||||
public void addWorkoutPaceData(Long workoutId, List<Workout.WorkoutPace.Response.Block> paceList, short number) {
|
||||
if (workoutId == null)
|
||||
return;
|
||||
|
||||
try (DBHandler db = GBApplication.acquireDB()) {
|
||||
HuaweiWorkoutPaceSampleDao dao = db.getDaoSession().getHuaweiWorkoutPaceSampleDao();
|
||||
|
||||
final DeleteQuery<HuaweiWorkoutPaceSample> tableDeleteQuery = dao.queryBuilder()
|
||||
.where(HuaweiWorkoutPaceSampleDao.Properties.WorkoutId.eq(workoutId))
|
||||
.buildDelete();
|
||||
tableDeleteQuery.executeDeleteWithoutDetachingEntities();
|
||||
if(number == 0) {
|
||||
final DeleteQuery<HuaweiWorkoutPaceSample> tableDeleteQuery = dao.queryBuilder()
|
||||
.where(HuaweiWorkoutPaceSampleDao.Properties.WorkoutId.eq(workoutId))
|
||||
.buildDelete();
|
||||
tableDeleteQuery.executeDeleteWithoutDetachingEntities();
|
||||
}
|
||||
|
||||
int paceIndex = 0;
|
||||
int paceIndex = (int) dao.queryBuilder().where(HuaweiWorkoutPaceSampleDao.Properties.WorkoutId.eq(workoutId)).count();
|
||||
for (Workout.WorkoutPace.Response.Block block : paceList) {
|
||||
|
||||
Integer correction = block.hasCorrection ? (int) block.correction : null;
|
||||
|
@ -77,7 +77,7 @@ public class GetWorkoutPaceRequest extends Request {
|
||||
LOG.info("Block num: " + packet.blocks.size());
|
||||
LOG.info("Blocks : " + Arrays.toString(packet.blocks.toArray()));
|
||||
|
||||
supportProvider.addWorkoutPaceData(this.databaseId, packet.blocks);
|
||||
supportProvider.addWorkoutPaceData(this.databaseId, packet.blocks, packet.paceNumber);
|
||||
|
||||
if (this.workoutNumbers.paceCount > this.number + 1) {
|
||||
GetWorkoutPaceRequest nextRequest = new GetWorkoutPaceRequest(
|
||||
|
Loading…
Reference in New Issue
Block a user