fix [分享列表为空的时候设置背景图]
This commit is contained in:
parent
f2d7617ebe
commit
25fbf11fbc
@ -1,9 +1,11 @@
|
||||
package com.yunbao.share.adapters;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.CompoundButton;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.RadioButton;
|
||||
import android.widget.TextView;
|
||||
|
||||
@ -12,6 +14,7 @@ import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.pdlive.shayu.R;
|
||||
import com.yunbao.common.glide.ImgLoader;
|
||||
import com.yunbao.common.utils.ViewUtils;
|
||||
import com.yunbao.common.views.weight.ClipPathCircleImage;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@ -23,18 +26,36 @@ import io.rong.imlib.model.Conversation;
|
||||
public class InternalShareAdapter extends RecyclerView.Adapter<InternalShareAdapter.ViewHolder> {
|
||||
List<SingleConversation> listData = new ArrayList<>();
|
||||
int selectPosition = -1;
|
||||
private int isEmpty = -233;
|
||||
private Context mContext;
|
||||
|
||||
public InternalShareAdapter(Context mContext) {
|
||||
this.mContext = mContext;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
if (viewType == isEmpty) {
|
||||
return new EmptyViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.view_layout_msg, parent, false));
|
||||
}
|
||||
return new ViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.item_internal_user, parent, false));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
|
||||
if (getItemViewType(position) == isEmpty) return;
|
||||
holder.bind(listData.get(position), position);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemViewType(int position) {
|
||||
if (listData.get(position).mCore.getTargetId().equals("isEmpty_-233-pdl-5YK76YC8")) {
|
||||
return isEmpty;
|
||||
}
|
||||
return super.getItemViewType(position);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return listData.size();
|
||||
@ -44,6 +65,11 @@ public class InternalShareAdapter extends RecyclerView.Adapter<InternalShareAdap
|
||||
if (listData == null) {
|
||||
listData = new ArrayList<>();
|
||||
}
|
||||
if (listData.isEmpty()) {
|
||||
Conversation conversation = new Conversation();
|
||||
conversation.setTargetId("isEmpty_-233-pdl-5YK76YC8");
|
||||
listData.add(new SingleConversation(mContext, conversation));
|
||||
}
|
||||
this.listData = listData;
|
||||
notifyDataSetChanged();
|
||||
|
||||
@ -53,6 +79,15 @@ public class InternalShareAdapter extends RecyclerView.Adapter<InternalShareAdap
|
||||
return selectPosition;
|
||||
}
|
||||
|
||||
public class EmptyViewHolder extends ViewHolder {
|
||||
|
||||
public EmptyViewHolder(@NonNull View itemView) {
|
||||
super(itemView);
|
||||
ViewUtils.findViewById(itemView, R.id.imageView, ImageView.class).setImageResource(R.mipmap.ic_addressbook_not_search);
|
||||
ViewUtils.findViewById(itemView, R.id.textView, TextView.class).setText(R.string.not_data_message_address_book_list);
|
||||
}
|
||||
}
|
||||
|
||||
public class ViewHolder extends RecyclerView.ViewHolder {
|
||||
ClipPathCircleImage mAvatar;
|
||||
TextView userName;
|
||||
|
@ -80,7 +80,7 @@ public class AppInternalShareDialog extends AbsDialogFullScreenPopupWindow {
|
||||
search = findViewById(R.id.search);
|
||||
mList = findViewById(R.id.recyclerView);
|
||||
mRefreshLayout = findViewById(R.id.rc_refresh);
|
||||
adapter = new InternalShareAdapter();
|
||||
adapter = new InternalShareAdapter(mContext);
|
||||
mList.setAdapter(adapter);
|
||||
initRefreshView();
|
||||
|
||||
@ -140,6 +140,7 @@ public class AppInternalShareDialog extends AbsDialogFullScreenPopupWindow {
|
||||
}
|
||||
|
||||
private void onConversationListRefresh(RefreshLayout refreshLayout) {
|
||||
search.setText("");
|
||||
listData.clear();
|
||||
startTime = 0;
|
||||
refreshData();
|
||||
|
Loading…
Reference in New Issue
Block a user