Implementata pulizia dei file di log.
Forzata chiusura app in caso di uncaught exception.
This commit is contained in:
parent
d3c518b7df
commit
e704bd1597
@ -70,19 +70,19 @@ public class MainApplication extends Application {
|
||||
|
||||
|
||||
// handler listener
|
||||
private Thread.UncaughtExceptionHandler _unCaughtExceptionHandler =
|
||||
private final Thread.UncaughtExceptionHandler _unCaughtExceptionHandler =
|
||||
new Thread.UncaughtExceptionHandler() {
|
||||
@Override
|
||||
public void uncaughtException(Thread thread, Throwable ex) {
|
||||
try {
|
||||
UtilityLogger.error(new Exception(ex));
|
||||
} catch (Exception e) {
|
||||
Log.e("Uncaught error", "Exception Logger failed!", e);
|
||||
//MainApplication.exit();
|
||||
}
|
||||
|
||||
// re-throw critical exception further to the os (important)
|
||||
defaultUncaughtExceptionHandler.uncaughtException(thread, ex);
|
||||
|
||||
try {
|
||||
UtilityLogger.error(new Exception(ex));
|
||||
MainApplication.exit();
|
||||
} catch (Exception e) {
|
||||
Log.e("Uncaught error", "Exception Logger failed!", e);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@ -2,6 +2,7 @@ package it.integry.integrywmsnative.core.context;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.annimon.stream.Stream;
|
||||
import com.google.firebase.crashlytics.FirebaseCrashlytics;
|
||||
import com.orhanobut.logger.AndroidLogAdapter;
|
||||
import com.orhanobut.logger.DiskLogAdapter;
|
||||
@ -91,6 +92,32 @@ public class AppContext {
|
||||
logsFolder = new File(mApplicationContext.getExternalFilesDir(null).getAbsolutePath());
|
||||
int maxBytesSize = 5 * 1024 * 1024;
|
||||
Logger.addLogAdapter(new DiskLogAdapter(logsFolder, maxBytesSize));
|
||||
|
||||
removeOldLogs(logsFolder);
|
||||
}
|
||||
|
||||
private void removeOldLogs(File logsFolder) {
|
||||
var files = logsFolder.listFiles();
|
||||
|
||||
if (files == null || files.length <= 1)
|
||||
return;
|
||||
|
||||
var logFiles = Stream.of(files)
|
||||
.sortBy(x -> -1 * x.lastModified())
|
||||
.skip(1)
|
||||
.toList();
|
||||
|
||||
for (var logFile : logFiles) {
|
||||
boolean isDeleted = logFile.delete();
|
||||
}
|
||||
|
||||
files = logsFolder.listFiles();
|
||||
|
||||
if (files == null || files.length > 1)
|
||||
return;
|
||||
|
||||
final boolean isRenamed = files[0].renameTo(new File(files[0].getParentFile().getAbsolutePath() + "/" + "logs_0.csv"));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -39,6 +39,9 @@ public class ColliDataRecoverService {
|
||||
if(isFilePresent(CommonConst.Files.RECOVER_COLLO_FILE)) {
|
||||
loadLocalFile();
|
||||
}
|
||||
|
||||
if(mtbColtsSessions == null)
|
||||
mtbColtsSessions = new ArrayList<>();
|
||||
}
|
||||
|
||||
public boolean thereIsAnExistantSession() {
|
||||
@ -47,7 +50,6 @@ public class ColliDataRecoverService {
|
||||
|
||||
public List<Integer> getAllSessionIDs() {
|
||||
if(thereIsAnExistantSession()) {
|
||||
|
||||
return Stream.of(mtbColtsSessions)
|
||||
.map(ColliDataRecoverDTO::getId)
|
||||
.toList();
|
||||
@ -56,7 +58,6 @@ public class ColliDataRecoverService {
|
||||
}
|
||||
|
||||
public ColliDataRecoverDTO getSession(Integer sessionID) {
|
||||
|
||||
if(sessionID == null) return null;
|
||||
|
||||
return getIfExists(sessionID);
|
||||
|
||||
@ -1210,8 +1210,9 @@ public class SpedizioneViewModel {
|
||||
.setOrders(orders);
|
||||
|
||||
this.mColliScaricoRESTConsumer.createUDS(createUDSRequestDTO, createdUDS -> {
|
||||
this.mCurrentMtbColt = createdUDS;
|
||||
mMtbColtSessionID = this.mColliDataRecoverService.startNewSession(createdUDS, mTestateOrdini);
|
||||
|
||||
this.mCurrentMtbColt = createdUDS;
|
||||
this.mIsNewLU = true;
|
||||
|
||||
if (onComplete != null) onComplete.run();
|
||||
@ -1342,53 +1343,6 @@ public class SpedizioneViewModel {
|
||||
this.sendOnRowSaved();
|
||||
this.sendOnLoadingEnded();
|
||||
}, this::sendError);
|
||||
|
||||
|
||||
// MtbColt mtbColt = new MtbColt()
|
||||
// .setNumCollo(mtbColrToUpdate.getNumCollo())
|
||||
// .setDataCollo(mtbColrToUpdate.getDataColloS())
|
||||
// .setSerCollo(mtbColrToUpdate.getSerCollo())
|
||||
// .setGestione(mtbColrToUpdate.getGestione())
|
||||
// .setMtbColr(new ObservableArrayList<>());
|
||||
// mtbColt.setOperation(CommonModelConsts.OPERATION.NO_OP);
|
||||
//
|
||||
// final MtbColr mtbColr = (MtbColr) mtbColrToUpdate.clone();
|
||||
// mtbColr.setOperation(CommonModelConsts.OPERATION.INSERT);
|
||||
// mtbColr.setRiga(null)
|
||||
// .setPesoLordoKg(null)
|
||||
// .setPesoNettoKg(null)
|
||||
// .setNumCnf(numCnf.subtract(mtbColrToUpdate.getNumCnf()))
|
||||
// .setQtaCnf(qtaCnf)
|
||||
// .setQtaCol(qtaTot.subtract(mtbColrToUpdate.getQtaCol()))
|
||||
// .setPartitaMag(partitaMag)
|
||||
// .setDataScadPartita(dataScad);
|
||||
//
|
||||
// mtbColt.getMtbColr().add(mtbColr);
|
||||
//
|
||||
// this.mColliMagazzinoRESTConsumer.saveCollo(mtbColt, (value) -> {
|
||||
//
|
||||
// mtbColr
|
||||
// .setNumCnf(numCnf)
|
||||
// .setQtaCnf(qtaCnf)
|
||||
// .setQtaCol(qtaTot);
|
||||
//
|
||||
// Optional<PickingObjectDTO> pickingObjectDTO = Stream.of(this.mPickingList.getValue())
|
||||
// .filter(x -> Stream.of(x.getWithdrawMtbColrs())
|
||||
// .anyMatch(y -> y == mtbColrToUpdate)).findSingle();
|
||||
//
|
||||
// if (pickingObjectDTO.isPresent()) {
|
||||
// pickingObjectDTO.get().getWithdrawMtbColrs().remove(mtbColrToUpdate);
|
||||
// pickingObjectDTO.get().getWithdrawMtbColrs().add(mtbColr);
|
||||
// }
|
||||
//
|
||||
// this.mCurrentMtbColt.getMtbColr().remove(mtbColrToUpdate);
|
||||
// this.mCurrentMtbColt.getMtbColr().add(mtbColr);
|
||||
//
|
||||
// this.resetMatchedRows();
|
||||
// this.sendOnRowSaved();
|
||||
// this.sendOnLoadingEnded();
|
||||
//
|
||||
// }, this::sendError);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user