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);
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();
focusedStatus = SpannableHelper.convertStatus(getApplication().getApplicationContext(), focusedStatus);
bundle.putSerializable(Helper.ARG_STATUS, focusedStatus);
currentFragment = Helper.addFragment(getSupportFragmentManager(), R.id.nav_host_fragment_content_main, new FragmentMastodonContext(), bundle, null, null);
StatusesVM timelinesVM = new ViewModelProvider(ContextActivity.this).get(StatusesVM.class);
timelinesVM.getStatus(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, focusedStatus.id).observe(ContextActivity.this, status -> {
if (status != null) {

View File

@ -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();
SpannableHelper.convertStatus(context.getApplicationContext(), statusToDeal);
adapter.notifyItemChanged(getPositionAsync(notificationList, statusList, statusToDeal));
} else {
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.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,26 +96,20 @@ 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)) {
statuses.add((i + 1), convertStatus);
statusAdapter.notifyItemInserted((i + 1));
if (requireActivity() instanceof ContextActivity) {
//Redraw decorations
statusAdapter.notifyItemRangeChanged(0, statuses.size());
}
break;
}
i++;
Status convertStatus = SpannableHelper.convertStatus(context, statusPosted);
int i = 0;
for (Status status : statuses) {
if (status.id.equals(convertStatus.in_reply_to_id)) {
statuses.add((i + 1), convertStatus);
statusAdapter.notifyItemInserted((i + 1));
if (requireActivity() instanceof ContextActivity) {
//Redraw decorations
statusAdapter.notifyItemRangeChanged(0, statuses.size());
}
};
mainHandler.post(myRunnable);
}).start();
break;
}
i++;
}
}
}
}

View File

@ -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();
Status convertStatus = SpannableHelper.convertStatus(context, statusPosted);
statuses.add(0, convertStatus);
statusAdapter.notifyItemInserted(0);
}
}
}