Fix potential crashes due to cash clean

This commit is contained in:
tom79 2019-05-19 18:52:36 +02:00
parent fc5b2563c4
commit 23a184e6c7
2 changed files with 15 additions and 11 deletions

View File

@ -6,8 +6,8 @@ android {
defaultConfig { defaultConfig {
minSdkVersion 16 minSdkVersion 16
targetSdkVersion 28 targetSdkVersion 28
versionCode 269 versionCode 270
versionName "2.0.1" versionName "2.0.2"
multiDexEnabled true multiDexEnabled true
renderscriptTargetApi 28 as int renderscriptTargetApi 28 as int
renderscriptSupportModeEnabled true renderscriptSupportModeEnabled true

View File

@ -990,17 +990,21 @@ public class API {
SQLiteDatabase db = Sqlite.getInstance(context, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open(); SQLiteDatabase db = Sqlite.getInstance(context, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
statuses = new TimelineCacheDAO(context, db).get(max_id); statuses = new TimelineCacheDAO(context, db).get(max_id);
Iterator<Status> i = statuses.iterator();
List<String> ids = new ArrayList<>(); if( statuses != null){
while (i.hasNext()) { Iterator<Status> i = statuses.iterator();
Status s = i.next(); List<String> ids = new ArrayList<>();
if( ids.contains(s.getId())) { while (i.hasNext()) {
i.remove(); Status s = i.next();
new TimelineCacheDAO(context, db).remove(s.getId()); if( ids.contains(s.getId())) {
}else{ i.remove();
ids.add(s.getId()); new TimelineCacheDAO(context, db).remove(s.getId());
}else{
ids.add(s.getId());
}
} }
} }
if( statuses == null){ if( statuses == null){
return getHomeTimeline(max_id); return getHomeTimeline(max_id);
}else{ }else{