ManualTransferActivity.java
4.12 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
package com.huaheng.robot.task;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.os.Bundle;
import android.widget.TextView;
import android.widget.Toast;
import com.huaheng.robot.R;
import com.huaheng.robot.https.HttpInterface;
import com.huaheng.robot.https.HttpInterface2;
import com.huaheng.robot.https.Subscribers.ProgressSubscriber;
import com.huaheng.robot.https.Subscribers.SubscriberOnNextListener;
import com.huaheng.robot.login.UserBean;
import com.huaheng.robot.shipment.ShipmentBill;
import com.huaheng.robot.shipment.ShipmentTaskModel;
import com.huaheng.robot.util.CommonActivity;
import com.huaheng.robot.util.WMSLog;
import com.huaheng.robot.util.WMSUtils;
import java.util.ArrayList;
import java.util.List;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
public class ManualTransferActivity extends CommonActivity {
@BindView(R.id.transferInfo)
TextView transferInfo;
private String fromIsLand;
private String toIsLand;
@Override
protected void initActivityOnCreate(Bundle savedInstanceState) {
super.initActivityOnCreate(savedInstanceState);
setContentView(R.layout.activity_manual_transfer);
ButterKnife.bind(this);
setTitle(getString(R.string.manual_transfer));
}
private void freshInfo(String text) {
transferInfo.setText(text);
}
private void showFromDialog(final String[] items) {
AlertDialog.Builder listDialog =
new AlertDialog.Builder(ManualTransferActivity.this);
listDialog.setTitle(R.string.fromIsLand);
listDialog.setItems(items, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
fromIsLand = items[which];
WMSLog.d("fromIsLand :" + fromIsLand);
showToDialog(items);
}
});
listDialog.show();
}
private void showToDialog(final String[] items) {
AlertDialog.Builder listDialog =
new AlertDialog.Builder(ManualTransferActivity.this);
listDialog.setTitle(R.string.toIsLand);
listDialog.setItems(items, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
toIsLand = items[which];
WMSLog.d("toIsLand :" + toIsLand);
showTransferDialog();
}
});
listDialog.show();
}
private void showTransferDialog(){
String str = getResources().getString(R.string.transfer_message);
String message = String.format(str, fromIsLand, toIsLand);
final AlertDialog.Builder normalDialog =
new AlertDialog.Builder(ManualTransferActivity.this);
normalDialog.setTitle(R.string.transfer_title);
normalDialog.setMessage(message);
normalDialog.setPositiveButton(R.string.ok,
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
transfer(Integer.parseInt(fromIsLand), Integer.parseInt(toIsLand));
}
});
normalDialog.setNegativeButton(R.string.cancel,
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
}
});
normalDialog.show();
}
@OnClick(R.id.transferBtn)
public void onViewClicked() {
String[] items = {"123", "222"};
showFromDialog(items);
}
private void transfer(int fromIsLand, int toIsLand) {
HttpInterface2.getInsstance().transfer(new ProgressSubscriber<String>(this, transferListener), fromIsLand, toIsLand);
}
SubscriberOnNextListener transferListener = new SubscriberOnNextListener<String>() {
@Override
public void onNext(String str) {
freshInfo(str);
}
@Override
public void onError(String str) {
}
};
}