From af1e1a53b4ffd960047d9b5dafb53b7ae9cafb72 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mieszko=20Wrzeszczy=C5=84ski?= Date: Thu, 3 Jan 2019 21:32:28 +0100 Subject: [PATCH] Add proper search --- .../findmytutor/activity/BaseActivity.java | 8 +------ .../activity/UsersListFragment.java | 22 +++++-------------- .../wmi/findmytutor/service/UserService.java | 8 +++++-- .../main/res/layout/info_popup_userlist.xml | 2 ++ app/src/main/res/values-pl/strings.xml | 5 +++-- app/src/main/res/values/strings.xml | 13 ++++++----- 6 files changed, 25 insertions(+), 33 deletions(-) diff --git a/app/src/main/java/com/uam/wmi/findmytutor/activity/BaseActivity.java b/app/src/main/java/com/uam/wmi/findmytutor/activity/BaseActivity.java index 36f212a..18d1955 100644 --- a/app/src/main/java/com/uam/wmi/findmytutor/activity/BaseActivity.java +++ b/app/src/main/java/com/uam/wmi/findmytutor/activity/BaseActivity.java @@ -220,17 +220,12 @@ public abstract class BaseActivity } public void handleBackgroundTaskLifeCycle() { - Log.e("Localization", String.valueOf(PrefUtils.isEnableSharingLocalization(getApplicationContext()))); Boolean shouldServiceRun = PrefUtils.isEnableSharingLocalization(getApplicationContext()) && isTutor; - Log.e("Localization", String.valueOf(shouldServiceRun)); if (shouldServiceRun) { startBackgroundLocalizationTask(); - Log.e("Localization", "JEstem i odpalam"); - } else { stopBackgroundLocalizationTask(); - Log.e("Localization", "JEstem i nie odpalam"); } } @@ -304,11 +299,10 @@ public abstract class BaseActivity } }); - - RxSearchObservable.fromView(searchView) .skip(0) .map(String::toLowerCase) + .filter(t -> !t.isEmpty()) .debounce(250, TimeUnit.MILLISECONDS) .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) diff --git a/app/src/main/java/com/uam/wmi/findmytutor/activity/UsersListFragment.java b/app/src/main/java/com/uam/wmi/findmytutor/activity/UsersListFragment.java index 9b89791..eb15075 100644 --- a/app/src/main/java/com/uam/wmi/findmytutor/activity/UsersListFragment.java +++ b/app/src/main/java/com/uam/wmi/findmytutor/activity/UsersListFragment.java @@ -229,7 +229,7 @@ public class UsersListFragment extends Fragment { private void fetchAllTutors() { disposable.add( (fetchOnlyOnlineUsers ? - userService.getAllOnlineTutors() : + userService.getAllActiveTutors() : userService.getAllOfflineTutors()) .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) @@ -313,12 +313,7 @@ public class UsersListFragment extends Fragment { message = getString(R.string.network_err); } - Snackbar snackbar = Snackbar.make(coordinatorLayout, message, Snackbar.LENGTH_LONG); - View view = snackbar.getView(); - CoordinatorLayout.LayoutParams params=(CoordinatorLayout.LayoutParams)view.getLayoutParams(); - params.gravity = Gravity.TOP; - view.setLayoutParams(params); - snackbar.show(); + createSnackbar(message); } private void showSearchError(Throwable e) { @@ -332,23 +327,18 @@ public class UsersListFragment extends Fragment { message = getString(R.string.search_null); } - /* Snackbar.make(coordinatorLayout, message, Snackbar.LENGTH_LONG) - .show(); -*/ + createSnackbar(message); + } - - - Snackbar snackbar = Snackbar.make(coordinatorLayout, message, Snackbar.LENGTH_LONG); + private void createSnackbar(String msg){ + Snackbar snackbar = Snackbar.make(coordinatorLayout, msg, Snackbar.LENGTH_LONG); View view = snackbar.getView(); CoordinatorLayout.LayoutParams params=(CoordinatorLayout.LayoutParams)view.getLayoutParams(); params.gravity = Gravity.TOP; view.setLayoutParams(params); snackbar.show(); - - } - private void toggleEmptyNotes() { if (tutorsList.size() > 0) { noNotesView.setVisibility(View.GONE); diff --git a/app/src/main/java/com/uam/wmi/findmytutor/service/UserService.java b/app/src/main/java/com/uam/wmi/findmytutor/service/UserService.java index 1399068..a393017 100644 --- a/app/src/main/java/com/uam/wmi/findmytutor/service/UserService.java +++ b/app/src/main/java/com/uam/wmi/findmytutor/service/UserService.java @@ -19,6 +19,7 @@ import retrofit2.http.HTTP; import retrofit2.http.POST; import retrofit2.http.PUT; import retrofit2.http.Path; +import retrofit2.http.Query; public interface UserService { @@ -34,11 +35,14 @@ public interface UserService { @GET("api/users/tutors/online") Single > getAllOnlineTutors(); + @GET("api/users/tutors/active") + Single > getAllActiveTutors(); + @GET("api/users/tutors/offline") Single > getAllOfflineTutors(); - @GET("api/users/tutors/search/{searchString}") - Single > searchUser(@Path("searchString") String searchString ); + @GET("api/users/tutors/search") + Single > searchUser(@Query(value = "searchString", encoded = true) String searchString); @POST("api/users") Completable createUser(@Body User user); diff --git a/app/src/main/res/layout/info_popup_userlist.xml b/app/src/main/res/layout/info_popup_userlist.xml index afd1c17..19761d7 100644 --- a/app/src/main/res/layout/info_popup_userlist.xml +++ b/app/src/main/res/layout/info_popup_userlist.xml @@ -72,4 +72,6 @@ android:text="@string/info_icon_userlist_summary" android:textColor="@color/half_black"/> + + \ No newline at end of file diff --git a/app/src/main/res/values-pl/strings.xml b/app/src/main/res/values-pl/strings.xml index 77ef3d5..e3fa57b 100644 --- a/app/src/main/res/values-pl/strings.xml +++ b/app/src/main/res/values-pl/strings.xml @@ -253,9 +253,10 @@ Pobierz dane z WMI Dane zostały zaktualizwane! - Brak użytkowników online. + + Brak aktywnych użytkowników. Brak użytkowników offline. - Tylko użytkownicy online + Tylko aktywni użytkownicy Błąd sieci! Brak wyników! diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 6860e0d..f9e86bc 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -260,7 +260,6 @@ exact localization (from mobile GPS) approximated localization manual localization (manually picked) - You can search for any tutor on the map by entering his name and surname in the search field. In this panel you can add users to your blacklist. Users from the blacklist can’t see any data that you share - localization, online status, or information about presence. @@ -298,9 +297,7 @@ - user is currently offline - user is inactive (didn’t share any localization data since 7 days) - After clicking on a name, the tutor tab will pop up, containing details about selected tutor. - By default, only active users are shown. You can change that in menu (three dots icon). - You can also search for a tutor directly, by entering name and surname of person that you look for. + After clicking on a name, the tutor tab will pop up, containing details about selected tutor.\n\nYou can search for any tutor on the map by entering his name and surname in the search field.\n\nBy default, only active users are shown. You can change that in menu (three dots icon).\n\nYou can also search for a tutor directly, by entering name and surname of person that you look for. Blacklist @@ -335,9 +332,13 @@ OFF Scrap! Data updated! - Currently, there are no\nonline users. + + + Currently, there are no\nactive users. Currently, there are no\noffline users. - Only online users + Only active users + + Network Error ! Search response is empty! Insert a name for this localization. -- 2.20.1