Fix #1040 - Fix a crash when reporting messages
This commit is contained in:
parent
ecd25badf7
commit
28ca138e43
|
@ -235,7 +235,14 @@ public class ReportActivity extends BaseBarActivity {
|
||||||
fragment = new FragmentMastodonTimeline();
|
fragment = new FragmentMastodonTimeline();
|
||||||
Bundle args = new Bundle();
|
Bundle args = new Bundle();
|
||||||
args.putSerializable(Helper.ARG_TIMELINE_TYPE, Timeline.TimeLineEnum.ACCOUNT_TIMELINE);
|
args.putSerializable(Helper.ARG_TIMELINE_TYPE, Timeline.TimeLineEnum.ACCOUNT_TIMELINE);
|
||||||
args.putSerializable(Helper.ARG_ACCOUNT, account);
|
args.putBoolean(Helper.ARG_SHOW_PINNED, false);
|
||||||
|
args.putBoolean(Helper.ARG_SHOW_REPLIES, true);
|
||||||
|
args.putBoolean(Helper.ARG_SHOW_REBLOGS, false);
|
||||||
|
args.putBoolean(Helper.ARG_CHECK_REMOTELY, false);
|
||||||
|
args.putString(Helper.ARG_VIEW_MODEL_KEY, "FEDILAB_REPORT_" + account.acct);
|
||||||
|
if (account != null) {
|
||||||
|
args.putSerializable(Helper.ARG_CACHED_ACCOUNT_ID, account.id);
|
||||||
|
}
|
||||||
//Set to display statuses with less options
|
//Set to display statuses with less options
|
||||||
args.putBoolean(Helper.ARG_MINIFIED, true);
|
args.putBoolean(Helper.ARG_MINIFIED, true);
|
||||||
if (status != null) {
|
if (status != null) {
|
||||||
|
@ -245,12 +252,7 @@ public class ReportActivity extends BaseBarActivity {
|
||||||
new CachedBundle(ReportActivity.this).insertBundle(args, Helper.getCurrentAccount(ReportActivity.this), bundleId -> {
|
new CachedBundle(ReportActivity.this).insertBundle(args, Helper.getCurrentAccount(ReportActivity.this), bundleId -> {
|
||||||
Bundle bundle = new Bundle();
|
Bundle bundle = new Bundle();
|
||||||
bundle.putLong(Helper.ARG_INTENT_ID, bundleId);
|
bundle.putLong(Helper.ARG_INTENT_ID, bundleId);
|
||||||
fragment.setArguments(bundle);
|
Helper.addFragment(getSupportFragmentManager(), R.id.fram_spam_container, fragment, bundle, null, null);
|
||||||
FragmentManager fragmentManager = getSupportFragmentManager();
|
|
||||||
FragmentTransaction fragmentTransaction =
|
|
||||||
fragmentManager.beginTransaction();
|
|
||||||
fragmentTransaction.replace(R.id.fram_spam_container, fragment);
|
|
||||||
fragmentTransaction.commit();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
binding.actionButton.setText(R.string.next);
|
binding.actionButton.setText(R.string.next);
|
||||||
|
@ -265,7 +267,14 @@ public class ReportActivity extends BaseBarActivity {
|
||||||
fragment = new FragmentMastodonTimeline();
|
fragment = new FragmentMastodonTimeline();
|
||||||
Bundle args = new Bundle();
|
Bundle args = new Bundle();
|
||||||
args.putSerializable(Helper.ARG_TIMELINE_TYPE, Timeline.TimeLineEnum.ACCOUNT_TIMELINE);
|
args.putSerializable(Helper.ARG_TIMELINE_TYPE, Timeline.TimeLineEnum.ACCOUNT_TIMELINE);
|
||||||
args.putSerializable(Helper.ARG_ACCOUNT, account);
|
args.putBoolean(Helper.ARG_SHOW_PINNED, false);
|
||||||
|
args.putBoolean(Helper.ARG_SHOW_REPLIES, true);
|
||||||
|
args.putBoolean(Helper.ARG_SHOW_REBLOGS, false);
|
||||||
|
args.putBoolean(Helper.ARG_CHECK_REMOTELY, false);
|
||||||
|
args.putString(Helper.ARG_VIEW_MODEL_KEY, "FEDILAB_REPORT_" + account.acct);
|
||||||
|
if (account != null) {
|
||||||
|
args.putSerializable(Helper.ARG_CACHED_ACCOUNT_ID, account.id);
|
||||||
|
}
|
||||||
//Set to display statuses with less options
|
//Set to display statuses with less options
|
||||||
args.putBoolean(Helper.ARG_MINIFIED, true);
|
args.putBoolean(Helper.ARG_MINIFIED, true);
|
||||||
if (status != null) {
|
if (status != null) {
|
||||||
|
@ -275,12 +284,7 @@ public class ReportActivity extends BaseBarActivity {
|
||||||
new CachedBundle(ReportActivity.this).insertBundle(args, Helper.getCurrentAccount(ReportActivity.this), bundleId -> {
|
new CachedBundle(ReportActivity.this).insertBundle(args, Helper.getCurrentAccount(ReportActivity.this), bundleId -> {
|
||||||
Bundle bundle = new Bundle();
|
Bundle bundle = new Bundle();
|
||||||
bundle.putLong(Helper.ARG_INTENT_ID, bundleId);
|
bundle.putLong(Helper.ARG_INTENT_ID, bundleId);
|
||||||
fragment.setArguments(bundle);
|
Helper.addFragment(getSupportFragmentManager(), R.id.fram_se_container, fragment, bundle, null, null);
|
||||||
FragmentManager fragmentManager = getSupportFragmentManager();
|
|
||||||
FragmentTransaction fragmentTransaction =
|
|
||||||
fragmentManager.beginTransaction();
|
|
||||||
fragmentTransaction.replace(R.id.fram_se_container, fragment);
|
|
||||||
fragmentTransaction.commit();
|
|
||||||
});
|
});
|
||||||
binding.actionButton.setText(R.string.next);
|
binding.actionButton.setText(R.string.next);
|
||||||
binding.actionButton.setOnClickListener(v -> {
|
binding.actionButton.setOnClickListener(v -> {
|
||||||
|
|
|
@ -187,7 +187,15 @@ public class FragmentMastodonTimeline extends Fragment implements StatusAdapter.
|
||||||
private String lemmy_post_id;
|
private String lemmy_post_id;
|
||||||
private boolean checkRemotely;
|
private boolean checkRemotely;
|
||||||
private String accountIDInRemoteInstance;
|
private String accountIDInRemoteInstance;
|
||||||
|
//This value is set to true in onResume meaning that the fragment is visible
|
||||||
private boolean isViewInitialized;
|
private boolean isViewInitialized;
|
||||||
|
//If onResume is called before getting all parameters, needToCallResume will be set to true so it can call safely initializeView()
|
||||||
|
private boolean needToCallResume;
|
||||||
|
//Some operations need to be done once only in onResume, the lockForResumeCall will be incremented to avoid useless calls
|
||||||
|
private int lockForResumeCall;
|
||||||
|
//All timelines that are not pinned - it will take the initial value of isViewInitialized
|
||||||
|
private boolean isNotPinnedTimeline;
|
||||||
|
private boolean bundleParamsRetrieved;
|
||||||
private Statuses initialStatuses;
|
private Statuses initialStatuses;
|
||||||
private String list_id;
|
private String list_id;
|
||||||
private TagTimeline tagTimeline;
|
private TagTimeline tagTimeline;
|
||||||
|
@ -202,8 +210,7 @@ public class FragmentMastodonTimeline extends Fragment implements StatusAdapter.
|
||||||
private boolean canBeFederated;
|
private boolean canBeFederated;
|
||||||
private boolean rememberPosition;
|
private boolean rememberPosition;
|
||||||
private String publicTrendsDomain;
|
private String publicTrendsDomain;
|
||||||
private int lockForResumeCall;
|
|
||||||
private boolean isNotPinnedTimeline;
|
|
||||||
|
|
||||||
|
|
||||||
//Allow to recreate data when detaching/attaching fragment
|
//Allow to recreate data when detaching/attaching fragment
|
||||||
|
@ -235,6 +242,14 @@ public class FragmentMastodonTimeline extends Fragment implements StatusAdapter.
|
||||||
@Override
|
@Override
|
||||||
public void onResume() {
|
public void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
|
if(bundleParamsRetrieved) {
|
||||||
|
initializeView();
|
||||||
|
} else {
|
||||||
|
needToCallResume = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initializeView() {
|
||||||
if (!isViewInitialized) {
|
if (!isViewInitialized) {
|
||||||
isViewInitialized = true;
|
isViewInitialized = true;
|
||||||
if (initialStatuses != null) {
|
if (initialStatuses != null) {
|
||||||
|
@ -255,6 +270,7 @@ public class FragmentMastodonTimeline extends Fragment implements StatusAdapter.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the position of the status in the ArrayList
|
* Return the position of the status in the ArrayList
|
||||||
*
|
*
|
||||||
|
@ -359,6 +375,8 @@ public class FragmentMastodonTimeline extends Fragment implements StatusAdapter.
|
||||||
ViewGroup container, Bundle savedInstanceState) {
|
ViewGroup container, Bundle savedInstanceState) {
|
||||||
|
|
||||||
timelineType = Timeline.TimeLineEnum.HOME;
|
timelineType = Timeline.TimeLineEnum.HOME;
|
||||||
|
bundleParamsRetrieved = false;
|
||||||
|
needToCallResume = false;
|
||||||
binding = FragmentPaginationBinding.inflate(inflater, container, false);
|
binding = FragmentPaginationBinding.inflate(inflater, container, false);
|
||||||
arguments = getArguments();
|
arguments = getArguments();
|
||||||
return binding.getRoot();
|
return binding.getRoot();
|
||||||
|
@ -486,7 +504,11 @@ public class FragmentMastodonTimeline extends Fragment implements StatusAdapter.
|
||||||
//Only fragment in main view pager should not have the view initialized
|
//Only fragment in main view pager should not have the view initialized
|
||||||
//AND Only the first fragment will initialize its view
|
//AND Only the first fragment will initialize its view
|
||||||
flagLoading = false;
|
flagLoading = false;
|
||||||
|
bundleParamsRetrieved = true;
|
||||||
|
if(needToCallResume) {
|
||||||
|
initializeView();
|
||||||
|
needToCallResume = false;
|
||||||
|
}
|
||||||
ContextCompat.registerReceiver(requireActivity(), receive_action, new IntentFilter(Helper.RECEIVE_STATUS_ACTION), ContextCompat.RECEIVER_NOT_EXPORTED);
|
ContextCompat.registerReceiver(requireActivity(), receive_action, new IntentFilter(Helper.RECEIVE_STATUS_ACTION), ContextCompat.RECEIVER_NOT_EXPORTED);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue