Add buttons for removing statuses/locations in sharing tab #122

Merged
s416204 merged 75 commits from addRemovingManuals into develop 2019-01-05 00:45:41 +01:00
5 changed files with 23 additions and 36 deletions
Showing only changes of commit ed2ec41d8d - Show all commits

View File

@ -229,13 +229,18 @@ public class BlackList extends AppCompatActivity {
userService.addStudentToBlacklist(PrefUtils.getUserId(getApplicationContext()), studentIdModel) userService.addStudentToBlacklist(PrefUtils.getUserId(getApplicationContext()), studentIdModel)
.subscribeOn(Schedulers.io()) .subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread()) .observeOn(AndroidSchedulers.mainThread())
.subscribe(()->{ .subscribe(this::handleAddUser,this::showError)
fetchBlackListedUsersIDs(PrefUtils.getUserId(getApplicationContext()));
Toast.makeText(getApplicationContext(), R.string.user_added, Toast.LENGTH_SHORT).show();
},this::showError)
); );
} }
private void handleAddUser(User user) {
blacklistedUsersIDs.clear();
blacklistedUsers.clear();
blacklistedUsersIDs.addAll(user.getBlacklist());
fetchBlackListedUsers();
}
private void showError(Throwable e) { private void showError(Throwable e) {
String message; String message;

View File

@ -12,6 +12,7 @@ import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView; import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.Toolbar; import android.support.v7.widget.Toolbar;
import android.text.TextUtils; import android.text.TextUtils;
import android.util.Log;
import android.view.Gravity; import android.view.Gravity;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.Menu; import android.view.Menu;
@ -156,6 +157,7 @@ public class WhiteList extends AppCompatActivity {
public void onSuccess(User user) { public void onSuccess(User user) {
whitelistedUsers.add(user); whitelistedUsers.add(user);
toggleEmptyNotes(); toggleEmptyNotes();
if (whitelistedUsers.size() == whitelistedUsersIDs.size()) { if (whitelistedUsers.size() == whitelistedUsersIDs.size()) {
mAdapter.notifyDataSetChanged(); mAdapter.notifyDataSetChanged();
} }
@ -216,13 +218,17 @@ public class WhiteList extends AppCompatActivity {
userService.addStudentToWhitelist(PrefUtils.getUserId(getApplicationContext()), studentIdModel) userService.addStudentToWhitelist(PrefUtils.getUserId(getApplicationContext()), studentIdModel)
.subscribeOn(Schedulers.io()) .subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread()) .observeOn(AndroidSchedulers.mainThread())
.subscribe(()->{ .subscribe(this::handleAddUser,this::showError)
fetchWhiteListedUsersIDs(PrefUtils.getUserId(getApplicationContext()));
Toast.makeText(getApplicationContext(), R.string.user_added, Toast.LENGTH_SHORT).show();
},this::showError)
); );
} }
private void handleAddUser(User user) {
whitelistedUsersIDs.clear();
whitelistedUsers.clear();
whitelistedUsersIDs.addAll(user.getWhitelist());
fetchWhiteListedUsers();
}
private void showError(Throwable e) { private void showError(Throwable e) {
String message; String message;

View File

@ -81,7 +81,7 @@ public interface UserService {
Completable setTutorBlacklist(@Path("tutorID") String tutorID, @Body IsUsingListBool isUsing); Completable setTutorBlacklist(@Path("tutorID") String tutorID, @Body IsUsingListBool isUsing);
@POST("api/users/blacklist/{tutorID}") @POST("api/users/blacklist/{tutorID}")
Completable addStudentToBlacklist(@Path("tutorID") String tutorID, @Body StudentIdModel student); Observable <User> addStudentToBlacklist(@Path("tutorID") String tutorID, @Body StudentIdModel student);
// @DELETE("api/users/blacklist/{tutorID}") // @DELETE("api/users/blacklist/{tutorID}")
@HTTP(method = "DELETE", path = "api/users/blacklist/{tutorID}", hasBody = true) @HTTP(method = "DELETE", path = "api/users/blacklist/{tutorID}", hasBody = true)
@ -94,7 +94,7 @@ public interface UserService {
Completable setTutorWhitelist(@Path("tutorID") String tutorID, @Body IsUsingListBool isUsing); Completable setTutorWhitelist(@Path("tutorID") String tutorID, @Body IsUsingListBool isUsing);
@POST("api/users/whitelist/{tutorID}") @POST("api/users/whitelist/{tutorID}")
Completable addStudentToWhitelist(@Path("tutorID") String tutorID, @Body StudentIdModel student); Observable <User> addStudentToWhitelist(@Path("tutorID") String tutorID, @Body StudentIdModel student);
// @DELETE("api/users/whitelist/{tutorID}") // @DELETE("api/users/whitelist/{tutorID}")
@HTTP(method = "DELETE", path = "api/users/whitelist/{tutorID}", hasBody = true) @HTTP(method = "DELETE", path = "api/users/whitelist/{tutorID}", hasBody = true)

View File

@ -35,18 +35,6 @@
android:textSize="15sp" /> android:textSize="15sp" />
<!--<TextView-->
<!--android:id="@+id/isOnline"-->
<!--android:layout_width="48dp"-->
<!--android:layout_height="30dp"-->
<!--android:layout_below="@+id/firstName"-->
<!--android:layout_marginStart="7dp"-->
<!--android:layout_marginTop="-10dp"-->
<!--android:layout_toEndOf="@+id/firstName"-->
<!--android:textColor="@color/note_list_text"-->
<!--android:textSize="@dimen/note_list_text" />-->
<ImageButton <ImageButton
android:id="@+id/removeUserImageButton" android:id="@+id/removeUserImageButton"
android:layout_width="wrap_content" android:layout_width="wrap_content"
@ -54,6 +42,7 @@
android:layout_below="@+id/firstName" android:layout_below="@+id/firstName"
android:layout_toEndOf="@+id/firstName" android:layout_toEndOf="@+id/firstName"
android:background="@null" android:background="@null"
android:layout_alignParentEnd="true"
app:srcCompat="@drawable/abc_ic_clear_material" /> app:srcCompat="@drawable/abc_ic_clear_material" />
</RelativeLayout> </RelativeLayout>

View File

@ -34,19 +34,6 @@
android:textColor="@color/note_list_text" android:textColor="@color/note_list_text"
android:textSize="15sp" /> android:textSize="15sp" />
<!--<TextView-->
<!--android:id="@+id/isOnline"-->
<!--android:layout_width="48dp"-->
<!--android:layout_height="30dp"-->
<!--android:layout_below="@+id/firstName"-->
<!--android:layout_marginStart="7dp"-->
<!--android:layout_marginTop="-10dp"-->
<!--android:layout_toEndOf="@+id/firstName"-->
<!--android:textColor="@color/note_list_text"-->
<!--android:textSize="@dimen/note_list_text" />-->
<ImageButton <ImageButton
android:id="@+id/removeUserImageButton" android:id="@+id/removeUserImageButton"
android:layout_width="wrap_content" android:layout_width="wrap_content"