侧边栏:任务中心
This commit is contained in:
@@ -64,6 +64,9 @@ public class CustomDrawerPopupAdapter extends RecyclerView.Adapter {
|
||||
if (holder instanceof DrawerRecommendViewHolder) {
|
||||
DrawerRecommendViewHolder recommendViewHolder = (DrawerRecommendViewHolder) holder;
|
||||
recommendViewHolder.setData(infoModels.get(position));
|
||||
}else if (holder instanceof DrawerTaskViewHolder) {
|
||||
DrawerTaskViewHolder taskViewHolder = (DrawerTaskViewHolder) holder;
|
||||
taskViewHolder.setData(infoModels.get(position));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
package com.yunbao.common.adapter;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.yunbao.common.R;
|
||||
import com.yunbao.common.bean.CustomSidebarChildModel;
|
||||
import com.yunbao.common.views.DrawerTaskChildViewHolder;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class DrawerTaskAdapter extends RecyclerView.Adapter {
|
||||
private Context mContext;
|
||||
private List<CustomSidebarChildModel> child = new ArrayList<>();
|
||||
|
||||
public DrawerTaskAdapter(Context mContext) {
|
||||
this.mContext = mContext;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
View taskCenterView = LayoutInflater.from(parent.getContext()).inflate(R.layout.view_tsak_center_child, parent, false);
|
||||
return new DrawerTaskChildViewHolder(taskCenterView);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
|
||||
DrawerTaskChildViewHolder taskChildViewHolder = (DrawerTaskChildViewHolder) holder;
|
||||
taskChildViewHolder.setData(child.get(position));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return child.size();
|
||||
}
|
||||
|
||||
public void updateData(List<CustomSidebarChildModel> mChild) {
|
||||
child.clear();
|
||||
child.addAll(mChild);
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
}
|
||||
@@ -19,6 +19,15 @@ public class CustomSidebarChildModel extends BaseModel {
|
||||
private String showType;
|
||||
@SerializedName("sort")
|
||||
private String sort;
|
||||
@SerializedName("english")
|
||||
private String english;
|
||||
//奖励领取状态 0未达到领取要求 1已领取 2未领取
|
||||
@SerializedName("status")
|
||||
private String status;
|
||||
@SerializedName("need_num")
|
||||
private String needNum;
|
||||
@SerializedName("now_num")
|
||||
private String nowNum;
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
@@ -91,4 +100,40 @@ public class CustomSidebarChildModel extends BaseModel {
|
||||
this.sort = sort;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getEnglish() {
|
||||
return english;
|
||||
}
|
||||
|
||||
public CustomSidebarChildModel setEnglish(String english) {
|
||||
this.english = english;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public CustomSidebarChildModel setStatus(String status) {
|
||||
this.status = status;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getNeedNum() {
|
||||
return needNum;
|
||||
}
|
||||
|
||||
public CustomSidebarChildModel setNeedNum(String needNum) {
|
||||
this.needNum = needNum;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getNowNum() {
|
||||
return nowNum;
|
||||
}
|
||||
|
||||
public CustomSidebarChildModel setNowNum(String nowNum) {
|
||||
this.nowNum = nowNum;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
package com.yunbao.common.views;
|
||||
|
||||
import android.graphics.Color;
|
||||
import android.text.TextUtils;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.yunbao.common.R;
|
||||
import com.yunbao.common.bean.CustomSidebarChildModel;
|
||||
import com.yunbao.common.glide.ImgLoader;
|
||||
|
||||
public class DrawerTaskChildViewHolder extends RecyclerView.ViewHolder {
|
||||
private ImageView icon;
|
||||
private TextView title, subtitle, toReceive;
|
||||
private RelativeLayout layout;
|
||||
|
||||
|
||||
public DrawerTaskChildViewHolder(@NonNull View itemView) {
|
||||
super(itemView);
|
||||
icon = itemView.findViewById(R.id.icon);
|
||||
title = itemView.findViewById(R.id.title);
|
||||
subtitle = itemView.findViewById(R.id.subtitle);
|
||||
toReceive = itemView.findViewById(R.id.to_receive);
|
||||
layout = itemView.findViewById(R.id.layout);
|
||||
}
|
||||
|
||||
public void setData(CustomSidebarChildModel model) {
|
||||
ImgLoader.display2(itemView.getContext(), model.getIcon(), icon);
|
||||
StringBuffer titleBuffer = new StringBuffer();
|
||||
titleBuffer
|
||||
.append(model.getTitle())
|
||||
.append("(")
|
||||
.append(model.getNowNum())
|
||||
.append("/")
|
||||
.append(model.getNeedNum())
|
||||
.append(")");
|
||||
title.setText(titleBuffer.toString());
|
||||
subtitle.setText(model.getSubtitle());
|
||||
if (TextUtils.equals(model.getStatus(), "0")) {
|
||||
layout.setEnabled(false);
|
||||
toReceive.setText(R.string.to_complete);
|
||||
toReceive.setBackgroundResource(R.drawable.bg_drawer_popup_task_status);
|
||||
toReceive.setEnabled(false);
|
||||
} else if (TextUtils.equals(model.getStatus(), "1")) {
|
||||
layout.setEnabled(false);
|
||||
toReceive.setText(R.string.already_collected);
|
||||
toReceive.setBackgroundResource(R.drawable.bg_drawer_popup_task_status2);
|
||||
toReceive.setTextColor(Color.parseColor("#DDDDDD"));
|
||||
} else if (TextUtils.equals(model.getStatus(), "2")) {
|
||||
toReceive.setBackgroundResource(R.drawable.bg_drawer_popup_task_status);
|
||||
toReceive.setEnabled(true);
|
||||
layout.setEnabled(true);
|
||||
toReceive.setText(R.string.to_receive);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,15 +1,37 @@
|
||||
package com.yunbao.common.views;
|
||||
|
||||
import android.view.View;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.yunbao.common.R;
|
||||
import com.yunbao.common.adapter.DrawerTaskAdapter;
|
||||
import com.yunbao.common.bean.CustomSidebarInfoModel;
|
||||
|
||||
/**
|
||||
* 侧边栏任务布局
|
||||
*/
|
||||
public class DrawerTaskViewHolder extends RecyclerView.ViewHolder {
|
||||
private TextView sendGoodGift, subtitle;
|
||||
private RecyclerView childList;
|
||||
private DrawerTaskAdapter taskAdapter;
|
||||
|
||||
public DrawerTaskViewHolder(@NonNull View itemView) {
|
||||
super(itemView);
|
||||
sendGoodGift = itemView.findViewById(R.id.send_good_gift);
|
||||
subtitle = itemView.findViewById(R.id.subtitle);
|
||||
childList = itemView.findViewById(R.id.child_list);
|
||||
taskAdapter = new DrawerTaskAdapter(itemView.getContext());
|
||||
childList.setLayoutManager(new LinearLayoutManager(itemView.getContext(), LinearLayoutManager.VERTICAL, false));
|
||||
childList.setAdapter(taskAdapter);
|
||||
}
|
||||
|
||||
public void setData(CustomSidebarInfoModel model) {
|
||||
sendGoodGift.setText(model.getTitle());
|
||||
subtitle.setText(model.getSubtitle());
|
||||
taskAdapter.updateData(model.getChild());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user