Loading app/src/main/java/app/fedilab/android/mastodon/helper/Helper.java +10 −6 Original line number Diff line number Diff line Loading @@ -909,8 +909,10 @@ public class Helper { if (args != null) fragment.setArguments(args); ft.add(containerViewId, fragment, tag); if (backStackName != null) ft.addToBackStack(backStackName); if(!fragmentManager.isDestroyed()) { ft.commit(); } } fragmentManager.executePendingTransactions(); return fragment; } Loading Loading @@ -1138,11 +1140,13 @@ public class Helper { .toSquare() .setBackgroundColor(fetchAccentColor(activity)) .build(); if (Helper.isValidContextForGlide(activity)) { Glide.with(activity) .asDrawable() .load(avatar) .apply(new RequestOptions().transform(new CenterCrop(), new RoundedCorners(10))) .into(view); } return; } } Loading app/src/main/java/app/fedilab/android/mastodon/ui/fragment/media/FragmentMediaProfile.java +18 −15 Original line number Diff line number Diff line Loading @@ -64,36 +64,41 @@ public class FragmentMediaProfile extends Fragment { private ImageAdapter imageAdapter; private boolean checkRemotely; private String accountId; private Bundle arguments; @Override public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { binding = FragmentPaginationBinding.inflate(inflater, container, false); arguments = getArguments(); return binding.getRoot(); } @Override public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(requireActivity()); boolean displayScrollBar = sharedpreferences.getBoolean(getString(R.string.SET_TIMELINE_SCROLLBAR), false); binding.recyclerView.setVerticalScrollBarEnabled(displayScrollBar); if (getArguments() != null) { long bundleId = getArguments().getLong(Helper.ARG_INTENT_ID, -1); if (arguments != null) { long bundleId = arguments.getLong(Helper.ARG_INTENT_ID, -1); if (bundleId != -1) { new CachedBundle(requireActivity()).getBundle(bundleId, currentAccount, this::initializeAfterBundle); } else { if (getArguments().containsKey(Helper.ARG_CACHED_ACCOUNT_ID)) { if (arguments.containsKey(Helper.ARG_CACHED_ACCOUNT_ID)) { try { accountTimeline = new CachedBundle(requireActivity()).getCachedAccount(currentAccount, getArguments().getString(Helper.ARG_CACHED_ACCOUNT_ID)); accountTimeline = new CachedBundle(requireActivity()).getCachedAccount(currentAccount, arguments.getString(Helper.ARG_CACHED_ACCOUNT_ID)); } catch (DBException e) { e.printStackTrace(); } } initializeAfterBundle(getArguments()); initializeAfterBundle(arguments); } } else { initializeAfterBundle(null); } return binding.getRoot(); } private void initializeAfterBundle(Bundle bundle) { if (bundle != null) { Loading @@ -102,7 +107,9 @@ public class FragmentMediaProfile extends Fragment { } checkRemotely = bundle.getBoolean(Helper.ARG_CHECK_REMOTELY, false); } if(accountTimeline == null) { return; } flagLoading = false; accountsVM = new ViewModelProvider(requireActivity()).get(AccountsVM.class); mediaStatuses = new ArrayList<>(); Loading Loading @@ -141,10 +148,6 @@ public class FragmentMediaProfile extends Fragment { } @Override public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); } /** * Intialize the common view for statuses on different timelines Loading app/src/main/java/app/fedilab/android/mastodon/ui/fragment/timeline/FragmentMastodonAccount.java +22 −21 Original line number Diff line number Diff line Loading @@ -76,6 +76,7 @@ public class FragmentMastodonAccount extends Fragment { private Boolean local; private boolean checkRemotely; private String instance, token, remoteAccountId; private Bundle arguments; public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { Loading @@ -84,27 +85,8 @@ public class FragmentMastodonAccount extends Fragment { token = currentToken; flagLoading = false; binding = FragmentPaginationBinding.inflate(inflater, container, false); SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(requireActivity()); boolean displayScrollBar = sharedpreferences.getBoolean(getString(R.string.SET_TIMELINE_SCROLLBAR), false); binding.recyclerView.setVerticalScrollBarEnabled(displayScrollBar); if (getArguments() != null) { long bundleId = getArguments().getLong(Helper.ARG_INTENT_ID, -1); if (bundleId != -1) { new CachedBundle(requireActivity()).getBundle(bundleId, currentAccount, this::initializeAfterBundle); } else { if (getArguments().containsKey(Helper.ARG_CACHED_ACCOUNT_ID)) { try { accountTimeline = new CachedBundle(requireActivity()).getCachedAccount(currentAccount, getArguments().getString(Helper.ARG_CACHED_ACCOUNT_ID)); } catch (DBException e) { e.printStackTrace(); } } initializeAfterBundle(getArguments()); } } else { initializeAfterBundle(null); } arguments = getArguments(); return binding.getRoot(); } Loading Loading @@ -149,7 +131,26 @@ public class FragmentMastodonAccount extends Fragment { super.onViewCreated(view, savedInstanceState); binding.loader.setVisibility(View.VISIBLE); binding.recyclerView.setVisibility(View.GONE); SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(requireActivity()); boolean displayScrollBar = sharedpreferences.getBoolean(getString(R.string.SET_TIMELINE_SCROLLBAR), false); binding.recyclerView.setVerticalScrollBarEnabled(displayScrollBar); if (arguments != null) { long bundleId = arguments.getLong(Helper.ARG_INTENT_ID, -1); if (bundleId != -1) { new CachedBundle(requireActivity()).getBundle(bundleId, currentAccount, this::initializeAfterBundle); } else { if (arguments.containsKey(Helper.ARG_CACHED_ACCOUNT_ID)) { try { accountTimeline = new CachedBundle(requireActivity()).getCachedAccount(currentAccount, arguments.getString(Helper.ARG_CACHED_ACCOUNT_ID)); } catch (DBException e) { e.printStackTrace(); } } initializeAfterBundle(arguments); } } else { initializeAfterBundle(null); } } /** Loading app/src/main/java/app/fedilab/android/mastodon/ui/fragment/timeline/FragmentMastodonContext.java +12 −3 Original line number Diff line number Diff line Loading @@ -28,6 +28,7 @@ import android.view.View; import android.view.ViewGroup; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.core.content.ContextCompat; import androidx.fragment.app.Fragment; import androidx.lifecycle.ViewModelProvider; Loading Loading @@ -157,6 +158,8 @@ public class FragmentMastodonContext extends Fragment { return found ? position : -1; } private Bundle arguments; public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { Loading @@ -165,13 +168,19 @@ public class FragmentMastodonContext extends Fragment { focusedStatusURI = null; refresh = true; binding = FragmentPaginationBinding.inflate(inflater, container, false); if (getArguments() != null) { long bundleId = getArguments().getLong(Helper.ARG_INTENT_ID, -1); arguments = getArguments(); return binding.getRoot(); } @Override public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); if (arguments != null) { long bundleId = arguments.getLong(Helper.ARG_INTENT_ID, -1); new CachedBundle(requireActivity()).getBundle(bundleId, currentAccount, this::initializeAfterBundle); } else { initializeAfterBundle(null); } return binding.getRoot(); } private void initializeAfterBundle(Bundle bundle) { Loading app/src/main/java/app/fedilab/android/mastodon/ui/fragment/timeline/FragmentMastodonTimeline.java +22 −17 Original line number Diff line number Diff line Loading @@ -90,6 +90,7 @@ public class FragmentMastodonTimeline extends Fragment implements StatusAdapter. private StatusAdapter statusAdapter; private Timeline.TimeLineEnum timelineType; private List<Status> timelineStatuses; private Bundle arguments; //Handle actions that can be done in other fragments private final BroadcastReceiver receive_action = new BroadcastReceiver() { @Override Loading Loading @@ -348,16 +349,7 @@ public class FragmentMastodonTimeline extends Fragment implements StatusAdapter. } } @Override public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); binding.loader.setVisibility(View.VISIBLE); binding.recyclerView.setVisibility(View.GONE); if (search != null) { binding.swipeContainer.setRefreshing(false); binding.swipeContainer.setEnabled(false); } } @Override public void onCreate(@Nullable Bundle savedInstanceState) { Loading @@ -369,24 +361,37 @@ public class FragmentMastodonTimeline extends Fragment implements StatusAdapter. timelineType = Timeline.TimeLineEnum.HOME; binding = FragmentPaginationBinding.inflate(inflater, container, false); if (getArguments() != null) { long bundleId = getArguments().getLong(Helper.ARG_INTENT_ID, -1); arguments = getArguments(); return binding.getRoot(); } @Override public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); binding.loader.setVisibility(View.VISIBLE); binding.recyclerView.setVisibility(View.GONE); if (search != null) { binding.swipeContainer.setRefreshing(false); binding.swipeContainer.setEnabled(false); } if (arguments != null) { long bundleId = arguments.getLong(Helper.ARG_INTENT_ID, -1); if (bundleId != -1) { new CachedBundle(requireActivity()).getBundle(bundleId, currentAccount, this::initializeAfterBundle); } else { if (getArguments().containsKey(Helper.ARG_CACHED_ACCOUNT_ID)) { if (arguments.containsKey(Helper.ARG_CACHED_ACCOUNT_ID)) { try { accountTimeline = new CachedBundle(requireActivity()).getCachedAccount(currentAccount, getArguments().getString(Helper.ARG_CACHED_ACCOUNT_ID)); accountTimeline = new CachedBundle(requireActivity()).getCachedAccount(currentAccount, arguments.getString(Helper.ARG_CACHED_ACCOUNT_ID)); } catch (DBException e) { e.printStackTrace(); } } initializeAfterBundle(getArguments()); initializeAfterBundle(arguments); } } return binding.getRoot(); } private void initializeAfterBundle(Bundle bundle) { if (bundle != null) { timelineType = (Timeline.TimeLineEnum) bundle.get(Helper.ARG_TIMELINE_TYPE); Loading Loading
app/src/main/java/app/fedilab/android/mastodon/helper/Helper.java +10 −6 Original line number Diff line number Diff line Loading @@ -909,8 +909,10 @@ public class Helper { if (args != null) fragment.setArguments(args); ft.add(containerViewId, fragment, tag); if (backStackName != null) ft.addToBackStack(backStackName); if(!fragmentManager.isDestroyed()) { ft.commit(); } } fragmentManager.executePendingTransactions(); return fragment; } Loading Loading @@ -1138,11 +1140,13 @@ public class Helper { .toSquare() .setBackgroundColor(fetchAccentColor(activity)) .build(); if (Helper.isValidContextForGlide(activity)) { Glide.with(activity) .asDrawable() .load(avatar) .apply(new RequestOptions().transform(new CenterCrop(), new RoundedCorners(10))) .into(view); } return; } } Loading
app/src/main/java/app/fedilab/android/mastodon/ui/fragment/media/FragmentMediaProfile.java +18 −15 Original line number Diff line number Diff line Loading @@ -64,36 +64,41 @@ public class FragmentMediaProfile extends Fragment { private ImageAdapter imageAdapter; private boolean checkRemotely; private String accountId; private Bundle arguments; @Override public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { binding = FragmentPaginationBinding.inflate(inflater, container, false); arguments = getArguments(); return binding.getRoot(); } @Override public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(requireActivity()); boolean displayScrollBar = sharedpreferences.getBoolean(getString(R.string.SET_TIMELINE_SCROLLBAR), false); binding.recyclerView.setVerticalScrollBarEnabled(displayScrollBar); if (getArguments() != null) { long bundleId = getArguments().getLong(Helper.ARG_INTENT_ID, -1); if (arguments != null) { long bundleId = arguments.getLong(Helper.ARG_INTENT_ID, -1); if (bundleId != -1) { new CachedBundle(requireActivity()).getBundle(bundleId, currentAccount, this::initializeAfterBundle); } else { if (getArguments().containsKey(Helper.ARG_CACHED_ACCOUNT_ID)) { if (arguments.containsKey(Helper.ARG_CACHED_ACCOUNT_ID)) { try { accountTimeline = new CachedBundle(requireActivity()).getCachedAccount(currentAccount, getArguments().getString(Helper.ARG_CACHED_ACCOUNT_ID)); accountTimeline = new CachedBundle(requireActivity()).getCachedAccount(currentAccount, arguments.getString(Helper.ARG_CACHED_ACCOUNT_ID)); } catch (DBException e) { e.printStackTrace(); } } initializeAfterBundle(getArguments()); initializeAfterBundle(arguments); } } else { initializeAfterBundle(null); } return binding.getRoot(); } private void initializeAfterBundle(Bundle bundle) { if (bundle != null) { Loading @@ -102,7 +107,9 @@ public class FragmentMediaProfile extends Fragment { } checkRemotely = bundle.getBoolean(Helper.ARG_CHECK_REMOTELY, false); } if(accountTimeline == null) { return; } flagLoading = false; accountsVM = new ViewModelProvider(requireActivity()).get(AccountsVM.class); mediaStatuses = new ArrayList<>(); Loading Loading @@ -141,10 +148,6 @@ public class FragmentMediaProfile extends Fragment { } @Override public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); } /** * Intialize the common view for statuses on different timelines Loading
app/src/main/java/app/fedilab/android/mastodon/ui/fragment/timeline/FragmentMastodonAccount.java +22 −21 Original line number Diff line number Diff line Loading @@ -76,6 +76,7 @@ public class FragmentMastodonAccount extends Fragment { private Boolean local; private boolean checkRemotely; private String instance, token, remoteAccountId; private Bundle arguments; public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { Loading @@ -84,27 +85,8 @@ public class FragmentMastodonAccount extends Fragment { token = currentToken; flagLoading = false; binding = FragmentPaginationBinding.inflate(inflater, container, false); SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(requireActivity()); boolean displayScrollBar = sharedpreferences.getBoolean(getString(R.string.SET_TIMELINE_SCROLLBAR), false); binding.recyclerView.setVerticalScrollBarEnabled(displayScrollBar); if (getArguments() != null) { long bundleId = getArguments().getLong(Helper.ARG_INTENT_ID, -1); if (bundleId != -1) { new CachedBundle(requireActivity()).getBundle(bundleId, currentAccount, this::initializeAfterBundle); } else { if (getArguments().containsKey(Helper.ARG_CACHED_ACCOUNT_ID)) { try { accountTimeline = new CachedBundle(requireActivity()).getCachedAccount(currentAccount, getArguments().getString(Helper.ARG_CACHED_ACCOUNT_ID)); } catch (DBException e) { e.printStackTrace(); } } initializeAfterBundle(getArguments()); } } else { initializeAfterBundle(null); } arguments = getArguments(); return binding.getRoot(); } Loading Loading @@ -149,7 +131,26 @@ public class FragmentMastodonAccount extends Fragment { super.onViewCreated(view, savedInstanceState); binding.loader.setVisibility(View.VISIBLE); binding.recyclerView.setVisibility(View.GONE); SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(requireActivity()); boolean displayScrollBar = sharedpreferences.getBoolean(getString(R.string.SET_TIMELINE_SCROLLBAR), false); binding.recyclerView.setVerticalScrollBarEnabled(displayScrollBar); if (arguments != null) { long bundleId = arguments.getLong(Helper.ARG_INTENT_ID, -1); if (bundleId != -1) { new CachedBundle(requireActivity()).getBundle(bundleId, currentAccount, this::initializeAfterBundle); } else { if (arguments.containsKey(Helper.ARG_CACHED_ACCOUNT_ID)) { try { accountTimeline = new CachedBundle(requireActivity()).getCachedAccount(currentAccount, arguments.getString(Helper.ARG_CACHED_ACCOUNT_ID)); } catch (DBException e) { e.printStackTrace(); } } initializeAfterBundle(arguments); } } else { initializeAfterBundle(null); } } /** Loading
app/src/main/java/app/fedilab/android/mastodon/ui/fragment/timeline/FragmentMastodonContext.java +12 −3 Original line number Diff line number Diff line Loading @@ -28,6 +28,7 @@ import android.view.View; import android.view.ViewGroup; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.core.content.ContextCompat; import androidx.fragment.app.Fragment; import androidx.lifecycle.ViewModelProvider; Loading Loading @@ -157,6 +158,8 @@ public class FragmentMastodonContext extends Fragment { return found ? position : -1; } private Bundle arguments; public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { Loading @@ -165,13 +168,19 @@ public class FragmentMastodonContext extends Fragment { focusedStatusURI = null; refresh = true; binding = FragmentPaginationBinding.inflate(inflater, container, false); if (getArguments() != null) { long bundleId = getArguments().getLong(Helper.ARG_INTENT_ID, -1); arguments = getArguments(); return binding.getRoot(); } @Override public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); if (arguments != null) { long bundleId = arguments.getLong(Helper.ARG_INTENT_ID, -1); new CachedBundle(requireActivity()).getBundle(bundleId, currentAccount, this::initializeAfterBundle); } else { initializeAfterBundle(null); } return binding.getRoot(); } private void initializeAfterBundle(Bundle bundle) { Loading
app/src/main/java/app/fedilab/android/mastodon/ui/fragment/timeline/FragmentMastodonTimeline.java +22 −17 Original line number Diff line number Diff line Loading @@ -90,6 +90,7 @@ public class FragmentMastodonTimeline extends Fragment implements StatusAdapter. private StatusAdapter statusAdapter; private Timeline.TimeLineEnum timelineType; private List<Status> timelineStatuses; private Bundle arguments; //Handle actions that can be done in other fragments private final BroadcastReceiver receive_action = new BroadcastReceiver() { @Override Loading Loading @@ -348,16 +349,7 @@ public class FragmentMastodonTimeline extends Fragment implements StatusAdapter. } } @Override public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); binding.loader.setVisibility(View.VISIBLE); binding.recyclerView.setVisibility(View.GONE); if (search != null) { binding.swipeContainer.setRefreshing(false); binding.swipeContainer.setEnabled(false); } } @Override public void onCreate(@Nullable Bundle savedInstanceState) { Loading @@ -369,24 +361,37 @@ public class FragmentMastodonTimeline extends Fragment implements StatusAdapter. timelineType = Timeline.TimeLineEnum.HOME; binding = FragmentPaginationBinding.inflate(inflater, container, false); if (getArguments() != null) { long bundleId = getArguments().getLong(Helper.ARG_INTENT_ID, -1); arguments = getArguments(); return binding.getRoot(); } @Override public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); binding.loader.setVisibility(View.VISIBLE); binding.recyclerView.setVisibility(View.GONE); if (search != null) { binding.swipeContainer.setRefreshing(false); binding.swipeContainer.setEnabled(false); } if (arguments != null) { long bundleId = arguments.getLong(Helper.ARG_INTENT_ID, -1); if (bundleId != -1) { new CachedBundle(requireActivity()).getBundle(bundleId, currentAccount, this::initializeAfterBundle); } else { if (getArguments().containsKey(Helper.ARG_CACHED_ACCOUNT_ID)) { if (arguments.containsKey(Helper.ARG_CACHED_ACCOUNT_ID)) { try { accountTimeline = new CachedBundle(requireActivity()).getCachedAccount(currentAccount, getArguments().getString(Helper.ARG_CACHED_ACCOUNT_ID)); accountTimeline = new CachedBundle(requireActivity()).getCachedAccount(currentAccount, arguments.getString(Helper.ARG_CACHED_ACCOUNT_ID)); } catch (DBException e) { e.printStackTrace(); } } initializeAfterBundle(getArguments()); initializeAfterBundle(arguments); } } return binding.getRoot(); } private void initializeAfterBundle(Bundle bundle) { if (bundle != null) { timelineType = (Timeline.TimeLineEnum) bundle.get(Helper.ARG_TIMELINE_TYPE); Loading