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.Pace.columnName + ","
|
||||||
+ HuaweiWorkoutPaceSampleDao.Properties.PointIndex.columnName + ","
|
+ HuaweiWorkoutPaceSampleDao.Properties.PointIndex.columnName + ","
|
||||||
+ HuaweiWorkoutPaceSampleDao.Properties.Correction.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);
|
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)
|
if (workoutId == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
try (DBHandler db = GBApplication.acquireDB()) {
|
try (DBHandler db = GBApplication.acquireDB()) {
|
||||||
HuaweiWorkoutPaceSampleDao dao = db.getDaoSession().getHuaweiWorkoutPaceSampleDao();
|
HuaweiWorkoutPaceSampleDao dao = db.getDaoSession().getHuaweiWorkoutPaceSampleDao();
|
||||||
|
|
||||||
final DeleteQuery<HuaweiWorkoutPaceSample> tableDeleteQuery = dao.queryBuilder()
|
if(number == 0) {
|
||||||
.where(HuaweiWorkoutPaceSampleDao.Properties.WorkoutId.eq(workoutId))
|
final DeleteQuery<HuaweiWorkoutPaceSample> tableDeleteQuery = dao.queryBuilder()
|
||||||
.buildDelete();
|
.where(HuaweiWorkoutPaceSampleDao.Properties.WorkoutId.eq(workoutId))
|
||||||
tableDeleteQuery.executeDeleteWithoutDetachingEntities();
|
.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) {
|
for (Workout.WorkoutPace.Response.Block block : paceList) {
|
||||||
|
|
||||||
Integer correction = block.hasCorrection ? (int) block.correction : null;
|
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("Block num: " + packet.blocks.size());
|
||||||
LOG.info("Blocks : " + Arrays.toString(packet.blocks.toArray()));
|
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) {
|
if (this.workoutNumbers.paceCount > this.number + 1) {
|
||||||
GetWorkoutPaceRequest nextRequest = new GetWorkoutPaceRequest(
|
GetWorkoutPaceRequest nextRequest = new GetWorkoutPaceRequest(
|
||||||
|
Loading…
Reference in New Issue
Block a user