В адаптере передаю открытие картинок во ViewPager, но неустраивает только одно, не открываются только те новости у которых 10 и больше картинок, а все остальные работают без вопросов!!! помогите исправить??
public class PostAdapter extends RecyclerView.Adapter<PostAdapter.PostViewHolder> {
private LayoutInflater mInflater;
private int mShowStyle;
VKPostArray obj;
VKApiPost p;
VKApiPhoto vkPhoto;
ArrayList<String> imgUrls1;
VKApiUser mainUser;
Context ctx;
public PostAdapter(Context context, VKPostArray posts, VKApiUser user, int showStyle) {
super();
this.obj = posts;
this.mainUser = user;
this.mInflater = LayoutInflater.from(context);
this.mShowStyle = showStyle;
}
@Override
public void onBindViewHolder(PostViewHolder holder, int position) {
p = obj.get(position);
holder.textPost.setText(p.text);
holder.textlikePost.setText(" " + p.likes_count);
holder.textrepostPost.setText(" " + p.reposts_count);
SimpleDateFormat format = new SimpleDateFormat("dd.MM.yyyy HH:mm");
holder.textDatePost.setText(format.format(new java.util.Date(p.date * 1000)));
VKAttachments att = new VKAttachments();
att = p.attachments;
int i;
imgUrls1 = new ArrayList<>();
try {
for (i = 0; i <= att.size(); i++) {
vkPhoto = (VKApiPhoto) att.get(i);
imgUrls1.add(vkPhoto.photo_604);
}
} catch (Exception e) {
holder.mNglContent.setImagesData(imgUrls1);
}
}
@Override
public int getItemCount() {
return obj.size();
}
@Override
public PostViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
if (mShowStyle == NineGridImageView.STYLE_GRID) {
return new PostViewHolder(mInflater.inflate(R.layout.recycler_item_wall, parent, false));
} else {
return new PostViewHolder(mInflater.inflate(R.layout.recycler_item_wall, parent, false));
}}
public class PostViewHolder extends RecyclerView.ViewHolder {
CardView cv;
TextView textPost, news_name, textDatePost, textrepostPost, textlikePost;
ImageView like, repost ;
NineGridImageView mNglContent;
private NineGridImageViewAdapter<String> mAdapter = new NineGridImageViewAdapter<String>() {
@Override
protected void onDisplayImage(Context context, ImageView imageView, String s) {
Picasso.with(context).load(s).placeholder(R.drawable.ic_ab_app).into(imageView);
}
@Override
protected ImageView generateImageView(Context context) {
return super.generateImageView(context);
}
@Override
protected void onItemImageClick(Context context, int position, List<String> list) {
try {
Intent intent = new Intent(context, FullPhoto.class);
intent.putStringArrayListExtra(Constants.BUNDLE_BITMAP, (ArrayList<String>)list);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(intent);
}catch (Exception e){}
}
};
public PostViewHolder(View itemView) {
super(itemView);
cv = (CardView) itemView.findViewById(R.id.card_view_wall);
news_name = (TextView) itemView.findViewById(R.id.news_name);
textDatePost = (TextView) itemView.findViewById(R.id.textDatePost);
textPost = (TextView) itemView.findViewById(R.id.textPost);
textlikePost = (TextView) itemView.findViewById(R.id.tv_likes_count);
textrepostPost = (TextView) itemView.findViewById(R.id.tv_reposts_count);
like = (ImageView) itemView.findViewById(R.id.iv_like);
repost = (ImageView) itemView.findViewById(R.id.iv_repost);
mNglContent = (NineGridImageView) itemView.findViewById(R.id.ngl_images);
mNglContent.setAdapter(mAdapter);
}
}
принимаю так:
if (getIntent().getExtras() != null) {
ar1 = getIntent().getExtras().getStringArrayList(Constants.BUNDLE_BITMAP);
}
Возникает ошибка:
java.lang.ClassCastException: java.util.AbstractList$SubAbstractListRandomAccess cannot be cast to java.util.ArrayList
at calculation.material.oma.sviter.by.PostAdapter$PostViewHolder$1$override.onItemImageClick(PostAdapter.java:112)
at calculation.material.oma.sviter.by.PostAdapter$PostViewHolder$1$override.access$dispatch(PostAdapter.java)
at calculation.material.oma.sviter.by.PostAdapter$PostViewHolder$1.onItemImageClick(PostAdapter.java:0)
at com.jaeger.ninegridimageview.NineGridImageView$1.onClick(NineGridImageView.java:167)
at android.view.View.performClick(View.java:5204)
at android.view.View$PerformClick.run(View.java:21153)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
}catch (Exception e){}
, что переводится на русский, какесли возникает ошибка типа Exception, сделать {}(ничего)