StudyTimeXrcAdapter.java 2.3 KB
package com.hh.xuetubao.adapter;

import android.content.Context;
import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.hh.xuetubao.R;
import com.hh.xuetubao.pieview.PColumn;

import java.text.DecimalFormat;
import java.util.List;

public class StudyTimeXrcAdapter extends RecyclerView.Adapter<StudyTimeXrcAdapter.ViewHolder> {

    private Context context;
    private List<String> day;
    private List<String> time;
    int max;

    public StudyTimeXrcAdapter(Context context, List<String> day, List<String> time, int max) {
        this.context = context;
        this.day = day;
        this.time = time;
        this.max = max;
        Log.e("maxValue1", "max" + max);
    }

    @NonNull
    @Override
    public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(context).inflate(R.layout.rc_read_time, null);
        ViewHolder holder = new ViewHolder(view);
        return holder;
    }

    @Override
    public void onBindViewHolder(@NonNull ViewHolder holder, int position) {

        int a = Integer.valueOf(day.get(position).substring(0, day.get(position).length() - 2));

        if (day.get(position) != null) {
            holder.tvDay.setText(time.get(position));
        }
//        if (time.get(position) != null) {
//            holder.tvTime.setText(a + "");  //day.get(position)
//        }

        String format = new DecimalFormat("0").format(max * 1.2);
        holder.pColumn.setData(a, Integer.valueOf(new DecimalFormat("0").format(max * 1.2)));

    }

    @Override
    public int getItemCount() {
        return day.size();
    }

    public class ViewHolder extends RecyclerView.ViewHolder {

        private final TextView tvDay;
//        private final TextView tvTime;
        private final PColumn pColumn;
//        private final View longView;

        public ViewHolder(View itemView) {
            super(itemView);
            tvDay = (TextView) itemView.findViewById(R.id.tv_day);
//            tvTime = (TextView) itemView.findViewById(R.id.tv_time);
            pColumn = itemView.findViewById(R.id.pcolum);
//            longView = itemView.findViewById(R.id.view_long);
        }
    }
}