-
Notifications
You must be signed in to change notification settings - Fork 1
/
TrainDetailActivity.java
153 lines (122 loc) · 4.08 KB
/
TrainDetailActivity.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
package com.tudaidai.tuantrip;
import android.os.AsyncTask;
import android.os.Bundle;
import android.text.Html;
import android.text.method.LinkMovementMethod;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.View.OnFocusChangeListener;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;
import com.tudaidai.tuantrip.app.TuanTripApp;
import com.tudaidai.tuantrip.types.ViewpointDetailResult;
import com.tudaidai.tuantrip.util.NotificationsUtil;
public class TrainDetailActivity extends BaseLbsActivity {
public static final String ID = "com.tudaidai.tuantrip.TrainDetailActivity.id";
static final boolean DEBUG = TuanTripSettings.DEBUG;
static final String TAG = "ViewpointDetailActivity";
private static final int MENU_REFRESH = 0;
ViewpointDetailResult vDetailResult;
double price = 0.0;
int id;
View menpiaoView;
View jiaotongView;
private void ensureUi(ViewpointDetailResult paramOrders) {
vDetailResult = paramOrders;
super.ensure(vDetailResult.viewpointDetail);
Button jiaotongTab = (Button) findViewById(R.id.jiaotongTab);
jiaotongTab.setOnFocusChangeListener(new OnFocusChangeListener() {
@Override
public void onFocusChange(View v, boolean hasFocus) {
if (hasFocus) {
content.removeAllViews();
if (jiaotongView == null) {
jiaotongView = mInflater.inflate(R.layout.lbs_common,
null);
detailText = (TextView) jiaotongView
.findViewById(R.id.detailText);
detailText.setText(Html
.fromHtml(vDetailResult.viewpointDetail
.getJiaotong()));
detailText.setMovementMethod(LinkMovementMethod
.getInstance());
content.addView(jiaotongView);
} else {
content.addView(jiaotongView);
}
}
}
});
jiaotongTab.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
}
});
}
protected void onCreate(Bundle bundle) {
super.onCreate(bundle);
setContentView(R.layout.train_detail_activity);
id = getIntent().getIntExtra(ID, -1);
String[] as = new String[1];
as[0] = new Integer(id).toString();
new TrainDetailTask().execute(as);
}
class TrainDetailTask extends
AsyncTask<String, Void, ViewpointDetailResult> {
private static final String TAG = "ViewPointDetailTask";
private Exception mReason;
public TrainDetailTask() {
}
protected ViewpointDetailResult doInBackground(
String... paramArrayOfString) {
if (DEBUG)
Log.d(TAG, "doInBackground()");
ViewpointDetailResult vDetailResult = null;
try {
TuanTripApp localTuanTripApp = ((TuanTrip) TrainDetailActivity.this
.getApplication()).getTuanTripApp();
vDetailResult = localTuanTripApp
.getViewPointDetailResult(paramArrayOfString);
if (DEBUG)
Log.d(TAG, "doInBackground() over");
} catch (Exception localException) {
this.mReason = localException;
vDetailResult = null;
}
return vDetailResult;
}
protected void onPostExecute(ViewpointDetailResult paramOrders) {
if (DEBUG)
Log.d(TAG, "onPostExecute()");
if (paramOrders != null
&& paramOrders.mHttpResult.getStat() == TuanTripSettings.POSTSUCCESS) {
ensureUi(paramOrders);
} else {
if (paramOrders == null) {
NotificationsUtil.ToastReasonForFailure(
TrainDetailActivity.this, mReason);
} else if (paramOrders.mHttpResult.getStat() == TuanTripSettings.POSTFAILED) {
Toast.makeText(TrainDetailActivity.this,
paramOrders.mHttpResult.getMessage(),
Toast.LENGTH_SHORT).show();
} else {
NotificationsUtil.ToastReasonForFailure(
TrainDetailActivity.this, mReason);
}
}
dismissProgressDialog();
}
protected void onCancelled() {
if (DEBUG)
Log.d(TAG, "onCancelled()");
super.onCancelled();
}
protected void onPreExecute() {
if (DEBUG)
Log.d(TAG, "onPreExecute()");
startProgressBar("加载信息", "加载中...");
}
}
}