示例#1
0
  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));
  }
示例#2
0
  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());
  }
示例#3
0
 public WaypointAdapter(Activity c) {
   super();
   this.context = c;
   this.dao = App.getWaypointDao();
   this.list = new ArrayList<Waypoint>(this.dao.loadAll());
   notifyDataSetChanged();
 }
示例#4
0
  public static boolean checkPlayServices() {
    playServicesAvailable =
        ConnectionResult.SUCCESS
            == GooglePlayServicesUtil.isGooglePlayServicesAvailable(App.getContext());

    if (!playServicesAvailable) showPlayServicesNotAvilableNotification();

    return playServicesAvailable;
  }
示例#5
0
  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));
    }
  }
示例#6
0
  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));
  }
示例#7
0
  public long getContactIdFromLocalStorage(Contact c) {
    ContactLink cl = App.getContactLinkDao().load(c.getTopic());

    return cl != null ? cl.getContactId() : 0;
  }
示例#8
0
 public static HashMap<String, Contact> getContacts() {
   return App.getContacts();
 }