From 31f7408ea65a58d5060f4e293856941a4132cf44 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mieszko=20Wrzeszczy=C5=84ski?= Date: Fri, 26 Oct 2018 14:04:52 +0200 Subject: [PATCH] get all tutors --- .../findmytutor/activity/UsersListActivity.java | 14 ++++++++------ .../uam/wmi/findmytutor/service/UserService.java | 4 ++++ .../uam/wmi/findmytutor/view/TutorsAdapter.java | 6 +++--- 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/app/src/main/java/com/uam/wmi/findmytutor/activity/UsersListActivity.java b/app/src/main/java/com/uam/wmi/findmytutor/activity/UsersListActivity.java index c801e28..89a7d3c 100644 --- a/app/src/main/java/com/uam/wmi/findmytutor/activity/UsersListActivity.java +++ b/app/src/main/java/com/uam/wmi/findmytutor/activity/UsersListActivity.java @@ -12,7 +12,9 @@ import android.view.View; import com.uam.wmi.findmytutor.R; import com.uam.wmi.findmytutor.model.PagedResultReturnedTutors; +import com.uam.wmi.findmytutor.model.ReturnedTutors; import com.uam.wmi.findmytutor.model.Tutor; +import com.uam.wmi.findmytutor.model.User; import com.uam.wmi.findmytutor.network.ApiClient; import com.uam.wmi.findmytutor.service.UserService; import com.uam.wmi.findmytutor.utils.MyDividerItemDecoration; @@ -33,7 +35,7 @@ public class UsersListActivity extends AppCompatActivity { private UserService apiService; private CompositeDisposable disposable = new CompositeDisposable(); private TutorsAdapter mAdapter; - private List tutorsList = new ArrayList<>(); + private List tutorsList = new ArrayList<>(); @BindView(R.id.coordinator_layout) CoordinatorLayout coordinatorLayout; @@ -62,18 +64,18 @@ public class UsersListActivity extends AppCompatActivity { private void fetchAllTutors() { disposable.add( - apiService.getPagedTutors(1) + apiService.apiUsersGet() .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) - .subscribeWith(new DisposableSingleObserver () { + .subscribeWith(new DisposableSingleObserver () { @Override - public void onSuccess(PagedResultReturnedTutors pagedResult) { + public void onSuccess(ReturnedTutors pagedResult) { tutorsList.clear(); - tutorsList.addAll(pagedResult.getResults().getTutors()); + tutorsList.addAll(pagedResult.getTutors()); mAdapter.notifyDataSetChanged(); - Log.e("TUTORS", String.valueOf(pagedResult.getResults().getTutors())); + Log.e("TUTORS", String.valueOf(pagedResult.getTutors())); } 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 883dcfd..e4a80ec 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 @@ -2,6 +2,7 @@ package com.uam.wmi.findmytutor.service; import com.uam.wmi.findmytutor.model.IsUsingListBool; import com.uam.wmi.findmytutor.model.PagedResultReturnedTutors; +import com.uam.wmi.findmytutor.model.ReturnedTutors; import com.uam.wmi.findmytutor.model.StudentIdModel; import com.uam.wmi.findmytutor.model.User; @@ -23,6 +24,9 @@ public interface UserService { @GET("api/users") Single > getAllUsers(); + @GET("api/users") + Single apiUsersGet(); + @POST("api/users") Completable createUser(@Body User user); diff --git a/app/src/main/java/com/uam/wmi/findmytutor/view/TutorsAdapter.java b/app/src/main/java/com/uam/wmi/findmytutor/view/TutorsAdapter.java index 73264b6..d3f24f1 100644 --- a/app/src/main/java/com/uam/wmi/findmytutor/view/TutorsAdapter.java +++ b/app/src/main/java/com/uam/wmi/findmytutor/view/TutorsAdapter.java @@ -23,9 +23,9 @@ import butterknife.ButterKnife; public class TutorsAdapter extends RecyclerView.Adapter { private Context context; - private List tutorsList; + private List tutorsList; - public TutorsAdapter(Context context, List tutors) { + public TutorsAdapter(Context context, List tutors) { this.context = context; this.tutorsList = tutors; @@ -63,7 +63,7 @@ public class TutorsAdapter extends RecyclerView.Adapter