diff options
Diffstat (limited to 'app/src/main/java/app/fedilab/android/viewmodel/mastodon/AccountsVM.java')
-rw-r--r-- | app/src/main/java/app/fedilab/android/viewmodel/mastodon/AccountsVM.java | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/app/src/main/java/app/fedilab/android/viewmodel/mastodon/AccountsVM.java b/app/src/main/java/app/fedilab/android/viewmodel/mastodon/AccountsVM.java index 1d640b2be..5d4e17cd7 100644 --- a/app/src/main/java/app/fedilab/android/viewmodel/mastodon/AccountsVM.java +++ b/app/src/main/java/app/fedilab/android/viewmodel/mastodon/AccountsVM.java @@ -296,6 +296,36 @@ public class AccountsVM extends AndroidViewModel { return accountMutableLiveData; } + + /** + * @param acct The acct of the account + * @return {@link LiveData} containing an {@link Account} + */ + public LiveData<Account> lookUpAccount(@NonNull String instance, @NonNull String acct) { + accountMutableLiveData = new MutableLiveData<>(); + MastodonAccountsService mastodonAccountsService = init(instance); + new Thread(() -> { + Account account = null; + Call<Account> accountCall = mastodonAccountsService.lookUpAccount(acct); + if (accountCall != null) { + + try { + Response<Account> accountResponse = accountCall.execute(); + if (accountResponse.isSuccessful()) { + account = accountResponse.body(); + } + } catch (Exception e) { + e.printStackTrace(); + } + } + Account finalAccount = account; + Handler mainHandler = new Handler(Looper.getMainLooper()); + Runnable myRunnable = () -> accountMutableLiveData.setValue(finalAccount); + mainHandler.post(myRunnable); + }).start(); + return accountMutableLiveData; + } + /** * @param id The id of the account * @return {@link LiveData} containing an {@link Account} |