public void onEventMainThread(Events.LocationMessageReceived e) { // Updates a contact or allocates a new one Contact c = App.getContacts().get(e.getTopic()); if (c == null) { Log.v(this.toString(), "Allocating new contact for " + e.getTopic()); c = new st.alr.mqttitude.model.Contact(e.getTopic()); updateContact(c); } c.setLocation(e.getGeocodableLocation()); App.getContacts().put(e.getTopic(), c); // if (e.getLocationMessage().hasTransition()) { // Notification noti = new Notification.InboxStyle( // new Notification.Builder(this.context) // .setContentTitle("title").setContentText("subject") // .setSmallIcon(R.drawable.ic_notification)).addLine( // "line1").build(); // // } // Fires a new event with the now updated or created contact to which // fragments can react EventBus.getDefault().post(new Events.ContactUpdated(c)); }
private static void showPlayServicesNotAvilableNotification() { NotificationCompat.Builder nb = new NotificationCompat.Builder(App.getContext()); NotificationManager nm = (NotificationManager) App.getContext().getSystemService(Context.NOTIFICATION_SERVICE); nb.setContentTitle(App.getContext().getString(R.string.app_name)) .setSmallIcon(R.drawable.ic_notification) .setContentText("Google Play Services are not available") .setPriority(android.support.v4.app.NotificationCompat.PRIORITY_MIN); nm.notify(Defaults.NOTIFCATION_ID, nb.build()); }
public WaypointAdapter(Activity c) { super(); this.context = c; this.dao = App.getWaypointDao(); this.list = new ArrayList<Waypoint>(this.dao.loadAll()); notifyDataSetChanged(); }
public static boolean checkPlayServices() { playServicesAvailable = ConnectionResult.SUCCESS == GooglePlayServicesUtil.isGooglePlayServicesAvailable(App.getContext()); if (!playServicesAvailable) showPlayServicesNotAvilableNotification(); return playServicesAvailable; }
public void updateAllContacts() { Iterator<Entry<String, Contact>> it = App.getContacts().entrySet().iterator(); while (it.hasNext()) { Entry<String, Contact> item = it.next(); Contact c = item.getValue(); updateContact(c); EventBus.getDefault().post(new Events.ContactUpdated(c)); } }
public void linkContact(Contact c, long contactId) { if (Preferences.isContactLinkCloudStorageEnabled()) { Log.e(this.toString(), "Saving a ContactLink to the cloud is not yet supported"); return; } Log.v( this.toString(), "Creating ContactLink from " + c.getTopic() + " to contactId " + contactId); ContactLink cl = new ContactLink(c.getTopic(), contactId); App.getContactLinkDao().insertOrReplace(cl); updateContact(c); EventBus.getDefault().postSticky(new Events.ContactUpdated(c)); }
public long getContactIdFromLocalStorage(Contact c) { ContactLink cl = App.getContactLinkDao().load(c.getTopic()); return cl != null ? cl.getContactId() : 0; }
public static HashMap<String, Contact> getContacts() { return App.getContacts(); }