diff options
author | rsudev <rasch@munin-soft.de> | 2012-02-18 22:32:58 +0100 |
---|---|---|
committer | rsudev <rasch@munin-soft.de> | 2012-02-18 23:10:30 +0100 |
commit | bb529cdaa9fdb391524320e73af9772be3d8b969 (patch) | |
tree | ce71cf4dac9de5756ed9ace61a56bbf7578f64b1 /main/src/cgeo/geocaching/cgCache.java | |
parent | 11b2147e0e4b8c8c478425ca0205bcbee490d098 (diff) | |
download | cgeo-bb529cdaa9fdb391524320e73af9772be3d8b969.zip cgeo-bb529cdaa9fdb391524320e73af9772be3d8b969.tar.gz cgeo-bb529cdaa9fdb391524320e73af9772be3d8b969.tar.bz2 |
Notify asynchronous cache changes (log offline)
Diffstat (limited to 'main/src/cgeo/geocaching/cgCache.java')
-rw-r--r-- | main/src/cgeo/geocaching/cgCache.java | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/main/src/cgeo/geocaching/cgCache.java b/main/src/cgeo/geocaching/cgCache.java index 0197248..d6e3801 100644 --- a/main/src/cgeo/geocaching/cgCache.java +++ b/main/src/cgeo/geocaching/cgCache.java @@ -24,6 +24,7 @@ import android.app.Activity; import android.content.Intent; import android.content.res.Resources; import android.net.Uri; +import android.os.Handler; import android.text.Spannable; import android.util.Log; @@ -101,6 +102,20 @@ public class cgCache implements ICache { private static final Pattern NUMBER_PATTERN = Pattern.compile("\\d+"); + private Handler changeNotificationHandler = null; + + public void setChangeNotificationHandler(Handler newNotificationHandler) { + changeNotificationHandler = newNotificationHandler; + } + + /** + * Sends a change notification to interested parties + */ + private void notifyChange() { + if (changeNotificationHandler != null) + changeNotificationHandler.sendEmptyMessage(0); + } + /** * Gather missing information from another cache object. * @@ -253,7 +268,12 @@ public class cgCache implements ICache { reliableLatLon = other.reliableLatLon; } - return isEqualTo(other); + boolean isEqual = isEqualTo(other); + + if (!isEqual) + notifyChange(); + + return isEqual; } /** @@ -413,6 +433,8 @@ public class cgCache implements ICache { cgeoapplication app = (cgeoapplication) ((Activity) fromActivity).getApplication(); final boolean status = app.saveLogOffline(geocode, date.getTime(), logType, log); + notifyChange(); + Resources res = ((Activity) fromActivity).getResources(); if (status) { fromActivity.showToast(res.getString(R.string.info_log_saved)); |