148 lines
6.4 KiB
Java
148 lines
6.4 KiB
Java
package com.ubt.jimu.user.view.adapter;
|
|
|
|
import android.content.Context;
|
|
import android.graphics.drawable.Drawable;
|
|
import android.view.View;
|
|
import android.widget.ImageView;
|
|
import android.widget.RelativeLayout;
|
|
import android.widget.TextView;
|
|
import com.bumptech.glide.Glide;
|
|
import com.bumptech.glide.RequestBuilder;
|
|
import com.bumptech.glide.request.RequestOptions;
|
|
import com.recyclelib.adapter.BaseRecyclerAdapter;
|
|
import com.ubt.jimu.R;
|
|
import com.ubt.jimu.base.entities.CollectionEntities;
|
|
import com.ubt.jimu.base.http.ApiObserver;
|
|
import com.ubt.jimu.base.http.manager.CommunityManager;
|
|
import com.ubt.jimu.community.view.PublishDetailActivity;
|
|
import com.ubt.jimu.user.view.CollectionActivity;
|
|
import com.ubtech.utils.StringUtils;
|
|
import java.util.List;
|
|
|
|
/* loaded from: classes2.dex */
|
|
public class CollectionAdapter extends BaseRecyclerAdapter<CollectionEntities.RecordsBean> {
|
|
private ImageView a;
|
|
private ImageView b;
|
|
private ImageView c;
|
|
private TextView d;
|
|
private TextView e;
|
|
private RelativeLayout f;
|
|
private TextView g;
|
|
private ImageView h;
|
|
private RequestOptions i;
|
|
private boolean j;
|
|
StringBuilder k;
|
|
|
|
public CollectionAdapter(Context context, List<CollectionEntities.RecordsBean> list) {
|
|
super(context, list);
|
|
this.j = false;
|
|
this.k = new StringBuilder();
|
|
this.i = RequestOptions.O().b(R.drawable.tab_base_user_default).a(R.drawable.tab_base_user_default);
|
|
}
|
|
|
|
@Override // com.recyclelib.adapter.BaseRecyclerAdapter
|
|
public int layoutId() {
|
|
return R.layout.item_collection;
|
|
}
|
|
|
|
public void setEdit(boolean z) {
|
|
this.j = z;
|
|
notifyDataSetChanged();
|
|
}
|
|
|
|
public /* synthetic */ void a(CollectionEntities.RecordsBean recordsBean, int i, View view) {
|
|
recordsBean.setSelect(!recordsBean.isSelect());
|
|
notifyItemChanged(i + 1);
|
|
((CollectionActivity) this.mContext).E0();
|
|
}
|
|
|
|
@Override // androidx.recyclerview.widget.RecyclerView.Adapter
|
|
public void onBindViewHolder(BaseRecyclerAdapter.BaseViewHolder baseViewHolder, final int i) {
|
|
final CollectionEntities.RecordsBean recordsBean = (CollectionEntities.RecordsBean) this.mList.get(i);
|
|
this.a = (ImageView) baseViewHolder.getView(R.id.img_play_background);
|
|
this.b = (ImageView) baseViewHolder.getView(R.id.img_play);
|
|
this.c = (ImageView) baseViewHolder.getView(R.id.img_header);
|
|
this.d = (TextView) baseViewHolder.getView(R.id.tv_nickname);
|
|
this.e = (TextView) baseViewHolder.getView(R.id.tv_hot_desc);
|
|
this.f = (RelativeLayout) baseViewHolder.getView(R.id.rl_covert);
|
|
this.g = (TextView) baseViewHolder.getView(R.id.tv_state);
|
|
this.h = (ImageView) baseViewHolder.getView(R.id.img_collection_select);
|
|
Glide.e(this.mContext).a(recordsBean.getPostCoverUrl()).a(this.a);
|
|
if (recordsBean.getUserBaseInfo() != null && recordsBean.getUserBaseInfo().getUserImage() != null) {
|
|
RequestBuilder<Drawable> a = Glide.e(this.mContext).a(recordsBean.getUserBaseInfo().getUserImage());
|
|
a.a(this.i);
|
|
a.a(this.c);
|
|
}
|
|
if (recordsBean.getUserBaseInfo() != null && !StringUtils.e(recordsBean.getUserBaseInfo().getNickName())) {
|
|
this.d.setText(recordsBean.getUserBaseInfo().getNickName());
|
|
}
|
|
this.b.setVisibility(8);
|
|
this.e.setText(recordsBean.getTitle());
|
|
if (recordsBean.getStatus() == 1) {
|
|
this.f.setVisibility(8);
|
|
} else if (recordsBean.getStatus() == 0) {
|
|
this.f.setVisibility(0);
|
|
this.g.setText(this.mContext.getString(R.string.pub_is_choice));
|
|
} else if (recordsBean.getStatus() == 2) {
|
|
this.f.setVisibility(0);
|
|
this.g.setText(this.mContext.getString(R.string.pub_no_through));
|
|
} else {
|
|
this.f.setVisibility(0);
|
|
this.g.setText(this.mContext.getString(R.string.pub_is_shield));
|
|
}
|
|
if (this.j) {
|
|
this.h.setVisibility(0);
|
|
} else {
|
|
this.h.setVisibility(8);
|
|
}
|
|
if (recordsBean.isSelect()) {
|
|
this.h.setBackgroundResource(R.mipmap.selected_img);
|
|
} else {
|
|
this.h.setBackgroundResource(R.mipmap.un_select_img);
|
|
}
|
|
this.h.setOnClickListener(new View.OnClickListener() { // from class: com.ubt.jimu.user.view.adapter.a
|
|
@Override // android.view.View.OnClickListener
|
|
public final void onClick(View view) {
|
|
CollectionAdapter.this.a(recordsBean, i, view);
|
|
}
|
|
});
|
|
baseViewHolder.itemView.setOnClickListener(new View.OnClickListener() { // from class: com.ubt.jimu.user.view.adapter.b
|
|
@Override // android.view.View.OnClickListener
|
|
public final void onClick(View view) {
|
|
CollectionAdapter.this.a(recordsBean, view);
|
|
}
|
|
});
|
|
}
|
|
|
|
public /* synthetic */ void a(CollectionEntities.RecordsBean recordsBean, View view) {
|
|
Context context = this.mContext;
|
|
if (((CollectionActivity) context).f) {
|
|
return;
|
|
}
|
|
PublishDetailActivity.start(context, recordsBean.getId());
|
|
}
|
|
|
|
public void a() {
|
|
StringBuilder sb = this.k;
|
|
sb.delete(0, sb.length());
|
|
for (int size = this.mList.size() - 1; size >= 0; size--) {
|
|
if (((CollectionEntities.RecordsBean) this.mList.get(size)).isSelect()) {
|
|
this.k.append(((CollectionEntities.RecordsBean) this.mList.get(size)).getId());
|
|
this.k.append(",");
|
|
}
|
|
}
|
|
CommunityManager.create().delCollectionPost(this.k.toString(), new ApiObserver<Boolean>(null) { // from class: com.ubt.jimu.user.view.adapter.CollectionAdapter.1
|
|
@Override // com.ubt.jimu.base.http.ApiObserver, io.reactivex.Observer
|
|
/* renamed from: a, reason: merged with bridge method [inline-methods] */
|
|
public void onNext(Boolean bool) {
|
|
for (int size2 = ((BaseRecyclerAdapter) CollectionAdapter.this).mList.size() - 1; size2 >= 0; size2--) {
|
|
if (((CollectionEntities.RecordsBean) ((BaseRecyclerAdapter) CollectionAdapter.this).mList.get(size2)).isSelect()) {
|
|
((BaseRecyclerAdapter) CollectionAdapter.this).mList.remove(size2);
|
|
}
|
|
}
|
|
CollectionAdapter.this.notifyDataSetChanged();
|
|
}
|
|
});
|
|
}
|
|
}
|