code clean up and string translations for last seen
This commit is contained in:
parent
f98e4289fb
commit
6d73598d5e
@ -28,7 +28,6 @@ import android.widget.ArrayAdapter;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.ListView;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.annimon.stream.Stream;
|
||||
import com.jakewharton.retrofit2.adapter.rxjava2.HttpException;
|
||||
@ -360,6 +359,7 @@ public class UsersListFragment extends Fragment {
|
||||
|
||||
public void restoreUsersList() {
|
||||
fetchAllTutors();
|
||||
fetchTopCords();
|
||||
}
|
||||
|
||||
private int sortByUserName(User t1, User t2) {
|
||||
@ -445,7 +445,6 @@ public class UsersListFragment extends Fragment {
|
||||
private void fetchTopCords(){
|
||||
disposable.add(
|
||||
coordinateService.getTopCoordinates()
|
||||
// coordinateService.getOnlineCoordinates()
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribeWith(new DisposableSingleObserver<List<Coordinate>>() {
|
||||
@ -459,35 +458,11 @@ public class UsersListFragment extends Fragment {
|
||||
}
|
||||
}
|
||||
mAdapter.notifyDataSetChanged();
|
||||
Log.e("PATRZ", tutorsTimeStamps.toString());
|
||||
Log.e("length", tutorsTimeStamps.size() +"");
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Throwable e) {
|
||||
Log.e("adapter",e +"");
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
private void fetchTopCords(String id){
|
||||
Log.e("MORDO2", id);
|
||||
|
||||
disposable.add(
|
||||
coordinateService.getTopCoordinatesByUserId(id)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribeWith(new DisposableSingleObserver<Coordinate>() {
|
||||
@Override
|
||||
public void onSuccess(Coordinate newCords) {
|
||||
Log.e("MORDO", newCords.toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Throwable e) {
|
||||
Log.e("adapter",e +"");
|
||||
}
|
||||
public void onError(Throwable e) {showSearchError(e);}
|
||||
}));
|
||||
}
|
||||
|
||||
|
@ -3,40 +3,20 @@ package com.uam.wmi.findmytutor.adapters;
|
||||
import android.content.Context;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.design.widget.CoordinatorLayout;
|
||||
import android.support.design.widget.Snackbar;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.util.Log;
|
||||
import android.view.Gravity;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.jakewharton.retrofit2.adapter.rxjava2.HttpException;
|
||||
import com.uam.wmi.findmytutor.R;
|
||||
import com.uam.wmi.findmytutor.model.Coordinate;
|
||||
import com.uam.wmi.findmytutor.model.User;
|
||||
import com.uam.wmi.findmytutor.network.ApiClient;
|
||||
import com.uam.wmi.findmytutor.service.CoordinateService;
|
||||
import com.uam.wmi.findmytutor.service.UserService;
|
||||
import com.uam.wmi.findmytutor.utils.RestApiHelper;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
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;
|
||||
import okhttp3.ResponseBody;
|
||||
|
||||
import static android.support.constraint.Constraints.TAG;
|
||||
import static com.mapbox.mapboxsdk.Mapbox.getApplicationContext;
|
||||
|
||||
|
||||
public class TutorsListAdapter extends RecyclerView.Adapter<TutorsListAdapter.MyViewHolder> {
|
||||
@ -44,10 +24,6 @@ public class TutorsListAdapter extends RecyclerView.Adapter<TutorsListAdapter.My
|
||||
private Context context;
|
||||
private List<User> tutorsList;
|
||||
private HashMap<String, String> tutorsTimeStamps;
|
||||
private CoordinateService coordinateService;
|
||||
private CompositeDisposable disposable = new CompositeDisposable();
|
||||
|
||||
|
||||
|
||||
public TutorsListAdapter(Context context, List<User> tutors, HashMap<String,String> tutorsTimeStamps) {
|
||||
this.context = context;
|
||||
@ -60,7 +36,6 @@ public class TutorsListAdapter extends RecyclerView.Adapter<TutorsListAdapter.My
|
||||
View itemView = LayoutInflater.from(parent.getContext())
|
||||
.inflate(R.layout.tutor_list_row, parent, false);
|
||||
|
||||
// fetchTopCords();
|
||||
return new MyViewHolder(itemView);
|
||||
}
|
||||
|
||||
@ -69,26 +44,22 @@ public class TutorsListAdapter extends RecyclerView.Adapter<TutorsListAdapter.My
|
||||
Drawable image = null;
|
||||
User tutor = tutorsList.get(position);
|
||||
|
||||
holder.firstName.setText(tutor.getFirstName() + " " + tutor.getLastName());
|
||||
|
||||
|
||||
holder.firstName.setText(String.format("%s %s", tutor.getFirstName(), tutor.getLastName()));
|
||||
|
||||
if (tutor.isIsOnline()) {
|
||||
image = context.getResources().getDrawable(R.drawable.user_list_online);
|
||||
holder.lastSeen.setText("Available now");
|
||||
holder.lastSeen.setText(R.string.available_now);
|
||||
} else {
|
||||
image = context.getResources().getDrawable(R.drawable.user_list_offline);
|
||||
String tmp = tutorsTimeStamps.get(tutor.getId());
|
||||
if (tmp != null){
|
||||
holder.lastSeen.setText("Last seen: " + tmp);
|
||||
}else {
|
||||
holder.lastSeen.setText("no timestamp");
|
||||
String ts = tutorsTimeStamps.get(tutor.getId());
|
||||
|
||||
if (ts != null){
|
||||
holder.lastSeen.setText(String.format("%s: %s", context.getResources().getString(R.string.last_seen), ts));
|
||||
}
|
||||
}
|
||||
|
||||
if (!tutor.isIsActive()) {
|
||||
image = context.getResources().getDrawable(R.drawable.user_list_off);
|
||||
holder.lastSeen.setText("Ages ago");
|
||||
}
|
||||
|
||||
image.setBounds(0, 0, image.getIntrinsicWidth(), image.getIntrinsicHeight());
|
||||
@ -111,8 +82,6 @@ public class TutorsListAdapter extends RecyclerView.Adapter<TutorsListAdapter.My
|
||||
@BindView(R.id.isOnline)
|
||||
TextView isOnline;
|
||||
|
||||
|
||||
|
||||
MyViewHolder(View view) {
|
||||
super(view);
|
||||
ButterKnife.bind(this, view);
|
||||
|
@ -33,7 +33,7 @@
|
||||
android:layout_marginEnd="0dp"
|
||||
android:layout_alignParentStart="true"
|
||||
android:textColor="#979797"
|
||||
android:textSize="11sp" />
|
||||
android:textSize="13sp" />
|
||||
|
||||
|
||||
<TextView
|
||||
|
@ -284,7 +284,9 @@
|
||||
<string name="exact_mode">dokładny</string>
|
||||
<string name="approx_mode">przybliżony</string>
|
||||
<string name="other_location">Niezapisana lokalizacja.</string>
|
||||
|
||||
<string name="last_seen">Ostatnio</string>
|
||||
<string name="available_now">Dostępny teraz</string>
|
||||
<string name="profile_activity_title">Profil</string>
|
||||
|
||||
|
||||
</resources>
|
||||
|
@ -453,5 +453,7 @@
|
||||
|
||||
<!--(ENG) Undefined manual -->
|
||||
<string name="other_location">Not saved location.</string>
|
||||
<string name="user_status_label">Status</string>
|
||||
<string name="user_status_label" translatable="false">Status</string>
|
||||
<string name="available_now">Available now</string>
|
||||
<string name="last_seen">Last seen</string>
|
||||
</resources>
|
||||
|
Loading…
Reference in New Issue
Block a user