package cn.flightfeather.thirdapp.dataanalysis;
|
|
import android.content.Context;
|
import android.content.Intent;
|
import android.support.v7.widget.RecyclerView;
|
import android.view.LayoutInflater;
|
import android.view.View;
|
import android.view.ViewGroup;
|
import android.widget.ImageView;
|
import android.widget.ProgressBar;
|
import android.widget.TextView;
|
|
import java.util.List;
|
|
import am.widget.circleprogressbar.CircleProgressBar;
|
import cn.flightfeather.thirdapp.R;
|
import cn.flightfeather.thirdapp.bean.vo.TaskVo;
|
import cn.flightfeather.thirdapp.util.CommonUtils;
|
import cn.flightfeather.thirdapp.view.ScrollTextView;
|
|
/**
|
* Created by hyhb01 on 2018/3/20.
|
* 顶层任务进度是适配器
|
*/
|
|
public class TaskProgressAdapter extends RecyclerView.Adapter<TaskProgressAdapter.TaskProgressHoler> {
|
|
private Context context;
|
private List<TaskVo> taskProgressVoList;
|
|
public TaskProgressAdapter(List<TaskVo> taskProgressVos, Context context){
|
this.taskProgressVoList = taskProgressVos;
|
this.context = context;
|
}
|
|
@Override
|
public TaskProgressHoler onCreateViewHolder(ViewGroup parent, int viewType) {
|
View view = LayoutInflater.from(context).inflate(R.layout.item_task_progress_2, parent, false);
|
return new TaskProgressHoler(view);
|
}
|
|
@Override
|
public void onBindViewHolder(TaskProgressHoler holder, final int position) {
|
//region 顶层任务状态
|
TaskVo thistaskProgressVo = taskProgressVoList.get(position);
|
int toptaskprogress = (int) (thistaskProgressVo.getCompletetask()/(float) thistaskProgressVo.getTotaltask()*100);
|
holder.text_top_task.setText(taskProgressVoList.get(position).getName());
|
holder.progress_complete.setProgress(toptaskprogress);
|
holder.image_top_task.setImageResource(CommonUtils.getIconByTaskType(taskProgressVoList.get(position).getTypeno().toString()));
|
switch (toptaskprogress) {
|
case 0:
|
holder.text_taskStatus.setText("未开始");
|
break;
|
case 100:
|
holder.text_taskStatus.setText("已结束");
|
break;
|
default:
|
holder.text_taskStatus.setText("进行中");
|
break;
|
}
|
//endregion
|
|
//region 我的任务进度
|
// int mytaskprogress = (int) (thistaskProgressVo.getMycompletetask()/(float) thistaskProgressVo.getMytotaltask()*100);
|
// holder.TV_my_progress.setTitle(String.valueOf(mytaskprogress) + "%");
|
// holder.PB_my_progress.setProgress(mytaskprogress);
|
//endregion
|
|
holder.itemView.setOnClickListener(new View.OnClickListener() {
|
@Override
|
public void onClick(View v) {
|
// showDialog(taskProgressVoList.get(position));
|
//region 点击跳转至对应顶层任务的具体界面
|
TaskVo taskProgressVo = taskProgressVoList.get(position);
|
Intent intent = new Intent(context, AnalysisTabActivity.class);
|
intent.putExtra(AnalysisTabActivity.ARG_PARAM1, taskProgressVo);
|
context.startActivity(intent);
|
//endregion
|
}
|
});
|
}
|
|
@Override
|
public int getItemCount() {
|
return taskProgressVoList.size();
|
}
|
|
class TaskProgressHoler extends RecyclerView.ViewHolder{
|
|
ScrollTextView text_top_task;//顶层任务名称
|
|
TextView text_taskStatus;//顶层任务当前状态“未开始”、“进行中”、“已结束”
|
|
CircleProgressBar progress_complete;//完成百分比进度
|
|
ImageView image_top_task;//任务图标随着任务类型不同而改变
|
|
private TextView TV_top_task_progress;
|
private TextView TV_my_progress;
|
private TextView TV_No;
|
|
private ProgressBar PB_top_task_progress;
|
private ProgressBar PB_my_progress;
|
|
|
|
public TaskProgressHoler(View itemView) {
|
super(itemView);
|
text_top_task = itemView.findViewById(R.id.text_top_task);
|
text_taskStatus = itemView.findViewById(R.id.text_taskStatus);
|
progress_complete = itemView.findViewById(R.id.progress_complete);
|
image_top_task = itemView.findViewById(R.id.image_top_task);
|
}
|
}
|
|
}
|