From 9047181e8fb99ca12f8f487c4b1108f37a59b2e9 Mon Sep 17 00:00:00 2001 From: Thomas Date: Wed, 1 Jun 2022 16:37:01 +0200 Subject: [PATCH] Add less restrictive catch close --- .../activities/AdminReportActivity.java | 42 +++++--- .../android/activities/ComposeActivity.java | 16 +++- .../activities/EditProfileActivity.java | 87 ++++++++++------- .../android/helper/SpannableHelper.java | 5 +- .../FragmentLoginPickInstanceMastodon.java | 2 + .../timeline/FragmentMastodonContext.java | 1 + .../viewmodel/mastodon/AccountsVM.java | 95 +++++++++---------- .../android/viewmodel/mastodon/AdminVM.java | 29 +++--- .../viewmodel/mastodon/AnnouncementsVM.java | 9 +- .../android/viewmodel/mastodon/AppsVM.java | 5 +- .../viewmodel/mastodon/InstanceSocialVM.java | 3 +- .../viewmodel/mastodon/InstancesVM.java | 5 +- .../viewmodel/mastodon/JoinInstancesVM.java | 3 +- .../viewmodel/mastodon/NodeInfoVM.java | 5 +- .../viewmodel/mastodon/NotificationsVM.java | 17 ++-- .../android/viewmodel/mastodon/OauthVM.java | 5 +- .../android/viewmodel/mastodon/ReorderVM.java | 3 +- .../android/viewmodel/mastodon/SearchVM.java | 3 +- .../viewmodel/mastodon/StatusesVM.java | 55 ++++++----- .../viewmodel/mastodon/TimelinesVM.java | 33 ++++--- 20 files changed, 228 insertions(+), 195 deletions(-) diff --git a/app/src/main/java/app/fedilab/android/activities/AdminReportActivity.java b/app/src/main/java/app/fedilab/android/activities/AdminReportActivity.java index b32e6c1d..d3727cf3 100644 --- a/app/src/main/java/app/fedilab/android/activities/AdminReportActivity.java +++ b/app/src/main/java/app/fedilab/android/activities/AdminReportActivity.java @@ -173,9 +173,14 @@ public class AdminReportActivity extends BaseActivity { if (adminAccount.disabled) { adminVM.enable(MainActivity.currentInstance, MainActivity.currentToken, account.id) .observe(AdminReportActivity.this, adminAccountResult -> { - adminAccount.disabled = false; - binding.disableAction.setText(R.string.disable); - binding.disabled.setText(R.string.no); + if (adminAccountResult != null) { + adminAccount.disabled = false; + binding.disableAction.setText(R.string.disable); + binding.disabled.setText(R.string.no); + } else { + Helper.sendToastMessage(getApplication(), Helper.RECEIVE_TOAST_TYPE_ERROR, getString(R.string.toast_error)); + } + }); } else { adminVM.performAction(MainActivity.currentInstance, MainActivity.currentToken, account.id, "disable ", null, null, null, null); @@ -189,9 +194,14 @@ public class AdminReportActivity extends BaseActivity { if (adminAccount.approved) { adminVM.reject(MainActivity.currentInstance, MainActivity.currentToken, account.id) .observe(AdminReportActivity.this, adminAccountResult -> { - adminAccount.approved = false; - binding.approveAction.setText(R.string.approve); - binding.approved.setText(R.string.no); + if (adminAccountResult != null) { + adminAccount.approved = false; + binding.approveAction.setText(R.string.approve); + binding.approved.setText(R.string.no); + } else { + Helper.sendToastMessage(getApplication(), Helper.RECEIVE_TOAST_TYPE_ERROR, getString(R.string.toast_error)); + } + }); } else { adminVM.approve(MainActivity.currentInstance, MainActivity.currentToken, account.id); @@ -205,9 +215,13 @@ public class AdminReportActivity extends BaseActivity { if (adminAccount.disabled) { adminVM.unsilence(MainActivity.currentInstance, MainActivity.currentToken, account.id) .observe(AdminReportActivity.this, adminAccountResult -> { - adminAccount.silenced = false; - binding.silenceAction.setText(R.string.silence); - binding.disabled.setText(R.string.no); + if (adminAccountResult != null) { + adminAccount.silenced = false; + binding.silenceAction.setText(R.string.silence); + binding.disabled.setText(R.string.no); + } else { + Helper.sendToastMessage(getApplication(), Helper.RECEIVE_TOAST_TYPE_ERROR, getString(R.string.toast_error)); + } }); } else { adminVM.performAction(MainActivity.currentInstance, MainActivity.currentToken, account.id, "silence", null, null, null, null); @@ -221,9 +235,13 @@ public class AdminReportActivity extends BaseActivity { if (adminAccount.disabled) { adminVM.unsuspend(MainActivity.currentInstance, MainActivity.currentToken, account.id) .observe(AdminReportActivity.this, adminAccountResult -> { - adminAccount.suspended = false; - binding.suspendAction.setText(R.string.suspend); - binding.suspended.setText(R.string.no); + if (adminAccountResult != null) { + adminAccount.suspended = false; + binding.suspendAction.setText(R.string.suspend); + binding.suspended.setText(R.string.no); + } else { + Helper.sendToastMessage(getApplication(), Helper.RECEIVE_TOAST_TYPE_ERROR, getString(R.string.toast_error)); + } }); } else { adminVM.performAction(MainActivity.currentInstance, MainActivity.currentToken, account.id, "suspend", null, null, null, null); diff --git a/app/src/main/java/app/fedilab/android/activities/ComposeActivity.java b/app/src/main/java/app/fedilab/android/activities/ComposeActivity.java index 24a49501..c0d986a5 100644 --- a/app/src/main/java/app/fedilab/android/activities/ComposeActivity.java +++ b/app/src/main/java/app/fedilab/android/activities/ComposeActivity.java @@ -178,10 +178,18 @@ public class ComposeActivity extends BaseActivity implements ComposeAdapter.Mana if (statusReplyId != null && statusDraft != null) {//Delete and redraft statusesVM.getStatus(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, statusReplyId) .observe(ComposeActivity.this, status1 -> { - statusesVM.getContext(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, statusReplyId) - .observe(ComposeActivity.this, statusContext -> { - initializeContextRedraftView(statusContext, status1); - }); + if (status1 != null) { + statusesVM.getContext(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, statusReplyId) + .observe(ComposeActivity.this, statusContext -> { + if (statusContext != null) { + initializeContextRedraftView(statusContext, status1); + } else { + Helper.sendToastMessage(getApplication(), Helper.RECEIVE_TOAST_TYPE_ERROR, getString(R.string.toast_error)); + } + }); + } else { + Helper.sendToastMessage(getApplication(), Helper.RECEIVE_TOAST_TYPE_ERROR, getString(R.string.toast_error)); + } }); } else if (statusDraft != null) {//Restore a draft with all messages new Thread(() -> { diff --git a/app/src/main/java/app/fedilab/android/activities/EditProfileActivity.java b/app/src/main/java/app/fedilab/android/activities/EditProfileActivity.java index 153afc45..31231758 100644 --- a/app/src/main/java/app/fedilab/android/activities/EditProfileActivity.java +++ b/app/src/main/java/app/fedilab/android/activities/EditProfileActivity.java @@ -73,8 +73,12 @@ public class EditProfileActivity extends BaseActivity { new ViewModelProvider(EditProfileActivity.this).get(AccountsVM.class).getConnectedAccount(BaseMainActivity.currentInstance, BaseMainActivity.currentToken) .observe(EditProfileActivity.this, account -> { - BaseMainActivity.accountWeakReference.get().mastodon_account = account; - initializeView(); + if (account != null) { + BaseMainActivity.accountWeakReference.get().mastodon_account = account; + initializeView(); + } else { + Helper.sendToastMessage(getApplication(), Helper.RECEIVE_TOAST_TYPE_ERROR, getString(R.string.toast_error)); + } }); } @@ -187,17 +191,21 @@ public class EditProfileActivity extends BaseActivity { .into(binding.accountPp); accountsVM.updateProfilePicture(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, data.getData(), AccountsVM.UpdateMediaType.AVATAR) .observe(EditProfileActivity.this, account -> { - sendBroadCast(account); - binding.avatarProgress.setVisibility(View.GONE); - BaseMainActivity.accountWeakReference.get().mastodon_account = account; - Helper.recreateMainActivity(EditProfileActivity.this); - new Thread(() -> { - try { - new app.fedilab.android.client.entities.app.Account(EditProfileActivity.this).insertOrUpdate(BaseMainActivity.accountWeakReference.get()); - } catch (DBException e) { - e.printStackTrace(); - } - }).start(); + if (account != null) { + sendBroadCast(account); + binding.avatarProgress.setVisibility(View.GONE); + BaseMainActivity.accountWeakReference.get().mastodon_account = account; + Helper.recreateMainActivity(EditProfileActivity.this); + new Thread(() -> { + try { + new app.fedilab.android.client.entities.app.Account(EditProfileActivity.this).insertOrUpdate(BaseMainActivity.accountWeakReference.get()); + } catch (DBException e) { + e.printStackTrace(); + } + }).start(); + } else { + Helper.sendToastMessage(getApplication(), Helper.RECEIVE_TOAST_TYPE_ERROR, getString(R.string.toast_error)); + } }); } else if (requestCode == PICK_MEDIA_HEADER && resultCode == RESULT_OK) { Glide.with(EditProfileActivity.this) @@ -208,18 +216,21 @@ public class EditProfileActivity extends BaseActivity { binding.headerProgress.setVisibility(View.VISIBLE); accountsVM.updateProfilePicture(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, data.getData(), AccountsVM.UpdateMediaType.HEADER) .observe(EditProfileActivity.this, account -> { - sendBroadCast(account); - binding.headerProgress.setVisibility(View.GONE); - BaseMainActivity.accountWeakReference.get().mastodon_account = account; - new Thread(() -> { - try { - new app.fedilab.android.client.entities.app.Account(EditProfileActivity.this).insertOrUpdate(BaseMainActivity.accountWeakReference.get()); - } catch (DBException e) { - e.printStackTrace(); - } - }).start(); - - Helper.recreateMainActivity(EditProfileActivity.this); + if (account != null) { + sendBroadCast(account); + binding.headerProgress.setVisibility(View.GONE); + BaseMainActivity.accountWeakReference.get().mastodon_account = account; + new Thread(() -> { + try { + new app.fedilab.android.client.entities.app.Account(EditProfileActivity.this).insertOrUpdate(BaseMainActivity.accountWeakReference.get()); + } catch (DBException e) { + e.printStackTrace(); + } + }).start(); + Helper.recreateMainActivity(EditProfileActivity.this); + } else { + Helper.sendToastMessage(getApplication(), Helper.RECEIVE_TOAST_TYPE_ERROR, getString(R.string.toast_error)); + } }); } } @@ -301,18 +312,22 @@ public class EditProfileActivity extends BaseActivity { getFields() ) .observe(EditProfileActivity.this, account -> { - BaseMainActivity.accountWeakReference.get().mastodon_account = account; - new Thread(() -> { - try { - new app.fedilab.android.client.entities.app.Account(EditProfileActivity.this).insertOrUpdate(BaseMainActivity.accountWeakReference.get()); - sendBroadCast(account); - } catch (DBException e) { - e.printStackTrace(); - } - }).start(); + if (account != null) { + BaseMainActivity.accountWeakReference.get().mastodon_account = account; + new Thread(() -> { + try { + new app.fedilab.android.client.entities.app.Account(EditProfileActivity.this).insertOrUpdate(BaseMainActivity.accountWeakReference.get()); + sendBroadCast(account); + } catch (DBException e) { + e.printStackTrace(); + } + }).start(); + Toasty.success(EditProfileActivity.this, getString(R.string.profiled_updated), Toasty.LENGTH_LONG).show(); + finish(); + } else { + Helper.sendToastMessage(getApplication(), Helper.RECEIVE_TOAST_TYPE_ERROR, getString(R.string.toast_error)); + } - Toasty.success(EditProfileActivity.this, getString(R.string.profiled_updated), Toasty.LENGTH_LONG).show(); - finish(); }); return true; } diff --git a/app/src/main/java/app/fedilab/android/helper/SpannableHelper.java b/app/src/main/java/app/fedilab/android/helper/SpannableHelper.java index bb0f2991..fac8cc6f 100644 --- a/app/src/main/java/app/fedilab/android/helper/SpannableHelper.java +++ b/app/src/main/java/app/fedilab/android/helper/SpannableHelper.java @@ -627,8 +627,11 @@ public class SpannableHelper { * @param text String - text to convert, it can be display name or bio * @return Spannable string */ - private static Spannable convertA(@NonNull Context context, @NonNull Account account, @NonNull String text, boolean limitedToDisplayName) { + private static Spannable convertA(@NonNull Context context, @NonNull Account account, String text, boolean limitedToDisplayName) { SpannableString initialContent; + if (text == null) { + return null; + } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) initialContent = new SpannableString(Html.fromHtml(text, Html.FROM_HTML_MODE_LEGACY)); else diff --git a/app/src/main/java/app/fedilab/android/ui/fragment/login/FragmentLoginPickInstanceMastodon.java b/app/src/main/java/app/fedilab/android/ui/fragment/login/FragmentLoginPickInstanceMastodon.java index 8747fefd..3452a79e 100644 --- a/app/src/main/java/app/fedilab/android/ui/fragment/login/FragmentLoginPickInstanceMastodon.java +++ b/app/src/main/java/app/fedilab/android/ui/fragment/login/FragmentLoginPickInstanceMastodon.java @@ -99,6 +99,8 @@ public class FragmentLoginPickInstanceMastodon extends Fragment implements Insta binding.regCategoryView.setLayoutManager(mLayoutManager); binding.regCategoryView.setNestedScrollingEnabled(false); binding.regCategoryView.setAdapter(instanceRegAdapter); + } else { + Helper.sendToastMessage(requireActivity(), Helper.RECEIVE_TOAST_TYPE_ERROR, getString(R.string.toast_error)); } }); } else { diff --git a/app/src/main/java/app/fedilab/android/ui/fragment/timeline/FragmentMastodonContext.java b/app/src/main/java/app/fedilab/android/ui/fragment/timeline/FragmentMastodonContext.java index 5eebb569..3dae88af 100644 --- a/app/src/main/java/app/fedilab/android/ui/fragment/timeline/FragmentMastodonContext.java +++ b/app/src/main/java/app/fedilab/android/ui/fragment/timeline/FragmentMastodonContext.java @@ -224,6 +224,7 @@ public class FragmentMastodonContext extends Fragment { private void initializeContextView(final Context context) { if (context == null) { + Helper.sendToastMessage(requireActivity(), Helper.RECEIVE_TOAST_TYPE_ERROR, getString(R.string.toast_error)); return; } if (pullToRefresh) { 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 c20b983f..7a7ad78e 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 @@ -24,7 +24,6 @@ import androidx.lifecycle.AndroidViewModel; import androidx.lifecycle.LiveData; import androidx.lifecycle.MutableLiveData; -import java.io.IOException; import java.util.LinkedHashMap; import java.util.List; import java.util.concurrent.TimeUnit; @@ -118,7 +117,7 @@ public class AccountsVM extends AndroidViewModel { if (accountResponse.isSuccessful()) { account = accountResponse.body(); } - } catch (IOException e) { + } catch (Exception e) { e.printStackTrace(); } } @@ -164,7 +163,7 @@ public class AccountsVM extends AndroidViewModel { errorMessage = stringResponse.errorBody().string(); } } - } catch (IOException e) { + } catch (Exception e) { e.printStackTrace(); errorMessage = e.getMessage() != null ? e.getMessage() : getApplication().getString(R.string.toast_error); } @@ -210,7 +209,7 @@ public class AccountsVM extends AndroidViewModel { if (accountResponse.isSuccessful()) { account = accountResponse.body(); } - } catch (IOException e) { + } catch (Exception e) { e.printStackTrace(); } } @@ -270,7 +269,7 @@ public class AccountsVM extends AndroidViewModel { if (accountResponse.isSuccessful()) { account = accountResponse.body(); } - } catch (IOException e) { + } catch (Exception e) { e.printStackTrace(); } } @@ -298,7 +297,7 @@ public class AccountsVM extends AndroidViewModel { if (accountResponse.isSuccessful()) { account = accountResponse.body(); } - } catch (IOException e) { + } catch (Exception e) { e.printStackTrace(); } } @@ -343,7 +342,7 @@ public class AccountsVM extends AndroidViewModel { pagination = MastodonHelper.getPagination(accountStatusesResponse.headers()); } - } catch (IOException e) { + } catch (Exception e) { e.printStackTrace(); } } @@ -378,7 +377,7 @@ public class AccountsVM extends AndroidViewModel { accountList = followersResponse.body(); pagination = MastodonHelper.getPagination(followersResponse.headers()); } - } catch (IOException e) { + } catch (Exception e) { e.printStackTrace(); } } @@ -414,7 +413,7 @@ public class AccountsVM extends AndroidViewModel { accountList = followingResponse.body(); pagination = MastodonHelper.getPagination(followingResponse.headers()); } - } catch (IOException e) { + } catch (Exception e) { e.printStackTrace(); } } @@ -446,7 +445,7 @@ public class AccountsVM extends AndroidViewModel { if (featuredTagsResponse.isSuccessful()) { featuredTagList = featuredTagsResponse.body(); } - } catch (IOException e) { + } catch (Exception e) { e.printStackTrace(); } } @@ -476,7 +475,7 @@ public class AccountsVM extends AndroidViewModel { if (listsResponse.isSuccessful()) { mastodonListList = listsResponse.body(); } - } catch (IOException e) { + } catch (Exception e) { e.printStackTrace(); } } @@ -506,7 +505,7 @@ public class AccountsVM extends AndroidViewModel { if (identityProofsResponse.isSuccessful()) { identityProofList = identityProofsResponse.body(); } - } catch (IOException e) { + } catch (Exception e) { e.printStackTrace(); } } @@ -537,7 +536,7 @@ public class AccountsVM extends AndroidViewModel { if (followResponse.isSuccessful()) { relationShip = followResponse.body(); } - } catch (IOException e) { + } catch (Exception e) { e.printStackTrace(); } } @@ -569,7 +568,7 @@ public class AccountsVM extends AndroidViewModel { if (followResponse.isSuccessful()) { relationShip = followResponse.body(); } - } catch (IOException e) { + } catch (Exception e) { e.printStackTrace(); } } @@ -599,7 +598,7 @@ public class AccountsVM extends AndroidViewModel { if (unfollowResponse.isSuccessful()) { relationShip = unfollowResponse.body(); } - } catch (IOException e) { + } catch (Exception e) { e.printStackTrace(); } } @@ -629,7 +628,7 @@ public class AccountsVM extends AndroidViewModel { if (blockResponse.isSuccessful()) { relationShip = blockResponse.body(); } - } catch (IOException e) { + } catch (Exception e) { e.printStackTrace(); } Handler mainHandler = new Handler(Looper.getMainLooper()); @@ -659,7 +658,7 @@ public class AccountsVM extends AndroidViewModel { if (unblockResponse.isSuccessful()) { relationShip = unblockResponse.body(); } - } catch (IOException e) { + } catch (Exception e) { e.printStackTrace(); } Handler mainHandler = new Handler(Looper.getMainLooper()); @@ -691,7 +690,7 @@ public class AccountsVM extends AndroidViewModel { if (muteResponse.isSuccessful()) { relationShip = muteResponse.body(); } - } catch (IOException e) { + } catch (Exception e) { e.printStackTrace(); } Handler mainHandler = new Handler(Looper.getMainLooper()); @@ -721,7 +720,7 @@ public class AccountsVM extends AndroidViewModel { if (unmuteResponse.isSuccessful()) { relationShip = unmuteResponse.body(); } - } catch (IOException e) { + } catch (Exception e) { e.printStackTrace(); } Handler mainHandler = new Handler(Looper.getMainLooper()); @@ -751,7 +750,7 @@ public class AccountsVM extends AndroidViewModel { if (endorseResponse.isSuccessful()) { relationShip = endorseResponse.body(); } - } catch (IOException e) { + } catch (Exception e) { e.printStackTrace(); } Handler mainHandler = new Handler(Looper.getMainLooper()); @@ -781,7 +780,7 @@ public class AccountsVM extends AndroidViewModel { if (unendorseResponse.isSuccessful()) { relationShip = unendorseResponse.body(); } - } catch (IOException e) { + } catch (Exception e) { e.printStackTrace(); } Handler mainHandler = new Handler(Looper.getMainLooper()); @@ -812,7 +811,7 @@ public class AccountsVM extends AndroidViewModel { if (noteResponse.isSuccessful()) { relationShip = noteResponse.body(); } - } catch (IOException e) { + } catch (Exception e) { e.printStackTrace(); } Handler mainHandler = new Handler(Looper.getMainLooper()); @@ -842,7 +841,7 @@ public class AccountsVM extends AndroidViewModel { if (relationshipsResponse.isSuccessful()) { relationShipList = relationshipsResponse.body(); } - } catch (IOException e) { + } catch (Exception e) { e.printStackTrace(); } } @@ -875,7 +874,7 @@ public class AccountsVM extends AndroidViewModel { if (searchResponse.isSuccessful()) { accountList = searchResponse.body(); } - } catch (IOException e) { + } catch (Exception e) { e.printStackTrace(); } } @@ -912,7 +911,7 @@ public class AccountsVM extends AndroidViewModel { statuses.statuses = SpannableHelper.convertStatus(getApplication().getApplicationContext(), statusList); statuses.pagination = MastodonHelper.getPagination(bookmarksResponse.headers()); } - } catch (IOException e) { + } catch (Exception e) { e.printStackTrace(); } } @@ -943,7 +942,7 @@ public class AccountsVM extends AndroidViewModel { statuses.statuses = SpannableHelper.convertStatus(getApplication().getApplicationContext(), statusList); statuses.pagination = MastodonHelper.getPagination(favouritesResponse.headers()); } - } catch (IOException e) { + } catch (Exception e) { e.printStackTrace(); } } @@ -975,7 +974,7 @@ public class AccountsVM extends AndroidViewModel { accounts.accounts = SpannableHelper.convertAccounts(getApplication().getApplicationContext(), accountList); accounts.pagination = MastodonHelper.getPagination(mutesResponse.headers()); } - } catch (IOException e) { + } catch (Exception e) { e.printStackTrace(); } } @@ -1007,7 +1006,7 @@ public class AccountsVM extends AndroidViewModel { accounts.accounts = SpannableHelper.convertAccounts(getApplication().getApplicationContext(), accountList); accounts.pagination = MastodonHelper.getPagination(blocksResponse.headers()); } - } catch (IOException e) { + } catch (Exception e) { e.printStackTrace(); } } @@ -1036,7 +1035,7 @@ public class AccountsVM extends AndroidViewModel { if (getDomainBlocksResponse.isSuccessful()) { stringList = getDomainBlocksResponse.body(); } - } catch (IOException e) { + } catch (Exception e) { e.printStackTrace(); } } @@ -1064,7 +1063,7 @@ public class AccountsVM extends AndroidViewModel { if (addDomainBlockCall != null) { try { addDomainBlockCall.execute(); - } catch (IOException e) { + } catch (Exception e) { e.printStackTrace(); } } @@ -1083,7 +1082,7 @@ public class AccountsVM extends AndroidViewModel { if (removeDomainBlockCall != null) { try { removeDomainBlockCall.execute(); - } catch (IOException e) { + } catch (Exception e) { e.printStackTrace(); } } @@ -1108,7 +1107,7 @@ public class AccountsVM extends AndroidViewModel { BaseMainActivity.filterFetched = true; filterList = getFiltersResponse.body(); } - } catch (IOException e) { + } catch (Exception e) { e.printStackTrace(); } } @@ -1138,7 +1137,7 @@ public class AccountsVM extends AndroidViewModel { if (getFiltersResponse.isSuccessful()) { filter = getFiltersResponse.body(); } - } catch (IOException e) { + } catch (Exception e) { e.printStackTrace(); } } @@ -1177,7 +1176,7 @@ public class AccountsVM extends AndroidViewModel { if (addFiltersResponse.isSuccessful()) { filter = addFiltersResponse.body(); } - } catch (IOException e) { + } catch (Exception e) { e.printStackTrace(); } } @@ -1212,7 +1211,7 @@ public class AccountsVM extends AndroidViewModel { if (editFiltersResponse.isSuccessful()) { filter = editFiltersResponse.body(); } - } catch (IOException e) { + } catch (Exception e) { e.printStackTrace(); } } @@ -1236,7 +1235,7 @@ public class AccountsVM extends AndroidViewModel { if (removeFilterCall != null) { try { removeFilterCall.execute(); - } catch (IOException e) { + } catch (Exception e) { e.printStackTrace(); } } @@ -1270,7 +1269,7 @@ public class AccountsVM extends AndroidViewModel { if (reportRequestsResponse.isSuccessful()) { report = reportRequestsResponse.body(); } - } catch (IOException e) { + } catch (Exception e) { e.printStackTrace(); } } @@ -1303,7 +1302,7 @@ public class AccountsVM extends AndroidViewModel { accounts.accounts = SpannableHelper.convertAccounts(getApplication().getApplicationContext(), accountList); accounts.pagination = MastodonHelper.getPagination(followRequestsResponse.headers()); } - } catch (IOException e) { + } catch (Exception e) { e.printStackTrace(); } Handler mainHandler = new Handler(Looper.getMainLooper()); @@ -1332,7 +1331,7 @@ public class AccountsVM extends AndroidViewModel { if (acceptFollowResponse.isSuccessful()) { relationShip = acceptFollowResponse.body(); } - } catch (IOException e) { + } catch (Exception e) { e.printStackTrace(); } } @@ -1362,7 +1361,7 @@ public class AccountsVM extends AndroidViewModel { if (rejectFollowResponse.isSuccessful()) { relationShip = rejectFollowResponse.body(); } - } catch (IOException e) { + } catch (Exception e) { e.printStackTrace(); } } @@ -1392,7 +1391,7 @@ public class AccountsVM extends AndroidViewModel { if (endorsementsResponse.isSuccessful()) { accountList = endorsementsResponse.body(); } - } catch (IOException e) { + } catch (Exception e) { e.printStackTrace(); } } @@ -1421,7 +1420,7 @@ public class AccountsVM extends AndroidViewModel { if (getFeaturedTagsResponse.isSuccessful()) { featuredTagList = getFeaturedTagsResponse.body(); } - } catch (IOException e) { + } catch (Exception e) { e.printStackTrace(); } Handler mainHandler = new Handler(Looper.getMainLooper()); @@ -1451,7 +1450,7 @@ public class AccountsVM extends AndroidViewModel { if (addFeaturedTagResponse.isSuccessful()) { featuredTag = addFeaturedTagResponse.body(); } - } catch (IOException e) { + } catch (Exception e) { e.printStackTrace(); } } @@ -1475,7 +1474,7 @@ public class AccountsVM extends AndroidViewModel { if (removeFeaturedTagCall != null) { try { removeFeaturedTagCall.execute(); - } catch (IOException e) { + } catch (Exception e) { e.printStackTrace(); } } @@ -1499,7 +1498,7 @@ public class AccountsVM extends AndroidViewModel { if (featuredTagsSuggestionsResponse.isSuccessful()) { tagList = featuredTagsSuggestionsResponse.body(); } - } catch (IOException e) { + } catch (Exception e) { e.printStackTrace(); } } @@ -1528,7 +1527,7 @@ public class AccountsVM extends AndroidViewModel { if (preferencesResponse.isSuccessful()) { preferences = preferencesResponse.body(); } - } catch (IOException e) { + } catch (Exception e) { e.printStackTrace(); } } @@ -1558,7 +1557,7 @@ public class AccountsVM extends AndroidViewModel { if (suggestionsResponse.isSuccessful()) { accountList = suggestionsResponse.body(); } - } catch (IOException e) { + } catch (Exception e) { e.printStackTrace(); } } @@ -1582,7 +1581,7 @@ public class AccountsVM extends AndroidViewModel { if (removeSuggestionCall != null) { try { removeSuggestionCall.execute(); - } catch (IOException e) { + } catch (Exception e) { e.printStackTrace(); } } diff --git a/app/src/main/java/app/fedilab/android/viewmodel/mastodon/AdminVM.java b/app/src/main/java/app/fedilab/android/viewmodel/mastodon/AdminVM.java index c73e6021..254566e6 100644 --- a/app/src/main/java/app/fedilab/android/viewmodel/mastodon/AdminVM.java +++ b/app/src/main/java/app/fedilab/android/viewmodel/mastodon/AdminVM.java @@ -23,7 +23,6 @@ import androidx.lifecycle.AndroidViewModel; import androidx.lifecycle.LiveData; import androidx.lifecycle.MutableLiveData; -import java.io.IOException; import java.util.List; import java.util.concurrent.TimeUnit; @@ -119,7 +118,7 @@ public class AdminVM extends AndroidViewModel { adminAccounts.adminAccounts = getAccountsResponse.body(); adminAccounts.pagination = MastodonHelper.getPagination(getAccountsResponse.headers()); } - } catch (IOException e) { + } catch (Exception e) { e.printStackTrace(); } } @@ -150,7 +149,7 @@ public class AdminVM extends AndroidViewModel { if (getAccountResponse.isSuccessful()) { adminAccount = getAccountResponse.body(); } - } catch (IOException e) { + } catch (Exception e) { e.printStackTrace(); } } @@ -188,7 +187,7 @@ public class AdminVM extends AndroidViewModel { if (performActionCall != null) { try { performActionCall.execute(); - } catch (IOException e) { + } catch (Exception e) { e.printStackTrace(); } } @@ -215,7 +214,7 @@ public class AdminVM extends AndroidViewModel { if (approveResponse.isSuccessful()) { adminAccount = approveResponse.body(); } - } catch (IOException e) { + } catch (Exception e) { e.printStackTrace(); } } @@ -247,7 +246,7 @@ public class AdminVM extends AndroidViewModel { if (rejectResponse.isSuccessful()) { adminAccount = rejectResponse.body(); } - } catch (IOException e) { + } catch (Exception e) { e.printStackTrace(); } } @@ -279,7 +278,7 @@ public class AdminVM extends AndroidViewModel { if (enableResponse.isSuccessful()) { adminAccount = enableResponse.body(); } - } catch (IOException e) { + } catch (Exception e) { e.printStackTrace(); } } @@ -311,7 +310,7 @@ public class AdminVM extends AndroidViewModel { if (unsilenceResponse.isSuccessful()) { adminAccount = unsilenceResponse.body(); } - } catch (IOException e) { + } catch (Exception e) { e.printStackTrace(); } } @@ -343,7 +342,7 @@ public class AdminVM extends AndroidViewModel { if (unsuspendResponse.isSuccessful()) { adminAccount = unsuspendResponse.body(); } - } catch (IOException e) { + } catch (Exception e) { e.printStackTrace(); } } @@ -382,7 +381,7 @@ public class AdminVM extends AndroidViewModel { adminReports.adminReports = adminReportList; adminReports.pagination = MastodonHelper.getPagination(getReportsResponse.headers()); } - } catch (IOException e) { + } catch (Exception e) { e.printStackTrace(); } } @@ -412,7 +411,7 @@ public class AdminVM extends AndroidViewModel { if (getReportResponse.isSuccessful()) { adminReport = getReportResponse.body(); } - } catch (IOException e) { + } catch (Exception e) { e.printStackTrace(); } } @@ -443,7 +442,7 @@ public class AdminVM extends AndroidViewModel { if (assignToSelfResponse.isSuccessful()) { adminReport = assignToSelfResponse.body(); } - } catch (IOException e) { + } catch (Exception e) { e.printStackTrace(); } } @@ -474,7 +473,7 @@ public class AdminVM extends AndroidViewModel { if (unassignResponse.isSuccessful()) { adminReport = unassignResponse.body(); } - } catch (IOException e) { + } catch (Exception e) { e.printStackTrace(); } } @@ -505,7 +504,7 @@ public class AdminVM extends AndroidViewModel { if (resolvedResponse.isSuccessful()) { adminReport = resolvedResponse.body(); } - } catch (IOException e) { + } catch (Exception e) { e.printStackTrace(); } } @@ -536,7 +535,7 @@ public class AdminVM extends AndroidViewModel { if (reopenResponse.isSuccessful()) { adminReport = reopenResponse.body(); } - } catch (IOException e) { + } catch (Exception e) { e.printStackTrace(); } } diff --git a/app/src/main/java/app/fedilab/android/viewmodel/mastodon/AnnouncementsVM.java b/app/src/main/java/app/fedilab/android/viewmodel/mastodon/AnnouncementsVM.java index b4f37082..c9ce5251 100644 --- a/app/src/main/java/app/fedilab/android/viewmodel/mastodon/AnnouncementsVM.java +++ b/app/src/main/java/app/fedilab/android/viewmodel/mastodon/AnnouncementsVM.java @@ -23,7 +23,6 @@ import androidx.lifecycle.AndroidViewModel; import androidx.lifecycle.LiveData; import androidx.lifecycle.MutableLiveData; -import java.io.IOException; import java.util.List; import java.util.concurrent.TimeUnit; @@ -80,7 +79,7 @@ public class AnnouncementsVM extends AndroidViewModel { if (getAnnouncementsResponse.isSuccessful()) { announcementList = getAnnouncementsResponse.body(); } - } catch (IOException e) { + } catch (Exception e) { e.printStackTrace(); } } @@ -106,7 +105,7 @@ public class AnnouncementsVM extends AndroidViewModel { if (dismissCall != null) { try { dismissCall.execute(); - } catch (IOException e) { + } catch (Exception e) { e.printStackTrace(); } } @@ -128,7 +127,7 @@ public class AnnouncementsVM extends AndroidViewModel { if (addReactionCall != null) { try { addReactionCall.execute(); - } catch (IOException e) { + } catch (Exception e) { e.printStackTrace(); } } @@ -150,7 +149,7 @@ public class AnnouncementsVM extends AndroidViewModel { if (removeReactionCall != null) { try { removeReactionCall.execute(); - } catch (IOException e) { + } catch (Exception e) { e.printStackTrace(); } } diff --git a/app/src/main/java/app/fedilab/android/viewmodel/mastodon/AppsVM.java b/app/src/main/java/app/fedilab/android/viewmodel/mastodon/AppsVM.java index 76911ab5..bfa73628 100644 --- a/app/src/main/java/app/fedilab/android/viewmodel/mastodon/AppsVM.java +++ b/app/src/main/java/app/fedilab/android/viewmodel/mastodon/AppsVM.java @@ -23,7 +23,6 @@ import androidx.lifecycle.AndroidViewModel; import androidx.lifecycle.LiveData; import androidx.lifecycle.MutableLiveData; -import java.io.IOException; import java.util.concurrent.TimeUnit; import app.fedilab.android.client.endpoints.MastodonAppsService; @@ -88,7 +87,7 @@ public class AppsVM extends AndroidViewModel { if (appResponse.isSuccessful()) { app = appResponse.body(); } - } catch (IOException e) { + } catch (Exception e) { e.printStackTrace(); } } @@ -117,7 +116,7 @@ public class AppsVM extends AndroidViewModel { if (appResponse.isSuccessful()) { app = appResponse.body(); } - } catch (IOException e) { + } catch (Exception e) { e.printStackTrace(); } } diff --git a/app/src/main/java/app/fedilab/android/viewmodel/mastodon/InstanceSocialVM.java b/app/src/main/java/app/fedilab/android/viewmodel/mastodon/InstanceSocialVM.java index a4e83f10..ecbffc63 100644 --- a/app/src/main/java/app/fedilab/android/viewmodel/mastodon/InstanceSocialVM.java +++ b/app/src/main/java/app/fedilab/android/viewmodel/mastodon/InstanceSocialVM.java @@ -22,7 +22,6 @@ import androidx.annotation.NonNull; import androidx.lifecycle.AndroidViewModel; import androidx.lifecycle.MutableLiveData; -import java.io.IOException; import java.util.concurrent.TimeUnit; import app.fedilab.android.client.entities.app.InstanceSocial; @@ -77,7 +76,7 @@ public class InstanceSocialVM extends AndroidViewModel { Runnable myRunnable = () -> instanceSocialMutableLiveData.setValue(response.body()); mainHandler.post(myRunnable); } - } catch (IOException e) { + } catch (Exception e) { e.printStackTrace(); } }).start(); diff --git a/app/src/main/java/app/fedilab/android/viewmodel/mastodon/InstancesVM.java b/app/src/main/java/app/fedilab/android/viewmodel/mastodon/InstancesVM.java index 6a1fec1b..e44bf7f6 100644 --- a/app/src/main/java/app/fedilab/android/viewmodel/mastodon/InstancesVM.java +++ b/app/src/main/java/app/fedilab/android/viewmodel/mastodon/InstancesVM.java @@ -23,7 +23,6 @@ import androidx.lifecycle.AndroidViewModel; import androidx.lifecycle.LiveData; import androidx.lifecycle.MutableLiveData; -import java.io.IOException; import java.util.ArrayList; import java.util.List; import java.util.concurrent.TimeUnit; @@ -80,7 +79,7 @@ public class InstancesVM extends AndroidViewModel { if (emojiResponse.isSuccessful()) { emojiInstance.emojiList = emojiResponse.body(); } - } catch (IOException e) { + } catch (Exception e) { e.printStackTrace(); } } @@ -113,7 +112,7 @@ public class InstancesVM extends AndroidViewModel { instanceInfo.info = instanceResponse.body(); } - } catch (IOException e) { + } catch (Exception e) { e.printStackTrace(); } } diff --git a/app/src/main/java/app/fedilab/android/viewmodel/mastodon/JoinInstancesVM.java b/app/src/main/java/app/fedilab/android/viewmodel/mastodon/JoinInstancesVM.java index 61b8c5c9..2909572c 100644 --- a/app/src/main/java/app/fedilab/android/viewmodel/mastodon/JoinInstancesVM.java +++ b/app/src/main/java/app/fedilab/android/viewmodel/mastodon/JoinInstancesVM.java @@ -23,7 +23,6 @@ import androidx.lifecycle.AndroidViewModel; import androidx.lifecycle.LiveData; import androidx.lifecycle.MutableLiveData; -import java.io.IOException; import java.util.List; import java.util.concurrent.TimeUnit; @@ -87,7 +86,7 @@ public class JoinInstancesVM extends AndroidViewModel { if (listResponse.isSuccessful()) { joinMastodonInstanceList = listResponse.body(); } - } catch (IOException e) { + } catch (Exception e) { e.printStackTrace(); } } diff --git a/app/src/main/java/app/fedilab/android/viewmodel/mastodon/NodeInfoVM.java b/app/src/main/java/app/fedilab/android/viewmodel/mastodon/NodeInfoVM.java index de08ccc5..522ccf54 100644 --- a/app/src/main/java/app/fedilab/android/viewmodel/mastodon/NodeInfoVM.java +++ b/app/src/main/java/app/fedilab/android/viewmodel/mastodon/NodeInfoVM.java @@ -24,7 +24,6 @@ import androidx.lifecycle.AndroidViewModel; import androidx.lifecycle.LiveData; import androidx.lifecycle.MutableLiveData; -import java.io.IOException; import java.util.concurrent.TimeUnit; import app.fedilab.android.client.NodeInfoService; @@ -85,12 +84,12 @@ public class NodeInfoVM extends AndroidViewModel { if (response.isSuccessful() && response.body() != null) { nodeInfo = response.body(); } - } catch (IOException e) { + } catch (Exception e) { e.printStackTrace(); } } } - } catch (IOException e) { + } catch (Exception e) { e.printStackTrace(); } } diff --git a/app/src/main/java/app/fedilab/android/viewmodel/mastodon/NotificationsVM.java b/app/src/main/java/app/fedilab/android/viewmodel/mastodon/NotificationsVM.java index 13355349..15faaf60 100644 --- a/app/src/main/java/app/fedilab/android/viewmodel/mastodon/NotificationsVM.java +++ b/app/src/main/java/app/fedilab/android/viewmodel/mastodon/NotificationsVM.java @@ -23,7 +23,6 @@ import androidx.lifecycle.AndroidViewModel; import androidx.lifecycle.LiveData; import androidx.lifecycle.MutableLiveData; -import java.io.IOException; import java.util.List; import java.util.concurrent.TimeUnit; @@ -109,7 +108,7 @@ public class NotificationsVM extends AndroidViewModel { } notifications.pagination = MastodonHelper.getPagination(notificationsResponse.headers()); } - } catch (IOException e) { + } catch (Exception e) { e.printStackTrace(); } } @@ -146,7 +145,7 @@ public class NotificationsVM extends AndroidViewModel { notification.status = SpannableHelper.convertStatus(getApplication().getApplicationContext(), notification.status); } } - } catch (IOException e) { + } catch (Exception e) { e.printStackTrace(); } } @@ -173,7 +172,7 @@ public class NotificationsVM extends AndroidViewModel { if (voidCall != null) { try { voidCall.execute(); - } catch (IOException e) { + } catch (Exception e) { e.printStackTrace(); } } @@ -201,7 +200,7 @@ public class NotificationsVM extends AndroidViewModel { if (voidCall != null) { try { voidCall.execute(); - } catch (IOException e) { + } catch (Exception e) { e.printStackTrace(); } } @@ -249,7 +248,7 @@ public class NotificationsVM extends AndroidViewModel { if (pushSubscriptionResponse.isSuccessful()) { pushSubscription = pushSubscriptionResponse.body(); } - } catch (IOException e) { + } catch (Exception e) { e.printStackTrace(); } } @@ -282,7 +281,7 @@ public class NotificationsVM extends AndroidViewModel { if (pushSubscriptionResponse.isSuccessful()) { pushSubscription = pushSubscriptionResponse.body(); } - } catch (IOException e) { + } catch (Exception e) { e.printStackTrace(); } } @@ -325,7 +324,7 @@ public class NotificationsVM extends AndroidViewModel { if (pushSubscriptionResponse.isSuccessful()) { pushSubscription = pushSubscriptionResponse.body(); } - } catch (IOException e) { + } catch (Exception e) { e.printStackTrace(); } } @@ -352,7 +351,7 @@ public class NotificationsVM extends AndroidViewModel { if (voidCall != null) { try { voidCall.execute(); - } catch (IOException e) { + } catch (Exception e) { e.printStackTrace(); } } diff --git a/app/src/main/java/app/fedilab/android/viewmodel/mastodon/OauthVM.java b/app/src/main/java/app/fedilab/android/viewmodel/mastodon/OauthVM.java index 38bc0718..4e1646f0 100644 --- a/app/src/main/java/app/fedilab/android/viewmodel/mastodon/OauthVM.java +++ b/app/src/main/java/app/fedilab/android/viewmodel/mastodon/OauthVM.java @@ -23,7 +23,6 @@ import androidx.lifecycle.AndroidViewModel; import androidx.lifecycle.LiveData; import androidx.lifecycle.MutableLiveData; -import java.io.IOException; import java.util.concurrent.TimeUnit; import app.fedilab.android.client.endpoints.MastodonAppsService; @@ -91,7 +90,7 @@ public class OauthVM extends AndroidViewModel { if (tokenResponse.isSuccessful()) { token = tokenResponse.body(); } - } catch (IOException e) { + } catch (Exception e) { e.printStackTrace(); } } @@ -121,7 +120,7 @@ public class OauthVM extends AndroidViewModel { if (voidCall != null) { try { voidCall.execute(); - } catch (IOException e) { + } catch (Exception e) { e.printStackTrace(); } } diff --git a/app/src/main/java/app/fedilab/android/viewmodel/mastodon/ReorderVM.java b/app/src/main/java/app/fedilab/android/viewmodel/mastodon/ReorderVM.java index 7df68955..2c391f2f 100644 --- a/app/src/main/java/app/fedilab/android/viewmodel/mastodon/ReorderVM.java +++ b/app/src/main/java/app/fedilab/android/viewmodel/mastodon/ReorderVM.java @@ -23,7 +23,6 @@ import androidx.lifecycle.AndroidViewModel; import androidx.lifecycle.LiveData; import androidx.lifecycle.MutableLiveData; -import java.io.IOException; import java.util.ArrayList; import java.util.concurrent.TimeUnit; @@ -156,7 +155,7 @@ public class ReorderVM extends AndroidViewModel { } } } - } catch (IOException e) { + } catch (Exception e) { e.printStackTrace(); } } diff --git a/app/src/main/java/app/fedilab/android/viewmodel/mastodon/SearchVM.java b/app/src/main/java/app/fedilab/android/viewmodel/mastodon/SearchVM.java index a454d24f..c1b09761 100644 --- a/app/src/main/java/app/fedilab/android/viewmodel/mastodon/SearchVM.java +++ b/app/src/main/java/app/fedilab/android/viewmodel/mastodon/SearchVM.java @@ -23,7 +23,6 @@ import androidx.lifecycle.AndroidViewModel; import androidx.lifecycle.LiveData; import androidx.lifecycle.MutableLiveData; -import java.io.IOException; import java.util.ArrayList; import java.util.List; import java.util.concurrent.TimeUnit; @@ -120,7 +119,7 @@ public class SearchVM extends AndroidViewModel { } } } - } catch (IOException e) { + } catch (Exception e) { e.printStackTrace(); } } diff --git a/app/src/main/java/app/fedilab/android/viewmodel/mastodon/StatusesVM.java b/app/src/main/java/app/fedilab/android/viewmodel/mastodon/StatusesVM.java index b7b3c449..71d68934 100644 --- a/app/src/main/java/app/fedilab/android/viewmodel/mastodon/StatusesVM.java +++ b/app/src/main/java/app/fedilab/android/viewmodel/mastodon/StatusesVM.java @@ -25,7 +25,6 @@ import androidx.lifecycle.AndroidViewModel; import androidx.lifecycle.LiveData; import androidx.lifecycle.MutableLiveData; -import java.io.IOException; import java.util.Date; import java.util.List; import java.util.concurrent.TimeUnit; @@ -127,7 +126,7 @@ public class StatusesVM extends AndroidViewModel { if (attachmentResponse.isSuccessful()) { attachment = attachmentResponse.body(); } - } catch (IOException e) { + } catch (Exception e) { e.printStackTrace(); } } @@ -187,7 +186,7 @@ public class StatusesVM extends AndroidViewModel { if (statusResponse.isSuccessful()) { status = statusResponse.body(); } - } catch (IOException e) { + } catch (Exception e) { e.printStackTrace(); } } @@ -249,7 +248,7 @@ public class StatusesVM extends AndroidViewModel { if (scheduledStatusResponse.isSuccessful()) { scheduledStatus = scheduledStatusResponse.body(); } - } catch (IOException e) { + } catch (Exception e) { e.printStackTrace(); } } @@ -281,7 +280,7 @@ public class StatusesVM extends AndroidViewModel { if (statusResponse.isSuccessful()) { status = SpannableHelper.convertStatus(getApplication().getApplicationContext(), statusResponse.body()); } - } catch (IOException e) { + } catch (Exception e) { e.printStackTrace(); } } @@ -313,7 +312,7 @@ public class StatusesVM extends AndroidViewModel { if (statusResponse.isSuccessful()) { status = statusResponse.body(); } - } catch (IOException e) { + } catch (Exception e) { e.printStackTrace(); } } @@ -366,7 +365,7 @@ public class StatusesVM extends AndroidViewModel { } } - } catch (IOException e) { + } catch (Exception e) { e.printStackTrace(); } } @@ -409,7 +408,7 @@ public class StatusesVM extends AndroidViewModel { accounts = SpannableHelper.convertAccounts(getApplication().getApplicationContext(), accountsResponse.body()); } headers = accountsResponse.headers(); - } catch (IOException e) { + } catch (Exception e) { e.printStackTrace(); } } @@ -454,7 +453,7 @@ public class StatusesVM extends AndroidViewModel { accounts = SpannableHelper.convertAccounts(getApplication().getApplicationContext(), accountsResponse.body()); } headers = accountsResponse.headers(); - } catch (IOException e) { + } catch (Exception e) { e.printStackTrace(); } } @@ -493,7 +492,7 @@ public class StatusesVM extends AndroidViewModel { errorMessage = statusResponse.errorBody().string(); } } - } catch (IOException e) { + } catch (Exception e) { e.printStackTrace(); errorMessage = e.getMessage() != null ? e.getMessage() : getApplication().getString(R.string.toast_error); } @@ -537,7 +536,7 @@ public class StatusesVM extends AndroidViewModel { errorMessage = statusResponse.errorBody().string(); } } - } catch (IOException e) { + } catch (Exception e) { e.printStackTrace(); errorMessage = e.getMessage() != null ? e.getMessage() : getApplication().getString(R.string.toast_error); } @@ -583,7 +582,7 @@ public class StatusesVM extends AndroidViewModel { errorMessage = statusResponse.errorBody().string(); } } - } catch (IOException e) { + } catch (Exception e) { e.printStackTrace(); errorMessage = e.getMessage() != null ? e.getMessage() : getApplication().getString(R.string.toast_error); } @@ -627,7 +626,7 @@ public class StatusesVM extends AndroidViewModel { errorMessage = statusResponse.errorBody().string(); } } - } catch (IOException e) { + } catch (Exception e) { e.printStackTrace(); errorMessage = e.getMessage() != null ? e.getMessage() : getApplication().getString(R.string.toast_error); } @@ -671,7 +670,7 @@ public class StatusesVM extends AndroidViewModel { errorMessage = statusResponse.errorBody().string(); } } - } catch (IOException e) { + } catch (Exception e) { e.printStackTrace(); errorMessage = e.getMessage() != null ? e.getMessage() : getApplication().getString(R.string.toast_error); } @@ -715,7 +714,7 @@ public class StatusesVM extends AndroidViewModel { errorMessage = statusResponse.errorBody().string(); } } - } catch (IOException e) { + } catch (Exception e) { e.printStackTrace(); errorMessage = e.getMessage() != null ? e.getMessage() : getApplication().getString(R.string.toast_error); } @@ -759,7 +758,7 @@ public class StatusesVM extends AndroidViewModel { errorMessage = statusResponse.errorBody().string(); } } - } catch (IOException e) { + } catch (Exception e) { e.printStackTrace(); errorMessage = e.getMessage() != null ? e.getMessage() : getApplication().getString(R.string.toast_error); } @@ -803,7 +802,7 @@ public class StatusesVM extends AndroidViewModel { errorMessage = statusResponse.errorBody().string(); } } - } catch (IOException e) { + } catch (Exception e) { e.printStackTrace(); errorMessage = e.getMessage() != null ? e.getMessage() : getApplication().getString(R.string.toast_error); } @@ -847,7 +846,7 @@ public class StatusesVM extends AndroidViewModel { errorMessage = statusResponse.errorBody().string(); } } - } catch (IOException e) { + } catch (Exception e) { e.printStackTrace(); errorMessage = e.getMessage() != null ? e.getMessage() : getApplication().getString(R.string.toast_error); } @@ -891,7 +890,7 @@ public class StatusesVM extends AndroidViewModel { errorMessage = statusResponse.errorBody().string(); } } - } catch (IOException e) { + } catch (Exception e) { e.printStackTrace(); errorMessage = e.getMessage() != null ? e.getMessage() : getApplication().getString(R.string.toast_error); } @@ -930,7 +929,7 @@ public class StatusesVM extends AndroidViewModel { if (cardResponse.isSuccessful()) { card = cardResponse.body(); } - } catch (IOException e) { + } catch (Exception e) { e.printStackTrace(); } } @@ -962,7 +961,7 @@ public class StatusesVM extends AndroidViewModel { if (attachmentResponse.isSuccessful()) { attachment = attachmentResponse.body(); } - } catch (IOException e) { + } catch (Exception e) { e.printStackTrace(); } } @@ -1008,7 +1007,7 @@ public class StatusesVM extends AndroidViewModel { if (attachmentResponse.isSuccessful()) { attachment = attachmentResponse.body(); } - } catch (IOException e) { + } catch (Exception e) { e.printStackTrace(); } } @@ -1040,7 +1039,7 @@ public class StatusesVM extends AndroidViewModel { if (pollResponse.isSuccessful()) { poll = pollResponse.body(); } - } catch (IOException e) { + } catch (Exception e) { e.printStackTrace(); } } @@ -1073,7 +1072,7 @@ public class StatusesVM extends AndroidViewModel { if (pollResponse.isSuccessful()) { poll = pollResponse.body(); } - } catch (IOException e) { + } catch (Exception e) { e.printStackTrace(); } } @@ -1115,7 +1114,7 @@ public class StatusesVM extends AndroidViewModel { scheduledStatusList = scheduledStatusResponse.body(); pagination = MastodonHelper.getPagination(scheduledStatusResponse.headers()); } - } catch (IOException e) { + } catch (Exception e) { e.printStackTrace(); } } @@ -1149,7 +1148,7 @@ public class StatusesVM extends AndroidViewModel { if (scheduledStatusResponse.isSuccessful()) { scheduledStatus = scheduledStatusResponse.body(); } - } catch (IOException e) { + } catch (Exception e) { e.printStackTrace(); } } @@ -1181,7 +1180,7 @@ public class StatusesVM extends AndroidViewModel { if (scheduledStatusResponse.isSuccessful()) { scheduledStatus = scheduledStatusResponse.body(); } - } catch (IOException e) { + } catch (Exception e) { e.printStackTrace(); } } @@ -1209,7 +1208,7 @@ public class StatusesVM extends AndroidViewModel { if (voidCall != null) { try { voidCall.execute(); - } catch (IOException e) { + } catch (Exception e) { e.printStackTrace(); } } diff --git a/app/src/main/java/app/fedilab/android/viewmodel/mastodon/TimelinesVM.java b/app/src/main/java/app/fedilab/android/viewmodel/mastodon/TimelinesVM.java index c4dec0cd..d40df65e 100644 --- a/app/src/main/java/app/fedilab/android/viewmodel/mastodon/TimelinesVM.java +++ b/app/src/main/java/app/fedilab/android/viewmodel/mastodon/TimelinesVM.java @@ -24,7 +24,6 @@ import androidx.lifecycle.AndroidViewModel; import androidx.lifecycle.LiveData; import androidx.lifecycle.MutableLiveData; -import java.io.IOException; import java.util.List; import java.util.concurrent.TimeUnit; @@ -118,7 +117,7 @@ public class TimelinesVM extends AndroidViewModel { statuses.statuses = SpannableHelper.convertStatus(getApplication().getApplicationContext(), filteredStatuses); statuses.pagination = MastodonHelper.getPagination(publicTlResponse.headers()); } - } catch (IOException e) { + } catch (Exception e) { e.printStackTrace(); } } @@ -167,7 +166,7 @@ public class TimelinesVM extends AndroidViewModel { statuses.statuses = SpannableHelper.convertStatus(getApplication().getApplicationContext(), filteredStatuses); statuses.pagination = MastodonHelper.getPagination(hashTagTlResponse.headers()); } - } catch (IOException e) { + } catch (Exception e) { e.printStackTrace(); } } @@ -223,7 +222,7 @@ public class TimelinesVM extends AndroidViewModel { } } } - } catch (IOException e) { + } catch (Exception e) { e.printStackTrace(); } } @@ -324,7 +323,7 @@ public class TimelinesVM extends AndroidViewModel { statuses.statuses = SpannableHelper.convertStatus(getApplication().getApplicationContext(), listTlResponse.body()); statuses.pagination = MastodonHelper.getPagination(listTlResponse.headers()); } - } catch (IOException e) { + } catch (Exception e) { e.printStackTrace(); } } @@ -364,7 +363,7 @@ public class TimelinesVM extends AndroidViewModel { } conversations.pagination = MastodonHelper.getPagination(conversationsResponse.headers()); } - } catch (IOException e) { + } catch (Exception e) { e.printStackTrace(); } } @@ -389,7 +388,7 @@ public class TimelinesVM extends AndroidViewModel { if (deleteStatusCall != null) { try { deleteStatusCall.execute(); - } catch (IOException e) { + } catch (Exception e) { e.printStackTrace(); } } @@ -414,7 +413,7 @@ public class TimelinesVM extends AndroidViewModel { if (markReadConversationResponse.isSuccessful()) { status = markReadConversationResponse.body(); } - } catch (IOException e) { + } catch (Exception e) { e.printStackTrace(); } } @@ -443,7 +442,7 @@ public class TimelinesVM extends AndroidViewModel { if (getListsResponse.isSuccessful()) { mastodonListList = getListsResponse.body(); } - } catch (IOException e) { + } catch (Exception e) { e.printStackTrace(); } } @@ -474,7 +473,7 @@ public class TimelinesVM extends AndroidViewModel { if (getListResponse.isSuccessful()) { mastodonList = getListResponse.body(); } - } catch (IOException e) { + } catch (Exception e) { e.printStackTrace(); } } @@ -505,7 +504,7 @@ public class TimelinesVM extends AndroidViewModel { if (createListResponse.isSuccessful()) { mastodonList = createListResponse.body(); } - } catch (IOException e) { + } catch (Exception e) { e.printStackTrace(); } } @@ -537,7 +536,7 @@ public class TimelinesVM extends AndroidViewModel { if (updateListResponse.isSuccessful()) { mastodonList = updateListResponse.body(); } - } catch (IOException e) { + } catch (Exception e) { e.printStackTrace(); } } @@ -561,7 +560,7 @@ public class TimelinesVM extends AndroidViewModel { if (deleteListCall != null) { try { deleteListCall.execute(); - } catch (IOException e) { + } catch (Exception e) { e.printStackTrace(); } } @@ -586,7 +585,7 @@ public class TimelinesVM extends AndroidViewModel { if (getAccountsInListResponse.isSuccessful()) { accountList = getAccountsInListResponse.body(); } - } catch (IOException e) { + } catch (Exception e) { e.printStackTrace(); } } @@ -611,7 +610,7 @@ public class TimelinesVM extends AndroidViewModel { if (addAccountsListCall != null) { try { addAccountsListCall.execute(); - } catch (IOException e) { + } catch (Exception e) { e.printStackTrace(); } } @@ -631,7 +630,7 @@ public class TimelinesVM extends AndroidViewModel { if (deleteAccountsListCall != null) { try { deleteAccountsListCall.execute(); - } catch (IOException e) { + } catch (Exception e) { e.printStackTrace(); } } @@ -682,7 +681,7 @@ public class TimelinesVM extends AndroidViewModel { if (addMarkerCall != null) { try { addMarkerCall.execute(); - } catch (IOException e) { + } catch (Exception e) { e.printStackTrace(); } }