mirror of
https://github.com/oliexdev/openScale.git
synced 2025-08-19 23:12:12 +02:00
Fix sync selectedUser field in driver with setSelectedScaleUser()
This commit is contained in:
@@ -110,6 +110,13 @@ public abstract class BluetoothStandardWeightProfile extends BluetoothCommunicat
|
||||
MAX_STEP
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSelectedScaleUser(ScaleUser user) {
|
||||
super.setSelectedScaleUser(user);
|
||||
this.selectedUser = user;
|
||||
LogManager.d(TAG, "setSelectedScaleUser: id=" + (user != null ? user.getId() : -1));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean onNextStep(int stepNr) {
|
||||
|
||||
@@ -746,7 +753,7 @@ public abstract class BluetoothStandardWeightProfile extends BluetoothCommunicat
|
||||
}
|
||||
|
||||
protected synchronized void storeUserScaleConsentCode(int userId, int consentCode) {
|
||||
prefs.edit().putInt("userConsentCode" + userId, consentCode).apply();
|
||||
prefs.edit().putInt("userConsentCode" + userId, consentCode).commit();
|
||||
LogManager.d(TAG, "storeUserScaleConsentCode: userId=" + userId + " now=" + getUserScaleConsent(userId));
|
||||
}
|
||||
|
||||
@@ -757,11 +764,11 @@ public abstract class BluetoothStandardWeightProfile extends BluetoothCommunicat
|
||||
protected synchronized void storeUserScaleIndex(int userId, int userIndex) {
|
||||
int currentUserIndex = getUserScaleIndex(userId);
|
||||
if (currentUserIndex != -1) {
|
||||
prefs.edit().putInt("userIdFromUserScaleIndex" + currentUserIndex, -1).apply();
|
||||
prefs.edit().putInt("userIdFromUserScaleIndex" + currentUserIndex, -1).commit();
|
||||
}
|
||||
prefs.edit().putInt("userScaleIndex" + userId, userIndex).apply();
|
||||
prefs.edit().putInt("userScaleIndex" + userId, userIndex).commit();
|
||||
if (userIndex != -1) {
|
||||
prefs.edit().putInt("userIdFromUserScaleIndex" + userIndex, userId).apply();
|
||||
prefs.edit().putInt("userIdFromUserScaleIndex" + userIndex, userId).commit();
|
||||
}
|
||||
LogManager.d(TAG, "storeUserScaleIndex: userId=" + userId + " now=" + getUserScaleIndex(userId));
|
||||
}
|
||||
|
@@ -101,6 +101,8 @@ class LegacyScaleAdapter(
|
||||
|
||||
private suspend fun provideUserDataToLegacyDriver() {
|
||||
try {
|
||||
currentInternalUser?.let { bluetoothDriverInstance.setSelectedScaleUser(it) }
|
||||
|
||||
LogManager.d(TAG, "Attempting to load user data for legacy driver: ${bluetoothDriverInstance.driverName()}")
|
||||
val userListFromDb = databaseRepository.getAllUsers().first()
|
||||
|
||||
@@ -325,8 +327,6 @@ class LegacyScaleAdapter(
|
||||
|
||||
provideUserDataToLegacyDriver()
|
||||
|
||||
currentInternalUser?.let { bluetoothDriverInstance.setSelectedScaleUser(it) }
|
||||
|
||||
LogManager.d(TAG, "connect: Calling connect() on Java driver instance (${bluetoothDriverInstance.driverName()}) for $address.")
|
||||
try {
|
||||
bluetoothDriverInstance.connect(address)
|
||||
|
Reference in New Issue
Block a user