Search in sources :

Example 1 with AccountConfiguration

use of com.xabber.android.ui.adapter.AccountConfiguration in project xabber-android by redsolution.

the class ContactListFragment method onCreateContextMenu.

@Override
public void onCreateContextMenu(ContextMenu menu, View view, ContextMenuInfo menuInfo) {
    AdapterContextMenuInfo info = (AdapterContextMenuInfo) menuInfo;
    BaseEntity baseEntity = (BaseEntity) listView.getItemAtPosition(info.position);
    if (baseEntity instanceof AbstractContact) {
        ContextMenuHelper.createContactContextMenu(getActivity(), adapter, (AbstractContact) baseEntity, menu);
    } else if (baseEntity instanceof AccountConfiguration) {
        ContextMenuHelper.createAccountContextMenu(getActivity(), adapter, baseEntity.getAccount(), menu);
    } else if (baseEntity instanceof GroupConfiguration) {
        ContextMenuHelper.createGroupContextMenu(getActivity(), adapter, baseEntity.getAccount(), baseEntity.getUser(), menu);
    } else {
        throw new IllegalStateException();
    }
}
Also used : AdapterContextMenuInfo(android.widget.AdapterView.AdapterContextMenuInfo) BaseEntity(com.xabber.android.data.entity.BaseEntity) AccountConfiguration(com.xabber.android.ui.adapter.AccountConfiguration) GroupConfiguration(com.xabber.android.ui.adapter.GroupConfiguration) AbstractContact(com.xabber.android.data.roster.AbstractContact)

Example 2 with AccountConfiguration

use of com.xabber.android.ui.adapter.AccountConfiguration in project xabber-android by redsolution.

the class ContactListFragment method scrollTo.

/**
     * Scroll contact list to specified account.
     *
     * @param account
     */
void scrollTo(String account) {
    long count = listView.getCount();
    for (int position = 0; position < (int) count; position++) {
        BaseEntity baseEntity = (BaseEntity) listView.getItemAtPosition(position);
        if (baseEntity != null && baseEntity instanceof AccountConfiguration && baseEntity.getAccount().equals(account)) {
            stopMovement();
            listView.setSelection(position);
            break;
        }
    }
}
Also used : BaseEntity(com.xabber.android.data.entity.BaseEntity) AccountConfiguration(com.xabber.android.ui.adapter.AccountConfiguration)

Aggregations

BaseEntity (com.xabber.android.data.entity.BaseEntity)2 AccountConfiguration (com.xabber.android.ui.adapter.AccountConfiguration)2 AdapterContextMenuInfo (android.widget.AdapterView.AdapterContextMenuInfo)1 AbstractContact (com.xabber.android.data.roster.AbstractContact)1 GroupConfiguration (com.xabber.android.ui.adapter.GroupConfiguration)1