Search in sources :

Example 1 with Room

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);
}
Also used : Bundle(android.os.Bundle) SearchView(android.support.v7.widget.SearchView) ImageView(android.widget.ImageView) DialogFragment(android.support.v4.app.DialogFragment) AndroidSchedulers(io.reactivex.android.schedulers.AndroidSchedulers) RealmSpotlightRoomRepository(chat.rocket.persistence.realm.repositories.RealmSpotlightRoomRepository) RocketChatAvatar(chat.rocket.android.widget.RocketChatAvatar) MethodCallHelper(chat.rocket.android.api.MethodCallHelper) DirectMessageRoomListHeader(chat.rocket.android.layouthelper.chatroom.roomlist.DirectMessageRoomListHeader) View(android.view.View) TextUtils(chat.rocket.android.helper.TextUtils) AbsoluteUrlHelper(chat.rocket.android.helper.AbsoluteUrlHelper) User(chat.rocket.core.models.User) RocketChatAbsoluteUrl(chat.rocket.android.fragment.chatroom.RocketChatAbsoluteUrl) RealmServerInfoRepository(chat.rocket.persistence.realm.repositories.RealmServerInfoRepository) RoomListAdapter(chat.rocket.android.layouthelper.chatroom.roomlist.RoomListAdapter) RxSearchView(com.jakewharton.rxbinding2.support.v7.widget.RxSearchView) UserRenderer(chat.rocket.android.renderer.UserRenderer) SessionInteractor(chat.rocket.core.interactors.SessionInteractor) List(java.util.List) TextView(android.widget.TextView) RealmSessionRepository(chat.rocket.persistence.realm.repositories.RealmSessionRepository) Room(chat.rocket.core.models.Room) BuildConfig(chat.rocket.android.BuildConfig) ChannelRoomListHeader(chat.rocket.android.layouthelper.chatroom.roomlist.ChannelRoomListHeader) Nullable(android.support.annotation.Nullable) RxCompoundButton(com.jakewharton.rxbinding2.widget.RxCompoundButton) AbstractFragment(chat.rocket.android.fragment.AbstractFragment) RocketChatCache(chat.rocket.android.RocketChatCache) NonNull(android.support.annotation.NonNull) ArrayList(java.util.ArrayList) SuppressLint(android.annotation.SuppressLint) Observable(io.reactivex.Observable) R(chat.rocket.android.R) RealmRoomRepository(chat.rocket.persistence.realm.repositories.RealmRoomRepository) AddDirectMessageDialogFragment(chat.rocket.android.fragment.sidebar.dialog.AddDirectMessageDialogFragment) AddChannelDialogFragment(chat.rocket.android.fragment.sidebar.dialog.AddChannelDialogFragment) FavoriteRoomListHeader(chat.rocket.android.layouthelper.chatroom.roomlist.FavoriteRoomListHeader) CompoundButton(android.widget.CompoundButton) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) Logger(chat.rocket.android.helper.Logger) UnreadRoomListHeader(chat.rocket.android.layouthelper.chatroom.roomlist.UnreadRoomListHeader) RoomInteractor(chat.rocket.core.interactors.RoomInteractor) TimeUnit(java.util.concurrent.TimeUnit) RecyclerView(android.support.v7.widget.RecyclerView) SpotlightRoom(chat.rocket.core.models.SpotlightRoom) RealmUserRepository(chat.rocket.persistence.realm.repositories.RealmUserRepository) RoomListHeader(chat.rocket.android.layouthelper.chatroom.roomlist.RoomListHeader) SortDirection(chat.rocket.core.SortDirection) Collections(java.util.Collections) RoomListAdapter(chat.rocket.android.layouthelper.chatroom.roomlist.RoomListAdapter) RecyclerView(android.support.v7.widget.RecyclerView) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) Logger(chat.rocket.android.helper.Logger) Room(chat.rocket.core.models.Room) SpotlightRoom(chat.rocket.core.models.SpotlightRoom) SpotlightRoom(chat.rocket.core.models.SpotlightRoom) SuppressLint(android.annotation.SuppressLint)

Example 2 with Room

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;
            }
        }
    }
}
Also used : SpotlightRoom(chat.rocket.core.models.SpotlightRoom) Room(chat.rocket.core.models.Room)

Example 3 with Room

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;
}
Also used : SpotlightRoom(chat.rocket.core.models.SpotlightRoom) Room(chat.rocket.core.models.Room)

Aggregations

Room (chat.rocket.core.models.Room)3 SpotlightRoom (chat.rocket.core.models.SpotlightRoom)3 SuppressLint (android.annotation.SuppressLint)1 Bundle (android.os.Bundle)1 NonNull (android.support.annotation.NonNull)1 Nullable (android.support.annotation.Nullable)1 DialogFragment (android.support.v4.app.DialogFragment)1 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)1 RecyclerView (android.support.v7.widget.RecyclerView)1 SearchView (android.support.v7.widget.SearchView)1 View (android.view.View)1 CompoundButton (android.widget.CompoundButton)1 ImageView (android.widget.ImageView)1 TextView (android.widget.TextView)1 BuildConfig (chat.rocket.android.BuildConfig)1 R (chat.rocket.android.R)1 RocketChatCache (chat.rocket.android.RocketChatCache)1 MethodCallHelper (chat.rocket.android.api.MethodCallHelper)1 AbstractFragment (chat.rocket.android.fragment.AbstractFragment)1 RocketChatAbsoluteUrl (chat.rocket.android.fragment.chatroom.RocketChatAbsoluteUrl)1