public void updateNotification() { if (!Preferences.isNotificationEnabled() || !playServicesAvailable) return; String title = null; String subtitle = null; long time = 0; if ((this.lastPublishedLocation != null) && Preferences.isNotificationLocationEnabled()) { time = this.lastPublishedLocationTime.getTime(); if ((this.lastPublishedLocation.getGeocoder() != null) && Preferences.isNotificationGeocoderEnabled()) { title = this.lastPublishedLocation.toString(); } else { title = this.lastPublishedLocation.toLatLonString(); } } else { title = this.context.getString(R.string.app_name); } subtitle = ServiceLocator.getStateAsString(this.context) + " | " + ServiceBroker.getStateAsString(this.context); notificationBuilder.setContentTitle(title); notificationBuilder .setSmallIcon(R.drawable.ic_notification) .setContentText(subtitle) .setPriority(android.support.v4.app.NotificationCompat.PRIORITY_MIN); if (time != 0) notificationBuilder.setWhen(this.lastPublishedLocationTime.getTime()); this.notification = notificationBuilder.build(); this.context.startForeground(Defaults.NOTIFCATION_ID, this.notification); }
public void onEvent(Events.PublishSuccessfull e) { Log.v(this.toString(), "Publish successful"); if ((e.getExtra() != null) && (e.getExtra() instanceof LocationMessage)) { LocationMessage l = (LocationMessage) e.getExtra(); this.lastPublishedLocation = l.getLocation(); this.lastPublishedLocationTime = l.getLocation().getDate(); if (Preferences.isNotificationGeocoderEnabled() && (l.getLocation().getGeocoder() == null)) (new ReverseGeocodingTask(this.context, this.handler)) .execute(new GeocodableLocation[] {l.getLocation()}); updateNotification(); if (Preferences.notificationTickerOnPublish() && !l.doesSupressTicker()) updateTicker(this.context.getString(R.string.statePublished)); } }