| | |
| | | import androidx.recyclerview.widget.RecyclerView; |
| | | |
| | | import com.hdl.photovoltaic.R; |
| | | import com.hdl.photovoltaic.ui.bean.DeviceBean; |
| | | import com.hdl.photovoltaic.ui.bean.CloudInverterDeviceBean; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | public class SearchDeviceAdapter extends RecyclerView.Adapter<SearchDeviceAdapter.MyViewHolder> { |
| | | List<DeviceBean> mList; |
| | | List<CloudInverterDeviceBean> mList; |
| | | |
| | | Context mContext; |
| | | |
| | |
| | | |
| | | @Override |
| | | public void onBindViewHolder(@NonNull SearchDeviceAdapter.MyViewHolder holder, int position) { |
| | | DeviceBean deviceBean = this.mList.get(position); |
| | | CloudInverterDeviceBean deviceBean = this.mList.get(position); |
| | | |
| | | holder.device_search_name_tv.setText(deviceBean.getHomeNameAndDeviceName()); |
| | | holder.device_search_sn_tv.setText("SN:"+deviceBean.getOsn()); |
| | |
| | | this.mOnclickListener = onClickListener; |
| | | } |
| | | |
| | | public void setList(List<DeviceBean> newData) { |
| | | public void setList(List<CloudInverterDeviceBean> newData) { |
| | | if (this.mList == null) { |
| | | this.mList = new ArrayList<>(); |
| | | } else { |
| | |
| | | */ |
| | | private void setTextViewStyle(TextView textView, int state_value) { |
| | | String text = mContext.getString(R.string.my_power_station_operation); |
| | | Drawable drawable = AppCompatResources.getDrawable(mContext, R.drawable.state_06b92a); |
| | | Drawable drawable = AppCompatResources.getDrawable(mContext, R.drawable.device_state_ff38c494); |
| | | switch (state_value) { |
| | | case 1: { |
| | | text = mContext.getString(R.string.my_power_station_connecting); |
| | | drawable = AppCompatResources.getDrawable(mContext, R.drawable.state_ffb300); |
| | | drawable = AppCompatResources.getDrawable(mContext, R.drawable.device_satte_ffb300); |
| | | } |
| | | break; |
| | | case 2: { |
| | | text = mContext.getString(R.string.my_power_station_malfunction); |
| | | drawable = AppCompatResources.getDrawable(mContext, R.drawable.state_e34343); |
| | | drawable = AppCompatResources.getDrawable(mContext, R.drawable.device_state_fff55252); |
| | | } |
| | | break; |
| | | case 3: { |
| | |
| | | break; |
| | | case 4: { |
| | | text = mContext.getString(R.string.my_power_station_off_line); |
| | | drawable = AppCompatResources.getDrawable(mContext, R.drawable.state_b9b9b9); |
| | | drawable = AppCompatResources.getDrawable(mContext, R.drawable.device_state_ffb9b9b9); |
| | | } |
| | | break; |
| | | |
| | | } |
| | | textView.setText(text); |
| | | // textView.setText(text); |
| | | textView.setBackground(drawable); |
| | | |
| | | |
| | | } |
| | | |
| | | public interface OnClickListener { |
| | | void onClick(int position, DeviceBean deviceBean); |
| | | void onClick(int position, CloudInverterDeviceBean deviceBean); |
| | | |
| | | } |
| | | |