OnshellActivity.java
4.56 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
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.R;
import com.huaheng.wms.WMSLog;
import com.huaheng.wms.model.CommonActivity;
import com.huaheng.wms.util.SpeechUtil;
import com.huaheng.wms.util.WMSUtils;
import com.huaheng.wms.views.LineLayout;
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 sn;
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) {
WMSLog.d("onViewClicked @@");
if (isEnterCN) {
onShellEdit.setText("");
onShellEdit.requestFocus();
onShellEdit.setHint(R.string.enter_warehouse_number);
isEnterCN = false;
showLayout();
} else {
submit();
}
}
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 {
sn = number;
}
enableButton(true);
} else {
enableButton(false);
}
}
});
}
private void showLayout() {
String name = "MYR930S-X 立式饮水机 白色 S2平台网销机";
String postion = "A-01-02";
String number = "629";
onShellContentLayout.setVisibility(View.VISIBLE);
onShellRecommandLayout.setLineName(getString(R.string.recommended_library_position));
onShellRecommandLayout.setLineContent(postion);
addGoodsInfo();
}
private void addGoodsInfo() {
LineLayout lineLayout = new LineLayout(mContext);
lineLayout.setLineName("商品名称");
lineLayout.setLineContent("矿泉水");
onshellLinear.addView(lineLayout);
View view = new View(mContext);
view.setMinimumHeight(1);
view.setMinimumWidth(-1);
view.setBackgroundResource(R.color.lightgray);
onshellLinear.addView(view);
LineLayout lineLayout2 = new LineLayout(mContext);
lineLayout2.setLineName("商品条码");
lineLayout2.setLineContent("2106302000038");
onshellLinear.addView(lineLayout2);
View view2 = new View(mContext);
view.setMinimumHeight(1);
view.setMinimumWidth(-1);
view.setBackgroundResource(R.color.lightgray);
onshellLinear.addView(view2);
}
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);
}
}