Search in sources :

Example 11 with StatusMode

use of com.xabber.android.data.account.StatusMode in project xabber-android by redsolution.

the class RoomChat method createOccupant.

/**
     * Warning: this method should be placed with packet provider.
     *
     * @return New occupant based on presence information.
     */
private Occupant createOccupant(String resource, Presence presence) {
    Occupant occupant = new Occupant(resource);
    String jid = null;
    Affiliation affiliation = Affiliation.none;
    Role role = Role.none;
    StatusMode statusMode = StatusMode.unavailable;
    String statusText = null;
    MUCUser mucUser = MUC.getMUCUserExtension(presence);
    if (mucUser != null) {
        MUCItem item = mucUser.getItem();
        if (item != null) {
            jid = item.getJid();
            try {
                affiliation = Affiliation.fromString(item.getAffiliation().toString());
            } catch (NoSuchElementException e) {
            }
            try {
                role = Role.fromString(item.getRole().toString());
            } catch (NoSuchElementException e) {
            }
            statusMode = StatusMode.createStatusMode(presence);
            statusText = presence.getStatus();
        }
    }
    if (statusText == null) {
        statusText = "";
    }
    occupant.setJid(jid);
    occupant.setAffiliation(affiliation);
    occupant.setRole(role);
    occupant.setStatusMode(statusMode);
    occupant.setStatusText(statusText);
    return occupant;
}
Also used : Role(com.xabber.xmpp.muc.Role) MUCItem(org.jivesoftware.smackx.muc.packet.MUCItem) StatusMode(com.xabber.android.data.account.StatusMode) MUCUser(org.jivesoftware.smackx.muc.packet.MUCUser) NoSuchElementException(java.util.NoSuchElementException) Affiliation(com.xabber.xmpp.muc.Affiliation)

Aggregations

StatusMode (com.xabber.android.data.account.StatusMode)11 View (android.view.View)6 ImageView (android.widget.ImageView)5 TextView (android.widget.TextView)5 ColorDrawable (android.graphics.drawable.ColorDrawable)3 RecyclerView (android.support.v7.widget.RecyclerView)3 AccountItem (com.xabber.android.data.account.AccountItem)3 LayoutInflater (android.view.LayoutInflater)2 Intent (android.content.Intent)1 SharedPreferences (android.content.SharedPreferences)1 Toolbar (android.support.v7.widget.Toolbar)1 AdapterView (android.widget.AdapterView)1 ListView (android.widget.ListView)1 FloatingActionButton (com.melnykov.fab.FloatingActionButton)1 ClientInfo (com.xabber.android.data.extension.capability.ClientInfo)1 ShowOfflineMode (com.xabber.android.data.roster.ShowOfflineMode)1 StatusEditorAdapter (com.xabber.android.ui.adapter.StatusEditorAdapter)1 StatusModeAdapter (com.xabber.android.ui.adapter.StatusModeAdapter)1 AccountPainter (com.xabber.android.ui.color.AccountPainter)1 BarPainter (com.xabber.android.ui.color.BarPainter)1