use of org.jivesoftware.smackx.muc.HostedRoom in project xabber-android by redsolution.
the class ConferenceFilterActivity method restoreConferenceList.
public static List<HostedRoom> restoreConferenceList(Bundle bundleExtra) {
List<String> conferencesNames = bundleExtra.getStringArrayList(ARG_CONFERENCE_LIST_NAMES);
List<String> conferencesJids = bundleExtra.getStringArrayList(ARG_CONFERENCE_LIST_JIDS);
List<HostedRoom> conferences = new ArrayList<>();
if (conferencesNames != null && conferencesJids != null && conferencesNames.size() == conferencesJids.size()) {
for (int i = 0; i < conferencesNames.size(); i++) {
try {
DiscoverItems.Item item = new DiscoverItems.Item(JidCreate.from(conferencesJids.get(i)));
item.setName(conferencesNames.get(i));
conferences.add(new HostedRoom(item));
} catch (XmppStringprepException e) {
LogManager.exception(LOG_TAG, e);
}
}
}
return conferences;
}
use of org.jivesoftware.smackx.muc.HostedRoom in project xabber-android by redsolution.
the class ConferenceSelectFragment method storeConferenceList.
private void storeConferenceList(Bundle intent) {
List<HostedRoom> conferencesList = hostedConferencesAdapter.getConferencesList();
ArrayList<String> names = new ArrayList<>();
ArrayList<String> jids = new ArrayList<>();
for (HostedRoom hostedRoom : conferencesList) {
names.add(hostedRoom.getName());
jids.add(hostedRoom.getJid().toString());
}
intent.putStringArrayList(ConferenceFilterActivity.ARG_CONFERENCE_LIST_NAMES, names);
intent.putStringArrayList(ConferenceFilterActivity.ARG_CONFERENCE_LIST_JIDS, jids);
}
use of org.jivesoftware.smackx.muc.HostedRoom in project ecf by eclipse.
the class XMPPChatRoomManager method getChatRooms.
protected ID[] getChatRooms() {
if (ecfConnection == null)
return null;
final XMPPConnection conn = ecfConnection.getXMPPConnection();
if (conn == null)
return null;
final Collection result = new ArrayList();
try {
final Collection svcs = MultiUserChat.getServiceNames(conn);
for (final Iterator svcsi = svcs.iterator(); svcsi.hasNext(); ) {
final String svc = (String) svcsi.next();
final Collection rooms = MultiUserChat.getHostedRooms(conn, svc);
for (final Iterator roomsi = rooms.iterator(); roomsi.hasNext(); ) {
final HostedRoom room = (HostedRoom) roomsi.next();
final ID roomID = createIDFromHostedRoom(room);
if (roomID != null)
result.add(roomID);
}
}
} catch (final XMPPException e) {
return null;
}
return (ID[]) result.toArray(new ID[] {});
}
use of org.jivesoftware.smackx.muc.HostedRoom in project xabber-android by redsolution.
the class HostedConferencesAdapter method getView.
@Override
public View getView(int position, View convertView, ViewGroup parent) {
// A ViewHolder keeps references to children views to avoid unnecessary calls
// to findViewById() on each row.
ViewHolder holder;
// by ListView is null.
if (convertView == null) {
convertView = inflater.inflate(android.R.layout.simple_list_item_2, null);
// Creates a ViewHolder and store references to the two children views
// we want to bind data to.
holder = new ViewHolder();
holder.name = (TextView) convertView.findViewById(android.R.id.text1);
holder.jid = (TextView) convertView.findViewById(android.R.id.text2);
// Bind the data efficiently with the holder.
convertView.setTag(holder);
} else {
// Get the ViewHolder back to get fast access to the TextView
// and the ImageView.
holder = (ViewHolder) convertView.getTag();
}
// If weren't re-ordering this you could rely on what you set last time
HostedRoom hostedRoom = filteredData.get(position);
holder.name.setText(hostedRoom.getName());
holder.jid.setText(hostedRoom.getJid());
return convertView;
}
use of org.jivesoftware.smackx.muc.HostedRoom in project xabber-android by redsolution.
the class MUCManager method requestHostedRooms.
public static void requestHostedRooms(final String account, final String serviceName, final HostedRoomsListener listener) {
final XMPPConnection xmppConnection = AccountManager.getInstance().getAccount(account).getConnectionThread().getXMPPConnection();
final Thread thread = new Thread("Get hosted rooms on server " + serviceName + " for account " + account) {
@Override
public void run() {
Collection<HostedRoom> hostedRooms = null;
try {
hostedRooms = MultiUserChatManager.getInstanceFor(xmppConnection).getHostedRooms(serviceName);
} catch (SmackException.NoResponseException | XMPPException.XMPPErrorException | SmackException.NotConnectedException e) {
e.printStackTrace();
}
final Collection<HostedRoom> finalHostedRooms = hostedRooms;
Application.getInstance().runOnUiThread(new Runnable() {
@Override
public void run() {
listener.onHostedRoomsReceived(finalHostedRooms);
}
});
}
};
thread.start();
}
Aggregations