merge develop
This commit is contained in:
commit
7b79a5339a
@ -10,7 +10,7 @@ android {
|
|||||||
applicationId "com.uam.wmi.findmytutor"
|
applicationId "com.uam.wmi.findmytutor"
|
||||||
minSdkVersion 22
|
minSdkVersion 22
|
||||||
targetSdkVersion 27
|
targetSdkVersion 27
|
||||||
versionCode 58
|
versionCode 59
|
||||||
versionName "1.0.0"
|
versionName "1.0.0"
|
||||||
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
|
||||||
vectorDrawables.useSupportLibrary = true
|
vectorDrawables.useSupportLibrary = true
|
||||||
@ -75,4 +75,6 @@ dependencies {
|
|||||||
|
|
||||||
// spinner loaders library
|
// spinner loaders library
|
||||||
implementation 'com.github.ybq:Android-SpinKit:1.2.0'
|
implementation 'com.github.ybq:Android-SpinKit:1.2.0'
|
||||||
|
// rx binding
|
||||||
|
implementation 'com.jakewharton.rxbinding:rxbinding:0.3.0'
|
||||||
}
|
}
|
||||||
|
@ -68,6 +68,7 @@ import io.reactivex.Observable;
|
|||||||
import io.reactivex.ObservableSource;
|
import io.reactivex.ObservableSource;
|
||||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||||
import io.reactivex.disposables.CompositeDisposable;
|
import io.reactivex.disposables.CompositeDisposable;
|
||||||
|
import io.reactivex.disposables.Disposable;
|
||||||
import io.reactivex.functions.Function;
|
import io.reactivex.functions.Function;
|
||||||
import io.reactivex.observers.DisposableObserver;
|
import io.reactivex.observers.DisposableObserver;
|
||||||
import io.reactivex.observers.DisposableSingleObserver;
|
import io.reactivex.observers.DisposableSingleObserver;
|
||||||
@ -153,7 +154,6 @@ public class BlackList extends AppCompatActivity {
|
|||||||
}));
|
}));
|
||||||
|
|
||||||
addToBlackListFab.setOnClickListener(this::showFabDialog);
|
addToBlackListFab.setOnClickListener(this::showFabDialog);
|
||||||
|
|
||||||
handleSwitch();
|
handleSwitch();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -173,34 +173,29 @@ public class BlackList extends AppCompatActivity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void fetchBlackListedUsers() {
|
private void fetchBlackListedUsers() {
|
||||||
prevSize = blacklistedUsers.size();
|
|
||||||
blacklistedUsers.clear();
|
|
||||||
|
|
||||||
disposable.add(getListOfBlacklistedUsers(tutorId)
|
disposable.add(getListOfBlacklistedUsers(tutorId)
|
||||||
.doOnSubscribe(t -> didFetched = false)
|
.doOnSubscribe(this::handleDoOnSubscribe)
|
||||||
.subscribeOn(Schedulers.io())
|
.subscribeOn(Schedulers.io())
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
.flatMap((Function<List<String>, Observable<String>>) Observable::fromIterable)
|
.flatMap(Observable::fromIterable)
|
||||||
.flatMap((Function<String, ObservableSource<User>>) this::getUserObservable)
|
.flatMap(this::getUserObservable)
|
||||||
.subscribeWith(new DisposableObserver<User>() {
|
.subscribe(user -> blacklistedUsers.add(user), this::handleError,this::handleComplete));
|
||||||
@Override
|
}
|
||||||
public void onNext(User user) {
|
|
||||||
blacklistedUsers.add(user);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
private void handleDoOnSubscribe(Disposable disposable) {
|
||||||
public void onError(Throwable e) {
|
prevSize = blacklistedUsers.size();
|
||||||
showError(e);
|
blacklistedUsers.clear();
|
||||||
didFetched = false;
|
didFetched = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
private void handleComplete() {
|
||||||
public void onComplete() {
|
Collections.sort(blacklistedUsers, this::sortByUserName);
|
||||||
Collections.sort(blacklistedUsers, (a, b) -> sortByUserName(a,b));
|
didFetched = true;
|
||||||
didFetched = true;
|
refreshUI();
|
||||||
refreshUI();
|
}
|
||||||
}
|
private void handleError(Throwable e){
|
||||||
}));
|
showError(e);
|
||||||
|
didFetched = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void refreshUI(){
|
private void refreshUI(){
|
||||||
@ -262,10 +257,8 @@ public class BlackList extends AppCompatActivity {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void handleAddUser(User user) {
|
private void handleAddUser(User user) {
|
||||||
Toast.makeText(this, R.string.add_user_to_list, Snackbar.LENGTH_LONG).show();
|
Toast.makeText(this, R.string.add_user_to_list, Snackbar.LENGTH_LONG).show();
|
||||||
|
|
||||||
blacklistedUsers.clear();
|
blacklistedUsers.clear();
|
||||||
fetchBlackListedUsers();
|
fetchBlackListedUsers();
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,6 @@ package com.uam.wmi.findmytutor.activity;
|
|||||||
import android.animation.Animator;
|
import android.animation.Animator;
|
||||||
import android.animation.AnimatorListenerAdapter;
|
import android.animation.AnimatorListenerAdapter;
|
||||||
import android.annotation.TargetApi;
|
import android.annotation.TargetApi;
|
||||||
import android.content.Context;
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
@ -28,7 +27,6 @@ import com.uam.wmi.findmytutor.model.ValidateUser;
|
|||||||
import com.uam.wmi.findmytutor.network.ApiClient;
|
import com.uam.wmi.findmytutor.network.ApiClient;
|
||||||
import com.uam.wmi.findmytutor.service.LdapService;
|
import com.uam.wmi.findmytutor.service.LdapService;
|
||||||
import com.uam.wmi.findmytutor.service.UserService;
|
import com.uam.wmi.findmytutor.service.UserService;
|
||||||
import com.uam.wmi.findmytutor.utils.LocaleHelper;
|
|
||||||
import com.uam.wmi.findmytutor.utils.PrefUtils;
|
import com.uam.wmi.findmytutor.utils.PrefUtils;
|
||||||
import com.uam.wmi.findmytutor.utils.RestApiHelper;
|
import com.uam.wmi.findmytutor.utils.RestApiHelper;
|
||||||
|
|
||||||
@ -41,8 +39,7 @@ import io.reactivex.disposables.CompositeDisposable;
|
|||||||
import io.reactivex.schedulers.Schedulers;
|
import io.reactivex.schedulers.Schedulers;
|
||||||
import okhttp3.ResponseBody;
|
import okhttp3.ResponseBody;
|
||||||
|
|
||||||
public class
|
public class LoginActivity extends AppCompatActivity {
|
||||||
LoginActivity extends AppCompatActivity {
|
|
||||||
|
|
||||||
private AutoCompleteTextView mLoginNameView;
|
private AutoCompleteTextView mLoginNameView;
|
||||||
private EditText mPasswordView;
|
private EditText mPasswordView;
|
||||||
@ -52,11 +49,6 @@ LoginActivity extends AppCompatActivity {
|
|||||||
private UserService userService;
|
private UserService userService;
|
||||||
private CompositeDisposable disposable = new CompositeDisposable();
|
private CompositeDisposable disposable = new CompositeDisposable();
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void attachBaseContext(Context base) {
|
|
||||||
super.attachBaseContext(LocaleHelper.onAttach(base));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
@ -157,9 +149,9 @@ LoginActivity extends AppCompatActivity {
|
|||||||
|
|
||||||
private void loginProcess(String email, String password) {
|
private void loginProcess(String email, String password) {
|
||||||
ValidateUser user = new ValidateUser(email, password);
|
ValidateUser user = new ValidateUser(email, password);
|
||||||
// LdapUser fakeUser = new LdapUser(email, password,"wmi","tutor",email,"Fałszywy",email);
|
// LdapUser fakeUser = new LdapUser(email, password,"wmi","tutor",email,"Fałszywy",email);
|
||||||
disposable.add(ldapService.validate(user)
|
disposable.add(ldapService.validate(user)
|
||||||
//disposable.add(ldapService.fakeValidate(fakeUser)
|
//disposable.add(ldapService.fakeValidate(fakeUser)
|
||||||
.subscribeOn(Schedulers.io())
|
.subscribeOn(Schedulers.io())
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
.subscribe(this::handleResponse, this::handleError));
|
.subscribe(this::handleResponse, this::handleError));
|
||||||
|
@ -151,7 +151,6 @@ public class SharingFragment extends PreferenceFragment implements SharedPrefere
|
|||||||
public void onError(Throwable e) {
|
public void onError(Throwable e) {
|
||||||
Toast.makeText(getApplicationContext(), R.string.error_location_fetch, Toast.LENGTH_SHORT).show();
|
Toast.makeText(getApplicationContext(), R.string.error_location_fetch, Toast.LENGTH_SHORT).show();
|
||||||
}
|
}
|
||||||
|
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -246,7 +245,6 @@ public class SharingFragment extends PreferenceFragment implements SharedPrefere
|
|||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
/** Button 'choose from map' button listener **/
|
/** Button 'choose from map' button listener **/
|
||||||
manualLocationButton.setOnPreferenceChangeListener((preference, o) -> {
|
manualLocationButton.setOnPreferenceChangeListener((preference, o) -> {
|
||||||
FragmentTransaction fragmentTransaction = getFragmentManager().beginTransaction();
|
FragmentTransaction fragmentTransaction = getFragmentManager().beginTransaction();
|
||||||
|
@ -66,28 +66,6 @@ public class TutorTab extends AppCompatActivity {
|
|||||||
private RecyclerView.LayoutManager dutyHoursLayoutManager;
|
private RecyclerView.LayoutManager dutyHoursLayoutManager;
|
||||||
private TutorTabViewModel newTab;
|
private TutorTabViewModel newTab;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public boolean isEmailValid(String email)
|
|
||||||
{
|
|
||||||
String regExpn =
|
|
||||||
"^(([\\w-]+\\.)+[\\w-]+|([a-zA-Z]{1}|[\\w-]{2,}))@"
|
|
||||||
+"((([0-1]?[0-9]{1,2}|25[0-5]|2[0-4][0-9])\\.([0-1]?"
|
|
||||||
+"[0-9]{1,2}|25[0-5]|2[0-4][0-9])\\."
|
|
||||||
+"([0-1]?[0-9]{1,2}|25[0-5]|2[0-4][0-9])\\.([0-1]?"
|
|
||||||
+"[0-9]{1,2}|25[0-5]|2[0-4][0-9])){1}|"
|
|
||||||
+"([a-zA-Z]+[\\w-]+\\.)+[a-zA-Z]{2,4})$";
|
|
||||||
|
|
||||||
CharSequence inputStr = email;
|
|
||||||
|
|
||||||
Pattern pattern = Pattern.compile(regExpn,Pattern.CASE_INSENSITIVE);
|
|
||||||
Matcher matcher = pattern.matcher(inputStr);
|
|
||||||
|
|
||||||
if(matcher.matches())
|
|
||||||
return true;
|
|
||||||
else
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
@ -118,8 +96,6 @@ public class TutorTab extends AppCompatActivity {
|
|||||||
|
|
||||||
getTutorTab();
|
getTutorTab();
|
||||||
|
|
||||||
// findViewById(R.id.contentTutorTabInfoImageButton).setOnClickListener(v-> InfoHelperUtils.infoPopUp(v,R.layout.info_popup_tutor_tab));
|
|
||||||
|
|
||||||
userName.setText(String.format("%s %s", PrefUtils.getUserFirstName(getApplicationContext()), PrefUtils.getUserLastName(getApplicationContext())));
|
userName.setText(String.format("%s %s", PrefUtils.getUserFirstName(getApplicationContext()), PrefUtils.getUserLastName(getApplicationContext())));
|
||||||
|
|
||||||
disposable.add(
|
disposable.add(
|
||||||
@ -236,7 +212,6 @@ public class TutorTab extends AppCompatActivity {
|
|||||||
}else{
|
}else{
|
||||||
userEmail.setError(getString(R.string.error_invalid_email));
|
userEmail.setError(getString(R.string.error_invalid_email));
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -286,7 +261,6 @@ public class TutorTab extends AppCompatActivity {
|
|||||||
Toast.makeText(getApplicationContext(),
|
Toast.makeText(getApplicationContext(),
|
||||||
"Network error " + error.getMessage(), Toast.LENGTH_SHORT).show();
|
"Network error " + error.getMessage(), Toast.LENGTH_SHORT).show();
|
||||||
|
|
||||||
|
|
||||||
Log.e("WMI SUCC", String.valueOf(error));
|
Log.e("WMI SUCC", String.valueOf(error));
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -309,5 +283,21 @@ public class TutorTab extends AppCompatActivity {
|
|||||||
super.attachBaseContext(LocaleHelper.onAttach(base));
|
super.attachBaseContext(LocaleHelper.onAttach(base));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isEmailValid(String email)
|
||||||
|
{
|
||||||
|
String regExpn =
|
||||||
|
"^(([\\w-]+\\.)+[\\w-]+|([a-zA-Z]{1}|[\\w-]{2,}))@"
|
||||||
|
+"((([0-1]?[0-9]{1,2}|25[0-5]|2[0-4][0-9])\\.([0-1]?"
|
||||||
|
+"[0-9]{1,2}|25[0-5]|2[0-4][0-9])\\."
|
||||||
|
+"([0-1]?[0-9]{1,2}|25[0-5]|2[0-4][0-9])\\.([0-1]?"
|
||||||
|
+"[0-9]{1,2}|25[0-5]|2[0-4][0-9])){1}|"
|
||||||
|
+"([a-zA-Z]+[\\w-]+\\.)+[a-zA-Z]{2,4})$";
|
||||||
|
|
||||||
|
CharSequence inputStr = email;
|
||||||
|
|
||||||
|
Pattern pattern = Pattern.compile(regExpn,Pattern.CASE_INSENSITIVE);
|
||||||
|
Matcher matcher = pattern.matcher(inputStr);
|
||||||
|
|
||||||
|
return matcher.matches();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -63,6 +63,7 @@ import io.reactivex.Observable;
|
|||||||
import io.reactivex.ObservableSource;
|
import io.reactivex.ObservableSource;
|
||||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||||
import io.reactivex.disposables.CompositeDisposable;
|
import io.reactivex.disposables.CompositeDisposable;
|
||||||
|
import io.reactivex.disposables.Disposable;
|
||||||
import io.reactivex.functions.Function;
|
import io.reactivex.functions.Function;
|
||||||
import io.reactivex.observers.DisposableObserver;
|
import io.reactivex.observers.DisposableObserver;
|
||||||
import io.reactivex.observers.DisposableSingleObserver;
|
import io.reactivex.observers.DisposableSingleObserver;
|
||||||
@ -316,6 +317,7 @@ public class UsersListFragment extends Fragment {
|
|||||||
tutorsList.addAll(users);
|
tutorsList.addAll(users);
|
||||||
mAdapter.notifyDataSetChanged();
|
mAdapter.notifyDataSetChanged();
|
||||||
toggleEmptyNotes();
|
toggleEmptyNotes();
|
||||||
|
fetchTopCords();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -425,6 +427,35 @@ public class UsersListFragment extends Fragment {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void onSaveInstanceState(Bundle outState) {
|
||||||
|
super.onSaveInstanceState(outState);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void fetchTopCords(){
|
||||||
|
disposable.add(
|
||||||
|
coordinateService.getTopCoordinates()
|
||||||
|
.subscribeOn(Schedulers.io())
|
||||||
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
|
.subscribe(this::addTimestamps,this::showError));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void addTimestamps(List<Coordinate> coordinates) {
|
||||||
|
for (Coordinate crd :
|
||||||
|
coordinates) {
|
||||||
|
Long ts = crd.getTimeStamp();
|
||||||
|
tutorsTimeStamps.put(crd.getUserId(), getDate(ts));
|
||||||
|
}
|
||||||
|
|
||||||
|
mAdapter.notifyDataSetChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getDate(long time) {
|
||||||
|
Calendar cal = Calendar.getInstance(Locale.ENGLISH);
|
||||||
|
cal.setTimeInMillis(time);
|
||||||
|
return DateFormat.format("HH:mm dd/MM", cal).toString();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDestroy() {
|
public void onDestroy() {
|
||||||
super.onDestroy();
|
super.onDestroy();
|
||||||
@ -447,54 +478,4 @@ public class UsersListFragment extends Fragment {
|
|||||||
super.onStop();
|
super.onStop();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onSaveInstanceState(Bundle outState) {
|
|
||||||
super.onSaveInstanceState(outState);
|
|
||||||
}
|
|
||||||
|
|
||||||
private Observable<List<User>> getListOfActiveUsers() {
|
|
||||||
return userService.getAllActiveTutors()
|
|
||||||
.toObservable()
|
|
||||||
.subscribeOn(Schedulers.io())
|
|
||||||
.observeOn(AndroidSchedulers.mainThread());
|
|
||||||
}
|
|
||||||
|
|
||||||
private Observable<Coordinate> getCoordinateObservable(User user) {
|
|
||||||
return coordinateService
|
|
||||||
.getTopCoordinateByUserId(user.getId())
|
|
||||||
.toObservable()
|
|
||||||
.subscribeOn(Schedulers.io())
|
|
||||||
.observeOn(AndroidSchedulers.mainThread());
|
|
||||||
}
|
|
||||||
|
|
||||||
private void fetchTopCords(){
|
|
||||||
tutorsTimeStamps.clear();
|
|
||||||
disposable.add(getListOfActiveUsers()
|
|
||||||
.subscribeOn(Schedulers.io())
|
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
|
||||||
.flatMap((Function<List<User>, Observable<User>>) Observable::fromIterable)
|
|
||||||
.flatMap((Function<User, ObservableSource<Coordinate>>) this::getCoordinateObservable)
|
|
||||||
.subscribeWith(new DisposableObserver<Coordinate>() {
|
|
||||||
@Override
|
|
||||||
public void onNext(Coordinate coordinate) {
|
|
||||||
Long ts = coordinate.getTimeStamp();
|
|
||||||
tutorsTimeStamps.put(coordinate.getUserId(), getDate(ts));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onError(Throwable e) {showError(e);}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onComplete() {
|
|
||||||
Log.e("USERS", String.valueOf(tutorsTimeStamps));
|
|
||||||
mAdapter.notifyDataSetChanged();
|
|
||||||
}
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
|
|
||||||
private String getDate(long time) {
|
|
||||||
Calendar cal = Calendar.getInstance(Locale.ENGLISH);
|
|
||||||
cal.setTimeInMillis(time);
|
|
||||||
String date = DateFormat.format("HH:mm dd/MM", cal).toString();
|
|
||||||
return date;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -58,6 +58,7 @@ import io.reactivex.Observable;
|
|||||||
import io.reactivex.ObservableSource;
|
import io.reactivex.ObservableSource;
|
||||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||||
import io.reactivex.disposables.CompositeDisposable;
|
import io.reactivex.disposables.CompositeDisposable;
|
||||||
|
import io.reactivex.disposables.Disposable;
|
||||||
import io.reactivex.functions.Function;
|
import io.reactivex.functions.Function;
|
||||||
import io.reactivex.observers.DisposableObserver;
|
import io.reactivex.observers.DisposableObserver;
|
||||||
import io.reactivex.schedulers.Schedulers;
|
import io.reactivex.schedulers.Schedulers;
|
||||||
@ -162,34 +163,29 @@ public class WhiteList extends AppCompatActivity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void fetchWhiteListedUsers() {
|
private void fetchWhiteListedUsers() {
|
||||||
prevSize = whitelistedUsers.size();
|
|
||||||
whitelistedUsers.clear();
|
|
||||||
|
|
||||||
disposable.add(getListOfWhitelistedUsers(tutorId)
|
disposable.add(getListOfWhitelistedUsers(tutorId)
|
||||||
.doOnSubscribe(t -> didFetched = false)
|
.doOnSubscribe(this::handleDoOnSubscribe)
|
||||||
.subscribeOn(Schedulers.io())
|
.subscribeOn(Schedulers.io())
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
.flatMap((Function<List<String>, Observable<String>>) Observable::fromIterable)
|
.flatMap(Observable::fromIterable)
|
||||||
.flatMap((Function<String, ObservableSource<User>>) this::getUserObservable)
|
.flatMap(this::getUserObservable)
|
||||||
.subscribeWith(new DisposableObserver<User>() {
|
.subscribe(user -> whitelistedUsers.add(user), this::handleError,this::handleComplete));
|
||||||
@Override
|
}
|
||||||
public void onNext(User user) {
|
|
||||||
whitelistedUsers.add(user);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
private void handleDoOnSubscribe(Disposable disposable) {
|
||||||
public void onError(Throwable e) {
|
prevSize = whitelistedUsers.size();
|
||||||
showError(e);
|
whitelistedUsers.clear();
|
||||||
didFetched = false;
|
didFetched = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
private void handleComplete() {
|
||||||
public void onComplete() {
|
Collections.sort(whitelistedUsers, this::sortByUserName);
|
||||||
Collections.sort(whitelistedUsers, (a, b) -> sortByUserName(a, b));
|
didFetched = true;
|
||||||
didFetched = true;
|
refreshUI();
|
||||||
refreshUI();
|
}
|
||||||
}
|
private void handleError(Throwable e){
|
||||||
}));
|
showError(e);
|
||||||
|
didFetched = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void refreshUI() {
|
private void refreshUI() {
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
/*
|
||||||
package com.uam.wmi.findmytutor.adapters;
|
package com.uam.wmi.findmytutor.adapters;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
@ -46,6 +47,7 @@ public class TutorsListAdapter extends RecyclerView.Adapter<TutorsListAdapter.My
|
|||||||
User tutor = tutorsList.get(position);
|
User tutor = tutorsList.get(position);
|
||||||
|
|
||||||
holder.firstName.setText(String.format("%s %s", tutor.getFirstName(), tutor.getLastName()));
|
holder.firstName.setText(String.format("%s %s", tutor.getFirstName(), tutor.getLastName()));
|
||||||
|
String ts = tutorsTimeStamps.get(tutor.getId());
|
||||||
|
|
||||||
if (tutor.isIsOnline()) {
|
if (tutor.isIsOnline()) {
|
||||||
image = context.getResources().getDrawable(R.drawable.user_list_online);
|
image = context.getResources().getDrawable(R.drawable.user_list_online);
|
||||||
@ -53,7 +55,6 @@ public class TutorsListAdapter extends RecyclerView.Adapter<TutorsListAdapter.My
|
|||||||
holder.loader.setVisibility(View.GONE);
|
holder.loader.setVisibility(View.GONE);
|
||||||
} else {
|
} else {
|
||||||
image = context.getResources().getDrawable(R.drawable.user_list_offline);
|
image = context.getResources().getDrawable(R.drawable.user_list_offline);
|
||||||
String ts = tutorsTimeStamps.get(tutor.getId());
|
|
||||||
|
|
||||||
if (ts != null){
|
if (ts != null){
|
||||||
holder.lastSeen.setText(R.string.last_sign);
|
holder.lastSeen.setText(R.string.last_sign);
|
||||||
@ -64,7 +65,123 @@ public class TutorsListAdapter extends RecyclerView.Adapter<TutorsListAdapter.My
|
|||||||
|
|
||||||
if (!tutor.isIsActive()) {
|
if (!tutor.isIsActive()) {
|
||||||
image = context.getResources().getDrawable(R.drawable.user_list_off);
|
image = context.getResources().getDrawable(R.drawable.user_list_off);
|
||||||
holder.lastSeen.setText("");
|
if(ts != null){
|
||||||
|
holder.lastSeen.setText(R.string.last_sign);
|
||||||
|
holder.lastSeen.append(String.format(": %s", ts));
|
||||||
|
}else{
|
||||||
|
holder.lastSeen.setVisibility(View.GONE);
|
||||||
|
}
|
||||||
|
holder.loader.setVisibility(View.GONE);
|
||||||
|
}
|
||||||
|
|
||||||
|
image.setBounds(0, 0, image.getIntrinsicWidth(), image.getIntrinsicHeight());
|
||||||
|
holder.isOnline.setCompoundDrawables(image, null, null, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getItemCount() {
|
||||||
|
return tutorsList.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
class MyViewHolder extends RecyclerView.ViewHolder {
|
||||||
|
|
||||||
|
@BindView(R.id.firstName)
|
||||||
|
TextView firstName;
|
||||||
|
|
||||||
|
@BindView(R.id.lastSeen)
|
||||||
|
TextView lastSeen;
|
||||||
|
|
||||||
|
@BindView(R.id.isOnline)
|
||||||
|
TextView isOnline;
|
||||||
|
|
||||||
|
@BindView(R.id.loader)
|
||||||
|
SpinKitView loader;
|
||||||
|
|
||||||
|
MyViewHolder(View view) {
|
||||||
|
super(view);
|
||||||
|
ButterKnife.bind(this, view);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
package com.uam.wmi.findmytutor.adapters;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.graphics.drawable.Drawable;
|
||||||
|
import android.support.annotation.NonNull;
|
||||||
|
import android.support.v7.widget.RecyclerView;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.TextView;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
import com.github.ybq.android.spinkit.SpinKitView;
|
||||||
|
import com.uam.wmi.findmytutor.R;
|
||||||
|
import com.uam.wmi.findmytutor.model.User;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import butterknife.BindView;
|
||||||
|
import butterknife.ButterKnife;
|
||||||
|
|
||||||
|
|
||||||
|
public class TutorsListAdapter extends RecyclerView.Adapter<TutorsListAdapter.MyViewHolder> {
|
||||||
|
|
||||||
|
private Context context;
|
||||||
|
private List<User> tutorsList;
|
||||||
|
private HashMap<String, String> tutorsTimeStamps;
|
||||||
|
|
||||||
|
public TutorsListAdapter(Context context, List<User> tutors, HashMap<String,String> tutorsTimeStamps) {
|
||||||
|
this.context = context;
|
||||||
|
this.tutorsList = tutors;
|
||||||
|
this.tutorsTimeStamps = tutorsTimeStamps;
|
||||||
|
}
|
||||||
|
@NonNull
|
||||||
|
@Override
|
||||||
|
public MyViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||||
|
View itemView = LayoutInflater.from(parent.getContext())
|
||||||
|
.inflate(R.layout.tutor_list_row, parent, false);
|
||||||
|
|
||||||
|
return new MyViewHolder(itemView);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onBindViewHolder(@NonNull MyViewHolder holder, int position) {
|
||||||
|
Drawable image = null;
|
||||||
|
User tutor = tutorsList.get(position);
|
||||||
|
|
||||||
|
holder.firstName.setText(String.format("%s %s", tutor.getFirstName(), tutor.getLastName()));
|
||||||
|
String ts = tutorsTimeStamps.get(tutor.getId());
|
||||||
|
|
||||||
|
if (tutor.isIsOnline()) {
|
||||||
|
image = context.getResources().getDrawable(R.drawable.user_list_online);
|
||||||
|
holder.lastSeen.setText(R.string.available_now);
|
||||||
|
holder.lastSeen.setVisibility(View.VISIBLE);
|
||||||
|
holder.loader.setVisibility(View.GONE);
|
||||||
|
} else if(tutor.isIsActive()){
|
||||||
|
image = context.getResources().getDrawable(R.drawable.user_list_offline);
|
||||||
|
|
||||||
|
if (ts != null){
|
||||||
|
holder.lastSeen.setText(R.string.last_sign);
|
||||||
|
holder.lastSeen.append(String.format(": %s", ts));
|
||||||
|
holder.loader.setVisibility(View.GONE);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
image = context.getResources().getDrawable(R.drawable.user_list_off);
|
||||||
|
|
||||||
|
if(ts == null){
|
||||||
|
holder.lastSeen.setText(R.string.never_logged_in);
|
||||||
|
}else{
|
||||||
|
holder.lastSeen.setText(R.string.last_sign);
|
||||||
|
holder.lastSeen.append(String.format(": %s", ts));
|
||||||
|
}
|
||||||
holder.loader.setVisibility(View.GONE);
|
holder.loader.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -43,9 +43,10 @@
|
|||||||
|
|
||||||
<android.support.design.widget.TextInputLayout
|
<android.support.design.widget.TextInputLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
android:id="@+id/email_til"
|
||||||
android:layout_height="wrap_content">
|
android:layout_height="wrap_content">
|
||||||
|
|
||||||
<AutoCompleteTextView
|
<android.support.design.widget.TextInputEditText
|
||||||
android:id="@+id/email"
|
android:id="@+id/email"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
@ -59,11 +60,9 @@
|
|||||||
<android.support.design.widget.TextInputLayout
|
<android.support.design.widget.TextInputLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
app:passwordToggleEnabled="true"
|
app:passwordToggleEnabled="true"
|
||||||
|
android:id="@+id/password_til"
|
||||||
android:layout_height="wrap_content">
|
android:layout_height="wrap_content">
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<android.support.design.widget.TextInputEditText
|
<android.support.design.widget.TextInputEditText
|
||||||
android:id="@+id/password"
|
android:id="@+id/password"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
@ -77,6 +77,7 @@
|
|||||||
android:layout_alignStart="@+id/userRoomLayout"
|
android:layout_alignStart="@+id/userRoomLayout"
|
||||||
android:layout_alignParentTop="true"
|
android:layout_alignParentTop="true"
|
||||||
android:layout_marginTop="30dp"
|
android:layout_marginTop="30dp"
|
||||||
|
android:layout_marginStart="5dp"
|
||||||
android:text="@string/personalInfoTitle"
|
android:text="@string/personalInfoTitle"
|
||||||
android:textColor="@color/mapboxRedDark"
|
android:textColor="@color/mapboxRedDark"
|
||||||
android:textSize="18sp"
|
android:textSize="18sp"
|
||||||
@ -113,7 +114,7 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_below="@+id/userRoomLayout"
|
android:layout_below="@+id/userRoomLayout"
|
||||||
android:layout_alignStart="@+id/userRoomLayout"
|
android:layout_alignStart="@+id/userRoomLayout"
|
||||||
android:layout_marginStart="0dp"
|
android:layout_marginStart="5dp"
|
||||||
android:layout_marginEnd="30dp"
|
android:layout_marginEnd="30dp"
|
||||||
android:layout_marginTop="10dp"
|
android:layout_marginTop="10dp"
|
||||||
android:gravity="center"
|
android:gravity="center"
|
||||||
@ -125,18 +126,18 @@
|
|||||||
<android.support.v7.widget.RecyclerView
|
<android.support.v7.widget.RecyclerView
|
||||||
android:id="@+id/dutyHourView"
|
android:id="@+id/dutyHourView"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="100dp"
|
android:layout_height="120dp"
|
||||||
android:layout_below="@+id/addDuty"
|
android:layout_below="@+id/addDuty"
|
||||||
|
|
||||||
android:layout_alignParentStart="true"
|
android:layout_alignParentStart="true"
|
||||||
android:layout_marginStart="30dp"
|
android:layout_marginStart="30dp"
|
||||||
android:layout_marginTop="0dp"
|
android:layout_marginTop="15dp"
|
||||||
android:layout_marginEnd="30dp"
|
android:layout_marginEnd="50dp"
|
||||||
android:scrollbars="vertical" />
|
android:scrollbars="vertical" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/userNoteTitle"
|
android:id="@+id/userNoteTitle"
|
||||||
android:textStyle="bold"
|
android:textStyle="bold"
|
||||||
|
android:layout_marginStart="5dp"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_below="@+id/dutyHourView"
|
android:layout_below="@+id/dutyHourView"
|
||||||
@ -153,6 +154,8 @@
|
|||||||
app:backgroundTint="@color/colorPrimary"
|
app:backgroundTint="@color/colorPrimary"
|
||||||
android:layout_alignBaseline="@+id/dutyTitle"
|
android:layout_alignBaseline="@+id/dutyTitle"
|
||||||
android:layout_toEndOf="@+id/dutyTitle"
|
android:layout_toEndOf="@+id/dutyTitle"
|
||||||
|
android:stateListAnimator="@null"
|
||||||
|
|
||||||
android:text="@string/addDuty" />
|
android:text="@string/addDuty" />
|
||||||
|
|
||||||
<android.support.design.widget.TextInputLayout
|
<android.support.design.widget.TextInputLayout
|
||||||
@ -163,12 +166,11 @@
|
|||||||
android:layout_alignParentStart="true"
|
android:layout_alignParentStart="true"
|
||||||
android:layout_marginStart="30dp"
|
android:layout_marginStart="30dp"
|
||||||
android:layout_marginEnd="30dp"
|
android:layout_marginEnd="30dp"
|
||||||
android:layout_marginTop="0dp"
|
android:layout_marginTop="15dp"
|
||||||
app:counterEnabled="true"
|
app:counterEnabled="true"
|
||||||
app:counterMaxLength="1000">
|
app:counterMaxLength="1000">
|
||||||
|
|
||||||
<android.support.design.widget.TextInputEditText
|
<android.support.design.widget.TextInputEditText
|
||||||
|
|
||||||
android:id="@+id/userNote"
|
android:id="@+id/userNote"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="100dp"
|
android:layout_height="100dp"
|
||||||
@ -178,7 +180,7 @@
|
|||||||
android:lineSpacingExtra="8sp"
|
android:lineSpacingExtra="8sp"
|
||||||
android:maxLength="1000"
|
android:maxLength="1000"
|
||||||
android:maxLines="7"
|
android:maxLines="7"
|
||||||
android:paddingTop="5dp"
|
android:paddingTop="15dp"
|
||||||
android:requiresFadingEdge="vertical"
|
android:requiresFadingEdge="vertical"
|
||||||
android:scrollbars="vertical"
|
android:scrollbars="vertical"
|
||||||
android:textColor="@color/note_list_text" />
|
android:textColor="@color/note_list_text" />
|
||||||
@ -192,18 +194,22 @@
|
|||||||
android:layout_alignEnd="@+id/userEmailLayout"
|
android:layout_alignEnd="@+id/userEmailLayout"
|
||||||
android:textColor="@color/white"
|
android:textColor="@color/white"
|
||||||
app:backgroundTint="@color/colorPrimary"
|
app:backgroundTint="@color/colorPrimary"
|
||||||
|
android:stateListAnimator="@null"
|
||||||
android:text="@string/scrap_tutor_tab" />
|
android:text="@string/scrap_tutor_tab" />
|
||||||
|
|
||||||
<android.support.v7.widget.AppCompatButton
|
<android.support.v7.widget.AppCompatButton
|
||||||
android:id="@+id/saveButton"
|
android:id="@+id/saveButton"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginStart="30dp"
|
||||||
|
android:layout_marginEnd="-20dp"
|
||||||
android:layout_below="@+id/userNoteLayout"
|
android:layout_below="@+id/userNoteLayout"
|
||||||
android:layout_alignEnd="@+id/dutyHourView"
|
android:layout_alignEnd="@+id/dutyHourView"
|
||||||
android:textColor="@color/white"
|
android:textColor="@color/white"
|
||||||
app:backgroundTint="@color/colorPrimary"
|
app:backgroundTint="@color/colorPrimary"
|
||||||
android:text="@string/saveButton" />
|
android:stateListAnimator="@null"
|
||||||
|
|
||||||
|
android:text="@string/saveButton" />
|
||||||
|
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
</android.support.v4.widget.NestedScrollView>
|
</android.support.v4.widget.NestedScrollView>
|
||||||
|
@ -7,7 +7,6 @@
|
|||||||
android:fontFamily="@font/lato_regular"
|
android:fontFamily="@font/lato_regular"
|
||||||
>
|
>
|
||||||
|
|
||||||
|
|
||||||
<android.support.v7.widget.AppCompatButton
|
<android.support.v7.widget.AppCompatButton
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:id="@+id/button_choose_from_map"
|
android:id="@+id/button_choose_from_map"
|
||||||
@ -16,6 +15,8 @@
|
|||||||
android:textColor="@color/white"
|
android:textColor="@color/white"
|
||||||
app:backgroundTint="@color/top_user_modal"
|
app:backgroundTint="@color/top_user_modal"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:stateListAnimator="@null"
|
||||||
|
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
|
||||||
|
@ -291,5 +291,8 @@
|
|||||||
<string name="batter_exclusions_title">Uwaga</string>
|
<string name="batter_exclusions_title">Uwaga</string>
|
||||||
<string name="batter_exclusions_message">Aby aplikacja była w pełni funkcjonalna, dodaj FMT do wyjątku w oszczędzaniu baterii</string>
|
<string name="batter_exclusions_message">Aby aplikacja była w pełni funkcjonalna, dodaj FMT do wyjątku w oszczędzaniu baterii</string>
|
||||||
|
|
||||||
|
<string name="never_logged_in">Nigdy</string>
|
||||||
|
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
|
||||||
|
@ -458,4 +458,5 @@
|
|||||||
<string name="last_sign">Last seen</string>
|
<string name="last_sign">Last seen</string>
|
||||||
<string name="batter_exclusions_message">To make app fully functional, add FMT to battery saving exclusions</string>
|
<string name="batter_exclusions_message">To make app fully functional, add FMT to battery saving exclusions</string>
|
||||||
<string name="batter_exclusions_title">Please note</string>
|
<string name="batter_exclusions_title">Please note</string>
|
||||||
|
<string name="never_logged_in">Never</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -9,7 +9,6 @@ buildscript {
|
|||||||
dependencies {
|
dependencies {
|
||||||
classpath 'com.android.tools.build:gradle:3.2.1'
|
classpath 'com.android.tools.build:gradle:3.2.1'
|
||||||
|
|
||||||
|
|
||||||
// NOTE: Do not place your application dependencies here; they belong
|
// NOTE: Do not place your application dependencies here; they belong
|
||||||
// in the individual module build.gradle files
|
// in the individual module build.gradle files
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user