Fix su null in ColliDataRecover

This commit is contained in:
Giuseppe Scorrano 2021-04-12 09:37:45 +02:00
parent 4cda247ddc
commit 36f9fa1e36

View File

@ -6,7 +6,6 @@ import androidx.appcompat.app.AppCompatActivity;
import com.annimon.stream.Optional;
import com.annimon.stream.Stream;
import com.google.android.gms.common.util.IOUtils;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
@ -122,7 +121,7 @@ public class ColliDataRecover {
}
public static boolean thereIsAnExistantSession() {
return mtbColtsSessions.size() > 0;
return mtbColtsSessions != null && mtbColtsSessions.size() > 0;
}
public static List<Integer> getAllSessionIDs() {
@ -193,13 +192,16 @@ public class ColliDataRecover {
try {
inputStream = mContext.openFileInput(CommonConst.Files.RECOVER_COLLO_FILE);
byte[] bytes = IOUtils.readInputStreamFully(inputStream);
byte[] bytes = new byte[inputStream.available()];
inputStream.read(bytes);
inputStream.close();
String jsonString = new String(bytes);
Type listType = new TypeToken<ArrayList<RecoverDTO>>(){}.getType();
mtbColtsSessions = gson.fromJson(jsonString, listType);
inputStream.close();
if(mtbColtsSessions == null) mtbColtsSessions = new ArrayList<>();
} catch (Exception e) {
e.printStackTrace();
UtilityExceptions.defaultException(mContext, e);