Improve conversation activity
This commit is contained in:
parent
37e0c9dbc4
commit
2a1e20543d
|
@ -316,14 +316,17 @@ public class ShowConversationActivity extends BaseActivity implements OnRetrieve
|
|||
statusListAdapter.notifyDataSetChanged();
|
||||
}else {
|
||||
if (context.getAncestors() != null && context.getAncestors().size() > 0) {
|
||||
Log.v(Helper.TAG,"getAncestors= " + context.getAncestors().size());
|
||||
statuses.addAll(0,context.getAncestors());
|
||||
statusListAdapter.notifyItemRangeInserted(0, context.getAncestors().size()-1);
|
||||
}
|
||||
statuses.add(initialStatus);
|
||||
|
||||
if (context.getDescendants() != null && context.getDescendants().size() > 0) {
|
||||
Log.v(Helper.TAG,"getDescendants= " + context.getDescendants().size());
|
||||
statuses.addAll(context.getAncestors().size()+1,context.getDescendants());
|
||||
statusListAdapter.notifyItemRangeInserted(context.getAncestors().size()+1, context.getDescendants().size()-1);
|
||||
}
|
||||
Log.v(Helper.TAG,"statuses= " +statuses.size());
|
||||
}
|
||||
/*statusListAdapter = new StatusListAdapter(ShowConversationActivity.this, position, null, isOnWifi, behaviorWithAttachments, positionSpinnerTrans, statuses);
|
||||
|
||||
|
|
|
@ -476,7 +476,7 @@ public class Status implements Parcelable{
|
|||
}
|
||||
|
||||
|
||||
public static void transform(Context context, Status status, OnRetrieveEmojiInterface listener){
|
||||
public static void transform(Context context, Status status){
|
||||
|
||||
if( ((Activity)context).isFinishing() || status == null)
|
||||
return;
|
||||
|
@ -493,12 +493,12 @@ public class Status implements Parcelable{
|
|||
status.setContentSpan(treatment(context, spannableStringContent, status));
|
||||
if( spannableStringCW.length() > 0)
|
||||
status.setContentSpanCW(treatment(context, spannableStringCW, status));
|
||||
makeEmojis(context, listener, status);
|
||||
|
||||
status.setClickable(true);
|
||||
}
|
||||
|
||||
|
||||
public static void transformTranslation(Context context, OnRetrieveEmojiInterface listener, Status status){
|
||||
public static void transformTranslation(Context context, Status status){
|
||||
|
||||
if( ((Activity)context).isFinishing() || status == null)
|
||||
return;
|
||||
|
@ -512,6 +512,14 @@ public class Status implements Parcelable{
|
|||
spannableStringTranslated = new SpannableString(Html.fromHtml(status.getContentTranslated()));
|
||||
|
||||
status.setContentSpanTranslated(treatment(context, spannableStringTranslated, status));
|
||||
String displayName;
|
||||
if( status.getReblog() != null){
|
||||
displayName = status.getReblog().getAccount().getDisplay_name();
|
||||
}else {
|
||||
displayName = status.getAccount().getDisplay_name();
|
||||
}
|
||||
SpannableString displayNameSpan = new SpannableString(displayName);
|
||||
status.setDisplayNameSpan(displayNameSpan);
|
||||
}
|
||||
|
||||
|
||||
|
@ -529,15 +537,10 @@ public class Status implements Parcelable{
|
|||
final List<Emojis> emojisAccounts = status.getReblog() != null ?status.getReblog().getAccount().getEmojis():status.getAccount().getEmojis();
|
||||
|
||||
status.getAccount().makeEmojisAccount(context, null, status.getAccount());
|
||||
String displayName;
|
||||
if( status.getReblog() != null){
|
||||
displayName = status.getReblog().getAccount().getDisplay_name();
|
||||
}else {
|
||||
displayName = status.getAccount().getDisplay_name();
|
||||
}
|
||||
SpannableString displayNameSpan = new SpannableString(displayName);
|
||||
SpannableString contentSpan = new SpannableString(status.getContent());
|
||||
SpannableString contentSpanCW = new SpannableString(status.getSpoiler_text());
|
||||
|
||||
SpannableString displayNameSpan = status.getDisplayNameSpan();
|
||||
SpannableString contentSpan = status.getContentSpan();
|
||||
SpannableString contentSpanCW = status.getContentSpanCW();
|
||||
if( emojisAccounts != null)
|
||||
emojis.addAll(emojisAccounts);
|
||||
if( emojis != null && emojis.size() > 0 ) {
|
||||
|
@ -565,7 +568,7 @@ public class Status implements Parcelable{
|
|||
@Override
|
||||
public void onResourceReady(@NonNull Bitmap resource, Transition<? super Bitmap> transition) {
|
||||
final String targetedEmoji = ":" + emoji.getShortcode() + ":";
|
||||
if (contentSpan.toString().contains(targetedEmoji)) {
|
||||
if (contentSpan != null && contentSpan.toString().contains(targetedEmoji)) {
|
||||
//emojis can be used several times so we have to loop
|
||||
for (int startPosition = -1; (startPosition = contentSpan.toString().indexOf(targetedEmoji, startPosition + 1)) != -1; startPosition++) {
|
||||
final int endPosition = startPosition + targetedEmoji.length();
|
||||
|
@ -577,7 +580,7 @@ public class Status implements Parcelable{
|
|||
endPosition, Spannable.SPAN_INCLUSIVE_EXCLUSIVE);
|
||||
}
|
||||
}
|
||||
if (displayNameSpan.toString().contains(targetedEmoji)) {
|
||||
if (displayNameSpan != null && displayNameSpan.toString().contains(targetedEmoji)) {
|
||||
//emojis can be used several times so we have to loop
|
||||
for (int startPosition = -1; (startPosition = displayNameSpan.toString().indexOf(targetedEmoji, startPosition + 1)) != -1; startPosition++) {
|
||||
final int endPosition = startPosition + targetedEmoji.length();
|
||||
|
@ -589,7 +592,8 @@ public class Status implements Parcelable{
|
|||
endPosition, Spannable.SPAN_INCLUSIVE_EXCLUSIVE);
|
||||
}
|
||||
}
|
||||
if (contentSpanCW.toString().contains(targetedEmoji)) {
|
||||
status.setDisplayNameSpan(displayNameSpan);
|
||||
if (contentSpanCW != null && contentSpanCW.toString().contains(targetedEmoji)) {
|
||||
//emojis can be used several times so we have to loop
|
||||
for (int startPosition = -1; (startPosition = contentSpanCW.toString().indexOf(targetedEmoji, startPosition + 1)) != -1; startPosition++) {
|
||||
final int endPosition = startPosition + targetedEmoji.length();
|
||||
|
|
|
@ -309,7 +309,7 @@ public class NotificationsListAdapter extends RecyclerView.Adapter implements On
|
|||
|
||||
holder.status_reply.setText("");
|
||||
if( !status.isClickable())
|
||||
Status.transform(context, status, NotificationsListAdapter.this);
|
||||
Status.transform(context, status);
|
||||
if( !status.isEmojiFound())
|
||||
Status.makeEmojis(context, NotificationsListAdapter.this, status);
|
||||
holder.notification_status_content.setText(status.getContentSpan(), TextView.BufferType.SPANNABLE);
|
||||
|
|
|
@ -422,7 +422,6 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
|
|||
if( viewHolder.getItemViewType() == DISPLAYED_STATUS || viewHolder.getItemViewType() == FOCUSED_STATUS || viewHolder.getItemViewType() == COMPACT_STATUS){
|
||||
final ViewHolder holder = (ViewHolder) viewHolder;
|
||||
final Status status = statuses.get(position);
|
||||
|
||||
final SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
||||
|
||||
status.setItemViewType(viewHolder.getItemViewType());
|
||||
|
@ -638,7 +637,7 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
|
|||
holder.vertical_content.setLayoutParams(params);
|
||||
holder.left_buttons.setLayoutParams(paramsB);
|
||||
if( !status.isClickable())
|
||||
Status.transform(context, status, this);
|
||||
Status.transform(context, status);
|
||||
if( !status.isEmojiFound())
|
||||
Status.makeEmojis(context, this, status);
|
||||
holder.status_content.setOnTouchListener(new View.OnTouchListener() {
|
||||
|
@ -2262,7 +2261,7 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
|
|||
status.setTranslated(true);
|
||||
status.setTranslationShown(true);
|
||||
status.setContentTranslated(translate.getTranslatedContent());
|
||||
Status.transformTranslation(context, StatusListAdapter.this, status);
|
||||
Status.transformTranslation(context, status);
|
||||
Status.makeEmojisTranslation(context, StatusListAdapter.this, status);
|
||||
notifyStatusChanged(status);
|
||||
}else {
|
||||
|
|
Loading…
Reference in New Issue