diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index b5a061b..4fbfa6b 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -48,6 +48,11 @@
android:label="@string/title_activity_sharing"
android:launchMode="singleTop" />
+
+
{
@@ -47,8 +49,9 @@ public class ListViewAdapter extends ArrayAdapter {
return position;
}
+ @NonNull
@Override
- public View getView(int position, View convertView, ViewGroup parent) {
+ public View getView(int position, View convertView, @NonNull ViewGroup parent) {
ViewHolder holder;
LayoutInflater inflater = (LayoutInflater) activity.getSystemService(Activity.LAYOUT_INFLATER_SERVICE);
// If holder not exist then locate all view from UI file.
@@ -67,11 +70,11 @@ public class ListViewAdapter extends ArrayAdapter {
holder.friendName.setText(getItem(position));
//get first letter of each String item
- String firstLetter = String.valueOf(getItem(position).charAt(0));
+ String firstLetter = String.valueOf(Objects.requireNonNull(getItem(position)).charAt(0));
ColorGenerator generator = ColorGenerator.MATERIAL; // or use DEFAULT
// generate random color
- int color = generator.getColor(getItem(position));
+ int color = generator.getColor(Objects.requireNonNull(getItem(position)));
TextDrawable drawable = TextDrawable.builder()
.buildRound(firstLetter, color); // radius in px
@@ -101,7 +104,7 @@ public class ListViewAdapter extends ArrayAdapter {
private ImageView imageView;
private TextView friendName;
- public ViewHolder(View v) {
+ ViewHolder(View v) {
imageView = (ImageView) v.findViewById(R.id.image_view);
friendName = (TextView) v.findViewById(R.id.text);
}
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 8c0b5ba..8ae2465 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
@@ -191,7 +191,7 @@ public abstract class BaseActivity
setFragment(sharingFragment);
} else if (itemId == R.id.nav_notif) {
- startActivity(new Intent(this, NotificationsActivity.class));
+ startActivity(new Intent(this, UsersListActivity.class));
}
//finish();
}, 300);
diff --git a/app/src/main/java/com/uam/wmi/findmytutor/activity/ListViewAdapter.java b/app/src/main/java/com/uam/wmi/findmytutor/activity/ListViewAdapter.java
new file mode 100644
index 0000000..51592d1
--- /dev/null
+++ b/app/src/main/java/com/uam/wmi/findmytutor/activity/ListViewAdapter.java
@@ -0,0 +1,111 @@
+package com.uam.wmi.findmytutor.activity;
+
+import android.app.Activity;
+import android.support.annotation.NonNull;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.ArrayAdapter;
+import android.widget.ImageView;
+import android.widget.TextView;
+
+import com.amulyakhare.textdrawable.TextDrawable;
+import com.amulyakhare.textdrawable.util.ColorGenerator;
+
+import com.uam.wmi.findmytutor.R;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Locale;
+import java.util.Objects;
+
+public class ListViewAdapter extends ArrayAdapter {
+
+ private UsersListActivity activity;
+ private List friendList;
+ private List searchList;
+
+ public ListViewAdapter(UsersListActivity context, int resource, List objects) {
+ super(context, resource, objects);
+ this.activity = context;
+ this.friendList = objects;
+ this.searchList = new ArrayList<>();
+ this.searchList.addAll(friendList);
+ }
+
+ @Override
+ public int getCount() {
+ return friendList.size();
+ }
+
+ @Override
+ public String getItem(int position) {
+ return friendList.get(position);
+ }
+
+ @Override
+ public long getItemId(int position) {
+ return position;
+ }
+
+ @NonNull
+ @Override
+ public View getView(int position, View convertView, @NonNull ViewGroup parent) {
+ ViewHolder holder;
+ LayoutInflater inflater = (LayoutInflater) activity.getSystemService(Activity.LAYOUT_INFLATER_SERVICE);
+ // If holder not exist then locate all view from UI file.
+ if (convertView == null) {
+ // inflate UI from XML file
+ convertView = inflater.inflate(R.layout.item_listview, parent, false);
+ // get all UI view
+ holder = new ViewHolder(convertView);
+ // set tag for holder
+ convertView.setTag(holder);
+ } else {
+ // if holder created, get tag from view
+ holder = (ViewHolder) convertView.getTag();
+ }
+
+ holder.friendName.setText(getItem(position));
+
+ //get first letter of each String item
+ String firstLetter = String.valueOf(Objects.requireNonNull(getItem(position)).charAt(0));
+
+ ColorGenerator generator = ColorGenerator.MATERIAL; // or use DEFAULT
+ // generate random color
+ int color = generator.getColor(Objects.requireNonNull(getItem(position)));
+
+ TextDrawable drawable = TextDrawable.builder()
+ .buildRound(firstLetter, color); // radius in px
+
+ holder.imageView.setImageDrawable(drawable);
+
+ return convertView;
+ }
+
+ // Filter method
+ public void filter(String charText) {
+ charText = charText.toLowerCase(Locale.getDefault());
+ friendList.clear();
+ if (charText.length() == 0) {
+ friendList.addAll(searchList);
+ } else {
+ for (String s : searchList) {
+ if (s.toLowerCase(Locale.getDefault()).contains(charText)) {
+ friendList.add(s);
+ }
+ }
+ }
+ notifyDataSetChanged();
+ }
+
+ private class ViewHolder {
+ private ImageView imageView;
+ private TextView friendName;
+
+ public ViewHolder(View v) {
+ imageView = v.findViewById(R.id.image_view);
+ friendName = v.findViewById(R.id.text);
+ }
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/uam/wmi/findmytutor/activity/LoginActivity.java b/app/src/main/java/com/uam/wmi/findmytutor/activity/LoginActivity.java
index 9047291..3b1dc78 100644
--- a/app/src/main/java/com/uam/wmi/findmytutor/activity/LoginActivity.java
+++ b/app/src/main/java/com/uam/wmi/findmytutor/activity/LoginActivity.java
@@ -395,7 +395,9 @@ public class LoginActivity extends AppCompatActivity implements LoaderCallbacks<
.subscribeWith(new DisposableSingleObserver() {
@Override
public void onSuccess(JwtToken jwtToken) {
- String token = jwtToken.getToken();
+ //String token = jwtToken.getToken();
+
+ String token = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJuYW1laWQiOiIzY2QyMWFlYi00ZGRmLTQ0YTktOWM3OC1kNGE3MjVlN2MwNDkiLCJzdWIiOiJhc2RAYXNkc2FkYWEiLCJqdGkiOiIwMDMzYWZhMy0yNDZhLTQ1YTYtOWZmYi1lNzhiYjg3MDMzMmIiLCJleHAiOjE1NDMxMzUwNjAsImlzcyI6Imh0dHA6Ly9maW5kbXl0dXRvci5jb20iLCJhdWQiOiJodHRwOi8vZmluZG15dHV0b3IuY29tIn0.rzks6-yjvVuYoO0pdiBwAfqDnMg8C8XrM9eA4h692m0";
JWT jwt = new JWT(token);
Claim role = jwt.getClaim("nameid");
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
new file mode 100644
index 0000000..c801e28
--- /dev/null
+++ b/app/src/main/java/com/uam/wmi/findmytutor/activity/UsersListActivity.java
@@ -0,0 +1,95 @@
+package com.uam.wmi.findmytutor.activity;
+
+import android.os.Bundle;
+import android.support.design.widget.CoordinatorLayout;
+import android.support.v7.app.AppCompatActivity;
+import android.support.v7.widget.DefaultItemAnimator;
+import android.support.v7.widget.LinearLayoutManager;
+import android.support.v7.widget.RecyclerView;
+import android.util.Log;
+import android.view.View;
+
+import com.uam.wmi.findmytutor.R;
+import com.uam.wmi.findmytutor.model.PagedResultReturnedTutors;
+
+import com.uam.wmi.findmytutor.model.Tutor;
+import com.uam.wmi.findmytutor.network.ApiClient;
+import com.uam.wmi.findmytutor.service.UserService;
+import com.uam.wmi.findmytutor.utils.MyDividerItemDecoration;
+import com.uam.wmi.findmytutor.view.TutorsAdapter;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import butterknife.BindView;
+import butterknife.ButterKnife;
+import io.reactivex.android.schedulers.AndroidSchedulers;
+import io.reactivex.disposables.CompositeDisposable;
+import io.reactivex.observers.DisposableSingleObserver;
+import io.reactivex.schedulers.Schedulers;
+
+public class UsersListActivity extends AppCompatActivity {
+ private static final String TAG = UsersListActivity.class.getSimpleName();
+ private UserService apiService;
+ private CompositeDisposable disposable = new CompositeDisposable();
+ private TutorsAdapter mAdapter;
+ private List tutorsList = new ArrayList<>();
+ @BindView(R.id.coordinator_layout)
+ CoordinatorLayout coordinatorLayout;
+
+ @BindView(R.id.recycler_view)
+ RecyclerView recyclerView;
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
+ setContentView(R.layout.users_list);
+ ButterKnife.bind(this);
+
+ apiService = ApiClient.getClient(getApplicationContext())
+ .create(UserService.class);
+ fetchAllTutors();
+ mAdapter = new TutorsAdapter(this, tutorsList);
+ RecyclerView.LayoutManager mLayoutManager = new LinearLayoutManager(getApplicationContext());
+ recyclerView.setLayoutManager(mLayoutManager);
+ recyclerView.setItemAnimator(new DefaultItemAnimator());
+ recyclerView.addItemDecoration(new MyDividerItemDecoration(this, LinearLayoutManager.VERTICAL, 16));
+ recyclerView.setAdapter(mAdapter);
+
+
+ }
+
+ private void fetchAllTutors() {
+ disposable.add(
+ apiService.getPagedTutors(1)
+ .subscribeOn(Schedulers.io())
+ .observeOn(AndroidSchedulers.mainThread())
+ .subscribeWith(new DisposableSingleObserver () {
+ @Override
+ public void onSuccess(PagedResultReturnedTutors pagedResult) {
+
+ tutorsList.clear();
+ tutorsList.addAll(pagedResult.getResults().getTutors());
+ mAdapter.notifyDataSetChanged();
+
+ Log.e("TUTORS", String.valueOf(pagedResult.getResults().getTutors()));
+
+
+ }
+
+ @Override
+ public void onError(Throwable e) {
+ Log.e("TUTORS_Error",e.toString());
+ }
+ }));
+
+
+ }
+
+ @Override
+ protected void onDestroy() {
+ super.onDestroy();
+ disposable.dispose();
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/uam/wmi/findmytutor/model/LdapUser.java b/app/src/main/java/com/uam/wmi/findmytutor/model/LdapUser.java
index b57c702..51f5cb9 100644
--- a/app/src/main/java/com/uam/wmi/findmytutor/model/LdapUser.java
+++ b/app/src/main/java/com/uam/wmi/findmytutor/model/LdapUser.java
@@ -11,7 +11,7 @@ import io.swagger.annotations.ApiModelProperty;
* LdapUser
*/
-public class LdapUser extends BaseResponse{
+public class LdapUser extends BaseResponse {
@SerializedName("login")
private String login = null;
diff --git a/app/src/main/java/com/uam/wmi/findmytutor/model/Model.java b/app/src/main/java/com/uam/wmi/findmytutor/model/Model.java
index 3b5ee47..bca9777 100644
--- a/app/src/main/java/com/uam/wmi/findmytutor/model/Model.java
+++ b/app/src/main/java/com/uam/wmi/findmytutor/model/Model.java
@@ -1,3 +1,4 @@
+/*
package com.uam.wmi.findmytutor.model;
@@ -14,3 +15,4 @@ public class Model
}
}
+*/
diff --git a/app/src/main/java/com/uam/wmi/findmytutor/model/PagedResult.java b/app/src/main/java/com/uam/wmi/findmytutor/model/PagedResult.java
index db05386..a5dab31 100644
--- a/app/src/main/java/com/uam/wmi/findmytutor/model/PagedResult.java
+++ b/app/src/main/java/com/uam/wmi/findmytutor/model/PagedResult.java
@@ -1,3 +1,4 @@
+
package com.uam.wmi.findmytutor.model;
import com.google.gson.annotations.Expose;
@@ -9,7 +10,7 @@ public class PagedResult {
@SerializedName("results")
@Expose
- private List results = null;
+ private List results = null;
@SerializedName("currentPage")
@Expose
private Integer currentPage;
@@ -29,11 +30,11 @@ public class PagedResult {
@Expose
private Integer lastRowOnPage;
- public List getResults() {
+ public List getResults() {
return results;
}
- public void setResults(List results) {
+ public void setResults(List results) {
this.results = results;
}
@@ -86,3 +87,15 @@ public class PagedResult {
}
}
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/src/main/java/com/uam/wmi/findmytutor/model/PagedResultReturnedTutors.java b/app/src/main/java/com/uam/wmi/findmytutor/model/PagedResultReturnedTutors.java
new file mode 100644
index 0000000..4e98f5f
--- /dev/null
+++ b/app/src/main/java/com/uam/wmi/findmytutor/model/PagedResultReturnedTutors.java
@@ -0,0 +1,89 @@
+package com.uam.wmi.findmytutor.model;
+
+import com.google.gson.annotations.Expose;
+import com.google.gson.annotations.SerializedName;
+import com.uam.wmi.findmytutor.model.Results;
+
+public class PagedResultReturnedTutors extends BaseResponse{
+
+ @SerializedName("results")
+ @Expose
+ private Results results;
+ @SerializedName("currentPage")
+ @Expose
+ private Integer currentPage;
+ @SerializedName("pageCount")
+ @Expose
+ private Integer pageCount;
+ @SerializedName("pageSize")
+ @Expose
+ private Integer pageSize;
+ @SerializedName("rowCount")
+ @Expose
+ private Integer rowCount;
+ @SerializedName("firstRowOnPage")
+ @Expose
+ private Integer firstRowOnPage;
+ @SerializedName("lastRowOnPage")
+ @Expose
+ private Integer lastRowOnPage;
+
+ public Results getResults() {
+ return results;
+ }
+
+ public void setResults(Results results) {
+ this.results = results;
+ }
+
+ public Integer getCurrentPage() {
+ return currentPage;
+ }
+
+ public void setCurrentPage(Integer currentPage) {
+ this.currentPage = currentPage;
+ }
+
+ public Integer getPageCount() {
+ return pageCount;
+ }
+
+ public void setPageCount(Integer pageCount) {
+ this.pageCount = pageCount;
+ }
+
+ public Integer getPageSize() {
+ return pageSize;
+ }
+
+ public void setPageSize(Integer pageSize) {
+ this.pageSize = pageSize;
+ }
+
+ public Integer getRowCount() {
+ return rowCount;
+ }
+
+ public void setRowCount(Integer rowCount) {
+ this.rowCount = rowCount;
+ }
+
+ public Integer getFirstRowOnPage() {
+ return firstRowOnPage;
+ }
+
+ public void setFirstRowOnPage(Integer firstRowOnPage) {
+ this.firstRowOnPage = firstRowOnPage;
+ }
+
+ public Integer getLastRowOnPage() {
+ return lastRowOnPage;
+ }
+
+ public void setLastRowOnPage(Integer lastRowOnPage) {
+ this.lastRowOnPage = lastRowOnPage;
+ }
+
+}
+
+
diff --git a/app/src/main/java/com/uam/wmi/findmytutor/model/PagedResultUserResponseModel.java b/app/src/main/java/com/uam/wmi/findmytutor/model/PagedResultUserResponseModel.java
index 0e16bb2..2927d71 100644
--- a/app/src/main/java/com/uam/wmi/findmytutor/model/PagedResultUserResponseModel.java
+++ b/app/src/main/java/com/uam/wmi/findmytutor/model/PagedResultUserResponseModel.java
@@ -1,5 +1,6 @@
package com.uam.wmi.findmytutor.model;
+import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
import java.util.ArrayList;
@@ -14,24 +15,31 @@ import io.swagger.annotations.ApiModelProperty;
public class PagedResultUserResponseModel extends BaseResponse {
@SerializedName("results")
+ @Expose
private List results = null;
@SerializedName("currentPage")
+ @Expose
private Integer currentPage = null;
@SerializedName("pageCount")
+ @Expose
private Integer pageCount = null;
@SerializedName("pageSize")
+ @Expose
private Integer pageSize = null;
@SerializedName("rowCount")
+ @Expose
private Integer rowCount = null;
@SerializedName("firstRowOnPage")
+ @Expose
private Integer firstRowOnPage = null;
@SerializedName("lastRowOnPage")
+ @Expose
private Integer lastRowOnPage = null;
public PagedResultUserResponseModel results(List results) {
diff --git a/app/src/main/java/com/uam/wmi/findmytutor/model/Results.java b/app/src/main/java/com/uam/wmi/findmytutor/model/Results.java
new file mode 100644
index 0000000..c57f109
--- /dev/null
+++ b/app/src/main/java/com/uam/wmi/findmytutor/model/Results.java
@@ -0,0 +1,33 @@
+package com.uam.wmi.findmytutor.model;
+
+
+import java.util.List;
+import com.google.gson.annotations.Expose;
+import com.google.gson.annotations.SerializedName;
+
+public class Results extends BaseResponse {
+
+ @SerializedName("tutors")
+ @Expose
+ private List tutors = null;
+ @SerializedName("blacklistersTutors")
+ @Expose
+ private List