Prepare backend 3a - fix filter crashes
This commit is contained in:
parent
937c16c088
commit
7604bf9f3d
|
@ -177,68 +177,69 @@ public class ArtListAdapter extends RecyclerView.Adapter implements OnPostAction
|
|||
public void onBindViewHolder(@NonNull final RecyclerView.ViewHolder viewHolder, int i) {
|
||||
final SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
||||
final String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null);
|
||||
if( viewHolder.getItemViewType() != HIDDEN_STATUS ) {
|
||||
final ViewHolderArt holder = (ViewHolderArt) viewHolder;
|
||||
final Status status = statuses.get(viewHolder.getAdapterPosition());
|
||||
if (!status.isClickable())
|
||||
Status.transform(context, status);
|
||||
if (!status.isEmojiFound())
|
||||
Status.makeEmojis(context, this, status);
|
||||
|
||||
final ViewHolderArt holder = (ViewHolderArt) viewHolder;
|
||||
final Status status = statuses.get(viewHolder.getAdapterPosition());
|
||||
if( !status.isClickable())
|
||||
Status.transform(context, status);
|
||||
if( !status.isEmojiFound())
|
||||
Status.makeEmojis(context, this, status);
|
||||
if (status.getAccount() != null && status.getAccount().getAvatar() != null)
|
||||
Glide.with(context)
|
||||
.load(status.getAccount().getAvatar())
|
||||
.apply(new RequestOptions().transforms(new FitCenter(), new RoundedCorners(10)))
|
||||
.into(holder.art_pp);
|
||||
|
||||
if( status.getAccount() != null && status.getAccount().getAvatar() != null)
|
||||
Glide.with(context)
|
||||
.load(status.getAccount().getAvatar())
|
||||
.apply(new RequestOptions().transforms(new FitCenter(), new RoundedCorners(10)))
|
||||
.into(holder.art_pp);
|
||||
if (status.getArt_attachment() != null)
|
||||
Glide.with(context)
|
||||
.load(status.getArt_attachment().getPreview_url())
|
||||
.into(holder.art_media);
|
||||
holder.art_pp.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Intent intent = new Intent(context, ShowAccountActivity.class);
|
||||
Bundle b = new Bundle();
|
||||
b.putParcelable("account", status.getAccount());
|
||||
intent.putExtras(b);
|
||||
context.startActivity(intent);
|
||||
}
|
||||
});
|
||||
|
||||
if( status.getArt_attachment() != null)
|
||||
Glide.with(context)
|
||||
.load(status.getArt_attachment().getPreview_url())
|
||||
.into(holder.art_media);
|
||||
holder.art_pp.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Intent intent = new Intent(context, ShowAccountActivity.class);
|
||||
Bundle b = new Bundle();
|
||||
b.putParcelable("account", status.getAccount());
|
||||
intent.putExtras(b);
|
||||
context.startActivity(intent);
|
||||
}
|
||||
});
|
||||
holder.art_media.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Intent intent = new Intent(context, MediaActivity.class);
|
||||
Bundle b = new Bundle();
|
||||
ArrayList<Attachment> attachments = new ArrayList<>();
|
||||
if (status.getArt_attachment() != null)
|
||||
attachments.add(status.getArt_attachment());
|
||||
else if (status.getMedia_attachments() != null && status.getMedia_attachments().size() > 0)
|
||||
attachments.add(status.getMedia_attachments().get(0));
|
||||
intent.putParcelableArrayListExtra("mediaArray", attachments);
|
||||
b.putInt("position", 0);
|
||||
intent.putExtras(b);
|
||||
context.startActivity(intent);
|
||||
}
|
||||
});
|
||||
holder.art_author.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Intent intent = new Intent(context, ShowConversationActivity.class);
|
||||
Bundle b = new Bundle();
|
||||
b.putParcelable("status", status);
|
||||
intent.putExtras(b);
|
||||
context.startActivity(intent);
|
||||
}
|
||||
});
|
||||
|
||||
holder.art_media.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Intent intent = new Intent(context, MediaActivity.class);
|
||||
Bundle b = new Bundle();
|
||||
ArrayList<Attachment> attachments = new ArrayList<>();
|
||||
if( status.getArt_attachment() != null)
|
||||
attachments.add(status.getArt_attachment());
|
||||
else if( status.getMedia_attachments() != null && status.getMedia_attachments().size() > 0)
|
||||
attachments.add(status.getMedia_attachments().get(0));
|
||||
intent.putParcelableArrayListExtra("mediaArray", attachments);
|
||||
b.putInt("position", 0);
|
||||
intent.putExtras(b);
|
||||
context.startActivity(intent);
|
||||
}
|
||||
});
|
||||
holder.art_author.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Intent intent = new Intent(context, ShowConversationActivity.class);
|
||||
Bundle b = new Bundle();
|
||||
b.putParcelable("status", status);
|
||||
intent.putExtras(b);
|
||||
context.startActivity(intent);
|
||||
}
|
||||
});
|
||||
if (status.getDisplayNameSpan() != null && status.getDisplayNameSpan().toString().trim().length() > 0)
|
||||
holder.art_username.setText(status.getDisplayNameSpan(), TextView.BufferType.SPANNABLE);
|
||||
else
|
||||
holder.art_username.setText(status.getAccount().getUsername());
|
||||
|
||||
if( status.getDisplayNameSpan() != null && status.getDisplayNameSpan().toString().trim().length() > 0)
|
||||
holder.art_username.setText( status.getDisplayNameSpan(), TextView.BufferType.SPANNABLE);
|
||||
else
|
||||
holder.art_username.setText( status.getAccount().getUsername());
|
||||
|
||||
holder.art_acct.setText(String.format("@%s", status.getAccount().getAcct()));
|
||||
holder.art_acct.setText(String.format("@%s", status.getAccount().getAcct()));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -188,112 +188,113 @@ public class PixelfedListAdapter extends RecyclerView.Adapter implements OnPostA
|
|||
public void onBindViewHolder(@NonNull final RecyclerView.ViewHolder viewHolder, int i) {
|
||||
final SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
||||
final String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null);
|
||||
if( viewHolder.getItemViewType() != HIDDEN_STATUS ) {
|
||||
final ViewHolderPixelfed holder = (ViewHolderPixelfed) viewHolder;
|
||||
final Status status = statuses.get(viewHolder.getAdapterPosition());
|
||||
if (!status.isClickable())
|
||||
Status.transform(context, status);
|
||||
if (!status.isEmojiFound())
|
||||
Status.makeEmojis(context, this, status);
|
||||
|
||||
final ViewHolderPixelfed holder = (ViewHolderPixelfed) viewHolder;
|
||||
final Status status = statuses.get(viewHolder.getAdapterPosition());
|
||||
if( !status.isClickable())
|
||||
Status.transform(context, status);
|
||||
if( !status.isEmojiFound())
|
||||
Status.makeEmojis(context, this, status);
|
||||
if (status.getAccount() != null && status.getAccount().getAvatar() != null)
|
||||
Glide.with(context)
|
||||
.load(status.getAccount().getAvatar())
|
||||
.apply(new RequestOptions().transforms(new FitCenter(), new RoundedCorners(10)))
|
||||
.into(holder.art_pp);
|
||||
|
||||
if( status.getAccount() != null && status.getAccount().getAvatar() != null)
|
||||
Glide.with(context)
|
||||
.load(status.getAccount().getAvatar())
|
||||
.apply(new RequestOptions().transforms(new FitCenter(), new RoundedCorners(10)))
|
||||
.into(holder.art_pp);
|
||||
boolean expand_media = sharedpreferences.getBoolean(Helper.SET_EXPAND_MEDIA, false);
|
||||
if (status.getMedia_attachments() != null && status.getMedia_attachments().size() > 0)
|
||||
GlideApp.with(context)
|
||||
.asBitmap()
|
||||
.load(status.getMedia_attachments().get(0).getPreview_url())
|
||||
.listener(new RequestListener<Bitmap>() {
|
||||
@Override
|
||||
public boolean onResourceReady(Bitmap resource, Object model, Target<Bitmap> target, DataSource dataSource, boolean isFirstResource) {
|
||||
if (status.isSensitive())
|
||||
notifyStatusChanged(status);
|
||||
return false;
|
||||
}
|
||||
|
||||
boolean expand_media = sharedpreferences.getBoolean(Helper.SET_EXPAND_MEDIA, false);
|
||||
if( status.getMedia_attachments() != null && status.getMedia_attachments().size() > 0)
|
||||
GlideApp.with(context)
|
||||
.asBitmap()
|
||||
.load(status.getMedia_attachments().get(0).getPreview_url())
|
||||
.listener(new RequestListener<Bitmap>(){
|
||||
@Override
|
||||
public boolean onResourceReady(Bitmap resource, Object model, Target<Bitmap> target, DataSource dataSource, boolean isFirstResource) {
|
||||
if(status.isSensitive())
|
||||
notifyStatusChanged(status);
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onLoadFailed(@Nullable GlideException e, Object model, Target target, boolean isFirstResource) {
|
||||
return false;
|
||||
}
|
||||
})
|
||||
.into(holder.art_media);
|
||||
RelativeLayout.LayoutParams rel_btn = new RelativeLayout.LayoutParams(
|
||||
ViewGroup.LayoutParams.MATCH_PARENT, holder.art_media.getHeight());
|
||||
holder.status_show_more.setLayoutParams(rel_btn);
|
||||
if (expand_media || !status.isSensitive()) {
|
||||
status.setAttachmentShown(true);
|
||||
holder.status_show_more.setVisibility(View.GONE);
|
||||
} else {
|
||||
if (!status.isAttachmentShown()) {
|
||||
holder.status_show_more.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
holder.status_show_more.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
holder.show_more_button_art.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
@Override
|
||||
public boolean onLoadFailed(@Nullable GlideException e, Object model, Target target, boolean isFirstResource) {
|
||||
return false;
|
||||
}
|
||||
})
|
||||
.into(holder.art_media);
|
||||
RelativeLayout.LayoutParams rel_btn = new RelativeLayout.LayoutParams(
|
||||
ViewGroup.LayoutParams.MATCH_PARENT, holder.art_media.getHeight());
|
||||
holder.status_show_more.setLayoutParams(rel_btn);
|
||||
if (expand_media || !status.isSensitive()) {
|
||||
status.setAttachmentShown(true);
|
||||
notifyStatusChanged(status);
|
||||
holder.status_show_more.setVisibility(View.GONE);
|
||||
} else {
|
||||
if (!status.isAttachmentShown()) {
|
||||
holder.status_show_more.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
holder.status_show_more.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
});
|
||||
holder.art_pp.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if( MainActivity.social != UpdateAccountInfoAsyncTask.SOCIAL.PIXELFED) {
|
||||
CrossActions.doCrossProfile(context, status.getAccount());
|
||||
}else{
|
||||
Intent intent = new Intent(context, ShowAccountActivity.class);
|
||||
|
||||
holder.show_more_button_art.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
status.setAttachmentShown(true);
|
||||
notifyStatusChanged(status);
|
||||
}
|
||||
});
|
||||
holder.art_pp.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (MainActivity.social != UpdateAccountInfoAsyncTask.SOCIAL.PIXELFED) {
|
||||
CrossActions.doCrossProfile(context, status.getAccount());
|
||||
} else {
|
||||
Intent intent = new Intent(context, ShowAccountActivity.class);
|
||||
Bundle b = new Bundle();
|
||||
b.putParcelable("account", status.getAccount());
|
||||
intent.putExtras(b);
|
||||
context.startActivity(intent);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
holder.art_media.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Intent intent = new Intent(context, MediaActivity.class);
|
||||
Bundle b = new Bundle();
|
||||
b.putParcelable("account", status.getAccount());
|
||||
ArrayList<Attachment> attachments = new ArrayList<>();
|
||||
if (status.getArt_attachment() != null)
|
||||
attachments.add(status.getArt_attachment());
|
||||
else if (status.getMedia_attachments() != null && status.getMedia_attachments().size() > 0)
|
||||
attachments.add(status.getMedia_attachments().get(0));
|
||||
intent.putParcelableArrayListExtra("mediaArray", attachments);
|
||||
b.putInt("position", 0);
|
||||
intent.putExtras(b);
|
||||
context.startActivity(intent);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
holder.art_media.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Intent intent = new Intent(context, MediaActivity.class);
|
||||
Bundle b = new Bundle();
|
||||
ArrayList<Attachment> attachments = new ArrayList<>();
|
||||
if( status.getArt_attachment() != null)
|
||||
attachments.add(status.getArt_attachment());
|
||||
else if( status.getMedia_attachments() != null && status.getMedia_attachments().size() > 0)
|
||||
attachments.add(status.getMedia_attachments().get(0));
|
||||
intent.putParcelableArrayListExtra("mediaArray", attachments);
|
||||
b.putInt("position", 0);
|
||||
intent.putExtras(b);
|
||||
context.startActivity(intent);
|
||||
}
|
||||
});
|
||||
holder.art_author.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if(MainActivity.social != UpdateAccountInfoAsyncTask.SOCIAL.PIXELFED) {
|
||||
CrossActions.doCrossConversation(context, status);
|
||||
}else {
|
||||
Intent intent = new Intent(context, ShowConversationActivity.class);
|
||||
Bundle b = new Bundle();
|
||||
b.putParcelable("status", status);
|
||||
intent.putExtras(b);
|
||||
context.startActivity(intent);
|
||||
});
|
||||
holder.art_author.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (MainActivity.social != UpdateAccountInfoAsyncTask.SOCIAL.PIXELFED) {
|
||||
CrossActions.doCrossConversation(context, status);
|
||||
} else {
|
||||
Intent intent = new Intent(context, ShowConversationActivity.class);
|
||||
Bundle b = new Bundle();
|
||||
b.putParcelable("status", status);
|
||||
intent.putExtras(b);
|
||||
context.startActivity(intent);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
if( status.getDisplayNameSpan() != null && status.getDisplayNameSpan().toString().trim().length() > 0)
|
||||
holder.art_username.setText( status.getDisplayNameSpan(), TextView.BufferType.SPANNABLE);
|
||||
else
|
||||
holder.art_username.setText( status.getAccount().getUsername());
|
||||
if (status.getDisplayNameSpan() != null && status.getDisplayNameSpan().toString().trim().length() > 0)
|
||||
holder.art_username.setText(status.getDisplayNameSpan(), TextView.BufferType.SPANNABLE);
|
||||
else
|
||||
holder.art_username.setText(status.getAccount().getUsername());
|
||||
|
||||
holder.art_acct.setText(String.format("@%s", status.getAccount().getAcct()));
|
||||
holder.art_acct.setText(String.format("@%s", status.getAccount().getAcct()));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -303,7 +303,7 @@ public class DisplayStatusFragment extends Fragment implements OnRetrieveFeedsIn
|
|||
});
|
||||
|
||||
|
||||
if( instanceType == null || instanceType.equals("MASTODON") || instanceType.equals("PIXELFED"))
|
||||
if( !instanceType.equals("PEERTUBE"))
|
||||
swipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
|
||||
@Override
|
||||
public void onRefresh() {
|
||||
|
@ -516,7 +516,12 @@ public class DisplayStatusFragment extends Fragment implements OnRetrieveFeedsIn
|
|||
safeStatuses.add(status);
|
||||
}
|
||||
this.statuses.addAll(safeStatuses);
|
||||
statusListAdapter.notifyItemRangeInserted(previousPosition, safeStatuses.size());
|
||||
if( instanceType.equals("MASTODON") || instanceType.equals("MISSKEY"))
|
||||
statusListAdapter.notifyItemRangeInserted(previousPosition, safeStatuses.size());
|
||||
else if( instanceType.equals("PIXELFED"))
|
||||
pixelfedListAdapter.notifyItemRangeInserted(previousPosition, safeStatuses.size());
|
||||
else if( instanceType.equals("ART"))
|
||||
artListAdapter.notifyItemRangeInserted(previousPosition, safeStatuses.size());
|
||||
}else if( tagTimeline == null || !tagTimeline.isART() || (tagTimeline.isART() && tagTimeline.isNSFW())) {
|
||||
this.statuses.addAll(statuses);
|
||||
statusListAdapter.notifyItemRangeInserted(previousPosition, statuses.size());
|
||||
|
@ -528,7 +533,13 @@ public class DisplayStatusFragment extends Fragment implements OnRetrieveFeedsIn
|
|||
safeStatuses.add(status);
|
||||
}
|
||||
this.statuses.addAll(safeStatuses);
|
||||
statusListAdapter.notifyItemRangeInserted(previousPosition, safeStatuses.size());
|
||||
|
||||
if( instanceType.equals("MASTODON") || instanceType.equals("MISSKEY"))
|
||||
statusListAdapter.notifyItemRangeInserted(previousPosition, safeStatuses.size());
|
||||
else if( instanceType.equals("PIXELFED"))
|
||||
pixelfedListAdapter.notifyItemRangeInserted(previousPosition, safeStatuses.size());
|
||||
else if( instanceType.equals("ART"))
|
||||
artListAdapter.notifyItemRangeInserted(previousPosition, safeStatuses.size());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -566,7 +577,13 @@ public class DisplayStatusFragment extends Fragment implements OnRetrieveFeedsIn
|
|||
try {
|
||||
((MainActivity) context).updateHomeCounter();
|
||||
}catch (Exception ignored){}
|
||||
statusListAdapter.notifyItemInserted(0);
|
||||
|
||||
if( instanceType.equals("MASTODON") || instanceType.equals("MISSKEY"))
|
||||
statusListAdapter.notifyItemInserted(0);
|
||||
else if( instanceType.equals("PIXELFED"))
|
||||
pixelfedListAdapter.notifyItemInserted(0);
|
||||
else if( instanceType.equals("ART"))
|
||||
artListAdapter.notifyItemInserted(0);
|
||||
if (textviewNoAction.getVisibility() == View.VISIBLE)
|
||||
textviewNoAction.setVisibility(View.GONE);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue