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) {
|
public void onBindViewHolder(@NonNull final RecyclerView.ViewHolder viewHolder, int i) {
|
||||||
final SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
final SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
||||||
final String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null);
|
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;
|
if (status.getAccount() != null && status.getAccount().getAvatar() != null)
|
||||||
final Status status = statuses.get(viewHolder.getAdapterPosition());
|
Glide.with(context)
|
||||||
if( !status.isClickable())
|
.load(status.getAccount().getAvatar())
|
||||||
Status.transform(context, status);
|
.apply(new RequestOptions().transforms(new FitCenter(), new RoundedCorners(10)))
|
||||||
if( !status.isEmojiFound())
|
.into(holder.art_pp);
|
||||||
Status.makeEmojis(context, this, status);
|
|
||||||
|
|
||||||
if( status.getAccount() != null && status.getAccount().getAvatar() != null)
|
if (status.getArt_attachment() != null)
|
||||||
Glide.with(context)
|
Glide.with(context)
|
||||||
.load(status.getAccount().getAvatar())
|
.load(status.getArt_attachment().getPreview_url())
|
||||||
.apply(new RequestOptions().transforms(new FitCenter(), new RoundedCorners(10)))
|
.into(holder.art_media);
|
||||||
.into(holder.art_pp);
|
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)
|
holder.art_media.setOnClickListener(new View.OnClickListener() {
|
||||||
Glide.with(context)
|
@Override
|
||||||
.load(status.getArt_attachment().getPreview_url())
|
public void onClick(View v) {
|
||||||
.into(holder.art_media);
|
Intent intent = new Intent(context, MediaActivity.class);
|
||||||
holder.art_pp.setOnClickListener(new View.OnClickListener() {
|
Bundle b = new Bundle();
|
||||||
@Override
|
ArrayList<Attachment> attachments = new ArrayList<>();
|
||||||
public void onClick(View v) {
|
if (status.getArt_attachment() != null)
|
||||||
Intent intent = new Intent(context, ShowAccountActivity.class);
|
attachments.add(status.getArt_attachment());
|
||||||
Bundle b = new Bundle();
|
else if (status.getMedia_attachments() != null && status.getMedia_attachments().size() > 0)
|
||||||
b.putParcelable("account", status.getAccount());
|
attachments.add(status.getMedia_attachments().get(0));
|
||||||
intent.putExtras(b);
|
intent.putParcelableArrayListExtra("mediaArray", attachments);
|
||||||
context.startActivity(intent);
|
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() {
|
if (status.getDisplayNameSpan() != null && status.getDisplayNameSpan().toString().trim().length() > 0)
|
||||||
@Override
|
holder.art_username.setText(status.getDisplayNameSpan(), TextView.BufferType.SPANNABLE);
|
||||||
public void onClick(View v) {
|
else
|
||||||
Intent intent = new Intent(context, MediaActivity.class);
|
holder.art_username.setText(status.getAccount().getUsername());
|
||||||
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_acct.setText(String.format("@%s", status.getAccount().getAcct()));
|
||||||
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()));
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -188,112 +188,113 @@ public class PixelfedListAdapter extends RecyclerView.Adapter implements OnPostA
|
||||||
public void onBindViewHolder(@NonNull final RecyclerView.ViewHolder viewHolder, int i) {
|
public void onBindViewHolder(@NonNull final RecyclerView.ViewHolder viewHolder, int i) {
|
||||||
final SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
final SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
||||||
final String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null);
|
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;
|
if (status.getAccount() != null && status.getAccount().getAvatar() != null)
|
||||||
final Status status = statuses.get(viewHolder.getAdapterPosition());
|
Glide.with(context)
|
||||||
if( !status.isClickable())
|
.load(status.getAccount().getAvatar())
|
||||||
Status.transform(context, status);
|
.apply(new RequestOptions().transforms(new FitCenter(), new RoundedCorners(10)))
|
||||||
if( !status.isEmojiFound())
|
.into(holder.art_pp);
|
||||||
Status.makeEmojis(context, this, status);
|
|
||||||
|
|
||||||
if( status.getAccount() != null && status.getAccount().getAvatar() != null)
|
boolean expand_media = sharedpreferences.getBoolean(Helper.SET_EXPAND_MEDIA, false);
|
||||||
Glide.with(context)
|
if (status.getMedia_attachments() != null && status.getMedia_attachments().size() > 0)
|
||||||
.load(status.getAccount().getAvatar())
|
GlideApp.with(context)
|
||||||
.apply(new RequestOptions().transforms(new FitCenter(), new RoundedCorners(10)))
|
.asBitmap()
|
||||||
.into(holder.art_pp);
|
.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);
|
@Override
|
||||||
if( status.getMedia_attachments() != null && status.getMedia_attachments().size() > 0)
|
public boolean onLoadFailed(@Nullable GlideException e, Object model, Target target, boolean isFirstResource) {
|
||||||
GlideApp.with(context)
|
return false;
|
||||||
.asBitmap()
|
}
|
||||||
.load(status.getMedia_attachments().get(0).getPreview_url())
|
})
|
||||||
.listener(new RequestListener<Bitmap>(){
|
.into(holder.art_media);
|
||||||
@Override
|
RelativeLayout.LayoutParams rel_btn = new RelativeLayout.LayoutParams(
|
||||||
public boolean onResourceReady(Bitmap resource, Object model, Target<Bitmap> target, DataSource dataSource, boolean isFirstResource) {
|
ViewGroup.LayoutParams.MATCH_PARENT, holder.art_media.getHeight());
|
||||||
if(status.isSensitive())
|
holder.status_show_more.setLayoutParams(rel_btn);
|
||||||
notifyStatusChanged(status);
|
if (expand_media || !status.isSensitive()) {
|
||||||
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) {
|
|
||||||
status.setAttachmentShown(true);
|
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() {
|
holder.show_more_button_art.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
if( MainActivity.social != UpdateAccountInfoAsyncTask.SOCIAL.PIXELFED) {
|
status.setAttachmentShown(true);
|
||||||
CrossActions.doCrossProfile(context, status.getAccount());
|
notifyStatusChanged(status);
|
||||||
}else{
|
}
|
||||||
Intent intent = new Intent(context, ShowAccountActivity.class);
|
});
|
||||||
|
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();
|
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);
|
intent.putExtras(b);
|
||||||
context.startActivity(intent);
|
context.startActivity(intent);
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
});
|
holder.art_author.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
holder.art_media.setOnClickListener(new View.OnClickListener() {
|
public void onClick(View v) {
|
||||||
@Override
|
if (MainActivity.social != UpdateAccountInfoAsyncTask.SOCIAL.PIXELFED) {
|
||||||
public void onClick(View v) {
|
CrossActions.doCrossConversation(context, status);
|
||||||
Intent intent = new Intent(context, MediaActivity.class);
|
} else {
|
||||||
Bundle b = new Bundle();
|
Intent intent = new Intent(context, ShowConversationActivity.class);
|
||||||
ArrayList<Attachment> attachments = new ArrayList<>();
|
Bundle b = new Bundle();
|
||||||
if( status.getArt_attachment() != null)
|
b.putParcelable("status", status);
|
||||||
attachments.add(status.getArt_attachment());
|
intent.putExtras(b);
|
||||||
else if( status.getMedia_attachments() != null && status.getMedia_attachments().size() > 0)
|
context.startActivity(intent);
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
});
|
|
||||||
|
|
||||||
if( status.getDisplayNameSpan() != null && status.getDisplayNameSpan().toString().trim().length() > 0)
|
if (status.getDisplayNameSpan() != null && status.getDisplayNameSpan().toString().trim().length() > 0)
|
||||||
holder.art_username.setText( status.getDisplayNameSpan(), TextView.BufferType.SPANNABLE);
|
holder.art_username.setText(status.getDisplayNameSpan(), TextView.BufferType.SPANNABLE);
|
||||||
else
|
else
|
||||||
holder.art_username.setText( status.getAccount().getUsername());
|
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() {
|
swipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onRefresh() {
|
public void onRefresh() {
|
||||||
|
@ -516,7 +516,12 @@ public class DisplayStatusFragment extends Fragment implements OnRetrieveFeedsIn
|
||||||
safeStatuses.add(status);
|
safeStatuses.add(status);
|
||||||
}
|
}
|
||||||
this.statuses.addAll(safeStatuses);
|
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())) {
|
}else if( tagTimeline == null || !tagTimeline.isART() || (tagTimeline.isART() && tagTimeline.isNSFW())) {
|
||||||
this.statuses.addAll(statuses);
|
this.statuses.addAll(statuses);
|
||||||
statusListAdapter.notifyItemRangeInserted(previousPosition, statuses.size());
|
statusListAdapter.notifyItemRangeInserted(previousPosition, statuses.size());
|
||||||
|
@ -528,7 +533,13 @@ public class DisplayStatusFragment extends Fragment implements OnRetrieveFeedsIn
|
||||||
safeStatuses.add(status);
|
safeStatuses.add(status);
|
||||||
}
|
}
|
||||||
this.statuses.addAll(safeStatuses);
|
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 {
|
try {
|
||||||
((MainActivity) context).updateHomeCounter();
|
((MainActivity) context).updateHomeCounter();
|
||||||
}catch (Exception ignored){}
|
}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)
|
if (textviewNoAction.getVisibility() == View.VISIBLE)
|
||||||
textviewNoAction.setVisibility(View.GONE);
|
textviewNoAction.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue