-
Notifications
You must be signed in to change notification settings - Fork 1
/
HBDTActivity.java
178 lines (150 loc) · 5.36 KB
/
HBDTActivity.java
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
package com.tudaidai.tuantrip;
import android.app.Activity;
import android.app.ProgressDialog;
import android.os.AsyncTask;
import android.os.Bundle;
import android.text.Html;
import android.util.Log;
import android.widget.TextView;
import android.widget.Toast;
import com.tudaidai.tuantrip.app.TuanTripApp;
import com.tudaidai.tuantrip.types.HBSKResult;
import com.tudaidai.tuantrip.util.NotificationsUtil;
public class HBDTActivity extends Activity {
static final boolean DEBUG = TuanTripSettings.DEBUG;
public static final String EXTRA_OPTION = "com.tudaidai.tuantrip.HBDTActivity.OPTION";
public static final String EXTRA_OPTION1 = "com.tudaidai.tuantrip.HBDTActivity.OPTION1";
public static final int OPTION_ORDER = 1;
public static final int OPTION_SET = 2;
public static final int REQUEST_CODE = 1;
public static final int RESPONSE_SUCCESS = 1;
public static final int RESPONSE_FAILED = 2;
static final String TAG = "HBDTActivity";
private ProgressDialog mProgressDialog;
TextView hangbandtText;
private void startProgressBar(String title, String content) {
mProgressDialog = ProgressDialog.show(this, title, content);
mProgressDialog.show();
}
private void dismissProgressDialog() {
this.mProgressDialog.dismiss();
}
protected void onCreate(Bundle paramBundle) {
super.onCreate(paramBundle);
setContentView(R.layout.hangban_dongtai_activity);
hangbandtText = (TextView) findViewById(R.id.hangbandtText);
String[] as = getIntent().getStringArrayExtra(EXTRA_OPTION);
if (as != null) {
new HBDTTask().execute(as);
} else {
String[] as1 = getIntent().getStringArrayExtra(EXTRA_OPTION1);
if (as1 != null) {
new HBDTTask1().execute(as1);
}
}
}
class HBDTTask extends AsyncTask<String, Void, HBSKResult> {
private static final boolean DEBUG = TuanTripSettings.DEBUG;
private static final String TAG = "HBSKTask";
private Exception mReason = null;
private HBDTTask() {
}
protected HBSKResult doInBackground(String... paramArrayOfVoid) {
if (DEBUG)
Log.d(TAG, "doInBackground()");
HBSKResult localAddrListResult1;
try {
TuanTrip tuanTrip = (TuanTrip) HBDTActivity.this
.getApplication();
TuanTripApp tuanTripApp = tuanTrip.getTuanTripApp();
localAddrListResult1 = tuanTripApp
.getHBDTResult(paramArrayOfVoid);
} catch (Exception localException) {
if (DEBUG)
Log.d("AddrTask", "Caught Exception.", localException);
this.mReason = localException;
localAddrListResult1 = null;
}
return localAddrListResult1;
}
protected void onCancelled() {
super.onCancelled();
HBDTActivity.this.dismissProgressDialog();
}
protected void onPostExecute(HBSKResult hbskResult) {
if (DEBUG)
Log.d(TAG, "onPostExecute(): ");
if (hbskResult == null) {
NotificationsUtil.ToastReasonForFailure(HBDTActivity.this,
mReason);
} else if (hbskResult.mHttpResult.getStat() == TuanTripSettings.POSTSUCCESS) {
hangbandtText.setText(Html.fromHtml(hbskResult.mResult));
} else if (hbskResult.mHttpResult.getStat() == TuanTripSettings.POSTFAILED) {
Toast.makeText(HBDTActivity.this,
hbskResult.mHttpResult.getMessage(), Toast.LENGTH_SHORT)
.show();
} else {
NotificationsUtil.ToastReasonForFailure(HBDTActivity.this,
mReason);
}
dismissProgressDialog();
}
protected void onPreExecute() {
if (DEBUG)
Log.d(TAG, "onPreExecute()");
startProgressBar("获取航班信息", "获取航班信息中...");
}
}
class HBDTTask1 extends AsyncTask<String, Void, HBSKResult> {
private static final boolean DEBUG = TuanTripSettings.DEBUG;
private static final String TAG = "HBSKTask";
private Exception mReason = null;
private HBDTTask1() {
}
protected HBSKResult doInBackground(String... paramArrayOfVoid) {
if (DEBUG)
Log.d(TAG, "doInBackground()");
HBSKResult localAddrListResult1;
try {
TuanTrip tuanTrip = (TuanTrip) HBDTActivity.this
.getApplication();
TuanTripApp tuanTripApp = tuanTrip.getTuanTripApp();
localAddrListResult1 = tuanTripApp
.getHBDTResult1(paramArrayOfVoid);
} catch (Exception localException) {
if (DEBUG)
Log.d("AddrTask", "Caught Exception.", localException);
this.mReason = localException;
localAddrListResult1 = null;
}
return localAddrListResult1;
}
protected void onCancelled() {
super.onCancelled();
HBDTActivity.this.dismissProgressDialog();
}
protected void onPostExecute(HBSKResult hbskResult) {
if (DEBUG)
Log.d(TAG, "onPostExecute(): ");
if (hbskResult == null) {
NotificationsUtil.ToastReasonForFailure(HBDTActivity.this,
mReason);
} else if (hbskResult.mHttpResult.getStat() == TuanTripSettings.POSTSUCCESS) {
hangbandtText.setText(Html.fromHtml(hbskResult.mResult));
} else if (hbskResult.mHttpResult.getStat() == TuanTripSettings.POSTFAILED) {
Toast.makeText(HBDTActivity.this,
hbskResult.mHttpResult.getMessage(), Toast.LENGTH_SHORT)
.show();
} else {
NotificationsUtil.ToastReasonForFailure(HBDTActivity.this,
mReason);
}
dismissProgressDialog();
}
protected void onPreExecute() {
if (DEBUG)
Log.d(TAG, "onPreExecute()");
startProgressBar("获取航班信息", "获取航班信息中...");
}
}
}