mirror of https://github.com/M66B/FairEmail.git
Auto save classifier model
This commit is contained in:
parent
9c3fd46905
commit
c2404bdce2
|
@ -239,7 +239,6 @@ public class MessageClassifier {
|
||||||
File file = getFile(context);
|
File file = getFile(context);
|
||||||
Helper.writeText(file, jroot.toString(2));
|
Helper.writeText(file, jroot.toString(2));
|
||||||
|
|
||||||
loaded = false;
|
|
||||||
Log.i("Classifier saved classes=" + classMessages.size() + " words=" + wordClassFrequency.size());
|
Log.i("Classifier saved classes=" + classMessages.size() + " words=" + wordClassFrequency.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -113,6 +113,7 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
|
||||||
|
|
||||||
private static ExecutorService executor = Helper.getBackgroundExecutor(1, "sync");
|
private static ExecutorService executor = Helper.getBackgroundExecutor(1, "sync");
|
||||||
|
|
||||||
|
private static final long BACKUP_DELAY = 30 * 1000L; // milliseconds
|
||||||
private static final long PURGE_DELAY = 30 * 1000L; // milliseconds
|
private static final long PURGE_DELAY = 30 * 1000L; // milliseconds
|
||||||
private static final long QUIT_DELAY = 5 * 1000L; // milliseconds
|
private static final long QUIT_DELAY = 5 * 1000L; // milliseconds
|
||||||
private static final long STILL_THERE_THRESHOLD = 3 * 60 * 1000L; // milliseconds
|
private static final long STILL_THERE_THRESHOLD = 3 * 60 * 1000L; // milliseconds
|
||||||
|
@ -350,6 +351,9 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
|
||||||
WorkerFts.cancel(ServiceSynchronize.this);
|
WorkerFts.cancel(ServiceSynchronize.this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getMainHandler().removeCallbacks(backup);
|
||||||
|
getMainHandler().postDelayed(backup, BACKUP_DELAY);
|
||||||
|
|
||||||
if (!isBackgroundService(ServiceSynchronize.this))
|
if (!isBackgroundService(ServiceSynchronize.this))
|
||||||
try {
|
try {
|
||||||
NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
|
NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
|
||||||
|
@ -542,6 +546,22 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Runnable backup = new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
queue.submit(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
try {
|
||||||
|
MessageClassifier.save(ServiceSynchronize.this);
|
||||||
|
} catch (Throwable ex) {
|
||||||
|
Log.e(ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
final TwoStateOwner cowner = new TwoStateOwner(this, "liveUnseenNotify");
|
final TwoStateOwner cowner = new TwoStateOwner(this, "liveUnseenNotify");
|
||||||
|
|
Loading…
Reference in New Issue