Commit 0b427044 authored by Filipe de Lima Brito's avatar Filipe de Lima Brito

Update SidebarMainPresenter.java

parent 15b8e060
...@@ -3,7 +3,9 @@ package chat.rocket.android.fragment.sidebar; ...@@ -3,7 +3,9 @@ package chat.rocket.android.fragment.sidebar;
import android.support.annotation.NonNull; import android.support.annotation.NonNull;
import android.support.v4.util.Pair; import android.support.v4.util.Pair;
import chat.rocket.core.SortDirection;
import chat.rocket.core.models.Spotlight; import chat.rocket.core.models.Spotlight;
import chat.rocket.persistence.realm.repositories.RealmSpotlightRepository;
import io.reactivex.Flowable; import io.reactivex.Flowable;
import io.reactivex.android.schedulers.AndroidSchedulers; import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.disposables.Disposable; import io.reactivex.disposables.Disposable;
...@@ -20,6 +22,7 @@ import chat.rocket.core.interactors.RoomInteractor; ...@@ -20,6 +22,7 @@ import chat.rocket.core.interactors.RoomInteractor;
import chat.rocket.core.models.Room; import chat.rocket.core.models.Room;
import chat.rocket.core.models.User; import chat.rocket.core.models.User;
import chat.rocket.core.repositories.UserRepository; import chat.rocket.core.repositories.UserRepository;
import java.util.List;
public class SidebarMainPresenter extends BasePresenter<SidebarMainContract.View> public class SidebarMainPresenter extends BasePresenter<SidebarMainContract.View>
implements SidebarMainContract.Presenter { implements SidebarMainContract.Presenter {
...@@ -30,18 +33,22 @@ public class SidebarMainPresenter extends BasePresenter<SidebarMainContract.View ...@@ -30,18 +33,22 @@ public class SidebarMainPresenter extends BasePresenter<SidebarMainContract.View
private final RocketChatCache rocketChatCache; private final RocketChatCache rocketChatCache;
private final AbsoluteUrlHelper absoluteUrlHelper; private final AbsoluteUrlHelper absoluteUrlHelper;
private final MethodCallHelper methodCallHelper; private final MethodCallHelper methodCallHelper;
private RealmSpotlightRepository realmSpotlightRepository;
public SidebarMainPresenter(String hostname, RoomInteractor roomInteractor, public SidebarMainPresenter(String hostname,
RoomInteractor roomInteractor,
UserRepository userRepository, UserRepository userRepository,
RocketChatCache rocketChatCache, RocketChatCache rocketChatCache,
AbsoluteUrlHelper absoluteUrlHelper, AbsoluteUrlHelper absoluteUrlHelper,
MethodCallHelper methodCallHelper) { MethodCallHelper methodCallHelper,
RealmSpotlightRepository realmSpotlightRepository) {
this.hostname = hostname; this.hostname = hostname;
this.roomInteractor = roomInteractor; this.roomInteractor = roomInteractor;
this.userRepository = userRepository; this.userRepository = userRepository;
this.rocketChatCache = rocketChatCache; this.rocketChatCache = rocketChatCache;
this.absoluteUrlHelper = absoluteUrlHelper; this.absoluteUrlHelper = absoluteUrlHelper;
this.methodCallHelper = methodCallHelper; this.methodCallHelper = methodCallHelper;
this.realmSpotlightRepository = realmSpotlightRepository;
} }
@Override @Override
...@@ -82,6 +89,12 @@ public class SidebarMainPresenter extends BasePresenter<SidebarMainContract.View ...@@ -82,6 +89,12 @@ public class SidebarMainPresenter extends BasePresenter<SidebarMainContract.View
rocketChatCache.setSelectedRoomId(spotlight.getId()); rocketChatCache.setSelectedRoomId(spotlight.getId());
} }
@Override
public Flowable<List<Spotlight>> searchSpotlight(String term) {
methodCallHelper.searchSpotlight(term);
return realmSpotlightRepository.getSuggestionsFor(term, 10);
}
@Override @Override
public void onUserOnline() { public void onUserOnline() {
updateCurrentUserStatus(User.STATUS_ONLINE); updateCurrentUserStatus(User.STATUS_ONLINE);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment