EmptyOutAdapter.java
8.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
package com.huaheng.mobilewms.adapter;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;
import com.huaheng.mobilewms.R;
import com.huaheng.mobilewms.bean.EmptyOut;
import com.huaheng.mobilewms.https.HttpInterface;
import com.huaheng.mobilewms.https.Subscribers.ProgressSubscriber;
import com.huaheng.mobilewms.https.Subscribers.SubscriberOnNextListener;
import com.huaheng.mobilewms.util.WMSUtils;
import java.util.ArrayList;
import java.util.List;
public class EmptyOutAdapter extends BaseAdapter {
private Context mContext;
private boolean showExtralTextView = false;
private List<EmptyOut> mList = new ArrayList<>();
private SubscriberOnNextListener executePrisonEmptyOutListener;
public void setFixErpCommandListener(SubscriberOnNextListener fixErpCommandListener) {
this.fixErpCommandListener = fixErpCommandListener;
}
private SubscriberOnNextListener fixErpCommandListener;
public EmptyOutAdapter(Context context) {
this.mContext = context;
}
public List<EmptyOut> getList() {
return mList;
}
public void setList(List<EmptyOut> list) {
mList = list;
}
@Override
public int getCount() {
return mList.size();
}
@Override
public Object getItem(int i) {
return mList.get(i);
}
@Override
public long getItemId(int i) {
return i;
}
public void showExtralText(boolean show){
this.showExtralTextView = show;
}
@Override
public View getView(int position, View convertView, ViewGroup viewGroup) {
// if(1==1) return null;
ViewHolder viewHolder = new ViewHolder();
if (convertView == null) {
convertView = LayoutInflater.from(mContext).inflate(R.layout.emptyout_list_item, null);
ImageView icon = (ImageView) convertView.findViewById(R.id.icon);
TextView containerCode = (TextView) convertView.findViewById(R.id.containerCode);
TextView locationCode = (TextView) convertView.findViewById(R.id.locationCode);
TextView wmsStatusStr = (TextView) convertView.findViewById(R.id.wmsStatusStr);
TextView wmsMsg = (TextView) convertView.findViewById(R.id.wmsMsg);
TextView chejian = (TextView) convertView.findViewById(R.id.chejian);
Button button = (Button) convertView.findViewById(R.id.button);
ImageView completeView = (ImageView) convertView.findViewById(R.id.completeView);
ImageView confirmView = (ImageView) convertView.findViewById(R.id.confirmView);
viewHolder._icon = icon;
viewHolder._containerCode = containerCode;
viewHolder._locationCode = locationCode;
viewHolder._wmsStatusStr = wmsStatusStr;
viewHolder._complete = completeView;
viewHolder._confirm = confirmView;
viewHolder._button = button;
viewHolder._wmsMsg = wmsMsg;
viewHolder._chejian = chejian;
convertView.setTag(viewHolder);
} else {
viewHolder = (ViewHolder) convertView.getTag();
}
final EmptyOut bean = (EmptyOut) mList.get(position);
if("叉车库".equals(bean.getCtpleixing())) {
//叉车出库
if(bean.isKongchu()) {
viewHolder._icon.setImageDrawable(mContext.getResources().getDrawable(R.mipmap.menu_icon_shangjia));
}else if(bean.isChaKan()){
viewHolder._icon.setImageDrawable(mContext.getResources().getDrawable(R.mipmap.menu_icon_query));
}
}else{
//堆垛机出库
if(bean.isKongchu()) {
viewHolder._icon.setImageDrawable(mContext.getResources().getDrawable(R.mipmap.menu_material));
}else if(bean.isChaKan()){
viewHolder._icon.setImageDrawable(mContext.getResources().getDrawable(R.mipmap.menu_icon_query));
}
//分拣
// viewHolder._icon.setImageDrawable(mContext.getResources().getDrawable(R.mipmap.menu2_icon_bjbf));
}
viewHolder._containerCode.setText(bean.getCtpid());
String location = bean.getCkuwei();
if(bean.getCkuwei().toUpperCase().startsWith("DK")) {
if (bean.isInner()) {
location = location + " 内侧";
}else{
location = location + " 外侧";
}
}
viewHolder._locationCode.setText(location);
viewHolder._wmsStatusStr.setText(String.valueOf(bean.getWmsStatusStr()));
if(bean.getWmsStatus() == 200){
viewHolder._confirm.setImageDrawable(mContext.getResources().getDrawable(R.mipmap.complete));
viewHolder._confirm.setVisibility(View.VISIBLE);
}else{
viewHolder._confirm.setVisibility(View.GONE);
}
if(bean.getWmsStatus() == 100){
viewHolder._complete.setImageDrawable(mContext.getResources().getDrawable(R.mipmap.man2));
// viewHolder._complete.setVisibility(View.VISIBLE);
}else{
viewHolder._complete.setVisibility(View.GONE);
}
if(bean.getWmsMsg() != null && !"".equals(bean.getWmsMsg())){
viewHolder._wmsMsg.setText(bean.getWmsMsg());
viewHolder._wmsMsg.setVisibility(View.VISIBLE);
}else{
viewHolder._wmsMsg.setVisibility(View.GONE);
}
if(bean.getWmsStatus() == 0){
if(bean.isKongchu()){
viewHolder._button.setText("下发任务");
}else{
viewHolder._button.setText("下发任务");
// viewHolder._button.setText("出库查看");
}
viewHolder._button.setVisibility(View.VISIBLE);
viewHolder._icon.setOnLongClickListener(new View.OnLongClickListener() {
@Override
public boolean onLongClick(View v) {
HttpInterface.getInsstance().fixErpCommand(new ProgressSubscriber<Integer>(mContext, fixErpCommandListener), bean.getCid().intValue());
return true;
}
});
viewHolder._button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if(bean.isChaKan()){
HttpInterface.getInsstance().executePrisonEmptyOut(new ProgressSubscriber<Integer>(mContext, executePrisonEmptyOutListener),bean.getCid().intValue(), "");
}else{
selectPort(bean);
}
}
});
}else{
viewHolder._icon.setOnLongClickListener(null);
viewHolder._button.setVisibility(View.GONE);
}
if(bean.hasChejian()){
viewHolder._chejian.setText(bean.getChejian());
viewHolder._chejian.setVisibility(View.VISIBLE);
}else{
viewHolder._chejian.setText("");
viewHolder._chejian.setVisibility(View.GONE);
}
return convertView;
}
private void checkPrisonEmptyOutListener(EmptyOut selectBean){
String location = selectBean.getCkuwei();
}
public void setExecutePrisonEmptyOutListener(SubscriberOnNextListener executePrisonEmptyOutListener) {
this.executePrisonEmptyOutListener = executePrisonEmptyOutListener;
}
private void selectPort(final EmptyOut bean){
final AlertDialog.Builder listDialog = new AlertDialog.Builder(mContext);
listDialog.setTitle("请选择出口:");
listDialog.setNegativeButton("从分拣口出", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
HttpInterface.getInsstance().executePrisonEmptyOut(new ProgressSubscriber<Integer>(mContext, executePrisonEmptyOutListener),bean.getCid().intValue(), "P1001");
}
});
listDialog.setPositiveButton("从出库口出", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
HttpInterface.getInsstance().executePrisonEmptyOut(new ProgressSubscriber<Integer>(mContext, executePrisonEmptyOutListener),bean.getCid().intValue(), "P1019");
}
});
listDialog.show();
}
private class ViewHolder {
ImageView _icon;
TextView _containerCode;
TextView _locationCode;
TextView _wmsStatusStr;
TextView _wmsMsg;
TextView _chejian;
ImageView _complete;
ImageView _confirm;
Button _button;
}
}