Keep intent longer

custom_intent
Thomas 10 months ago
parent 504e30c44a
commit e589e2549d

@ -321,7 +321,7 @@ public abstract class BaseMainActivity extends BaseActivity implements NetworkSt
args2.putSerializable(Helper.ARG_STATUS, statusSent);
new CachedBundle(BaseMainActivity.this).insertBundle(args2, currentAccount, bundleId2 -> {
Bundle bundle2 = new Bundle();
bundle.putLong(Helper.ARG_INTENT_ID, bundleId2);
bundle2.putLong(Helper.ARG_INTENT_ID, bundleId2);
intentContext.putExtras(bundle2);
intentContext.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intentContext);
@ -348,7 +348,6 @@ public abstract class BaseMainActivity extends BaseActivity implements NetworkSt
}
}
});
}
}
};
@ -378,6 +377,7 @@ public abstract class BaseMainActivity extends BaseActivity implements NetworkSt
//Delete cache older than 7 days
new StatusCache(activity).deleteForAllAccountAfter7Days();
new TimelineCacheLogs(activity).deleteForAllAccountAfter7Days();
new CachedBundle(activity).deleteOldIntent();
} catch (DBException e) {
e.printStackTrace();
}

@ -30,6 +30,7 @@ import java.io.BufferedOutputStream;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.Calendar;
import java.util.Date;
import java.util.zip.GZIPInputStream;
import java.util.zip.GZIPOutputStream;
@ -142,9 +143,11 @@ public class CachedBundle {
}
}
}
removeIntent(String.valueOf(id));
} catch (DBException ignored) {
}
if( bundle == null) {
bundle = new Bundle();
}
Handler mainHandler = new Handler(Looper.getMainLooper());
Bundle finalBundle = bundle;
Runnable myRunnable = () -> callback.get(finalBundle);
@ -253,6 +256,27 @@ public class CachedBundle {
db.delete(Sqlite.TABLE_INTENT, Sqlite.COL_ID + " = '" + id + "'", null);
}
/**
* Remove a bundle from db
*
*/
public long deleteOldIntent() throws DBException {
if (db == null) {
throw new DBException("db is null. Wrong initialization.");
}
Calendar cal = Calendar.getInstance();
cal.setTime(new Date());
cal.add(Calendar.DATE, -1);
Date date = cal.getTime();
String dateStr = Helper.dateToString(date);
try {
return db.delete(Sqlite.TABLE_INTENT, Sqlite.COL_CREATED_AT + " < ?", new String[]{dateStr});
}catch (Exception e) {
e.printStackTrace();
return -1;
}
}
/**
* Remove a bundle from db
*/

Loading…
Cancel
Save