OnshellActivity.java
7.1 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
package com.huaheng.wms.onshell;
import android.content.Context;
import android.os.Bundle;
import android.text.Editable;
import android.text.TextWatcher;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.LinearLayout;
import com.huaheng.wms.MainActivity;
import com.huaheng.wms.R;
import com.huaheng.wms.WMSLog;
import com.huaheng.wms.https.HttpInterface;
import com.huaheng.wms.https.Subscribers.ProgressSubscriber;
import com.huaheng.wms.https.Subscribers.SubscriberOnNextListener;
import com.huaheng.wms.login.UserBean;
import com.huaheng.wms.login.WareHouseActivity;
import com.huaheng.wms.menu.ModulesBean;
import com.huaheng.wms.model.CommonActivity;
import com.huaheng.wms.util.DataBaseHelpter;
import com.huaheng.wms.util.SpeechUtil;
import com.huaheng.wms.util.WMSUtils;
import com.huaheng.wms.views.LineLayout;
import java.util.ArrayList;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
/*
** 上架
*/
public class OnshellActivity extends CommonActivity {
@BindView(R.id.onShellEdit)
EditText onShellEdit;
@BindView(R.id.onShellRecommandLayout)
LineLayout onShellRecommandLayout;
@BindView(R.id.onShellContentLayout)
LinearLayout onShellContentLayout;
@BindView(R.id.onShellEnsureBtn)
Button onShellEnsureBtn;
@BindView(R.id.onShellEnsureLayout)
LinearLayout onShellEnsureLayout;
@BindView(R.id.onshell_linear)
LinearLayout onshellLinear;
private String cn;
private String location;
private Context mContext;
private boolean isEnterCN = true;
@Override
protected void initActivityOnCreate(Bundle savedInstanceState) {
super.initActivityOnCreate(savedInstanceState);
setContentView(R.layout.activity_on_shell);
ButterKnife.bind(this);
setTitle(getString(R.string.on_the_shelf));
mContext = this;
initView();
enableButton(false);
}
@OnClick({R.id.onShellEnsureLayout})
public void onViewClicked(View view) {
if (isEnterCN) {
scanContainer(cn);
WMSUtils.resetEdit(onShellEdit);
onShellEdit.setHint(R.string.enter_warehouse_number);
isEnterCN = false;
} else {
scanLocationCode(location);
}
}
private void initView() {
onShellEdit.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
}
@Override
public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
}
@Override
public void afterTextChanged(Editable editable) {
String number = editable.toString();
if (number != null && number.length() > 0) {
if (isEnterCN) {
cn = number;
} else {
location = number;
}
enableButton(true);
} else {
enableButton(false);
}
}
});
}
private void showLayout(ArrayList<ContainerInfo> containerInfos) {
String postion = "";
postion = containerInfos.get(0).getLocationCode();
onShellContentLayout.setVisibility(View.VISIBLE);
onShellRecommandLayout.setLineName(getString(R.string.recommended_library_position));
onShellRecommandLayout.setLineContent(postion);
addGoodsInfo(containerInfos);
}
private void addGoodsInfo(ArrayList<ContainerInfo> containerInfos) {
for(ContainerInfo containerInfo : containerInfos) {
LineLayout lineLayout = new LineLayout(mContext);
lineLayout.setLineName(mContext.getString(R.string.commodity_name));
lineLayout.setLineContent(containerInfo.getName());
onshellLinear.addView(lineLayout);
View view = new View(mContext);
view.setMinimumHeight(1);
view.setMinimumWidth(-1);
onshellLinear.addView(view);
LineLayout lineLayout2 = new LineLayout(mContext);
lineLayout2.setLineName(mContext.getString(R.string.commodity_barcode));
lineLayout2.setLineContent(containerInfo.getBarcode());
onshellLinear.addView(lineLayout2);
View view2 = new View(mContext);
view2.setMinimumHeight(1);
view2.setMinimumWidth(-1);
onshellLinear.addView(view2);
LineLayout lineLayout3 = new LineLayout(mContext);
lineLayout3.setLineName(mContext.getString(R.string.commodity_number));
lineLayout3.setLineContent(String.valueOf((int)containerInfo.getQty()));
onshellLinear.addView(lineLayout3);
View view3 = new View(mContext);
view3.setMinimumHeight(1);
view3.setMinimumWidth(-1);
onshellLinear.addView(view3);
View view4 = new View(mContext);
view4.setMinimumHeight(15);
view4.setMinimumWidth(-1);
onshellLinear.addView(view4);
}
}
private void enableButton(boolean enable) {
if (enable) {
onShellEnsureBtn.setBackgroundResource(R.drawable.blue_button_bg);
onShellEnsureLayout.setClickable(true);
} else {
onShellEnsureBtn.setBackgroundResource(R.drawable.gray_button_bg);
onShellEnsureLayout.setClickable(false);
}
}
private void submit() {
SpeechUtil.getInstance(this).speech(this.getString(R.string.onshell_success));
finish();
WMSUtils.startActivity(this, OnshellActivity.class);
}
private void scanContainer(String containerCode) {
HttpInterface.getInsstance().scanContainer(new ProgressSubscriber<ArrayList<ContainerInfo>>(OnshellActivity.this, scanContainerListener), containerCode);
}
SubscriberOnNextListener scanContainerListener = new SubscriberOnNextListener<ArrayList<ContainerInfo>>() {
@Override
public void onNext(ArrayList<ContainerInfo> containerInfos) {
WMSLog.d("scanContainerListener containerInfos:" + containerInfos.toString());
if(WMSUtils.isNotEmptyList(containerInfos)) {
showLayout(containerInfos);
} else {
WMSUtils.showShort(getString(R.string.toast_error));
}
}
@Override
public void onError(String str) {
}
};
private void scanLocationCode(String locationCode) {
HttpInterface.getInsstance().scanLocationCode(new ProgressSubscriber<String>(OnshellActivity.this, scanLocationListener), locationCode);
}
SubscriberOnNextListener scanLocationListener = new SubscriberOnNextListener<String>() {
@Override
public void onNext(String result) {
WMSLog.d("scanLocationListener result:" + result);
submit();
}
@Override
public void onError(String str) {
WMSLog.d("scanLocationListener onError str:" + str);
WMSUtils.resetEdit(onShellEdit);
}
};
}