Commit 1934aae1 authored by Filipe de Lima Brito's avatar Filipe de Lima Brito

Update SidebarMainFragment.java

parent 45c2e5dc
...@@ -48,6 +48,8 @@ import java.util.ArrayList; ...@@ -48,6 +48,8 @@ import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import rx.Subscriber;
import rx.functions.Action1;
public class SidebarMainFragment extends AbstractFragment implements SidebarMainContract.View { public class SidebarMainFragment extends AbstractFragment implements SidebarMainContract.View {
private SidebarMainContract.Presenter presenter; private SidebarMainContract.Presenter presenter;
...@@ -55,7 +57,6 @@ public class SidebarMainFragment extends AbstractFragment implements SidebarMain ...@@ -55,7 +57,6 @@ public class SidebarMainFragment extends AbstractFragment implements SidebarMain
private String hostname; private String hostname;
private MethodCallHelper methodCallHelper; private MethodCallHelper methodCallHelper;
private RealmSpotlightRepository realmSpotlightRepository;
private SearchView searchView; private SearchView searchView;
private static final String HOSTNAME = "hostname"; private static final String HOSTNAME = "hostname";
...@@ -83,7 +84,6 @@ public class SidebarMainFragment extends AbstractFragment implements SidebarMain ...@@ -83,7 +84,6 @@ public class SidebarMainFragment extends AbstractFragment implements SidebarMain
hostname = args == null ? null : args.getString(HOSTNAME); hostname = args == null ? null : args.getString(HOSTNAME);
methodCallHelper = new MethodCallHelper(getContext(), hostname); methodCallHelper = new MethodCallHelper(getContext(), hostname);
realmSpotlightRepository = new RealmSpotlightRepository(hostname);
RealmUserRepository userRepository = new RealmUserRepository(hostname); RealmUserRepository userRepository = new RealmUserRepository(hostname);
...@@ -100,7 +100,8 @@ public class SidebarMainFragment extends AbstractFragment implements SidebarMain ...@@ -100,7 +100,8 @@ public class SidebarMainFragment extends AbstractFragment implements SidebarMain
userRepository, userRepository,
new RocketChatCache(getContext()), new RocketChatCache(getContext()),
absoluteUrlHelper, absoluteUrlHelper,
TextUtils.isEmpty(hostname) ? null : new MethodCallHelper(getContext(), hostname) TextUtils.isEmpty(hostname) ? null : new MethodCallHelper(getContext(), hostname),
new RealmSpotlightRepository(hostname)
); );
} }
...@@ -175,15 +176,10 @@ public class SidebarMainFragment extends AbstractFragment implements SidebarMain ...@@ -175,15 +176,10 @@ public class SidebarMainFragment extends AbstractFragment implements SidebarMain
return Observable.just(Collections.<Spotlight>emptyList()); return Observable.just(Collections.<Spotlight>emptyList());
} else { } else {
adapter.setMode(RoomListAdapter.MODE_SPOTLIGHT); adapter.setMode(RoomListAdapter.MODE_SPOTLIGHT);
final String queryString = charSequence.toString(); return presenter.searchSpotlight(charSequence.toString()).toObservable();
methodCallHelper.searchSpotlight(queryString);
return realmSpotlightRepository.getSuggestionsFor(queryString, SortDirection.ASC, 10).toObservable();
} }
}) })
.subscribe( .subscribe(this::showSearchSuggestions, Logger::report);
this::showSearchSuggestions,
Logger::report
);
} }
private void showSearchSuggestions(List<Spotlight> spotlightList) { private void showSearchSuggestions(List<Spotlight> spotlightList) {
......
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