Browse Source

Offload logging

main
M66B 6 years ago
parent
commit
390074a2c3
1 changed files with 14 additions and 2 deletions
  1. +14
    -2
      app/src/main/java/eu/faircode/email/EntityLog.java

+ 14
- 2
app/src/main/java/eu/faircode/email/EntityLog.java View File

@ -22,6 +22,8 @@ package eu.faircode.email;
import android.content.Context; import android.content.Context;
import java.util.Date; import java.util.Date;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.room.Entity; import androidx.room.Entity;
@ -46,11 +48,21 @@ public class EntityLog {
@NonNull @NonNull
public String data; public String data;
private static ExecutorService executor = Executors.newSingleThreadExecutor();
static void log(Context context, String data) { static void log(Context context, String data) {
EntityLog entry = new EntityLog();
final EntityLog entry = new EntityLog();
entry.time = new Date().getTime(); entry.time = new Date().getTime();
entry.data = data; entry.data = data;
DB.getInstance(context).log().insertLog(entry);
final DB db = DB.getInstance(context);
executor.submit(new Runnable() {
@Override
public void run() {
db.log().insertLog(entry);
}
});
} }
@Override @Override


Loading…
Cancel
Save