use of chat.rocket.core.models.Room in project Rocket.Chat.Android by RocketChat.
the class SidebarMainFragment method onSetupView.
@SuppressLint("RxLeakedSubscription")
@Override
protected void onSetupView() {
setupUserActionToggle();
setupUserStatusButtons();
setupLogoutButton();
setupVersionInfo();
adapter = new RoomListAdapter();
adapter.setOnItemClickListener(new RoomListAdapter.OnItemClickListener() {
@Override
public void onItemClick(Room room) {
searchView.clearFocus();
presenter.onRoomSelected(room);
}
@Override
public void onItemClick(SpotlightRoom spotlightRoom) {
searchView.setQuery(null, false);
searchView.clearFocus();
methodCallHelper.joinRoom(spotlightRoom.getId()).onSuccessTask(task -> {
presenter.onSpotlightRoomSelected(spotlightRoom);
return null;
});
}
});
RecyclerView recyclerView = (RecyclerView) rootView.findViewById(R.id.room_list_container);
recyclerView.setLayoutManager(new LinearLayoutManager(getContext(), LinearLayoutManager.VERTICAL, false));
recyclerView.setAdapter(adapter);
searchView = (SearchView) rootView.findViewById(R.id.search);
RxSearchView.queryTextChanges(searchView).compose(bindToLifecycle()).debounce(300, TimeUnit.MILLISECONDS).observeOn(AndroidSchedulers.mainThread()).switchMap(it -> {
if (it.length() == 0) {
adapter.setMode(RoomListAdapter.MODE_ROOM);
return Observable.just(Collections.<SpotlightRoom>emptyList());
}
adapter.setMode(RoomListAdapter.MODE_SPOTLIGHT_ROOM);
final String queryString = it.toString();
methodCallHelper.searchSpotlightRooms(queryString);
return realmSpotlightRoomRepository.getSuggestionsFor(queryString, SortDirection.DESC, 10).toObservable();
}).subscribe(this::showSearchSuggestions, Logger::report);
}
use of chat.rocket.core.models.Room in project Rocket.Chat.Android by RocketChat.
the class RoomListAdapter method calculateHeadersPosition.
private void calculateHeadersPosition() {
headersPosition.clear();
int roomIdx = 0;
int totalRooms = roomList.size();
int totalHeaders = roomListHeaders.size();
for (int i = 0; i < totalHeaders; i++) {
final RoomListHeader header = roomListHeaders.get(i);
if (!header.shouldShow(roomList)) {
continue;
}
headersPosition.put(roomIdx + headersPosition.size(), header);
for (; roomIdx < totalRooms; roomIdx++) {
final Room room = roomList.get(roomIdx);
if (!header.owns(room)) {
break;
}
}
}
}
use of chat.rocket.core.models.Room in project Rocket.Chat.Android by RocketChat.
the class AutocompleteChannelInteractorTest method getRoom.
private Room getRoom(String id, String name, String type) {
Room room = mock(Room.class);
when(room.getId()).thenReturn(id);
when(room.getName()).thenReturn(name);
when(room.getType()).thenReturn(type);
return room;
}
Aggregations