Refresh call log only if DB actually changed
This commit is contained in:
parent
8398658e12
commit
1ecb236332
|
@ -197,7 +197,7 @@ public class MainActivity extends AppCompatActivity {
|
|||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN_ORDERED)
|
||||
public void onSecondaryDbUpdateFinished(SecondaryDbUpdateFinished event) {
|
||||
reloadCallLog();
|
||||
if (event.updated) reloadCallLog();
|
||||
}
|
||||
|
||||
private void checkPermissions() {
|
||||
|
|
|
@ -1,3 +1,11 @@
|
|||
package dummydomain.yetanothercallblocker.event;
|
||||
|
||||
public class SecondaryDbUpdateFinished {}
|
||||
public class SecondaryDbUpdateFinished {
|
||||
|
||||
public final boolean updated;
|
||||
|
||||
public SecondaryDbUpdateFinished(boolean updated) {
|
||||
this.updated = updated;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -104,19 +104,22 @@ public class TaskService extends IntentService {
|
|||
private void updateSecondaryDb() {
|
||||
Settings settings = App.getSettings();
|
||||
|
||||
boolean updated = false;
|
||||
|
||||
SecondaryDbUpdatingEvent sticky = new SecondaryDbUpdatingEvent();
|
||||
|
||||
postStickyEvent(sticky);
|
||||
try {
|
||||
if (YacbHolder.getCommunityDatabase().updateSecondaryDb()) {
|
||||
settings.setLastUpdateTime(System.currentTimeMillis());
|
||||
updated = true;
|
||||
}
|
||||
settings.setLastUpdateCheckTime(System.currentTimeMillis());
|
||||
} finally {
|
||||
removeStickyEvent(sticky);
|
||||
}
|
||||
|
||||
postEvent(new SecondaryDbUpdateFinished());
|
||||
postEvent(new SecondaryDbUpdateFinished(updated));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -34,19 +34,22 @@ public class UpdateWorker extends Worker {
|
|||
|
||||
Settings settings = App.getSettings();
|
||||
|
||||
boolean updated = false;
|
||||
|
||||
SecondaryDbUpdatingEvent sticky = new SecondaryDbUpdatingEvent();
|
||||
|
||||
postStickyEvent(sticky);
|
||||
try {
|
||||
if (YacbHolder.getCommunityDatabase().updateSecondaryDb()) {
|
||||
settings.setLastUpdateTime(System.currentTimeMillis());
|
||||
updated = true;
|
||||
}
|
||||
settings.setLastUpdateCheckTime(System.currentTimeMillis());
|
||||
} finally {
|
||||
removeStickyEvent(sticky);
|
||||
}
|
||||
|
||||
postEvent(new SecondaryDbUpdateFinished());
|
||||
postEvent(new SecondaryDbUpdateFinished(updated));
|
||||
|
||||
LOG.info("doWork() finished");
|
||||
return Result.success();
|
||||
|
|
Loading…
Reference in New Issue