From 70405221ea55f76f2e38c3ea0cc20e2c92478851 Mon Sep 17 00:00:00 2001 From: Thomas Date: Fri, 23 Feb 2024 09:37:54 +0100 Subject: [PATCH] clean code --- .../mastodon/activities/MediaActivity.java | 3 +- .../mastodon/activities/ReportActivity.java | 2 -- .../mastodon/client/entities/api/Tag.java | 3 +- .../android/mastodon/helper/Helper.java | 2 +- .../mastodon/helper/MastodonHelper.java | 2 +- .../ui/drawer/NotificationAdapter.java | 33 ++++++++++++------- .../timeline/FragmentMastodonTimeline.java | 7 ++-- 7 files changed, 31 insertions(+), 21 deletions(-) diff --git a/app/src/main/java/app/fedilab/android/mastodon/activities/MediaActivity.java b/app/src/main/java/app/fedilab/android/mastodon/activities/MediaActivity.java index c78991a5..58547752 100644 --- a/app/src/main/java/app/fedilab/android/mastodon/activities/MediaActivity.java +++ b/app/src/main/java/app/fedilab/android/mastodon/activities/MediaActivity.java @@ -464,7 +464,8 @@ public class MediaActivity extends BaseTransparentActivity implements OnDownload } @Override - public void onDownloaded(String saveFilePath, String downloadUrl, Error error) {} + public void onDownloaded(String saveFilePath, String downloadUrl, Error error) { + } @Override public void onUpdateProgress(int progress) { diff --git a/app/src/main/java/app/fedilab/android/mastodon/activities/ReportActivity.java b/app/src/main/java/app/fedilab/android/mastodon/activities/ReportActivity.java index 2f7a4b22..c3b4b186 100644 --- a/app/src/main/java/app/fedilab/android/mastodon/activities/ReportActivity.java +++ b/app/src/main/java/app/fedilab/android/mastodon/activities/ReportActivity.java @@ -22,8 +22,6 @@ import android.widget.RadioButton; import androidx.annotation.Nullable; import androidx.appcompat.widget.LinearLayoutCompat; -import androidx.fragment.app.FragmentManager; -import androidx.fragment.app.FragmentTransaction; import androidx.lifecycle.ViewModelProvider; import androidx.recyclerview.widget.LinearLayoutManager; diff --git a/app/src/main/java/app/fedilab/android/mastodon/client/entities/api/Tag.java b/app/src/main/java/app/fedilab/android/mastodon/client/entities/api/Tag.java index c2c9288d..ac59de9e 100644 --- a/app/src/main/java/app/fedilab/android/mastodon/client/entities/api/Tag.java +++ b/app/src/main/java/app/fedilab/android/mastodon/client/entities/api/Tag.java @@ -45,7 +45,8 @@ public class Tag implements Serializable { for (History h : history) { try { weight += Integer.parseInt(h.accounts); - } catch (Exception ignored) {} + } catch (Exception ignored) { + } } } return weight; diff --git a/app/src/main/java/app/fedilab/android/mastodon/helper/Helper.java b/app/src/main/java/app/fedilab/android/mastodon/helper/Helper.java index eb80cfc3..9686f98d 100644 --- a/app/src/main/java/app/fedilab/android/mastodon/helper/Helper.java +++ b/app/src/main/java/app/fedilab/android/mastodon/helper/Helper.java @@ -909,7 +909,7 @@ public class Helper { if (args != null) fragment.setArguments(args); ft = fragmentManager.beginTransaction(); ft.add(containerViewId, fragment, tag); - if (backStackName != null) { + if (backStackName != null) { ft = fragmentManager.beginTransaction(); ft.addToBackStack(backStackName); } diff --git a/app/src/main/java/app/fedilab/android/mastodon/helper/MastodonHelper.java b/app/src/main/java/app/fedilab/android/mastodon/helper/MastodonHelper.java index 5e9f8c56..97c1567c 100644 --- a/app/src/main/java/app/fedilab/android/mastodon/helper/MastodonHelper.java +++ b/app/src/main/java/app/fedilab/android/mastodon/helper/MastodonHelper.java @@ -499,7 +499,7 @@ public class MastodonHelper { accountId = account.id; acct = account.acct; } - accountsVM.mute(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, accountId, true, (int) delayToPass*1000) + accountsVM.mute(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, accountId, true, (int) delayToPass * 1000) .observe((LifecycleOwner) context, relationShip -> { if (listener != null) { listener.onTimedMute(relationShip); diff --git a/app/src/main/java/app/fedilab/android/mastodon/ui/drawer/NotificationAdapter.java b/app/src/main/java/app/fedilab/android/mastodon/ui/drawer/NotificationAdapter.java index f873bd8a..67ca291a 100644 --- a/app/src/main/java/app/fedilab/android/mastodon/ui/drawer/NotificationAdapter.java +++ b/app/src/main/java/app/fedilab/android/mastodon/ui/drawer/NotificationAdapter.java @@ -140,56 +140,67 @@ public class NotificationAdapter extends RecyclerView.Adapter { return TYPE_FOLLOW; - case "follow_request": + } + case "follow_request" -> { return TYPE_FOLLOW_REQUEST; - case "mention": + } + case "mention" -> { if (notificationList.get(position).status != null) { return TYPE_MENTION; } else { return TYPE_HIDDEN; } - case "reblog": + } + case "reblog" -> { if (notificationList.get(position).status != null) { return TYPE_REBLOG; } else { return TYPE_HIDDEN; } - case "update": + } + case "update" -> { if (notificationList.get(position).status != null) { return TYPE_UPDATE; } else { return TYPE_HIDDEN; } - case "favourite": + } + case "favourite" -> { if (notificationList.get(position).status != null) { return TYPE_FAVOURITE; } else { return TYPE_HIDDEN; } - case "poll": + } + case "poll" -> { if (notificationList.get(position).status != null) { return TYPE_POLL; } else { return TYPE_HIDDEN; } - case "status": + } + case "status" -> { if (notificationList.get(position).status != null) { return TYPE_STATUS; } else { return TYPE_HIDDEN; } - case "admin.sign_up": + } + case "admin.sign_up" -> { return TYPE_ADMIN_SIGNUP; - case "admin.report": + } + case "admin.report" -> { return TYPE_ADMIN_REPORT; - case "pleroma:emoji_reaction": + } + case "pleroma:emoji_reaction" -> { if (notificationList.get(position).status != null) { return TYPE_REACTION; } else { return TYPE_HIDDEN; } + } } } return super.getItemViewType(position); diff --git a/app/src/main/java/app/fedilab/android/mastodon/ui/fragment/timeline/FragmentMastodonTimeline.java b/app/src/main/java/app/fedilab/android/mastodon/ui/fragment/timeline/FragmentMastodonTimeline.java index b175eff9..10e91b28 100644 --- a/app/src/main/java/app/fedilab/android/mastodon/ui/fragment/timeline/FragmentMastodonTimeline.java +++ b/app/src/main/java/app/fedilab/android/mastodon/ui/fragment/timeline/FragmentMastodonTimeline.java @@ -212,7 +212,6 @@ public class FragmentMastodonTimeline extends Fragment implements StatusAdapter. private String publicTrendsDomain; - //Allow to recreate data when detaching/attaching fragment public void recreate() { initialStatuses = null; @@ -242,7 +241,7 @@ public class FragmentMastodonTimeline extends Fragment implements StatusAdapter. @Override public void onResume() { super.onResume(); - if(bundleParamsRetrieved) { + if (bundleParamsRetrieved) { initializeView(); } else { needToCallResume = true; @@ -450,7 +449,7 @@ public class FragmentMastodonTimeline extends Fragment implements StatusAdapter. } //When visiting a profile without being authenticated if (checkRemotely) { - String[] acctArray = accountTimeline!=null?accountTimeline.acct.split("@"):new String[]{}; + String[] acctArray = accountTimeline != null ? accountTimeline.acct.split("@") : new String[]{}; if (acctArray.length > 1) { remoteInstance = acctArray[1]; } @@ -505,7 +504,7 @@ public class FragmentMastodonTimeline extends Fragment implements StatusAdapter. //AND Only the first fragment will initialize its view flagLoading = false; bundleParamsRetrieved = true; - if(needToCallResume) { + if (needToCallResume) { initializeView(); needToCallResume = false; }