mirror of
https://gitlab.com/xynngh/YetAnotherCallBlocker.git
synced 2025-06-05 22:19:12 +02:00
Refresh call log only if DB actually changed
This commit is contained in:
@@ -197,7 +197,7 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
|
|
||||||
@Subscribe(threadMode = ThreadMode.MAIN_ORDERED)
|
@Subscribe(threadMode = ThreadMode.MAIN_ORDERED)
|
||||||
public void onSecondaryDbUpdateFinished(SecondaryDbUpdateFinished event) {
|
public void onSecondaryDbUpdateFinished(SecondaryDbUpdateFinished event) {
|
||||||
reloadCallLog();
|
if (event.updated) reloadCallLog();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkPermissions() {
|
private void checkPermissions() {
|
||||||
|
@@ -1,3 +1,11 @@
|
|||||||
package dummydomain.yetanothercallblocker.event;
|
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() {
|
private void updateSecondaryDb() {
|
||||||
Settings settings = App.getSettings();
|
Settings settings = App.getSettings();
|
||||||
|
|
||||||
|
boolean updated = false;
|
||||||
|
|
||||||
SecondaryDbUpdatingEvent sticky = new SecondaryDbUpdatingEvent();
|
SecondaryDbUpdatingEvent sticky = new SecondaryDbUpdatingEvent();
|
||||||
|
|
||||||
postStickyEvent(sticky);
|
postStickyEvent(sticky);
|
||||||
try {
|
try {
|
||||||
if (YacbHolder.getCommunityDatabase().updateSecondaryDb()) {
|
if (YacbHolder.getCommunityDatabase().updateSecondaryDb()) {
|
||||||
settings.setLastUpdateTime(System.currentTimeMillis());
|
settings.setLastUpdateTime(System.currentTimeMillis());
|
||||||
|
updated = true;
|
||||||
}
|
}
|
||||||
settings.setLastUpdateCheckTime(System.currentTimeMillis());
|
settings.setLastUpdateCheckTime(System.currentTimeMillis());
|
||||||
} finally {
|
} finally {
|
||||||
removeStickyEvent(sticky);
|
removeStickyEvent(sticky);
|
||||||
}
|
}
|
||||||
|
|
||||||
postEvent(new SecondaryDbUpdateFinished());
|
postEvent(new SecondaryDbUpdateFinished(updated));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -34,19 +34,22 @@ public class UpdateWorker extends Worker {
|
|||||||
|
|
||||||
Settings settings = App.getSettings();
|
Settings settings = App.getSettings();
|
||||||
|
|
||||||
|
boolean updated = false;
|
||||||
|
|
||||||
SecondaryDbUpdatingEvent sticky = new SecondaryDbUpdatingEvent();
|
SecondaryDbUpdatingEvent sticky = new SecondaryDbUpdatingEvent();
|
||||||
|
|
||||||
postStickyEvent(sticky);
|
postStickyEvent(sticky);
|
||||||
try {
|
try {
|
||||||
if (YacbHolder.getCommunityDatabase().updateSecondaryDb()) {
|
if (YacbHolder.getCommunityDatabase().updateSecondaryDb()) {
|
||||||
settings.setLastUpdateTime(System.currentTimeMillis());
|
settings.setLastUpdateTime(System.currentTimeMillis());
|
||||||
|
updated = true;
|
||||||
}
|
}
|
||||||
settings.setLastUpdateCheckTime(System.currentTimeMillis());
|
settings.setLastUpdateCheckTime(System.currentTimeMillis());
|
||||||
} finally {
|
} finally {
|
||||||
removeStickyEvent(sticky);
|
removeStickyEvent(sticky);
|
||||||
}
|
}
|
||||||
|
|
||||||
postEvent(new SecondaryDbUpdateFinished());
|
postEvent(new SecondaryDbUpdateFinished(updated));
|
||||||
|
|
||||||
LOG.info("doWork() finished");
|
LOG.info("doWork() finished");
|
||||||
return Result.success();
|
return Result.success();
|
||||||
|
Reference in New Issue
Block a user