Closed adaonder closed 1 year ago
get Data code;
List
I delete all data before adding data. Code;
LocalRealmDB.getInstance().deleteAll(TerminalRDB.class, new OnResultListenerAdapter
@Override
public void onSuccess(String message) {
super.onSuccess(message);
if (StringUtil.isEmpty(SharedPrefsUtils.getString(Parameters.SharedPref.LAST_CLOCK_RECORD_EVENT_TYPE))) {
JsonElement lastClockRecordJE = dataJO.get(Parameters.REST.GraphQL.lastClockRecord);
if (!lastClockRecordJE.isJsonNull()) {
ClockRecord clockRecord = DataUtil.getModelDateData(lastClockRecordJE, ClockRecord.class);
if (clockRecord != null) {
SharedPrefsUtils.setString(Parameters.SharedPref.LAST_CLOCK_RECORD_EVENT_TYPE, clockRecord.getEventType().name());
}
}
}
JsonElement filterWithPaginateTerminalsJE = dataJO.get(Parameters.REST.GraphQL.filterWithPaginateTerminals).getAsJsonObject().getAsJsonArray(Parameters.REST.GraphQL.CONTENT);
if (!filterWithPaginateTerminalsJE.isJsonNull()) {
List<Terminal> terminalList = DataUtil.getModelDateListData(filterWithPaginateTerminalsJE.getAsJsonArray(), Terminal.class);
List<TerminalRDB> localTerminals = new ArrayList<>();
if (ControlUtil.isData(terminalList)) {
for (Terminal terminal : terminalList) {
TerminalRDB localTerminal = new TerminalRDB();
localTerminal.setId(terminal.getId());
localTerminal.setName(terminal.getName());
localTerminal.setTerminalType(terminal.getTerminalType());
localTerminal.setSerialNumber(terminal.getSerialNumber());
localTerminal.setQuickPass(terminal.isQuickPass());
localTerminal.setClockInOutAllowed(terminal.isClockInOutAllowed());
localTerminal.setClockInOutDescriptionRequired(terminal.isClockInOutDescriptionRequired());
localTerminal.setDutyInOutAllowed(terminal.isDutyInOutAllowed());
localTerminal.setDutyInOutDescriptionRequired(terminal.isDutyInOutDescriptionRequired());
localTerminal.setBreakInOutAllowed(terminal.isBreakInOutAllowed());
localTerminal.setBreakInOutDescriptionRequired(terminal.isBreakInOutDescriptionRequired());
localTerminal.setLunchInOutAllowed(terminal.isLunchInOutAllowed());
localTerminal.setLunchInOutDescriptionRequired(terminal.isLunchInOutDescriptionRequired());
localTerminal.setImageRequired(terminal.isImageRequired());
localTerminal.setInOutManualTakePhotoEnable(BooleanUtils.isTrue(terminal.getInOutManualTakePhotoEnable()) ? Boolean.TRUE.toString() : Boolean.FALSE.toString());
localTerminal.setDisabled(terminal.isDisabled());
localTerminal.setIndoorTrackingController(terminal.isIndoorTrackingController());
localTerminal.setAccessControlEnabled(terminal.isAccessControlEnabled());
localTerminal.setEmployeeAccessEnable(terminal.isEmployeeAccessEnable());
localTerminal.setCameraRotation(terminal.getCameraRotation());
localTerminals.add(localTerminal);
}
}
//LocalDB.getInstance().addTerminals(localTerminals);
LogUtil.e("saveDataList ......");
LocalRealmDB.getInstance().saveDataList(localTerminals, new OnResultListenerAdapter<String>() {
@Override
public void onSuccess(String message) {
super.onSuccess(message);
if (listener != null) {
listener.onSuccess(message);
}
}
@Override
public void onFail(String error) {
super.onFail(error);
if (listener != null) {
listener.onFail(error);
}
FirebaseUtil.sendLog(error, employeeJWT);
}
});
}
}
@Override
public void onFail(String error) {
super.onFail(error);
if (listener != null) {
listener.onFail(error);
}
}
});
Hi @adaonder
It is a bit hard to follow the flow in your code, but my guess is that you have a timing issue somewhere, i.e. that you are using executeTransactionAsync
somewhere and then immediately check for the result instead of waiting for the callback.
If you can provide a minimal project that reproduces the behaviour, we would be able to help you more easily.
@cmelchior I'm waiting for the onSuccess method then I pull the data. for executeTransactionAsync.
getRealm().executeTransactionAsync(realm -> {
//Log.e("RED_LOG", "realm");
realm.insertOrUpdate(dataList);
}, new Realm.Transaction.OnSuccess() -> {
LogUtil.e("onSuccess");
RealmResults
models.size() // 0
}, error -> {
//Log.e("RED_LOG", "onError");
LogUtil.e("error: " + error.getMessage());
});
thanks. no problem.
How frequently does the bug occur?
Sometimes
Description
I'm pulling empty data, but I've added new data. It works fine on most devices but data returns blank on some devices. I've caught firebase null returning devices. For example Redmi Note 8 Pro, Xiaomi M2007J20CG, and some Samsung devices SM-A336E, SM-J415F...
Stacktrace & log output
Can you reproduce the bug?
Sometimes
Reproduction Steps
My Realm Class;
public class LocalRealmDB { public static final String TAG = LocalRealmDB.class.getName();
}
Version
10.13.2-transformer-api
What Atlas App Services are you using?
Local Database only
Are you using encryption?
No
Platform OS and version(s)
Android 9,10,11
Build environment
Android Studio version: Android Studio Electric Eel | 2022.1.1 Patch 2 Android Build Tools version: 33 Gradle version: 7.4.2