Search in sources :

Example 1 with Logger

use of chat.rocket.android.helper.Logger 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 Logger

use of chat.rocket.android.helper.Logger in project Rocket.Chat.Android by RocketChat.

the class AddDirectMessageDialogFragment method onSetupDialog.

@SuppressLint("RxLeakedSubscription")
@Override
protected void onSetupDialog() {
    View buttonAddDirectMessage = getDialog().findViewById(R.id.btn_add_direct_message);
    AutoCompleteTextView autoCompleteTextView = (AutoCompleteTextView) getDialog().findViewById(R.id.editor_username);
    AbsoluteUrlHelper absoluteUrlHelper = new AbsoluteUrlHelper(hostname, new RealmServerInfoRepository(), new RealmUserRepository(hostname), new SessionInteractor(new RealmSessionRepository(hostname)));
    compositeDisposable.add(absoluteUrlHelper.getRocketChatAbsoluteUrl().subscribeOn(AndroidSchedulers.from(BackgroundLooper.get())).observeOn(AndroidSchedulers.mainThread()).subscribe(this::setupView, Logger::report));
    RxTextView.textChanges(autoCompleteTextView).map(text -> !TextUtils.isEmpty(text)).compose(bindToLifecycle()).subscribe(buttonAddDirectMessage::setEnabled, Logger::report);
    buttonAddDirectMessage.setOnClickListener(view -> createRoom());
}
Also used : SessionInteractor(chat.rocket.core.interactors.SessionInteractor) AbsoluteUrlHelper(chat.rocket.android.helper.AbsoluteUrlHelper) RealmSessionRepository(chat.rocket.persistence.realm.repositories.RealmSessionRepository) Logger(chat.rocket.android.helper.Logger) RxTextView(com.jakewharton.rxbinding2.widget.RxTextView) AutoCompleteTextView(android.widget.AutoCompleteTextView) TextView(android.widget.TextView) View(android.view.View) RealmServerInfoRepository(chat.rocket.persistence.realm.repositories.RealmServerInfoRepository) RealmUserRepository(chat.rocket.persistence.realm.repositories.RealmUserRepository) AutoCompleteTextView(android.widget.AutoCompleteTextView) SuppressLint(android.annotation.SuppressLint)

Example 3 with Logger

use of chat.rocket.android.helper.Logger in project Rocket.Chat.Android by RocketChat.

the class RoomPresenter method onUnreadCount.

@Override
public void onUnreadCount() {
    final Disposable subscription = getRoomUserPair().flatMap(roomUserPair -> messageInteractor.unreadCountFor(roomUserPair.first, roomUserPair.second)).subscribeOn(AndroidSchedulers.from(BackgroundLooper.get())).observeOn(AndroidSchedulers.mainThread()).subscribe(count -> view.showUnreadCount(count), Logger::report);
    addSubscription(subscription);
}
Also used : Disposable(io.reactivex.disposables.Disposable) User(chat.rocket.core.models.User) Settings(chat.rocket.core.models.Settings) Optional(com.fernandocejas.arrow.optional.Optional) UserRepository(chat.rocket.core.repositories.UserRepository) RoomRepository(chat.rocket.core.repositories.RoomRepository) Logger(chat.rocket.android.helper.Logger) NonNull(android.support.annotation.NonNull) Single(io.reactivex.Single) AndroidSchedulers(io.reactivex.android.schedulers.AndroidSchedulers) LogIfError(chat.rocket.android.helper.LogIfError) MessageInteractor(chat.rocket.core.interactors.MessageInteractor) Message(chat.rocket.core.models.Message) MethodCallHelper(chat.rocket.android.api.MethodCallHelper) Disposable(io.reactivex.disposables.Disposable) ConnectivityManagerApi(chat.rocket.android.service.ConnectivityManagerApi) Pair(android.support.v4.util.Pair) Room(chat.rocket.core.models.Room) SyncState(chat.rocket.core.SyncState) Nullable(android.support.annotation.Nullable) BackgroundLooper(chat.rocket.android.BackgroundLooper) BasePresenter(chat.rocket.android.shared.BasePresenter) AbsoluteUrlHelper(chat.rocket.android.helper.AbsoluteUrlHelper) Logger(chat.rocket.android.helper.Logger)

Example 4 with Logger

