Ejemplo n.º 1
0
 private StatusMode getStatus(Presence presence) {
   if (presence.getType() == Presence.Type.subscribe) return StatusMode.subscribe;
   if (presence.getType() == Presence.Type.available) {
     if (presence.getMode() != null) {
       return StatusMode.valueOf(presence.getMode().name());
     }
     return StatusMode.available;
   }
   return StatusMode.offline;
 }
Ejemplo n.º 2
0
  private void updateContactStatus() {
    Cursor cursor =
        getContentResolver()
            .query(
                RosterProvider.CONTENT_URI,
                STATUS_QUERY,
                RosterProvider.RosterConstants.JID + " = ?",
                new String[] {mWithJabberID},
                null);
    int MODE_IDX = cursor.getColumnIndex(RosterProvider.RosterConstants.STATUS_MODE);
    int MSG_IDX = cursor.getColumnIndex(RosterProvider.RosterConstants.STATUS_MESSAGE);

    if (cursor.getCount() == 1) {
      cursor.moveToFirst();
      int status_mode = cursor.getInt(MODE_IDX);
      String status_message = cursor.getString(MSG_IDX);
      Log.d(TAG, "contact status changed: " + status_mode + " " + status_message);
      mSubTitle.setVisibility(
          (status_message != null && status_message.length() != 0) ? View.VISIBLE : View.GONE);
      mSubTitle.setText(status_message);
      mStatusMode.setImageResource(StatusMode.values()[status_mode].getDrawableId());
    }
    cursor.close();
  }