diff --git a/app/src/main/java/app/fedilab/android/mastodon/activities/ActionActivity.java b/app/src/main/java/app/fedilab/android/mastodon/activities/ActionActivity.java index d3c89017..6488927e 100644 --- a/app/src/main/java/app/fedilab/android/mastodon/activities/ActionActivity.java +++ b/app/src/main/java/app/fedilab/android/mastodon/activities/ActionActivity.java @@ -60,42 +60,43 @@ public class ActionActivity extends BaseBarActivity { private void displayTimeline(Timeline.TimeLineEnum type) { canGoBack = true; if (type == Timeline.TimeLineEnum.MUTED_TIMELINE || type == Timeline.TimeLineEnum.BLOCKED_TIMELINE || type == Timeline.TimeLineEnum.MUTED_TIMELINE_HOME) { - + fragmentMastodonAccount = new FragmentMastodonAccount(); + Bundle bundle = new Bundle(); + bundle.putSerializable(Helper.ARG_TIMELINE_TYPE, type); + bundle.putString(Helper.ARG_VIEW_MODEL_KEY, "FEDILAB_" + type.getValue()); + fragmentMastodonAccount.setArguments(bundle); + FragmentManager fragmentManager = getSupportFragmentManager(); + FragmentTransaction fragmentTransaction = + fragmentManager.beginTransaction(); + fragmentTransaction.replace(R.id.fragment_container, fragmentMastodonAccount); + fragmentTransaction.commit(); ThemeHelper.slideViewsToLeft(binding.buttonContainer, binding.fragmentContainer, () -> { - fragmentMastodonAccount = new FragmentMastodonAccount(); - Bundle bundle = new Bundle(); - bundle.putSerializable(Helper.ARG_TIMELINE_TYPE, type); - bundle.putString(Helper.ARG_VIEW_MODEL_KEY, "FEDILAB_" + type.getValue()); - fragmentMastodonAccount.setArguments(bundle); - FragmentManager fragmentManager = getSupportFragmentManager(); - FragmentTransaction fragmentTransaction = - fragmentManager.beginTransaction(); - fragmentTransaction.replace(R.id.fragment_container, fragmentMastodonAccount); - fragmentTransaction.commit(); + }); } else if (type == Timeline.TimeLineEnum.BLOCKED_DOMAIN_TIMELINE) { + fragmentMastodonDomainBlock = new FragmentMastodonDomainBlock(); + FragmentManager fragmentManager = getSupportFragmentManager(); + FragmentTransaction fragmentTransaction = + fragmentManager.beginTransaction(); + fragmentTransaction.replace(R.id.fragment_container, fragmentMastodonDomainBlock); + fragmentTransaction.commit(); ThemeHelper.slideViewsToLeft(binding.buttonContainer, binding.fragmentContainer, () -> { - fragmentMastodonDomainBlock = new FragmentMastodonDomainBlock(); - FragmentManager fragmentManager = getSupportFragmentManager(); - FragmentTransaction fragmentTransaction = - fragmentManager.beginTransaction(); - fragmentTransaction.replace(R.id.fragment_container, fragmentMastodonDomainBlock); - fragmentTransaction.commit(); + }); } else { - + fragmentMastodonTimeline = new FragmentMastodonTimeline(); + Bundle bundle = new Bundle(); + bundle.putSerializable(Helper.ARG_TIMELINE_TYPE, type); + bundle.putString(Helper.ARG_VIEW_MODEL_KEY, "FEDILAB_" + type.getValue()); + fragmentMastodonTimeline.setArguments(bundle); + FragmentManager fragmentManager = getSupportFragmentManager(); + FragmentTransaction fragmentTransaction = + fragmentManager.beginTransaction(); + fragmentTransaction.replace(R.id.fragment_container, fragmentMastodonTimeline); + fragmentTransaction.commit(); ThemeHelper.slideViewsToLeft(binding.buttonContainer, binding.fragmentContainer, () -> { - fragmentMastodonTimeline = new FragmentMastodonTimeline(); - Bundle bundle = new Bundle(); - bundle.putSerializable(Helper.ARG_TIMELINE_TYPE, type); - bundle.putString(Helper.ARG_VIEW_MODEL_KEY, "FEDILAB_" + type.getValue()); - fragmentMastodonTimeline.setArguments(bundle); - FragmentManager fragmentManager = getSupportFragmentManager(); - FragmentTransaction fragmentTransaction = - fragmentManager.beginTransaction(); - fragmentTransaction.replace(R.id.fragment_container, fragmentMastodonTimeline); - fragmentTransaction.commit(); + }); } diff --git a/app/src/main/java/app/fedilab/android/mastodon/activities/FollowedTagActivity.java b/app/src/main/java/app/fedilab/android/mastodon/activities/FollowedTagActivity.java index c3067a0f..db8e8e86 100644 --- a/app/src/main/java/app/fedilab/android/mastodon/activities/FollowedTagActivity.java +++ b/app/src/main/java/app/fedilab/android/mastodon/activities/FollowedTagActivity.java @@ -207,19 +207,20 @@ public class FollowedTagActivity extends BaseBarActivity implements FollowedTagA public void click(Tag tag) { this.tag = tag; canGoBack = true; + fragmentMastodonTimeline = new FragmentMastodonTimeline(); + Bundle bundle = new Bundle(); + bundle.putSerializable(Helper.ARG_SEARCH_KEYWORD, tag.name); + bundle.putSerializable(Helper.ARG_TIMELINE_TYPE, Timeline.TimeLineEnum.TAG); + setTitle(tag.name); + fragmentMastodonTimeline.setArguments(bundle); + FragmentManager fragmentManager = getSupportFragmentManager(); + FragmentTransaction fragmentTransaction = + fragmentManager.beginTransaction(); + fragmentTransaction.replace(R.id.fragment_container, fragmentMastodonTimeline); + fragmentTransaction.commit(); + invalidateOptionsMenu(); ThemeHelper.slideViewsToLeft(binding.recyclerView, binding.fragmentContainer, () -> { - fragmentMastodonTimeline = new FragmentMastodonTimeline(); - Bundle bundle = new Bundle(); - bundle.putSerializable(Helper.ARG_SEARCH_KEYWORD, tag.name); - bundle.putSerializable(Helper.ARG_TIMELINE_TYPE, Timeline.TimeLineEnum.TAG); - setTitle(tag.name); - fragmentMastodonTimeline.setArguments(bundle); - FragmentManager fragmentManager = getSupportFragmentManager(); - FragmentTransaction fragmentTransaction = - fragmentManager.beginTransaction(); - fragmentTransaction.replace(R.id.fragment_container, fragmentMastodonTimeline); - fragmentTransaction.commit(); - invalidateOptionsMenu(); + }); } } diff --git a/app/src/main/java/app/fedilab/android/mastodon/activities/MastodonListActivity.java b/app/src/main/java/app/fedilab/android/mastodon/activities/MastodonListActivity.java index 6e15f2be..a9bf7c6e 100644 --- a/app/src/main/java/app/fedilab/android/mastodon/activities/MastodonListActivity.java +++ b/app/src/main/java/app/fedilab/android/mastodon/activities/MastodonListActivity.java @@ -459,19 +459,20 @@ public class MastodonListActivity extends BaseBarActivity implements MastodonLis this.mastodonList = mastodonList; canGoBack = true; + fragmentMastodonTimeline = new FragmentMastodonTimeline(); + Bundle bundle = new Bundle(); + bundle.putSerializable(Helper.ARG_LIST_ID, mastodonList.id); + bundle.putSerializable(Helper.ARG_TIMELINE_TYPE, Timeline.TimeLineEnum.LIST); + setTitle(mastodonList.title); + fragmentMastodonTimeline.setArguments(bundle); + FragmentManager fragmentManager = getSupportFragmentManager(); + FragmentTransaction fragmentTransaction = + fragmentManager.beginTransaction(); + fragmentTransaction.replace(R.id.fragment_container, fragmentMastodonTimeline); + fragmentTransaction.commit(); + invalidateOptionsMenu(); ThemeHelper.slideViewsToLeft(binding.recyclerView, binding.fragmentContainer, () -> { - fragmentMastodonTimeline = new FragmentMastodonTimeline(); - Bundle bundle = new Bundle(); - bundle.putSerializable(Helper.ARG_LIST_ID, mastodonList.id); - bundle.putSerializable(Helper.ARG_TIMELINE_TYPE, Timeline.TimeLineEnum.LIST); - setTitle(mastodonList.title); - fragmentMastodonTimeline.setArguments(bundle); - FragmentManager fragmentManager = getSupportFragmentManager(); - FragmentTransaction fragmentTransaction = - fragmentManager.beginTransaction(); - fragmentTransaction.replace(R.id.fragment_container, fragmentMastodonTimeline); - fragmentTransaction.commit(); - invalidateOptionsMenu(); + }); } diff --git a/app/src/main/java/app/fedilab/android/mastodon/activities/admin/AdminActionActivity.java b/app/src/main/java/app/fedilab/android/mastodon/activities/admin/AdminActionActivity.java index 81065469..5def59c0 100644 --- a/app/src/main/java/app/fedilab/android/mastodon/activities/admin/AdminActionActivity.java +++ b/app/src/main/java/app/fedilab/android/mastodon/activities/admin/AdminActionActivity.java @@ -132,43 +132,46 @@ public class AdminActionActivity extends BaseBarActivity { private void displayTimeline(AdminEnum type) { canGoBack = true; if (type == REPORT) { + fragmentAdminReport = new FragmentAdminReport(); + Bundle bundle = new Bundle(); + bundle.putSerializable(Helper.ARG_TIMELINE_TYPE, type); + bundle.putString(Helper.ARG_VIEW_MODEL_KEY, "FEDILAB_" + type.getValue()); + fragmentAdminReport.setArguments(bundle); + FragmentManager fragmentManager = getSupportFragmentManager(); + FragmentTransaction fragmentTransaction = + fragmentManager.beginTransaction(); + fragmentTransaction.replace(R.id.fragment_container, fragmentAdminReport); + fragmentTransaction.commit(); ThemeHelper.slideViewsToLeft(binding.buttonContainer, binding.fragmentContainer, () -> { - fragmentAdminReport = new FragmentAdminReport(); - Bundle bundle = new Bundle(); - bundle.putSerializable(Helper.ARG_TIMELINE_TYPE, type); - bundle.putString(Helper.ARG_VIEW_MODEL_KEY, "FEDILAB_" + type.getValue()); - fragmentAdminReport.setArguments(bundle); - FragmentManager fragmentManager = getSupportFragmentManager(); - FragmentTransaction fragmentTransaction = - fragmentManager.beginTransaction(); - fragmentTransaction.replace(R.id.fragment_container, fragmentAdminReport); - fragmentTransaction.commit(); + }); } else if (type == ACCOUNT) { + fragmentAdminAccount = new FragmentAdminAccount(); + Bundle bundle = new Bundle(); + bundle.putSerializable(Helper.ARG_TIMELINE_TYPE, type); + bundle.putString(Helper.ARG_VIEW_MODEL_KEY, "FEDILAB_" + type.getValue()); + fragmentAdminAccount.setArguments(bundle); + FragmentManager fragmentManager = getSupportFragmentManager(); + FragmentTransaction fragmentTransaction = + fragmentManager.beginTransaction(); + fragmentTransaction.replace(R.id.fragment_container, fragmentAdminAccount); + fragmentTransaction.commit(); ThemeHelper.slideViewsToLeft(binding.buttonContainer, binding.fragmentContainer, () -> { - fragmentAdminAccount = new FragmentAdminAccount(); - Bundle bundle = new Bundle(); - bundle.putSerializable(Helper.ARG_TIMELINE_TYPE, type); - bundle.putString(Helper.ARG_VIEW_MODEL_KEY, "FEDILAB_" + type.getValue()); - fragmentAdminAccount.setArguments(bundle); - FragmentManager fragmentManager = getSupportFragmentManager(); - FragmentTransaction fragmentTransaction = - fragmentManager.beginTransaction(); - fragmentTransaction.replace(R.id.fragment_container, fragmentAdminAccount); - fragmentTransaction.commit(); + }); } else if (type == DOMAIN) { + fragmentAdminDomain = new FragmentAdminDomain(); + Bundle bundle = new Bundle(); + bundle.putSerializable(Helper.ARG_TIMELINE_TYPE, type); + bundle.putString(Helper.ARG_VIEW_MODEL_KEY, "FEDILAB_" + type.getValue()); + fragmentAdminDomain.setArguments(bundle); + FragmentManager fragmentManager = getSupportFragmentManager(); + FragmentTransaction fragmentTransaction = + fragmentManager.beginTransaction(); + fragmentTransaction.replace(R.id.fragment_container, fragmentAdminDomain); + fragmentTransaction.commit(); ThemeHelper.slideViewsToLeft(binding.buttonContainer, binding.fragmentContainer, () -> { - fragmentAdminDomain = new FragmentAdminDomain(); - Bundle bundle = new Bundle(); - bundle.putSerializable(Helper.ARG_TIMELINE_TYPE, type); - bundle.putString(Helper.ARG_VIEW_MODEL_KEY, "FEDILAB_" + type.getValue()); - fragmentAdminDomain.setArguments(bundle); - FragmentManager fragmentManager = getSupportFragmentManager(); - FragmentTransaction fragmentTransaction = - fragmentManager.beginTransaction(); - fragmentTransaction.replace(R.id.fragment_container, fragmentAdminDomain); - fragmentTransaction.commit(); + }); } switch (type) { diff --git a/app/src/main/java/app/fedilab/android/mastodon/activities/admin/AdminReportActivity.java b/app/src/main/java/app/fedilab/android/mastodon/activities/admin/AdminReportActivity.java index 5e62a713..e987fad8 100644 --- a/app/src/main/java/app/fedilab/android/mastodon/activities/admin/AdminReportActivity.java +++ b/app/src/main/java/app/fedilab/android/mastodon/activities/admin/AdminReportActivity.java @@ -157,10 +157,10 @@ public class AdminReportActivity extends BaseBarActivity { lastActive.append(Helper.shortDateToString(ip.used_at)).append(" - ").append(ip.ip).append("\r\n"); } } - if (lastActive.toString().trim().length() == 0) { + if (lastActive.toString().trim().isEmpty()) { binding.lastActiveContainer.setVisibility(View.GONE); } - if (adminAccount.email == null || adminAccount.email.trim().length() == 0) { + if (adminAccount.email == null || adminAccount.email.trim().isEmpty()) { binding.emailContainer.setVisibility(View.GONE); } binding.lastActive.setText(lastActive.toString()); @@ -260,7 +260,7 @@ public class AdminReportActivity extends BaseBarActivity { //Animate emojis - if (account.emojis != null && account.emojis.size() > 0) { + if (account.emojis != null && !account.emojis.isEmpty()) { boolean disableAnimatedEmoji = sharedpreferences.getBoolean(getString(R.string.SET_DISABLE_ANIMATED_EMOJI), false); if (!disableAnimatedEmoji) { scheduledExecutorService = Executors.newSingleThreadScheduledExecutor(); diff --git a/app/src/main/java/app/fedilab/android/mastodon/ui/drawer/admin/AdminAccountAdapter.java b/app/src/main/java/app/fedilab/android/mastodon/ui/drawer/admin/AdminAccountAdapter.java index ac40fead..f9c3debe 100644 --- a/app/src/main/java/app/fedilab/android/mastodon/ui/drawer/admin/AdminAccountAdapter.java +++ b/app/src/main/java/app/fedilab/android/mastodon/ui/drawer/admin/AdminAccountAdapter.java @@ -95,7 +95,7 @@ public class AdminAccountAdapter extends RecyclerView.Adapter 0) { + } else if (adminAccount.ips != null && !adminAccount.ips.isEmpty()) { holder.binding.lastActive.setText(Helper.shortDateToString(adminAccount.ips.get(0).used_at)); holder.binding.ip.setText(adminAccount.ips.get(0).ip); } else { diff --git a/app/src/main/java/app/fedilab/android/mastodon/ui/drawer/admin/ReportAdapter.java b/app/src/main/java/app/fedilab/android/mastodon/ui/drawer/admin/ReportAdapter.java index 75b17e82..90aa8012 100644 --- a/app/src/main/java/app/fedilab/android/mastodon/ui/drawer/admin/ReportAdapter.java +++ b/app/src/main/java/app/fedilab/android/mastodon/ui/drawer/admin/ReportAdapter.java @@ -33,6 +33,7 @@ import app.fedilab.android.databinding.DrawerReportBinding; import app.fedilab.android.mastodon.activities.AccountReportActivity; import app.fedilab.android.mastodon.client.entities.api.Account; import app.fedilab.android.mastodon.client.entities.api.admin.AdminReport; +import app.fedilab.android.mastodon.client.entities.app.CachedBundle; import app.fedilab.android.mastodon.helper.Helper; import app.fedilab.android.mastodon.helper.MastodonHelper; @@ -61,8 +62,8 @@ public class ReportAdapter extends RecyclerView.Adapter AdminReport report = reports.get(position); Account account = report.account.account; Account target_account = report.target_account.account; - if (account.display_name == null || account.display_name.trim().equals("")) { - if (account.display_name != null && !account.display_name.trim().equals("")) + if (account.display_name == null || account.display_name.trim().isEmpty()) { + if (account.display_name != null && !account.display_name.trim().isEmpty()) holder.binding.accountDnReporter.setText(account.display_name); else holder.binding.accountDnReporter.setText(account.username.replace("@", "")); @@ -91,10 +92,15 @@ public class ReportAdapter extends RecyclerView.Adapter holder.binding.mainContainer.setOnClickListener(view -> { Intent intent = new Intent(context, AccountReportActivity.class); - Bundle b = new Bundle(); - b.putSerializable(Helper.ARG_REPORT, report); - intent.putExtras(b); - context.startActivity(intent); + Bundle args = new Bundle(); + args.putSerializable(Helper.ARG_REPORT, report); + new CachedBundle(context).insertBundle(args, Helper.getCurrentAccount(context), bundleId -> { + Bundle bundle = new Bundle(); + bundle.putLong(Helper.ARG_INTENT_ID, bundleId); + intent.putExtras(bundle); + intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); + context.startActivity(intent); + }); }); } diff --git a/app/src/main/java/app/fedilab/android/mastodon/ui/fragment/admin/FragmentAdminReport.java b/app/src/main/java/app/fedilab/android/mastodon/ui/fragment/admin/FragmentAdminReport.java index 93f03cd2..9d5b2bd9 100644 --- a/app/src/main/java/app/fedilab/android/mastodon/ui/fragment/admin/FragmentAdminReport.java +++ b/app/src/main/java/app/fedilab/android/mastodon/ui/fragment/admin/FragmentAdminReport.java @@ -116,7 +116,7 @@ public class FragmentAdminReport extends Fragment { .observe(getViewLifecycleOwner(), this::initializeStatusesCommonView); }); - if (adminReports == null || adminReports.adminReports == null || adminReports.adminReports.size() == 0) { + if (adminReports == null || adminReports.adminReports == null || adminReports.adminReports.isEmpty()) { binding.noAction.setVisibility(View.VISIBLE); return; } @@ -188,7 +188,7 @@ public class FragmentAdminReport extends Fragment { return; } binding.loadingNextElements.setVisibility(View.GONE); - if (adminReports != null && admReports != null && admReports.adminReports != null && admReports.adminReports.size() > 0) { + if (adminReports != null && admReports != null && admReports.adminReports != null && !admReports.adminReports.isEmpty()) { flagLoading = admReports.pagination.max_id == null; //There are some adminReports present in the timeline int startId = adminReports.size();