use of chat.rocket.android.helper.Logger in project Rocket.Chat.Android by RocketChat.

the class RoomPresenter method getMessages.

private void getMessages() {
    final Disposable subscription = roomRepository.getById(roomId).filter(Optional::isPresent).map(Optional::get).flatMap(messageInteractor::getAllFrom).subscribeOn(AndroidSchedulers.from(BackgroundLooper.get())).observeOn(AndroidSchedulers.mainThread()).subscribe(messages -> view.showMessages(messages), Logger::report);
    addSubscription(subscription);
}
Also used : Disposable(io.reactivex.disposables.Disposable) Optional(com.fernandocejas.arrow.optional.Optional) Logger(chat.rocket.android.helper.Logger)

Example 5 with Logger

use of chat.rocket.android.helper.Logger in project Rocket.Chat.Android by RocketChat.

the class RoomPresenter method getUserPreferences.

private void getUserPreferences() {
    final Disposable subscription = userRepository.getCurrent().filter(Optional::isPresent).map(Optional::get).filter(user -> user.getSettings() != null).map(User::getSettings).filter(settings -> settings.getPreferences() != null).map(Settings::getPreferences).distinctUntilChanged().subscribeOn(AndroidSchedulers.from(BackgroundLooper.get())).observeOn(AndroidSchedulers.mainThread()).subscribe(preferences -> {
        if (preferences.isAutoImageLoad()) {
            view.autoloadImages();
        } else {
            view.manualLoadImages();
        }
    }, Logger::report);
    addSubscription(subscription);
}
Also used : Disposable(io.reactivex.disposables.Disposable) User(chat.rocket.core.models.User) Settings(chat.rocket.core.models.Settings) Optional(com.fernandocejas.arrow.optional.Optional) UserRepository(chat.rocket.core.repositories.UserRepository) RoomRepository(chat.rocket.core.repositories.RoomRepository) Logger(chat.rocket.android.helper.Logger) NonNull(android.support.annotation.NonNull) Single(io.reactivex.Single) AndroidSchedulers(io.reactivex.android.schedulers.AndroidSchedulers) LogIfError(chat.rocket.android.helper.LogIfError) MessageInteractor(chat.rocket.core.interactors.MessageInteractor) Message(chat.rocket.core.models.Message) MethodCallHelper(chat.rocket.android.api.MethodCallHelper) Disposable(io.reactivex.disposables.Disposable) ConnectivityManagerApi(chat.rocket.android.service.ConnectivityManagerApi) Pair(android.support.v4.util.Pair) Room(chat.rocket.core.models.Room) SyncState(chat.rocket.core.SyncState) Nullable(android.support.annotation.Nullable) BackgroundLooper(chat.rocket.android.BackgroundLooper) BasePresenter(chat.rocket.android.shared.BasePresenter) AbsoluteUrlHelper(chat.rocket.android.helper.AbsoluteUrlHelper) User(chat.rocket.core.models.User) Optional(com.fernandocejas.arrow.optional.Optional) Logger(chat.rocket.android.helper.Logger) Settings(chat.rocket.core.models.Settings)

Aggregations

Logger (chat.rocket.android.helper.Logger)22 Disposable (io.reactivex.disposables.Disposable)18 Optional (com.fernandocejas.arrow.optional.Optional)9 AbsoluteUrlHelper (chat.rocket.android.helper.AbsoluteUrlHelper)7 NonNull (android.support.annotation.NonNull)6 Nullable (android.support.annotation.Nullable)6 Pair (android.support.v4.util.Pair)6 MethodCallHelper (chat.rocket.android.api.MethodCallHelper)6 Room (chat.rocket.core.models.Room)6 AndroidSchedulers (io.reactivex.android.schedulers.AndroidSchedulers)6 BackgroundLooper (chat.rocket.android.BackgroundLooper)5 LogIfError (chat.rocket.android.helper.LogIfError)5 MessageInteractor (chat.rocket.core.interactors.MessageInteractor)5 Message (chat.rocket.core.models.Message)5 User (chat.rocket.core.models.User)5 Single (io.reactivex.Single)5 SuppressLint (android.annotation.SuppressLint)4 View (android.view.View)4 ConnectivityManagerApi (chat.rocket.android.service.ConnectivityManagerApi)4 BasePresenter (chat.rocket.android.shared.BasePresenter)4