fix(account-cards): add the progressbar for the accept and decline follow request actions
This commit is contained in:
parent
ca07240a70
commit
9f5c420e66
3 changed files with 30 additions and 3 deletions
|
@ -319,7 +319,18 @@ public class FollowRequestsListFragment extends MastodonRecyclerFragment<FollowR
|
|||
|
||||
private void onFollowRequestButtonClick(View v) {
|
||||
itemView.setHasTransientState(true);
|
||||
UiUtils.handleFollowRequest((Activity) v.getContext(), item.account, accountID, null, v == acceptButton, relationship, rel -> {
|
||||
UiUtils.handleFollowRequest((Activity) v.getContext(), item.account, accountID, null, v == acceptButton, relationship, (Boolean visible) -> {
|
||||
if(v==acceptButton){
|
||||
acceptButton.setTextVisible(!visible);
|
||||
acceptProgress.setVisibility(visible ? View.VISIBLE : View.GONE);
|
||||
acceptButton.setClickable(!visible);
|
||||
}else{
|
||||
rejectButton.setTextVisible(!visible);
|
||||
rejectProgress.setVisibility(visible ? View.VISIBLE : View.GONE);
|
||||
rejectButton.setClickable(!visible);
|
||||
}
|
||||
itemView.setHasTransientState(false);
|
||||
}, rel -> {
|
||||
if(getContext()==null) return;
|
||||
itemView.setHasTransientState(false);
|
||||
relationships.put(item.account.id, rel);
|
||||
|
|
|
@ -172,7 +172,18 @@ public class AccountCardStatusDisplayItem extends StatusDisplayItem{
|
|||
|
||||
private void onFollowRequestButtonClick(View v) {
|
||||
itemView.setHasTransientState(true);
|
||||
UiUtils.handleFollowRequest((Activity) v.getContext(), item.account, item.parentFragment.getAccountID(), null, v == acceptButton, relationship, rel -> {
|
||||
UiUtils.handleFollowRequest((Activity) v.getContext(), item.account, item.parentFragment.getAccountID(), null, v == acceptButton, relationship, (Boolean visible) -> {
|
||||
if(v==acceptButton){
|
||||
acceptButton.setTextVisible(!visible);
|
||||
acceptProgress.setVisibility(visible ? View.VISIBLE : View.GONE);
|
||||
acceptButton.setClickable(!visible);
|
||||
}else{
|
||||
rejectButton.setTextVisible(!visible);
|
||||
rejectProgress.setVisibility(visible ? View.VISIBLE : View.GONE);
|
||||
rejectButton.setClickable(!visible);
|
||||
}
|
||||
itemView.setHasTransientState(false);
|
||||
}, rel -> {
|
||||
if(v.getContext()==null || rel==null) return;
|
||||
itemView.setHasTransientState(false);
|
||||
item.parentFragment.putRelationship(item.account.id, rel);
|
||||
|
|
|
@ -934,17 +934,20 @@ public class UiUtils {
|
|||
}
|
||||
|
||||
|
||||
public static void handleFollowRequest(Activity activity, Account account, String accountID, @Nullable String notificationID, boolean accepted, Relationship relationship, Consumer<Relationship> resultCallback) {
|
||||
public static void handleFollowRequest(Activity activity, Account account, String accountID, @Nullable String notificationID, boolean accepted, Relationship relationship, Consumer<Boolean> progressCallback, Consumer<Relationship> resultCallback) {
|
||||
progressCallback.accept(true);
|
||||
if (accepted) {
|
||||
new AuthorizeFollowRequest(account.id).setCallback(new Callback<>() {
|
||||
@Override
|
||||
public void onSuccess(Relationship rel) {
|
||||
E.post(new FollowRequestHandledEvent(accountID, true, account, rel));
|
||||
progressCallback.accept(false);
|
||||
resultCallback.accept(rel);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(ErrorResponse error) {
|
||||
progressCallback.accept(false);
|
||||
resultCallback.accept(relationship);
|
||||
error.showToast(activity);
|
||||
}
|
||||
|
@ -956,11 +959,13 @@ public class UiUtils {
|
|||
E.post(new FollowRequestHandledEvent(accountID, false, account, rel));
|
||||
if (notificationID != null)
|
||||
E.post(new NotificationDeletedEvent(notificationID));
|
||||
progressCallback.accept(false);
|
||||
resultCallback.accept(rel);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(ErrorResponse error) {
|
||||
progressCallback.accept(false);
|
||||
resultCallback.accept(relationship);
|
||||
error.showToast(activity);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue