Commit fbaf0602 authored by Thomas's avatar Thomas
Browse files

- Fix some crashes

parent 5e6d6265
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -294,6 +294,7 @@ public class ComposeActivity extends BaseActivity implements ComposeAdapter.Mana
        composeAdapter.manageDrafts = this;
        LinearLayoutManager mLayoutManager = new LinearLayoutManager(ComposeActivity.this);
        binding.recyclerView.setLayoutManager(mLayoutManager);
        binding.recyclerView.setItemAnimator(null);
        binding.recyclerView.setAdapter(composeAdapter);
        composeAdapter.setStatusCount(context.ancestors.size() + 1);
        binding.recyclerView.addItemDecoration(new DividerDecorationSimple(ComposeActivity.this, statusList));
@@ -649,6 +650,7 @@ public class ComposeActivity extends BaseActivity implements ComposeAdapter.Mana
                    composeAdapter.promptDraftListener = this;
                    LinearLayoutManager mLayoutManager = new LinearLayoutManager(ComposeActivity.this);
                    binding.recyclerView.setLayoutManager(mLayoutManager);
                    binding.recyclerView.setItemAnimator(null);
                    binding.recyclerView.setAdapter(composeAdapter);
                    binding.recyclerView.scrollToPosition(composeAdapter.getItemCount() - 1);

@@ -722,6 +724,7 @@ public class ComposeActivity extends BaseActivity implements ComposeAdapter.Mana
                    composeAdapter.promptDraftListener = this;
                    LinearLayoutManager mLayoutManager = new LinearLayoutManager(ComposeActivity.this);
                    binding.recyclerView.setLayoutManager(mLayoutManager);
                    binding.recyclerView.setItemAnimator(null);
                    binding.recyclerView.setAdapter(composeAdapter);
                    statusesVM.getContext(currentInstance, BaseMainActivity.currentToken, statusReply.id)
                            .observe(ComposeActivity.this, this::initializeContextView);
