forked from mirrors/Fedilab
		
	Fix issue #493 - Crash when adding account to a list from profile
This commit is contained in:
		
							parent
							
								
									9d8c815a1a
								
							
						
					
					
						commit
						3a3f6aa347
					
				
					 3 changed files with 6 additions and 5 deletions
				
			
		| 
						 | 
				
			
			@ -875,7 +875,7 @@ public class ProfileActivity extends BaseActivity {
 | 
			
		|||
                                                        updateAccount();
 | 
			
		||||
                                                        if (isChecked) {
 | 
			
		||||
                                                            timelinesVM.addAccountsList(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, listsId[which], userIds).observe(ProfileActivity.this, success -> {
 | 
			
		||||
                                                                if (!success) {
 | 
			
		||||
                                                                if (success == null || !success) {
 | 
			
		||||
                                                                    Toasty.error(ProfileActivity.this, getString(R.string.toast_error_add_to_list), Toast.LENGTH_LONG).show();
 | 
			
		||||
                                                                }
 | 
			
		||||
                                                            });
 | 
			
		||||
| 
						 | 
				
			
			@ -886,7 +886,7 @@ public class ProfileActivity extends BaseActivity {
 | 
			
		|||
                                        } else {
 | 
			
		||||
                                            if (isChecked) {
 | 
			
		||||
                                                timelinesVM.addAccountsList(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, listsId[which], userIds).observe(ProfileActivity.this, success -> {
 | 
			
		||||
                                                    if (!success) {
 | 
			
		||||
                                                    if (success == null || !success) {
 | 
			
		||||
                                                        Toasty.error(ProfileActivity.this, getString(R.string.toast_error_add_to_list), Toast.LENGTH_LONG).show();
 | 
			
		||||
                                                    }
 | 
			
		||||
                                                });
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -179,7 +179,7 @@ public interface MastodonTimelinesService {
 | 
			
		|||
    //Add account in a list
 | 
			
		||||
    @FormUrlEncoded
 | 
			
		||||
    @POST("lists/{id}/accounts")
 | 
			
		||||
    Call<Boolean> addAccountsList(
 | 
			
		||||
    Call<Void> addAccountsList(
 | 
			
		||||
            @Header("Authorization") String token,
 | 
			
		||||
            @Path("id") String id,
 | 
			
		||||
            @Field("account_ids[]") List<String> account_ids
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -843,14 +843,15 @@ public class TimelinesVM extends AndroidViewModel {
 | 
			
		|||
        MastodonTimelinesService mastodonTimelinesService = init(instance);
 | 
			
		||||
        booleanMutableLiveData = new MutableLiveData<>();
 | 
			
		||||
        new Thread(() -> {
 | 
			
		||||
            Call<Boolean> addAccountsListCall = mastodonTimelinesService.addAccountsList(token, listId, accountIds);
 | 
			
		||||
            Call<Void> addAccountsListCall = mastodonTimelinesService.addAccountsList(token, listId, accountIds);
 | 
			
		||||
            Boolean reply = null;
 | 
			
		||||
            if (addAccountsListCall != null) {
 | 
			
		||||
                try {
 | 
			
		||||
                    Response<Boolean> response = addAccountsListCall.execute();
 | 
			
		||||
                    Response<Void> response = addAccountsListCall.execute();
 | 
			
		||||
                    reply = response.isSuccessful();
 | 
			
		||||
                } catch (Exception e) {
 | 
			
		||||
                    e.printStackTrace();
 | 
			
		||||
                    reply = false;
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
            Handler mainHandler = new Handler(Looper.getMainLooper());
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in a new issue