Commit 96680343 authored by Thomas's avatar Thomas
Browse files

some fixes

parent dc1155d7
Loading
Loading
Loading
Loading
+3 −9
Original line number Diff line number Diff line
@@ -88,15 +88,9 @@ public class ContextActivity extends BaseActivity {
        }
        MastodonHelper.loadPPMastodon(binding.profilePicture, currentAccount.mastodon_account);
        Bundle bundle = new Bundle();
        new Thread(() -> {
        focusedStatus = SpannableHelper.convertStatus(getApplication().getApplicationContext(), focusedStatus);
            Handler mainHandler = new Handler(Looper.getMainLooper());
            Runnable myRunnable = () -> {
        bundle.putSerializable(Helper.ARG_STATUS, focusedStatus);
        currentFragment = Helper.addFragment(getSupportFragmentManager(), R.id.nav_host_fragment_content_main, new FragmentMastodonContext(), bundle, null, null);
            };
            mainHandler.post(myRunnable);
        }).start();
        StatusesVM timelinesVM = new ViewModelProvider(ContextActivity.this).get(StatusesVM.class);
        timelinesVM.getStatus(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, focusedStatus.id).observe(ContextActivity.this, status -> {
            if (status != null) {
+2 −8
Original line number Diff line number Diff line
@@ -35,8 +35,6 @@ import android.graphics.drawable.Drawable;
import android.os.Build;
import android.os.Bundle;
import android.os.CountDownTimer;
import android.os.Handler;
import android.os.Looper;
import android.text.Html;
import android.text.Spannable;
import android.text.SpannableString;
@@ -1628,12 +1626,8 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
                            if (translate.getTranslatedContent() != null) {
                                statusToDeal.translationShown = true;
                                statusToDeal.translationContent = translate.getTranslatedContent();
                                new Thread(() -> {
                                SpannableHelper.convertStatus(context.getApplicationContext(), statusToDeal);
                                    Handler mainHandler = new Handler(Looper.getMainLooper());
                                    Runnable myRunnable = () -> adapter.notifyItemChanged(getPositionAsync(notificationList, statusList, statusToDeal));
                                    mainHandler.post(myRunnable);
                                }).start();
                                adapter.notifyItemChanged(getPositionAsync(notificationList, statusList, statusToDeal));
                            } else {
                                Toasty.error(context, context.getString(R.string.toast_error_translate), Toast.LENGTH_LONG).show();
                            }
+13 −21
Original line number Diff line number Diff line
@@ -21,8 +21,6 @@ import android.content.BroadcastReceiver;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@@ -98,10 +96,7 @@ public class FragmentMastodonContext extends Fragment {
                    }
                } else if (statusPosted != null && statusAdapter != null) {
                    if (requireActivity() instanceof ContextActivity) {
                        new Thread(() -> {
                        Status convertStatus = SpannableHelper.convertStatus(context, statusPosted);
                            Handler mainHandler = new Handler(Looper.getMainLooper());
                            Runnable myRunnable = () -> {
                        int i = 0;
                        for (Status status : statuses) {
                            if (status.id.equals(convertStatus.in_reply_to_id)) {
@@ -115,9 +110,6 @@ public class FragmentMastodonContext extends Fragment {
                            }
                            i++;
                        }
                            };
                            mainHandler.post(myRunnable);
                        }).start();
                    }
                }
            }
+3 −9
Original line number Diff line number Diff line
@@ -118,15 +118,9 @@ public class FragmentMastodonTimeline extends Fragment implements StatusAdapter.
                        statusAdapter.notifyItemRemoved(position);
                    }
                } else if (statusPosted != null && statusAdapter != null && timelineType == Timeline.TimeLineEnum.HOME) {
                    new Thread(() -> {
                    Status convertStatus = SpannableHelper.convertStatus(context, statusPosted);
                        Handler mainHandler = new Handler(Looper.getMainLooper());
                        Runnable myRunnable = () -> {
                    statuses.add(0, convertStatus);
                    statusAdapter.notifyItemInserted(0);
                        };
                        mainHandler.post(myRunnable);
                    }).start();
                }
            }
        }