mirror of
https://codeberg.org/tom79/Fedilab.git
synced 2024-12-22 08:40:03 +02:00
Fix some crashes
This commit is contained in:
parent
1f2e6c4327
commit
dd2c1c5bef
6 changed files with 94 additions and 71 deletions
|
@ -909,7 +909,9 @@ public class Helper {
|
|||
if (args != null) fragment.setArguments(args);
|
||||
ft.add(containerViewId, fragment, tag);
|
||||
if (backStackName != null) ft.addToBackStack(backStackName);
|
||||
ft.commit();
|
||||
if(!fragmentManager.isDestroyed()) {
|
||||
ft.commit();
|
||||
}
|
||||
}
|
||||
fragmentManager.executePendingTransactions();
|
||||
return fragment;
|
||||
|
@ -1138,11 +1140,13 @@ public class Helper {
|
|||
.toSquare()
|
||||
.setBackgroundColor(fetchAccentColor(activity))
|
||||
.build();
|
||||
Glide.with(activity)
|
||||
.asDrawable()
|
||||
.load(avatar)
|
||||
.apply(new RequestOptions().transform(new CenterCrop(), new RoundedCorners(10)))
|
||||
.into(view);
|
||||
if (Helper.isValidContextForGlide(activity)) {
|
||||
Glide.with(activity)
|
||||
.asDrawable()
|
||||
.load(avatar)
|
||||
.apply(new RequestOptions().transform(new CenterCrop(), new RoundedCorners(10)))
|
||||
.into(view);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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) {
|
||||
|
@ -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<>();
|
||||
|
@ -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
|
||||
|
|
|
@ -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) {
|
||||
|
@ -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();
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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;
|
||||
|
@ -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) {
|
||||
|
||||
|
@ -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) {
|
||||
|
|
|
@ -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
|
||||
|
@ -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) {
|
||||
|
@ -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);
|
||||
|
|
|
@ -47,21 +47,26 @@ public class FragmentProfileTimeline extends Fragment {
|
|||
private FragmentProfileTimelinesBinding binding;
|
||||
private boolean checkRemotely;
|
||||
private boolean show_boosts = true, show_replies = true;
|
||||
|
||||
private Bundle arguments;
|
||||
public View onCreateView(@NonNull LayoutInflater inflater,
|
||||
ViewGroup container, Bundle savedInstanceState) {
|
||||
binding = FragmentProfileTimelinesBinding.inflate(inflater, container, false);
|
||||
if (getArguments() != null) {
|
||||
String cached_account_id = getArguments().getString(Helper.ARG_CACHED_ACCOUNT_ID);
|
||||
arguments = getArguments();
|
||||
return binding.getRoot();
|
||||
}
|
||||
@Override
|
||||
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
if (arguments != null) {
|
||||
String cached_account_id = arguments.getString(Helper.ARG_CACHED_ACCOUNT_ID);
|
||||
try {
|
||||
account = new CachedBundle(requireActivity()).getCachedAccount(currentAccount, cached_account_id);
|
||||
} catch (DBException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
checkRemotely = getArguments().getBoolean(Helper.ARG_CHECK_REMOTELY, false);
|
||||
checkRemotely = arguments.getBoolean(Helper.ARG_CHECK_REMOTELY, false);
|
||||
initializeAfterBundle();
|
||||
}
|
||||
return binding.getRoot();
|
||||
}
|
||||
|
||||
|
||||
|
@ -163,10 +168,6 @@ public class FragmentProfileTimeline extends Fragment {
|
|||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue