some fixes

This commit is contained in:
Thomas 2022-07-16 09:21:43 +02:00
parent dc1155d7c2
commit 96680343e0
4 changed files with 21 additions and 47 deletions

View File

@ -88,15 +88,9 @@ public class ContextActivity extends BaseActivity {
} }
MastodonHelper.loadPPMastodon(binding.profilePicture, currentAccount.mastodon_account); MastodonHelper.loadPPMastodon(binding.profilePicture, currentAccount.mastodon_account);
Bundle bundle = new Bundle(); Bundle bundle = new Bundle();
new Thread(() -> {
focusedStatus = SpannableHelper.convertStatus(getApplication().getApplicationContext(), focusedStatus); focusedStatus = SpannableHelper.convertStatus(getApplication().getApplicationContext(), focusedStatus);
Handler mainHandler = new Handler(Looper.getMainLooper());
Runnable myRunnable = () -> {
bundle.putSerializable(Helper.ARG_STATUS, focusedStatus); bundle.putSerializable(Helper.ARG_STATUS, focusedStatus);
currentFragment = Helper.addFragment(getSupportFragmentManager(), R.id.nav_host_fragment_content_main, new FragmentMastodonContext(), bundle, null, null); 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); StatusesVM timelinesVM = new ViewModelProvider(ContextActivity.this).get(StatusesVM.class);
timelinesVM.getStatus(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, focusedStatus.id).observe(ContextActivity.this, status -> { timelinesVM.getStatus(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, focusedStatus.id).observe(ContextActivity.this, status -> {
if (status != null) { if (status != null) {

View File

@ -35,8 +35,6 @@ import android.graphics.drawable.Drawable;
import android.os.Build; import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.os.CountDownTimer; import android.os.CountDownTimer;
import android.os.Handler;
import android.os.Looper;
import android.text.Html; import android.text.Html;
import android.text.Spannable; import android.text.Spannable;
import android.text.SpannableString; import android.text.SpannableString;
@ -1628,12 +1626,8 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
if (translate.getTranslatedContent() != null) { if (translate.getTranslatedContent() != null) {
statusToDeal.translationShown = true; statusToDeal.translationShown = true;
statusToDeal.translationContent = translate.getTranslatedContent(); statusToDeal.translationContent = translate.getTranslatedContent();
new Thread(() -> {
SpannableHelper.convertStatus(context.getApplicationContext(), statusToDeal); SpannableHelper.convertStatus(context.getApplicationContext(), statusToDeal);
Handler mainHandler = new Handler(Looper.getMainLooper()); adapter.notifyItemChanged(getPositionAsync(notificationList, statusList, statusToDeal));
Runnable myRunnable = () -> adapter.notifyItemChanged(getPositionAsync(notificationList, statusList, statusToDeal));
mainHandler.post(myRunnable);
}).start();
} else { } else {
Toasty.error(context, context.getString(R.string.toast_error_translate), Toast.LENGTH_LONG).show(); Toasty.error(context, context.getString(R.string.toast_error_translate), Toast.LENGTH_LONG).show();
} }

View File

@ -21,8 +21,6 @@ import android.content.BroadcastReceiver;
import android.content.Intent; import android.content.Intent;
import android.content.IntentFilter; import android.content.IntentFilter;
import android.os.Bundle; import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
@ -98,10 +96,7 @@ public class FragmentMastodonContext extends Fragment {
} }
} else if (statusPosted != null && statusAdapter != null) { } else if (statusPosted != null && statusAdapter != null) {
if (requireActivity() instanceof ContextActivity) { if (requireActivity() instanceof ContextActivity) {
new Thread(() -> {
Status convertStatus = SpannableHelper.convertStatus(context, statusPosted); Status convertStatus = SpannableHelper.convertStatus(context, statusPosted);
Handler mainHandler = new Handler(Looper.getMainLooper());
Runnable myRunnable = () -> {
int i = 0; int i = 0;
for (Status status : statuses) { for (Status status : statuses) {
if (status.id.equals(convertStatus.in_reply_to_id)) { if (status.id.equals(convertStatus.in_reply_to_id)) {
@ -115,9 +110,6 @@ public class FragmentMastodonContext extends Fragment {
} }
i++; i++;
} }
};
mainHandler.post(myRunnable);
}).start();
} }
} }
} }

View File

@ -118,15 +118,9 @@ public class FragmentMastodonTimeline extends Fragment implements StatusAdapter.
statusAdapter.notifyItemRemoved(position); statusAdapter.notifyItemRemoved(position);
} }
} else if (statusPosted != null && statusAdapter != null && timelineType == Timeline.TimeLineEnum.HOME) { } else if (statusPosted != null && statusAdapter != null && timelineType == Timeline.TimeLineEnum.HOME) {
new Thread(() -> {
Status convertStatus = SpannableHelper.convertStatus(context, statusPosted); Status convertStatus = SpannableHelper.convertStatus(context, statusPosted);
Handler mainHandler = new Handler(Looper.getMainLooper());
Runnable myRunnable = () -> {
statuses.add(0, convertStatus); statuses.add(0, convertStatus);
statusAdapter.notifyItemInserted(0); statusAdapter.notifyItemInserted(0);
};
mainHandler.post(myRunnable);
}).start();
} }
} }
} }