You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

145 lines
4.8 KiB
Java

package com.rehome.zhdcoa.adapter;
import android.content.Context;
import android.graphics.Color;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.CheckBox;
import android.widget.TextView;
import com.rehome.zhdcoa.R;
import com.rehome.zhdcoa.bean.RealTimeKcpdInfo;
import com.rehome.zhdcoa.entity.KcpdInfo;
import com.zhy.autolayout.utils.AutoUtils;
import java.util.List;
public class RealTimeKcpdAdapter extends BaseAdapter implements View.OnClickListener{
private final List<RealTimeKcpdInfo.RowsBean> infos;
private final Context context;
private final RealTimeKcpdAdapter.Callback mCallback;
public interface Callback {
void cbClick(View view);
}
public RealTimeKcpdAdapter(List<RealTimeKcpdInfo.RowsBean> infos, Context context, RealTimeKcpdAdapter.Callback mCallback) {
this.infos = infos;
this.context = context;
this.mCallback = mCallback;
}
@Override
public int getCount() {
return infos.size();
}
@Override
public Object getItem(int i) {
return infos.get(i);
}
@Override
public long getItemId(int i) {
return i;
}
@Override
public View getView(final int i, View view, ViewGroup viewGroup) {
final RealTimeKcpdAdapter.ViewHolder holder;
if (view == null) {
holder = new RealTimeKcpdAdapter.ViewHolder();
view = LayoutInflater.from(context).inflate(R.layout.adapter_real_time_kcpd, viewGroup, false);
holder.tv_ms = view.findViewById(R.id.tv_ms);
holder.tv_sl = view.findViewById(R.id.tv_sl);
holder.tv_wl = view.findViewById(R.id.tv_wl);
holder.tv_hg = view.findViewById(R.id.tv_hg);
holder.cb = view.findViewById(R.id.cb_isprint);
holder.tv_pdsl = view.findViewById(R.id.tv_pdsl);
holder.tv_pdzt = view.findViewById(R.id.tv_pdzt);
holder.tv_hjzy = view.findViewById(R.id.tv_hjzy);
holder.tv_wzbm = view.findViewById(R.id.tv_wzbm);
view.setTag(holder);
AutoUtils.autoSize(view);
} else {
holder = (RealTimeKcpdAdapter.ViewHolder) view.getTag();
}
holder.tv_ms.setText(infos.get(i).getDESCRIPTION());
holder.tv_wl.setText(infos.get(i).getBINNUM());
holder.tv_sl.setText(infos.get(i).getCURBAL() + "");
holder.tv_hg.setText(infos.get(i).getITEMNUM());
holder.cb.setChecked(infos.get(i).isFlag());
holder.tv_pdsl.setText(infos.get(i).getPDSL());
holder.tv_hjzy.setText(infos.get(i).getSTOCKTYPE());
holder.tv_wzbm.setText(infos.get(i).getITEMNUM());
2 years ago
if (infos.get(i).getISPD().equals("1")) {
holder.tv_pdzt.setText("已盘点");
int color = context.getResources().getColor(R.color.red);
holder.tv_pdzt.setTextColor(color);
holder.tv_ms.setTextColor(color);
holder.tv_wl.setTextColor(color);
holder.tv_sl.setTextColor(color);
holder.tv_hg.setTextColor(color);
holder.tv_pdsl.setTextColor(color);
holder.tv_hjzy.setTextColor(color);
holder.tv_wzbm.setTextColor(color);
if (infos.get(i).getCURBAL().equals(infos.get(i).getPDSL())){
int color1 = context.getResources().getColor(R.color.red);
holder.tv_sl.setTextColor(color1);
holder.tv_pdsl.setTextColor(color1);
}else {
int color2 = context.getResources().getColor(R.color.green);
holder.tv_pdsl.setTextColor(color2);
holder.tv_wzbm.setTextColor(color2);
holder.tv_sl.setTextColor(color2);
holder.tv_pdzt.setTextColor(color2);
holder.tv_hjzy.setTextColor(color2);
}
} else {
holder.tv_pdzt.setText("未盘点");
holder.tv_pdzt.setTextColor(Color.GRAY);
holder.tv_ms.setTextColor(Color.GRAY);
holder.tv_wl.setTextColor(Color.GRAY);
holder.tv_sl.setTextColor(Color.GRAY);
holder.tv_hg.setTextColor(Color.GRAY);
holder.tv_pdsl.setTextColor(Color.GRAY);
holder.tv_hjzy.setTextColor(Color.GRAY);
holder.tv_wzbm.setTextColor(Color.GRAY);
}
holder.cb.setOnClickListener(this);
holder.cb.setTag(i);
return view;
}
@Override
public void onClick(View view) {
mCallback.cbClick(view);
}
static class ViewHolder {
TextView tv_sl;
TextView tv_ms;
TextView tv_wl;
TextView tv_hg;
CheckBox cb;
TextView tv_pdsl;
TextView tv_pdzt;
TextView tv_hjzy;
TextView tv_wzbm;
}
}