Add wrapper override

This commit is contained in:
Mieszko Wrzeszczyński 2019-01-05 00:12:33 +01:00
parent cb1e7bcdef
commit 46cdaa8ef9
11 changed files with 101 additions and 219 deletions

View File

@ -49,10 +49,14 @@ import com.uam.wmi.findmytutor.utils.PrefUtils;
import com.uam.wmi.findmytutor.utils.RecyclerTouchListener; import com.uam.wmi.findmytutor.utils.RecyclerTouchListener;
import com.uam.wmi.findmytutor.utils.RestApiHelper; import com.uam.wmi.findmytutor.utils.RestApiHelper;
import com.uam.wmi.findmytutor.utils.SharingLevel; import com.uam.wmi.findmytutor.utils.SharingLevel;
import com.uam.wmi.findmytutor.utils.WrapContentLinearLayoutManager;
import java.text.Collator;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Locale;
import java.util.Set; import java.util.Set;
import butterknife.BindView; import butterknife.BindView;
@ -82,10 +86,10 @@ public class BlackList extends AppCompatActivity {
Switch aSwitch; Switch aSwitch;
@BindView(R.id.add_to_black_list_fab) @BindView(R.id.add_to_black_list_fab)
FloatingActionButton addToBlackListFab; FloatingActionButton addToBlackListFab;
private Integer prevSize;
private BlackListAdapter mAdapter; private BlackListAdapter mAdapter;
private List<User> blacklistedUsers = new ArrayList<>(); private List<User> blacklistedUsers = new ArrayList<>();
private HashSet<String> blacklistedUsersIDs = new HashSet<>(); private Collator plCollator = Collator.getInstance(Locale.forLanguageTag("pl-PL"));
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
@ -112,12 +116,12 @@ public class BlackList extends AppCompatActivity {
setSupportActionBar(toolbar); setSupportActionBar(toolbar);
mAdapter = new BlackListAdapter(this, blacklistedUsers); mAdapter = new BlackListAdapter(this, blacklistedUsers);
RecyclerView.LayoutManager mLayoutManager = new LinearLayoutManager(getApplicationContext()); recyclerView.setLayoutManager(new WrapContentLinearLayoutManager(getApplicationContext()));
recyclerView.setLayoutManager(mLayoutManager);
recyclerView.setItemAnimator(new DefaultItemAnimator()); recyclerView.setItemAnimator(new DefaultItemAnimator());
recyclerView.addItemDecoration(new MyDividerItemDecoration(this, LinearLayoutManager.VERTICAL, 16)); recyclerView.addItemDecoration(new MyDividerItemDecoration(this, LinearLayoutManager.VERTICAL, 16));
recyclerView.setAdapter(mAdapter); recyclerView.setAdapter(mAdapter);
fetchBlackListedUsers();
/** /**
* On long press on RecyclerView item, open alert dialog * On long press on RecyclerView item, open alert dialog
* with options to choose * with options to choose
@ -136,32 +140,9 @@ public class BlackList extends AppCompatActivity {
addToBlackListFab.setOnClickListener(this::showFabDialog); addToBlackListFab.setOnClickListener(this::showFabDialog);
fetchBlackListedUsersIDs(PrefUtils.getUserId(getApplicationContext()));
handleSwitch(); handleSwitch();
} }
private void fetchBlackListedUsersIDs(String userId) {
disposable.add(
userService.getTutorBlacklistedByID(userId)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribeWith(new DisposableSingleObserver<List<String>>() {
@Override
public void onSuccess(List<String> users) {
blacklistedUsersIDs.addAll(users);
didFetched = true;
fetchBlackListedUsers();
toggleEmptyNotes();
}
@Override
public void onError(Throwable e) {
showError(e);
}
})
);
}
private Observable<List<String>> getListOfBlacklistedUsers(String userId) { private Observable<List<String>> getListOfBlacklistedUsers(String userId) {
return userService.getTutorBlacklistedByID(userId) return userService.getTutorBlacklistedByID(userId)
.toObservable() .toObservable()
@ -178,7 +159,11 @@ public class BlackList extends AppCompatActivity {
} }
private void fetchBlackListedUsers() { private void fetchBlackListedUsers() {
disposable.add(getListOfBlacklistedUsers(PrefUtils.getUserId(getApplicationContext())) prevSize = blacklistedUsers.size();
blacklistedUsers.clear();
disposable.add(getListOfBlacklistedUsers(tutorId)
.subscribeOn(Schedulers.io()) .subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread()) .observeOn(AndroidSchedulers.mainThread())
.flatMap((Function<List<String>, Observable<String>>) Observable::fromIterable) .flatMap((Function<List<String>, Observable<String>>) Observable::fromIterable)
@ -196,12 +181,21 @@ public class BlackList extends AppCompatActivity {
@Override @Override
public void onComplete() { public void onComplete() {
toggleEmptyNotes(); Collections.sort(blacklistedUsers, (a, b) -> sortByUserName(a,b));
mAdapter.notifyDataSetChanged(); refreshUI();
} }
})); }));
} }
private void refreshUI(){
toggleEmptyNotes();
mAdapter.notifyItemRangeInserted(prevSize, blacklistedUsers.size() - prevSize);
mAdapter.notifyDataSetChanged();
}
private int sortByUserName(User t1, User t2) {
return plCollator.compare(t1.getLastName(), t2.getLastName());
}
private void showFabDialog(View v){ private void showFabDialog(View v){
LayoutInflater layoutInflaterAndroid = LayoutInflater.from(getApplicationContext()); LayoutInflater layoutInflaterAndroid = LayoutInflater.from(getApplicationContext());
@ -256,9 +250,7 @@ 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();
blacklistedUsersIDs.clear();
blacklistedUsers.clear(); blacklistedUsers.clear();
blacklistedUsersIDs.addAll(user.getBlacklist());
fetchBlackListedUsers(); fetchBlackListedUsers();
} }

View File

@ -148,10 +148,10 @@ public class 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));

View File

@ -68,7 +68,6 @@ public class UsersListFragment extends Fragment {
private CompositeDisposable disposable = new CompositeDisposable(); private CompositeDisposable disposable = new CompositeDisposable();
private TutorsListAdapter mAdapter; private TutorsListAdapter mAdapter;
private List<User> tutorsList = new ArrayList<>(); private List<User> tutorsList = new ArrayList<>();
private List<User> tutorsFiltered = new ArrayList<>();
private Collator plCollator = Collator.getInstance(Locale.forLanguageTag("pl-PL")); private Collator plCollator = Collator.getInstance(Locale.forLanguageTag("pl-PL"));
private Boolean fetchOnlyOnlineUsers = PrefUtils.getShowOnlyOnlineUsers(getApplicationContext()); private Boolean fetchOnlyOnlineUsers = PrefUtils.getShowOnlyOnlineUsers(getApplicationContext());
@ -80,7 +79,7 @@ public class UsersListFragment extends Fragment {
} }
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
mAdapter = new TutorsListAdapter(getActivity().getApplicationContext(), tutorsFiltered); mAdapter = new TutorsListAdapter(getActivity().getApplicationContext(), tutorsList);
View view = inflater.inflate(R.layout.users_list, container, false); View view = inflater.inflate(R.layout.users_list, container, false);
view.setBackgroundColor(getResources().getColor(android.R.color.white)); view.setBackgroundColor(getResources().getColor(android.R.color.white));
setHasOptionsMenu(true); setHasOptionsMenu(true);
@ -109,7 +108,7 @@ public class UsersListFragment extends Fragment {
recyclerView, new RecyclerTouchListener.ClickListener() { recyclerView, new RecyclerTouchListener.ClickListener() {
@Override @Override
public void onClick(View view, final int position) { public void onClick(View view, final int position) {
showNoteDialog(tutorsFiltered.get(position)); showNoteDialog(tutorsList.get(position));
} }
@Override @Override
@ -236,12 +235,9 @@ public class UsersListFragment extends Fragment {
.observeOn(AndroidSchedulers.mainThread()) .observeOn(AndroidSchedulers.mainThread())
.map(tutors -> { .map(tutors -> {
List<User> tutorsList = new ArrayList<>(tutors); List<User> tutorsList = new ArrayList<>(tutors);
List<User> onlineTutors = Stream.of(tutorsList).filter(User::isIsOnline).toList(); List<User> onlineTutors = Stream.of(tutorsList).filter(User::isIsOnline).toList();
List<User> activeNotOnlineTutors = Stream.of(tutorsList) List<User> activeNotOnlineTutors = Stream.of(tutorsList)
.filter(t -> t.isIsActive() && !onlineTutors.contains(t)).toList(); .filter(t -> t.isIsActive() && !onlineTutors.contains(t)).toList();
List<User> notActiveTutors = Stream.of(tutorsList) List<User> notActiveTutors = Stream.of(tutorsList)
.filterNot(User::isIsActive).toList(); .filterNot(User::isIsActive).toList();
@ -259,9 +255,7 @@ public class UsersListFragment extends Fragment {
@Override @Override
public void onSuccess(List<User> users) { public void onSuccess(List<User> users) {
tutorsList.clear(); tutorsList.clear();
tutorsFiltered.clear();
tutorsList.addAll(users); tutorsList.addAll(users);
tutorsFiltered.addAll(users);
mAdapter.notifyDataSetChanged(); mAdapter.notifyDataSetChanged();
toggleEmptyNotes(); toggleEmptyNotes();
} }
@ -282,8 +276,8 @@ public class UsersListFragment extends Fragment {
.subscribeWith(new DisposableSingleObserver<List<User>>() { .subscribeWith(new DisposableSingleObserver<List<User>>() {
@Override @Override
public void onSuccess(List<User> users) { public void onSuccess(List<User> users) {
tutorsFiltered.clear(); tutorsList.clear();
tutorsFiltered.addAll(users); tutorsList.addAll(users);
mAdapter.notifyDataSetChanged(); mAdapter.notifyDataSetChanged();
} }

View File

@ -39,10 +39,14 @@ import com.uam.wmi.findmytutor.utils.MyDividerItemDecoration;
import com.uam.wmi.findmytutor.utils.PrefUtils; import com.uam.wmi.findmytutor.utils.PrefUtils;
import com.uam.wmi.findmytutor.utils.RecyclerTouchListener; import com.uam.wmi.findmytutor.utils.RecyclerTouchListener;
import com.uam.wmi.findmytutor.utils.RestApiHelper; import com.uam.wmi.findmytutor.utils.RestApiHelper;
import com.uam.wmi.findmytutor.utils.WrapContentLinearLayoutManager;
import java.text.Collator;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashSet; import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Locale;
import butterknife.BindView; import butterknife.BindView;
import butterknife.ButterKnife; import butterknife.ButterKnife;
@ -56,6 +60,8 @@ import io.reactivex.observers.DisposableSingleObserver;
import io.reactivex.schedulers.Schedulers; import io.reactivex.schedulers.Schedulers;
import okhttp3.ResponseBody; import okhttp3.ResponseBody;
public class WhiteList extends AppCompatActivity { public class WhiteList extends AppCompatActivity {
private CompositeDisposable disposable = new CompositeDisposable(); private CompositeDisposable disposable = new CompositeDisposable();
@ -72,8 +78,10 @@ public class WhiteList extends AppCompatActivity {
@BindView(R.id.add_to_white_list_fab) @BindView(R.id.add_to_white_list_fab)
FloatingActionButton addToWhiteListFab; FloatingActionButton addToWhiteListFab;
private WhiteListAdapter mAdapter; private WhiteListAdapter mAdapter;
private Integer prevSize;
private List<User> whitelistedUsers = new ArrayList<>(); private List<User> whitelistedUsers = new ArrayList<>();
private HashSet<String> whitelistedUsersIDs = new HashSet<>(); private Collator plCollator = Collator.getInstance(Locale.forLanguageTag("pl-PL"));
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
@ -100,8 +108,7 @@ public class WhiteList extends AppCompatActivity {
setSupportActionBar(toolbar); setSupportActionBar(toolbar);
mAdapter = new WhiteListAdapter(this, whitelistedUsers); mAdapter = new WhiteListAdapter(this, whitelistedUsers);
RecyclerView.LayoutManager mLayoutManager = new LinearLayoutManager(getApplicationContext()); recyclerView.setLayoutManager(new WrapContentLinearLayoutManager(getApplicationContext()));
recyclerView.setLayoutManager(mLayoutManager);
recyclerView.setItemAnimator(new DefaultItemAnimator()); recyclerView.setItemAnimator(new DefaultItemAnimator());
recyclerView.addItemDecoration(new MyDividerItemDecoration(this, LinearLayoutManager.VERTICAL, 16)); recyclerView.addItemDecoration(new MyDividerItemDecoration(this, LinearLayoutManager.VERTICAL, 16));
recyclerView.setAdapter(mAdapter); recyclerView.setAdapter(mAdapter);
@ -123,31 +130,8 @@ public class WhiteList extends AppCompatActivity {
})); }));
addToWhiteListFab.setOnClickListener(this::showFabDialog); addToWhiteListFab.setOnClickListener(this::showFabDialog);
fetchWhiteListedUsersIDs(PrefUtils.getUserId(getApplicationContext()));
handleSwitch();
}
private void fetchWhiteListedUsersIDs(String userId) {
disposable.add(
userService.getTutorWhitelistedByID(userId)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribeWith(new DisposableSingleObserver<List<String>>() {
@Override
public void onSuccess(List<String> users) {
whitelistedUsersIDs.addAll(users);
didFetched = true;
fetchWhiteListedUsers(); fetchWhiteListedUsers();
toggleEmptyNotes(); handleSwitch();
}
@Override
public void onError(Throwable e) {
showError(e);
}
})
);
} }
private Observable<List<String>> getListOfWhitelistedUsers(String userId) { private Observable<List<String>> getListOfWhitelistedUsers(String userId) {
@ -166,7 +150,10 @@ public class WhiteList extends AppCompatActivity {
} }
private void fetchWhiteListedUsers() { private void fetchWhiteListedUsers() {
disposable.add(getListOfWhitelistedUsers(PrefUtils.getUserId(getApplicationContext())) prevSize = whitelistedUsers.size();
whitelistedUsers.clear();
disposable.add(getListOfWhitelistedUsers(tutorId)
.subscribeOn(Schedulers.io()) .subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread()) .observeOn(AndroidSchedulers.mainThread())
.flatMap((Function<List<String>, Observable<String>>) Observable::fromIterable) .flatMap((Function<List<String>, Observable<String>>) Observable::fromIterable)
@ -184,12 +171,22 @@ public class WhiteList extends AppCompatActivity {
@Override @Override
public void onComplete() { public void onComplete() {
toggleEmptyNotes(); Collections.sort(whitelistedUsers, (a, b) -> sortByUserName(a,b));
mAdapter.notifyDataSetChanged(); refreshUI();
} }
})); }));
} }
private void refreshUI(){
toggleEmptyNotes();
mAdapter.notifyItemRangeInserted(prevSize, whitelistedUsers.size() - prevSize);
mAdapter.notifyDataSetChanged();
}
private int sortByUserName(User t1, User t2) {
return plCollator.compare(t1.getLastName(), t2.getLastName());
}
private void showFabDialog(View v){ private void showFabDialog(View v){
LayoutInflater layoutInflaterAndroid = LayoutInflater.from(getApplicationContext()); LayoutInflater layoutInflaterAndroid = LayoutInflater.from(getApplicationContext());
@SuppressLint("InflateParams") View view = layoutInflaterAndroid.inflate(R.layout.white_list_fab_modal, null); @SuppressLint("InflateParams") View view = layoutInflaterAndroid.inflate(R.layout.white_list_fab_modal, null);
@ -241,16 +238,11 @@ public class WhiteList 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();
whitelistedUsersIDs.clear();
whitelistedUsers.clear();
whitelistedUsersIDs.addAll(user.getWhitelist());
fetchWhiteListedUsers(); fetchWhiteListedUsers();
} }
private void showError(Throwable e) { private void showError(Throwable e) {
String message; String message;
Log.e("ERR", String.valueOf(e));
if (e instanceof HttpException) { if (e instanceof HttpException) {
ResponseBody responseBody = ((HttpException) e).response().errorBody(); ResponseBody responseBody = ((HttpException) e).response().errorBody();
@ -266,7 +258,6 @@ public class WhiteList extends AppCompatActivity {
} }
private void toggleEmptyNotes() { private void toggleEmptyNotes() {
if (didFetched && whitelistedUsers.size() == 0) { if (didFetched && whitelistedUsers.size() == 0) {
noNotesView.setText(R.string.list_is_empty); noNotesView.setText(R.string.list_is_empty);
noNotesView.setVisibility(View.VISIBLE); noNotesView.setVisibility(View.VISIBLE);
@ -301,7 +292,6 @@ public class WhiteList extends AppCompatActivity {
@Override @Override
public boolean onCreateOptionsMenu(Menu menu) { public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.menu_white_list, menu); getMenuInflater().inflate(R.menu.menu_white_list, menu);
return true; return true;
} }

View File

@ -41,11 +41,11 @@ public class BlackListAdapter extends RecyclerView.Adapter<BlackListAdapter.MyVi
private CompositeDisposable disposable = new CompositeDisposable(); private CompositeDisposable disposable = new CompositeDisposable();
private UserService userService; private UserService userService;
public BlackListAdapter(Context context, List<User> tutors) { public BlackListAdapter(Context context, List<User> tutors) {
this.context = context; this.context = context;
this.tutorsList = tutors; this.tutorsList = tutors;
} }
@NonNull @NonNull
@Override @Override
public MyViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { public MyViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
@ -73,25 +73,12 @@ public class BlackListAdapter extends RecyclerView.Adapter<BlackListAdapter.MyVi
.subscribeOn(Schedulers.io()) .subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread()) .observeOn(AndroidSchedulers.mainThread())
.subscribe(()->{ .subscribe(()->{
Toast.makeText(getApplicationContext(), "User removed", Toast.LENGTH_SHORT).show(); Toast.makeText(getApplicationContext(), R.string.user_removed, Toast.LENGTH_SHORT).show();
tutorsList.remove(position); tutorsList.remove(position);
notifyDataSetChanged(); notifyDataSetChanged();
},this::showError) },this::showError)
); );
}); });
//
// if (tutor.isIsOnline()) {
// image = context.getResources().getDrawable(R.drawable.user_list_online);
// } else {
// image = context.getResources().getDrawable(R.drawable.user_list_offline);
// }
//
// if (!tutor.isIsActive()) {
// image = context.getResources().getDrawable(R.drawable.user_list_off);
// }
// image.setBounds(0, 0, image.getIntrinsicWidth(), image.getIntrinsicHeight());
// holder.isOnline.setCompoundDrawables(image, null, null, null);
} }
@Override @Override
@ -107,8 +94,6 @@ public class BlackListAdapter extends RecyclerView.Adapter<BlackListAdapter.MyVi
@BindView(R.id.lastName) @BindView(R.id.lastName)
TextView lastName; TextView lastName;
// @BindView(R.id.isOnline)
// TextView isOnline;
@BindView(R.id.removeUserImageButton) @BindView(R.id.removeUserImageButton)
ImageButton imageButton; ImageButton imageButton;
@ -127,8 +112,8 @@ public class BlackListAdapter extends RecyclerView.Adapter<BlackListAdapter.MyVi
} else { } else {
message = "Network Error !"; message = "Network Error !";
} }
Toast.makeText(getApplicationContext(), message, Toast.LENGTH_SHORT).show(); Toast.makeText(getApplicationContext(), message, Toast.LENGTH_SHORT).show();
} }
} }

View File

@ -29,7 +29,7 @@ public class DutyHoursAdapter extends RecyclerView.Adapter<DutyHoursAdapter.MyV
public DutyHoursAdapter(Context context, List<DutyHourViewModel> hours) { public DutyHoursAdapter(Context context, List<DutyHourViewModel> hours) {
this.context = context; this.context = context;
this.hours = new ArrayList<DutyHourViewModel>(hours); this.hours = new ArrayList<>(hours);
} }

View File

@ -39,7 +39,6 @@ public class WhiteListAdapter extends RecyclerView.Adapter<WhiteListAdapter.MyVi
private CompositeDisposable disposable = new CompositeDisposable(); private CompositeDisposable disposable = new CompositeDisposable();
private UserService userService; private UserService userService;
public WhiteListAdapter(Context context, List<User> tutors) { public WhiteListAdapter(Context context, List<User> tutors) {
this.context = context; this.context = context;
this.tutorsList = tutors; this.tutorsList = tutors;
@ -62,7 +61,7 @@ public class WhiteListAdapter extends RecyclerView.Adapter<WhiteListAdapter.MyVi
holder.firstName.setText(tutor.getFirstName() + " " + tutor.getLastName()); holder.firstName.setText(tutor.getFirstName() + " " + tutor.getLastName());
holder.lastName.setText("Index: " + tutor.getLdapLogin() + " Email: " + tutor.getEmail()); holder.lastName.setText("Index: " + tutor.getLdapLogin() + " Email: " + tutor.getEmail());
//"s416196" //""
holder.imageButton.setOnClickListener(l ->{ holder.imageButton.setOnClickListener(l ->{
StudentIdModel studentIdModel = new StudentIdModel(tutor.getLdapLogin()); StudentIdModel studentIdModel = new StudentIdModel(tutor.getLdapLogin());
String tutorId = PrefUtils.getUserId(getApplicationContext()); String tutorId = PrefUtils.getUserId(getApplicationContext());
@ -71,25 +70,13 @@ public class WhiteListAdapter extends RecyclerView.Adapter<WhiteListAdapter.MyVi
.subscribeOn(Schedulers.io()) .subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread()) .observeOn(AndroidSchedulers.mainThread())
.subscribe(()->{ .subscribe(()->{
Toast.makeText(getApplicationContext(), "User removed", Toast.LENGTH_SHORT).show(); Toast.makeText(getApplicationContext(), R.string.user_removed, Toast.LENGTH_SHORT).show();
tutorsList.remove(position); tutorsList.remove(position);
notifyDataSetChanged(); notifyDataSetChanged();
},this::showError) },this::showError)
); );
}); });
//
// if (tutor.isIsOnline()) {
// image = context.getResources().getDrawable(R.drawable.user_list_online);
// } else {
// image = context.getResources().getDrawable(R.drawable.user_list_offline);
// }
//
// if (!tutor.isIsActive()) {
// image = context.getResources().getDrawable(R.drawable.user_list_off);
// }
// image.setBounds(0, 0, image.getIntrinsicWidth(), image.getIntrinsicHeight());
// holder.isOnline.setCompoundDrawables(image, null, null, null);
} }
@Override @Override
@ -105,8 +92,6 @@ public class WhiteListAdapter extends RecyclerView.Adapter<WhiteListAdapter.MyVi
@BindView(R.id.lastName) @BindView(R.id.lastName)
TextView lastName; TextView lastName;
// @BindView(R.id.isOnline)
// TextView isOnline;
@BindView(R.id.removeUserImageButton) @BindView(R.id.removeUserImageButton)
ImageButton imageButton; ImageButton imageButton;

View File

@ -6,7 +6,7 @@ import java.util.Arrays;
import java.util.List; import java.util.List;
public class Const { public class Const {
public final static String BASE_URL = "https://s416084.projektstudencki.pl/develop/"; public final static String BASE_URL = "https://s416084.projektstudencki.pl/master/";
public final static Integer mapRefreshInterval = 5000; public final static Integer mapRefreshInterval = 5000;
public final static Integer onlineBackgroundLocationInterval = 7000; public final static Integer onlineBackgroundLocationInterval = 7000;
public final static Integer offlineBackgroundLocationInterval = 360000; public final static Integer offlineBackgroundLocationInterval = 360000;

View File

@ -0,0 +1,30 @@
package com.uam.wmi.findmytutor.utils;
import android.content.Context;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.util.AttributeSet;
import android.util.Log;
public class WrapContentLinearLayoutManager extends LinearLayoutManager {
public WrapContentLinearLayoutManager(Context context) {
super(context);
}
public WrapContentLinearLayoutManager(Context context, int orientation, boolean reverseLayout) {
super(context, orientation, reverseLayout);
}
public WrapContentLinearLayoutManager(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
super(context, attrs, defStyleAttr, defStyleRes);
}
@Override
public void onLayoutChildren(RecyclerView.Recycler recycler, RecyclerView.State state) {
try {
super.onLayoutChildren(recycler, state);
} catch (IndexOutOfBoundsException e) {
e.printStackTrace();
}
}
}

View File

@ -268,6 +268,7 @@
<!--(ENG) Blacked/Whited users --> <!--(ENG) Blacked/Whited users -->
<string name="add_user_to_list">Użytkownik został dodany!</string> <string name="add_user_to_list">Użytkownik został dodany!</string>
<string name="user_removed">Użytkownik usunięty!</string>
</resources> </resources>

View File

@ -54,12 +54,10 @@
<!-- Strings related to SharingActivity --> <!-- Strings related to SharingActivity -->
<string name="title_activity_sharing">Sharing</string> <string name="title_activity_sharing">Sharing</string>
<!-- Strings related to settings --> <!-- Strings related to settings -->
<string name="title_sharing">Sharing</string> <string name="title_sharing">Sharing</string>
<string name="settings_category_location">Location sharing</string> <string name="settings_category_location">Location sharing</string>
<string name="settings_category_status">Status settings</string> <string name="settings_category_status">Status settings</string>
@ -87,14 +85,10 @@
<string name="title_manual_status">Add custom status</string> <string name="title_manual_status">Add custom status</string>
<string name="settings_description">Descrition</string> <string name="settings_description">Description</string>
<string name="saveButton">Save</string> <string name="saveButton">Save</string>
<string name="tutorTabHint">Edit your note. It will be shown in the users list.</string> <string name="tutorTabHint">Edit your note. It will be shown in the users list.</string>
<string name="key_description">key_description</string> <string name="key_description">key_description</string>
<string name="manual_location">Manual location</string> <string name="manual_location">Manual location</string>
<string name="title_list_manual_location">Choose manual location</string> <string name="title_list_manual_location">Choose manual location</string>
<string name="title_manual_location">Add custom location</string> <string name="title_manual_location">Add custom location</string>
@ -302,96 +296,6 @@
<string name="title_activity_white_list">Whitelist</string> <string name="title_activity_white_list">Whitelist</string>
<string name="white_list_title">Add user to Whitelist</string> <string name="white_list_title">Add user to Whitelist</string>
<string name="large_text" translatable="false">
"Material is the metaphor.\n\n"
"A material metaphor is the unifying theory of a rationalized space and a system of motion."
"The material is grounded in tactile reality, inspired by the study of paper and ink, yet "
"technologically advanced and open to imagination and magic.\n"
"Surfaces and edges of the material provide visual cues that are grounded in reality. The "
"use of familiar tactile attributes helps users quickly understand affordances. Yet the "
"flexibility of the material creates new affordances that supercede those in the physical "
"world, without breaking the rules of physics.\n"
"The fundamentals of light, surface, and movement are key to conveying how objects move, "
"interact, and exist in space and in relation to each other. Realistic lighting shows "
"seams, divides space, and indicates moving parts.\n\n"
"Bold, graphic, intentional.\n\n"
"The foundational elements of print based design typography, grids, space, scale, color, "
"and use of imagery guide visual treatments. These elements do far more than please the "
"eye. They create hierarchy, meaning, and focus. Deliberate color choices, edge to edge "
"imagery, large scale typography, and intentional white space create a bold and graphic "
"interface that immerse the user in the experience.\n"
"An emphasis on user actions makes core functionality immediately apparent and provides "
"waypoints for the user.\n\n"
"Motion provides meaning.\n\n"
"Motion respects and reinforces the user as the prime mover. Primary user actions are "
"inflection points that initiate motion, transforming the whole design.\n"
"All action takes place in a single environment. Objects are presented to the user without "
"breaking the continuity of experience even as they transform and reorganize.\n"
"Motion is meaningful and appropriate, serving to focus attention and maintain continuity. "
"Feedback is subtle yet clear. Transitions are efficient yet coherent.\n\n"
"3D world.\n\n"
"The material environment is a 3D space, which means all objects have x, y, and z "
"dimensions. The z-axis is perpendicularly aligned to the plane of the display, with the "
"positive z-axis extending towards the viewer. Every sheet of material occupies a single "
"position along the z-axis and has a standard 1dp thickness.\n"
"On the web, the z-axis is used for layering and not for perspective. The 3D world is "
"emulated by manipulating the y-axis.\n\n"
"Light and shadow.\n\n"
"Within the material environment, virtual lights illuminate the scene. Key lights create "
"directional shadows, while ambient light creates soft shadows from all angles.\n"
"Shadows in the material environment are cast by these two light sources. In Android "
"development, shadows occur when light sources are blocked by sheets of material at "
"various positions along the z-axis. On the web, shadows are depicted by manipulating the "
"y-axis only. The following example shows the card with a height of 6dp.\n\n"
"Resting elevation.\n\n"
"All material objects, regardless of size, have a resting elevation, or default elevation "
"that does not change. If an object changes elevation, it should return to its resting "
"elevation as soon as possible.\n\n"
"Component elevations.\n\n"
"The resting elevation for a component type is consistent across apps (e.g., FAB elevation "
"does not vary from 6dp in one app to 16dp in another app).\n"
"Components may have different resting elevations across platforms, depending on the depth "
"of the environment (e.g., TV has a greater depth than mobile or desktop).\n\n"
"Responsive elevation and dynamic elevation offsets.\n\n"
"Some component types have responsive elevation, meaning they change elevation in response "
"to user input (e.g., normal, focused, and pressed) or system events. These elevation "
"changes are consistently implemented using dynamic elevation offsets.\n"
"Dynamic elevation offsets are the goal elevation that a component moves towards, relative "
"to the components resting state. They ensure that elevation changes are consistent "
"across actions and component types. For example, all components that lift on press have "
"the same elevation change relative to their resting elevation.\n"
"Once the input event is completed or cancelled, the component will return to its resting "
"elevation.\n\n"
"Avoiding elevation interference.\n\n"
"Components with responsive elevations may encounter other components as they move between "
"their resting elevations and dynamic elevation offsets. Because material cannot pass "
"through other material, components avoid interfering with one another any number of ways, "
"whether on a per component basis or using the entire app layout.\n"
"On a component level, components can move or be removed before they cause interference. "
"For example, a floating action button (FAB) can disappear or move off screen before a "
"user picks up a card, or it can move if a snackbar appears.\n"
"On the layout level, design your app layout to minimize opportunities for interference. "
"For example, position the FAB to one side of stream of a cards so the FAB wont interfere "
"when a user tries to pick up one of cards.\n\n"
</string>
<string name="info_icon_userlist_summary">After clicking on a name, the tutor tab will pop up, containing details about selected tutor.\n\nYou can search for any tutor on the map by entering his name and surname in the search field.\n\nBy default, only active users are shown. You can change that in menu (three dots icon).\n\nYou can also search for a tutor directly, by entering name and surname of person that you look for.</string> <string name="info_icon_userlist_summary">After clicking on a name, the tutor tab will pop up, containing details about selected tutor.\n\nYou can search for any tutor on the map by entering his name and surname in the search field.\n\nBy default, only active users are shown. You can change that in menu (three dots icon).\n\nYou can also search for a tutor directly, by entering name and surname of person that you look for.</string>
<!--(ENG) Blacklist --> <!--(ENG) Blacklist -->
@ -439,5 +343,6 @@
<!--(ENG) Blacked/Whited users --> <!--(ENG) Blacked/Whited users -->
<string name="add_user_to_list">User has been added!</string> <string name="add_user_to_list">User has been added!</string>
<string name="user_removed">User removed!</string>
</resources> </resources>