@@ -737,6 +740,7 @@ public class ComposeActivity extends BaseActivity implements ComposeAdapter.Mana
                    composeAdapter.promptDraftListener = this;
                    LinearLayoutManager mLayoutManager = new LinearLayoutManager(ComposeActivity.this);
                    binding.recyclerView.setLayoutManager(mLayoutManager);
                    binding.recyclerView.setItemAnimator(null);
                    binding.recyclerView.setAdapter(composeAdapter);
                } else {
                    //Compose without replying
@@ -747,6 +751,7 @@ public class ComposeActivity extends BaseActivity implements ComposeAdapter.Mana
                    composeAdapter.promptDraftListener = this;
                    LinearLayoutManager mLayoutManager = new LinearLayoutManager(ComposeActivity.this);
                    binding.recyclerView.setLayoutManager(mLayoutManager);
                    binding.recyclerView.setItemAnimator(null);
                    binding.recyclerView.setAdapter(composeAdapter);
                    if (statusMention != null) {
                        composeAdapter.loadMentions(statusMention);
+6 −3
Original line number Diff line number Diff line
@@ -260,8 +260,10 @@ public class ComposeWorker extends Worker {

                if (dataPost.scheduledDate == null) {
                    if (dataPost.statusEditId == null) {
                        String visibility = statuses.get(i).visibility != null ? statuses.get(i).visibility.toLowerCase() : null;
                        String quoteApprovalPolicy = statuses.get(i).quote_approval_policy != null ? statuses.get(i).quote_approval_policy.toLowerCase() : null;
                        statusCall = mastodonStatusesService.createStatus(null, dataPost.token, statuses.get(i).text, attachmentIds, poll_options, poll_expire_in,
                                poll_multiple, poll_hide_totals, statuses.get(i).quote_id == null ? in_reply_to_status : null, statuses.get(i).sensitive, statuses.get(i).spoilerChecked ? statuses.get(i).spoiler_text : null, statuses.get(i).visibility.toLowerCase(), statuses.get(i).language, statuses.get(i).quote_approval_policy.toLowerCase(), statuses.get(i).quote_id, statuses.get(i).quote_id, statuses.get(i).content_type, statuses.get(i).local_only);
                                poll_multiple, poll_hide_totals, statuses.get(i).quote_id == null ? in_reply_to_status : null, statuses.get(i).sensitive, statuses.get(i).spoilerChecked ? statuses.get(i).spoiler_text : null, visibility, statuses.get(i).language, quoteApprovalPolicy, statuses.get(i).quote_id, statuses.get(i).quote_id, statuses.get(i).content_type, statuses.get(i).local_only);
                    } else { //Status is edited
                        StatusParams statusParams = new StatusParams();
                        statusParams.status = statuses.get(i).text;
@@ -276,7 +278,7 @@ public class ComposeWorker extends Worker {
                        statusParams.in_reply_to_id =  statuses.get(i).quote_id == null ? in_reply_to_status : null;
                        statusParams.sensitive =  statuses.get(i).sensitive;
                        statusParams.spoiler_text = statuses.get(i).spoilerChecked ? statuses.get(i).spoiler_text : null;
                        statusParams.visibility = statuses.get(i).visibility.toLowerCase();
                        statusParams.visibility = statuses.get(i).visibility != null ? statuses.get(i).visibility.toLowerCase() : null;
                        String quote_id = statuses.get(i).quote_id;
                        if (quote_id != null) {
                            statusParams.quoted_status_id = quote_id.toLowerCase();
@@ -384,8 +386,9 @@ public class ComposeWorker extends Worker {
                            e.printStackTrace();
                        }
                    }
                    String scheduledVisibility = statuses.get(i).visibility != null ? statuses.get(i).visibility.toLowerCase() : null;
                    Call<ScheduledStatus> scheduledStatusCall = mastodonStatusesService.createScheduledStatus(null, dataPost.token, statuses.get(i).text, attachmentIds, poll_options, poll_expire_in,
                            poll_multiple, poll_hide_totals, statuses.get(i).quote_id == null ? in_reply_to_status : null, statuses.get(i).sensitive, statuses.get(i).spoilerChecked ? statuses.get(i).spoiler_text : null, statuses.get(i).visibility.toLowerCase(), dataPost.scheduledDate, statuses.get(i).language);
                            poll_multiple, poll_hide_totals, statuses.get(i).quote_id == null ? in_reply_to_status : null, statuses.get(i).sensitive, statuses.get(i).spoilerChecked ? statuses.get(i).spoiler_text : null, scheduledVisibility, dataPost.scheduledDate, statuses.get(i).language);
                    try {
                        Response<ScheduledStatus> statusResponse = scheduledStatusCall.execute();

+4 −0
Original line number Diff line number Diff line
@@ -599,6 +599,10 @@ public class ComposeAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder
                        threadConfirm.setPositiveButton(R.string.thread_long_message_yes, (dialog, which) -> {
                            String currentContent = holder.binding.content.getText().toString();
                            ArrayList<String> splitText = ComposeHelper.splitToots(currentContent, max_car);
                            if (splitText == null || splitText.isEmpty()) {
                                dialog.dismiss();
                                return;
                            }
                            holder.binding.content.setText(splitText.get(0));
                            int statusListSize = statusList.size();
                            int i = 0;
+2 −2
Original line number Diff line number Diff line
@@ -65,7 +65,7 @@ public class FragmentMastodonContext extends Fragment {
        @Override
        public void onReceive(android.content.Context context, Intent intent) {
            Bundle args = intent.getExtras();
            if (args != null) {
            if (args != null && isAdded()) {
                long bundleId = args.getLong(Helper.ARG_INTENT_ID, -1);
                new CachedBundle(requireActivity()).getBundle(bundleId, Helper.getCurrentAccount(requireActivity()), bundle -> {
                    Status receivedStatus = (Status) bundle.getSerializable(Helper.ARG_STATUS_ACTION);
@@ -111,7 +111,7 @@ public class FragmentMastodonContext extends Fragment {
                            statusAdapter.notifyItemChanged(position);
                        }
                    } else if (statusPosted != null && statusAdapter != null) {
                        if (requireActivity() instanceof ContextActivity) {
                        if (isAdded() && requireActivity() instanceof ContextActivity) {
                            int i = 0;
                            for (Status status : statuses) {
                                if (status.id.equals(statusPosted.in_reply_to_id)) {