use of org.thoughtcrime.securesms.database.model.MegaphoneRecord in project Signal-Android by WhisperSystems.
the class MegaphoneRepository method markFinished.
@AnyThread
public void markFinished(@NonNull Event event, @Nullable Runnable onComplete) {
executor.execute(() -> {
MegaphoneRecord record = databaseCache.get(event);
if (record != null && record.isFinished()) {
return;
}
database.markFinished(event);
resetDatabaseCache();
if (onComplete != null) {
onComplete.run();
}
});
}
use of org.thoughtcrime.securesms.database.model.MegaphoneRecord in project Signal-Android by signalapp.
the class MegaphoneDatabase method getAllAndDeleteMissing.
@NonNull
public List<MegaphoneRecord> getAllAndDeleteMissing() {
SQLiteDatabase db = getWritableDatabase();
List<MegaphoneRecord> records = new ArrayList<>();
db.beginTransaction();
try {
Set<String> missingKeys = new HashSet<>();
try (Cursor cursor = db.query(TABLE_NAME, null, null, null, null, null, null)) {
while (cursor != null && cursor.moveToNext()) {
String event = cursor.getString(cursor.getColumnIndexOrThrow(EVENT));
int seenCount = cursor.getInt(cursor.getColumnIndexOrThrow(SEEN_COUNT));
long lastSeen = cursor.getLong(cursor.getColumnIndexOrThrow(LAST_SEEN));
long firstVisible = cursor.getLong(cursor.getColumnIndexOrThrow(FIRST_VISIBLE));
boolean finished = cursor.getInt(cursor.getColumnIndexOrThrow(FINISHED)) == 1;
if (Event.hasKey(event)) {
records.add(new MegaphoneRecord(Event.fromKey(event), seenCount, lastSeen, firstVisible, finished));
} else {
Log.w(TAG, "No in-app handing for event '" + event + "'! Deleting it from the database.");
missingKeys.add(event);
}
}
}
for (String missing : missingKeys) {
String query = EVENT + " = ?";
String[] args = new String[] { missing };
db.delete(TABLE_NAME, query, args);
}
db.setTransactionSuccessful();
} finally {
db.endTransaction();
}
return records;
}
use of org.thoughtcrime.securesms.database.model.MegaphoneRecord in project Signal-Android by signalapp.
the class MegaphoneRepository method markFinished.
@AnyThread
public void markFinished(@NonNull Event event, @Nullable Runnable onComplete) {
executor.execute(() -> {
MegaphoneRecord record = databaseCache.get(event);
if (record != null && record.isFinished()) {
return;
}
database.markFinished(event);
resetDatabaseCache();
if (onComplete != null) {
onComplete.run();
}
});
}
Aggregations