Sort users by online category
This commit is contained in:
parent
31f7408ea6
commit
c7231bc70a
@ -62,7 +62,6 @@
|
||||
|
||||
<activity android:name=".activity.ProfileActivity" />
|
||||
<!--<activity android:name=".activity.MapActivity" />-->
|
||||
<activity android:name=".activity.NotificationsActivity" />
|
||||
</application>
|
||||
|
||||
</manifest>
|
||||
|
@ -70,24 +70,6 @@ public abstract class BaseActivity
|
||||
toolbar = (Toolbar) findViewById(R.id.toolbar);
|
||||
setSupportActionBar(toolbar);
|
||||
}
|
||||
private void setData() {
|
||||
stringArrayList = new ArrayList<>();
|
||||
stringArrayList.add("Quynh Trang");
|
||||
stringArrayList.add("Hoang Bien");
|
||||
stringArrayList.add("Duc Tuan");
|
||||
stringArrayList.add("Dang Thanh");
|
||||
stringArrayList.add("Xuan Luu");
|
||||
stringArrayList.add("Phan Thanh");
|
||||
stringArrayList.add("Kim Kien");
|
||||
stringArrayList.add("Ngo Trang");
|
||||
stringArrayList.add("Thanh Ngan");
|
||||
stringArrayList.add("Nguyen Duong");
|
||||
stringArrayList.add("Quoc Cuong");
|
||||
stringArrayList.add("Tran Ha");
|
||||
stringArrayList.add("Vu Danh");
|
||||
stringArrayList.add("Minh Meo");
|
||||
}
|
||||
|
||||
|
||||
private void setUpNav() {
|
||||
|
||||
@ -190,7 +172,8 @@ public abstract class BaseActivity
|
||||
// startActivity(new Intent(this, ProfileActivity.class));
|
||||
setFragment(sharingFragment);
|
||||
|
||||
} else if (itemId == R.id.nav_notif) {
|
||||
} else if (itemId == R.id.nav_user_list) {
|
||||
//removeFragment(sharingFragment);
|
||||
startActivity(new Intent(this, UsersListActivity.class));
|
||||
}
|
||||
//finish();
|
||||
|
@ -395,9 +395,9 @@ public class LoginActivity extends AppCompatActivity implements LoaderCallbacks<
|
||||
.subscribeWith(new DisposableSingleObserver<JwtToken>() {
|
||||
@Override
|
||||
public void onSuccess(JwtToken jwtToken) {
|
||||
//String token = jwtToken.getToken();
|
||||
String token = jwtToken.getToken();
|
||||
|
||||
String token = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJuYW1laWQiOiIzY2QyMWFlYi00ZGRmLTQ0YTktOWM3OC1kNGE3MjVlN2MwNDkiLCJzdWIiOiJhc2RAYXNkc2FkYWEiLCJqdGkiOiIwMDMzYWZhMy0yNDZhLTQ1YTYtOWZmYi1lNzhiYjg3MDMzMmIiLCJleHAiOjE1NDMxMzUwNjAsImlzcyI6Imh0dHA6Ly9maW5kbXl0dXRvci5jb20iLCJhdWQiOiJodHRwOi8vZmluZG15dHV0b3IuY29tIn0.rzks6-yjvVuYoO0pdiBwAfqDnMg8C8XrM9eA4h692m0";
|
||||
//String token = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJuYW1laWQiOiIzY2QyMWFlYi00ZGRmLTQ0YTktOWM3OC1kNGE3MjVlN2MwNDkiLCJzdWIiOiJhc2RAYXNkc2FkYWEiLCJqdGkiOiIwMDMzYWZhMy0yNDZhLTQ1YTYtOWZmYi1lNzhiYjg3MDMzMmIiLCJleHAiOjE1NDMxMzUwNjAsImlzcyI6Imh0dHA6Ly9maW5kbXl0dXRvci5jb20iLCJhdWQiOiJodHRwOi8vZmluZG15dHV0b3IuY29tIn0.rzks6-yjvVuYoO0pdiBwAfqDnMg8C8XrM9eA4h692m0";
|
||||
|
||||
JWT jwt = new JWT(token);
|
||||
Claim role = jwt.getClaim("nameid");
|
||||
|
@ -198,9 +198,6 @@ public class MainActivity extends AppCompatActivity implements
|
||||
case R.id.nav_map:
|
||||
// setFragment(mapFragment);
|
||||
return true;
|
||||
case R.id.nav_notif:
|
||||
setFragment(notificationFragment);
|
||||
return true;
|
||||
case R.id.nav_profile:
|
||||
setFragment(sharingFragment);
|
||||
return true;
|
||||
@ -373,12 +370,12 @@ public class MainActivity extends AppCompatActivity implements
|
||||
markerAnimator.setDuration(2000);
|
||||
markerAnimator.start();
|
||||
|
||||
coordsMap.replace(id,element);
|
||||
coordsMap.put(id,element);
|
||||
} else if (!cord.getTimeStamp().equals(element.getTimeStamp())){
|
||||
Log.d("mapper", "update");
|
||||
Log.d("mapper", " "+cord.getTimeStamp());
|
||||
Log.d("mapper", " "+element.getTimeStamp());
|
||||
coordsMap.replace(id,element);
|
||||
coordsMap.put(id,element);
|
||||
}
|
||||
} else {
|
||||
coordsMap.put(id,element);
|
||||
|
@ -1,179 +0,0 @@
|
||||
package com.uam.wmi.findmytutor.activity;
|
||||
|
||||
import android.animation.ObjectAnimator;
|
||||
import android.animation.TypeEvaluator;
|
||||
import android.animation.ValueAnimator;
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.util.Log;
|
||||
|
||||
import com.mapbox.mapboxsdk.Mapbox;
|
||||
import com.mapbox.mapboxsdk.annotations.Marker;
|
||||
import com.mapbox.mapboxsdk.annotations.MarkerViewOptions;
|
||||
import com.mapbox.mapboxsdk.geometry.LatLng;
|
||||
import com.mapbox.mapboxsdk.maps.MapView;
|
||||
import com.mapbox.mapboxsdk.maps.MapboxMap;
|
||||
import com.mapbox.mapboxsdk.maps.OnMapReadyCallback;
|
||||
import com.uam.wmi.findmytutor.R;
|
||||
import com.uam.wmi.findmytutor.model.Coordinate;
|
||||
import com.uam.wmi.findmytutor.network.RetrofitClientInstance;
|
||||
import com.uam.wmi.findmytutor.service.CoordinateService;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.disposables.CompositeDisposable;
|
||||
import io.reactivex.observers.DisposableSingleObserver;
|
||||
import io.reactivex.schedulers.Schedulers;
|
||||
|
||||
|
||||
public class NotificationsActivity extends BaseActivity {
|
||||
|
||||
private MapView mapView;
|
||||
private CoordinateService coordinateService;
|
||||
private CompositeDisposable disposable = new CompositeDisposable();
|
||||
private List<Coordinate> coordinatesList = new ArrayList<>();
|
||||
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
mapInit(savedInstanceState);
|
||||
|
||||
// coordinateService = ApiClient.getClient(getApplicationContext())
|
||||
// .create(CoordinateService.class);
|
||||
final SharedPreferences sharedPref = getSharedPreferences("fmtPrefs", Context.MODE_PRIVATE);
|
||||
final String authToken = sharedPref.getString("authToken",null);
|
||||
|
||||
coordinateService = RetrofitClientInstance.createService(CoordinateService.class,"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJuYW1laWQiOiI2YjhmNzFiMS00NDM2LTQxZGQtYjg3MC1mNzZlNjdkNDM4NDMiLCJzdWIiOiJzdHJpbmciLCJqdGkiOiJiZGRjZTAwMC0xN2U4LTQwNDUtYWZiNS1kY2RkOWNhNDFiNmQiLCJodHRwOi8vc2NoZW1hcy5taWNyb3NvZnQuY29tL3dzLzIwMDgvMDYvaWRlbnRpdHkvY2xhaW1zL3JvbGUiOiJUdXRvciIsImV4cCI6MTU0MTcxNzk2MywiaXNzIjoiaHR0cDovL2ZpbmRteXR1dG9yLmNvbSIsImF1ZCI6Imh0dHA6Ly9maW5kbXl0dXRvci5jb20ifQ.JJVNeMAwwla6DJk6X8qZUgPFKJp-Epx55W9V_fIwpgg");
|
||||
|
||||
fetchTopCoords();
|
||||
}
|
||||
|
||||
private void mapInit(Bundle savedInstanceState) {
|
||||
// Mapbox access token is configured here. This needs to be called either in your application
|
||||
// object or in the same activity which contains the mapview.
|
||||
Mapbox.getInstance(this, getString(R.string.access_token));
|
||||
// This contains the MapView in XML and needs to be called after the access token is configured.
|
||||
// setContentView(R.layout.activity_notifications);
|
||||
|
||||
mapView = (MapView) findViewById(R.id.mapView2);
|
||||
mapView.onCreate(savedInstanceState);
|
||||
mapView.getMapAsync(new OnMapReadyCallback() {
|
||||
@Override
|
||||
public void onMapReady(MapboxMap mapboxMap) {
|
||||
|
||||
final Marker marker = mapboxMap.addMarker(new MarkerViewOptions()
|
||||
.position(new LatLng(64.900932, -18.167040)));
|
||||
|
||||
mapboxMap.setOnMapClickListener(new MapboxMap.OnMapClickListener() {
|
||||
@Override
|
||||
public void onMapClick(@NonNull LatLng point) {
|
||||
|
||||
// When the user clicks on the map, we want to animate the marker to that
|
||||
// location.
|
||||
ValueAnimator markerAnimator = ObjectAnimator.ofObject(marker, "position",
|
||||
new LatLngEvaluator(), marker.getPosition(), point);
|
||||
markerAnimator.setDuration(2000);
|
||||
markerAnimator.start();
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private void fetchTopCoords() {
|
||||
disposable.add(
|
||||
coordinateService.getTopCoordinates()
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribeWith(new DisposableSingleObserver<List<Coordinate>>() {
|
||||
@Override
|
||||
public void onSuccess(List<Coordinate> coordsList) {
|
||||
|
||||
Log.d("mapTag", "co?");
|
||||
for (Coordinate element:
|
||||
coordsList) {
|
||||
Log.d("mapTag", element.getUserId());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Throwable e) {
|
||||
Log.e("Error",e.toString());
|
||||
}
|
||||
})
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStart() {
|
||||
super.onStart();
|
||||
mapView.onStart();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
mapView.onResume();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPause() {
|
||||
super.onPause();
|
||||
mapView.onPause();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStop() {
|
||||
super.onStop();
|
||||
mapView.onStop();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLowMemory() {
|
||||
super.onLowMemory();
|
||||
mapView.onLowMemory();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
mapView.onDestroy();
|
||||
disposable.dispose();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onSaveInstanceState(Bundle outState) {
|
||||
super.onSaveInstanceState(outState);
|
||||
mapView.onSaveInstanceState(outState);
|
||||
}
|
||||
|
||||
private static class LatLngEvaluator implements TypeEvaluator<LatLng> {
|
||||
// Method is used to interpolate the marker animation.
|
||||
|
||||
private LatLng latLng = new LatLng();
|
||||
|
||||
@Override
|
||||
public LatLng evaluate(float fraction, LatLng startValue, LatLng endValue) {
|
||||
latLng.setLatitude(startValue.getLatitude()
|
||||
+ ((endValue.getLatitude() - startValue.getLatitude()) * fraction));
|
||||
latLng.setLongitude(startValue.getLongitude()
|
||||
+ ((endValue.getLongitude() - startValue.getLongitude()) * fraction));
|
||||
return latLng;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getContentViewId() { return R.layout.activity_notifications; }
|
||||
|
||||
@Override
|
||||
protected int getNavigationMenuItemId() { return R.id.nav_notif; }
|
||||
}
|
@ -1,36 +1,44 @@
|
||||
package com.uam.wmi.findmytutor.activity;
|
||||
|
||||
import android.graphics.Color;
|
||||
import android.os.Bundle;
|
||||
import android.support.design.widget.CoordinatorLayout;
|
||||
import android.support.design.widget.Snackbar;
|
||||
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.MenuItem;
|
||||
import android.view.View;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.jakewharton.retrofit2.adapter.rxjava2.HttpException;
|
||||
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;
|
||||
import com.uam.wmi.findmytutor.utils.RecyclerTouchListener;
|
||||
import com.uam.wmi.findmytutor.utils.RestApiHelper;
|
||||
import com.uam.wmi.findmytutor.view.TutorsAdapter;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.disposables.CompositeDisposable;
|
||||
import io.reactivex.functions.Function;
|
||||
import io.reactivex.observers.DisposableSingleObserver;
|
||||
import io.reactivex.schedulers.Schedulers;
|
||||
import okhttp3.ResponseBody;
|
||||
|
||||
public class UsersListActivity extends AppCompatActivity {
|
||||
public class UsersListActivity extends BaseActivity {
|
||||
private static final String TAG = UsersListActivity.class.getSimpleName();
|
||||
private UserService apiService;
|
||||
private CompositeDisposable disposable = new CompositeDisposable();
|
||||
@ -41,17 +49,21 @@ public class UsersListActivity extends AppCompatActivity {
|
||||
|
||||
@BindView(R.id.recycler_view)
|
||||
RecyclerView recyclerView;
|
||||
|
||||
|
||||
@BindView(R.id.txt_empty_notes_view)
|
||||
TextView noNotesView;
|
||||
|
||||
@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);
|
||||
@ -59,39 +71,93 @@ public class UsersListActivity extends AppCompatActivity {
|
||||
recyclerView.addItemDecoration(new MyDividerItemDecoration(this, LinearLayoutManager.VERTICAL, 16));
|
||||
recyclerView.setAdapter(mAdapter);
|
||||
|
||||
fetchAllTutors();
|
||||
|
||||
recyclerView.addOnItemTouchListener(new RecyclerTouchListener(this,
|
||||
recyclerView, new RecyclerTouchListener.ClickListener() {
|
||||
@Override
|
||||
public void onClick(View view, final int position) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLongClick(View view, int position) {
|
||||
//showActionsDialog(position);
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
|
||||
private void fetchAllTutors() {
|
||||
disposable.add(
|
||||
disposable.add(
|
||||
apiService.apiUsersGet()
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribeWith(new DisposableSingleObserver <ReturnedTutors>() {
|
||||
.map(tutors -> {
|
||||
List<User> tutorsList = new ArrayList<>(tutors.getTutors());
|
||||
Collections.sort(tutorsList, (t1, t2) -> t2.isIsOnline().compareTo(t1.isIsOnline()));
|
||||
|
||||
return tutorsList;
|
||||
})
|
||||
.subscribeWith(new DisposableSingleObserver <List<User>>() {
|
||||
@Override
|
||||
public void onSuccess(ReturnedTutors pagedResult) {
|
||||
|
||||
tutorsList.clear();
|
||||
tutorsList.addAll(pagedResult.getTutors());
|
||||
mAdapter.notifyDataSetChanged();
|
||||
|
||||
Log.e("TUTORS", String.valueOf(pagedResult.getTutors()));
|
||||
|
||||
|
||||
public void onSuccess(List<User> users) {
|
||||
tutorsList.clear();
|
||||
tutorsList.addAll(users);
|
||||
mAdapter.notifyDataSetChanged();
|
||||
toggleEmptyNotes();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Throwable e) {
|
||||
Log.e("TUTORS_Error",e.toString());
|
||||
showError(e);
|
||||
}
|
||||
}));
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void showError(Throwable e) {
|
||||
String message = "Something went wrong!";
|
||||
|
||||
if (e instanceof HttpException) {
|
||||
ResponseBody responseBody = ((HttpException) e).response().errorBody();
|
||||
message = RestApiHelper.getErrorMessage(responseBody);
|
||||
}
|
||||
|
||||
Snackbar snackbar = Snackbar.make(coordinatorLayout, message, Snackbar.LENGTH_LONG);
|
||||
View sbView = snackbar.getView();
|
||||
TextView textView = sbView.findViewById(android.support.design.R.id.snackbar_text);
|
||||
textView.setTextColor(Color.BLUE);
|
||||
snackbar.show();
|
||||
}
|
||||
|
||||
private void toggleEmptyNotes() {
|
||||
if (tutorsList.size() > 0) {
|
||||
noNotesView.setVisibility(View.GONE);
|
||||
} else {
|
||||
noNotesView.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
disposable.dispose();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getContentViewId() {
|
||||
return R.layout.users_list;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getNavigationMenuItemId() {
|
||||
return R.id.nav_user_list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSaveInstanceState(Bundle outState) {
|
||||
super.onSaveInstanceState(outState);
|
||||
}
|
||||
}
|
@ -13,7 +13,7 @@ import java.util.List;
|
||||
* ReturnedTutors
|
||||
*/
|
||||
|
||||
public class ReturnedTutors extends User {
|
||||
public class ReturnedTutors extends User{
|
||||
@SerializedName("tutors")
|
||||
@Expose
|
||||
private List<User> tutors = null;
|
||||
|
@ -0,0 +1,62 @@
|
||||
package com.uam.wmi.findmytutor.utils;
|
||||
|
||||
import android.content.Context;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.view.GestureDetector;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
|
||||
/**
|
||||
* Created by ravi on 21/02/18.
|
||||
*/
|
||||
|
||||
public class RecyclerTouchListener implements RecyclerView.OnItemTouchListener {
|
||||
|
||||
private ClickListener clicklistener;
|
||||
private GestureDetector gestureDetector;
|
||||
|
||||
public RecyclerTouchListener(Context context, final RecyclerView recycleView, final ClickListener clicklistener) {
|
||||
|
||||
this.clicklistener = clicklistener;
|
||||
gestureDetector = new GestureDetector(context, new GestureDetector.SimpleOnGestureListener() {
|
||||
@Override
|
||||
public boolean onSingleTapUp(MotionEvent e) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLongPress(MotionEvent e) {
|
||||
View child = recycleView.findChildViewUnder(e.getX(), e.getY());
|
||||
if (child != null && clicklistener != null) {
|
||||
clicklistener.onLongClick(child, recycleView.getChildAdapterPosition(child));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onInterceptTouchEvent(RecyclerView rv, MotionEvent e) {
|
||||
View child = rv.findChildViewUnder(e.getX(), e.getY());
|
||||
if (child != null && clicklistener != null && gestureDetector.onTouchEvent(e)) {
|
||||
clicklistener.onClick(child, rv.getChildAdapterPosition(child));
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTouchEvent(RecyclerView rv, MotionEvent e) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRequestDisallowInterceptTouchEvent(boolean disallowIntercept) {
|
||||
|
||||
}
|
||||
|
||||
public interface ClickListener {
|
||||
void onClick(View view, int position);
|
||||
|
||||
void onLongClick(View view, int position);
|
||||
}
|
||||
}
|
@ -1,6 +1,8 @@
|
||||
package com.uam.wmi.findmytutor.view;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.TypedArray;
|
||||
import android.graphics.Color;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.text.Html;
|
||||
import android.util.Log;
|
||||
@ -64,11 +66,17 @@ public class TutorsAdapter extends RecyclerView.Adapter<TutorsAdapter.MyViewHold
|
||||
@Override
|
||||
public void onBindViewHolder(MyViewHolder holder, int position) {
|
||||
User tutor = tutorsList.get(position);
|
||||
Log.e("tutor", tutor.toString());
|
||||
|
||||
holder.firstName.setText(tutor.getFirstName());
|
||||
holder.isOnline.setText(Html.fromHtml("•"));
|
||||
holder.lastName.setText(tutor.getLastName());
|
||||
holder.isOnline.setText(Html.fromHtml("•"));
|
||||
|
||||
holder.isOnline.setTextColor(getRandomMaterialColor("400"));
|
||||
|
||||
if(!tutor.isIsActive())
|
||||
holder.isOnline.setTextColor(Color.BLACK);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -76,4 +84,17 @@ public class TutorsAdapter extends RecyclerView.Adapter<TutorsAdapter.MyViewHold
|
||||
return tutorsList.size();
|
||||
}
|
||||
|
||||
private int getRandomMaterialColor(String typeColor) {
|
||||
int returnColor = Color.GRAY;
|
||||
int arrayId = context.getResources().getIdentifier("mdcolor_" + typeColor, "array", context.getPackageName());
|
||||
|
||||
if (arrayId != 0) {
|
||||
TypedArray colors = context.getResources().obtainTypedArray(arrayId);
|
||||
int index = (int) (Math.random() * colors.length());
|
||||
returnColor = colors.getColor(index, Color.GRAY);
|
||||
colors.recycle();
|
||||
}
|
||||
return returnColor;
|
||||
}
|
||||
|
||||
}
|
@ -1,42 +1,39 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="80dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:clickable="true"
|
||||
android:paddingBottom="@dimen/dimen_10"
|
||||
android:focusable="true"
|
||||
android:foreground="?attr/selectableItemBackground"
|
||||
android:paddingLeft="@dimen/activity_margin"
|
||||
android:paddingTop="@dimen/dimen_10"
|
||||
android:paddingRight="@dimen/activity_margin"
|
||||
android:paddingTop="@dimen/dimen_10">
|
||||
|
||||
android:paddingBottom="@dimen/dimen_10">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/firstName"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="14dp"
|
||||
android:layout_alignParentTop="true"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:layout_marginTop="13dp"
|
||||
android:textColor="@color/note_list_text"
|
||||
android:textSize="@dimen/note_list_text" />
|
||||
android:id="@+id/isOnline"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="@dimen/dot_height"
|
||||
android:layout_marginTop="@dimen/dimen_10"
|
||||
android:layout_marginEnd="@dimen/dot_margin_right"
|
||||
android:includeFontPadding="false"
|
||||
android:lineSpacingExtra="10dp"
|
||||
android:textSize="@dimen/dot_text_size" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/lastName"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="14dp"
|
||||
android:layout_below="@+id/firstName"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_toEndOf="@id/isOnline"
|
||||
android:textColor="@color/note_list_text"
|
||||
android:textSize="@dimen/note_list_text" />
|
||||
|
||||
|
||||
<TextView
|
||||
android:id="@+id/isOnline"
|
||||
android:id="@+id/firstName"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="14dp"
|
||||
android:layout_below="@+id/lastName"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_toEndOf="@id/isOnline"
|
||||
android:textColor="@color/note_list_text"
|
||||
android:textSize="@dimen/note_list_text" />
|
||||
|
||||
|
||||
</RelativeLayout>
|
||||
</RelativeLayout>
|
||||
|
@ -1,42 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="80dp"
|
||||
android:clickable="true"
|
||||
android:paddingBottom="@dimen/dimen_10"
|
||||
android:paddingLeft="@dimen/activity_margin"
|
||||
android:paddingRight="@dimen/activity_margin"
|
||||
android:paddingTop="@dimen/dimen_10">
|
||||
|
||||
|
||||
<TextView
|
||||
android:id="@+id/firstName"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="14dp"
|
||||
android:layout_alignParentTop="true"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:layout_marginTop="13dp"
|
||||
android:textColor="@color/note_list_text"
|
||||
android:textSize="@dimen/note_list_text" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/lastName"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="14dp"
|
||||
android:layout_below="@+id/firstName"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:textColor="@color/note_list_text"
|
||||
android:textSize="@dimen/note_list_text" />
|
||||
|
||||
|
||||
<TextView
|
||||
android:id="@+id/isOnline"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="14dp"
|
||||
android:layout_below="@+id/lastName"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:textColor="@color/note_list_text"
|
||||
android:textSize="@dimen/note_list_text" />
|
||||
|
||||
|
||||
</RelativeLayout>
|
@ -6,7 +6,6 @@
|
||||
android:layout_height="match_parent"
|
||||
tools:context=".activity.UsersListActivity">
|
||||
|
||||
|
||||
<android.support.design.widget.AppBarLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
@ -15,4 +14,5 @@
|
||||
|
||||
<include layout="@layout/users_list_main" />
|
||||
|
||||
</android.support.design.widget.CoordinatorLayout>
|
||||
</android.support.design.widget.CoordinatorLayout>
|
||||
|
||||
|
@ -14,5 +14,16 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/txt_empty_notes_view"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:layout_marginTop="@dimen/margin_top_no_notes"
|
||||
android:fontFamily="sans-serif-light"
|
||||
android:text="@string/there_is_no_users_in_system"
|
||||
android:textColor="@color/msg_no_notes"
|
||||
android:textSize="@dimen/msg_no_notes" />
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
</RelativeLayout>
|
@ -11,7 +11,7 @@
|
||||
android:icon="@drawable/outline_map_white_24dp"
|
||||
android:title="@string/nav_map" />
|
||||
<item
|
||||
android:id="@+id/nav_notif"
|
||||
android:id="@+id/nav_user_list"
|
||||
android:icon="@drawable/mapbox_info_icon_default"
|
||||
android:title="Active" />
|
||||
</menu>
|
@ -197,4 +197,5 @@ functionality.</string>
|
||||
</plurals>
|
||||
|
||||
<string name="title_activity_main2">Main2Activity</string>
|
||||
<string name="there_is_no_users_in_system">There is no users in system</string>
|
||||
</resources>
|
||||
|
Loading…
Reference in New Issue
Block a user