回答編集履歴
1
コード修正
answer
CHANGED
@@ -15,18 +15,18 @@
|
|
15
15
|
try {
|
16
16
|
//入力値を使ってアクセスを行う
|
17
17
|
String urlA = TO_API1 + "request_data1=" + testA + "&request_data2=" + testB;
|
18
|
-
Future<ResponseA>
|
18
|
+
Future<ResponseA> futureA = es.submit(new XMLAcquirer(urlA, root -> new ResponseA(root)));
|
19
|
-
ResponseA resA =
|
19
|
+
ResponseA resA = futureA.get();
|
20
20
|
|
21
21
|
//resA のデータを使って次のアクセスを行う
|
22
22
|
String urlB = TO_API2 + "api_id=" + API_ID + resA.api_id1 + resA.api_id2 + "&lang=" + LANG;
|
23
|
-
Future<ResponseB>
|
23
|
+
Future<ResponseB> futureB = es.submit(new XMLAcquirer(urlB, root -> new ResponseB(root)));
|
24
|
-
ResponseB resB =
|
24
|
+
ResponseB resB = futureB.get();
|
25
25
|
|
26
26
|
//さらに resB のデータを使って次のアクセスを行う
|
27
27
|
String urlC = TO_API3 + "request_data1=" + resB.data1 + "&request_data2=" + resB.data2;
|
28
|
-
Future<ResponseC>
|
28
|
+
Future<ResponseC> futureC = es.submit(new XMLAcquirer(urlC, root -> new ResponseC(root)));
|
29
|
-
ResponseC resC =
|
29
|
+
ResponseC resC = futureC.get();
|
30
30
|
|
31
31
|
// resC のデータを保存する?
|
32
32
|
saveSharedPreferences(resC);
|
@@ -40,6 +40,7 @@
|
|
40
40
|
});
|
41
41
|
thread.start();
|
42
42
|
}
|
43
|
+
//urlA の XML を解析して必要なデータを内部に保持する
|
43
44
|
static class ResponseA {
|
44
45
|
ResponseA(Element rootElement) {
|
45
46
|
NodeList nodeListData1 = rootElement.getElementsByTagName("data1");
|
@@ -56,6 +57,7 @@
|
|
56
57
|
String api_id1;
|
57
58
|
String api_id2;
|
58
59
|
}
|
60
|
+
//urlB の XML を解析して必要なデータを内部に保持する
|
59
61
|
static class ResponseB {
|
60
62
|
ResponseB(Element rootElement) {
|
61
63
|
NodeList nodeListData1 = rootElement.getElementsByTagName("data1");
|
@@ -72,6 +74,7 @@
|
|
72
74
|
String data1;
|
73
75
|
String data2;
|
74
76
|
}
|
77
|
+
//urlC の XML を解析して必要なデータを内部に保持する
|
75
78
|
static class ResponseC {
|
76
79
|
ResponseC(Element rootElement) {
|
77
80
|
NodeList nodeListData1 = rootElement.getElementsByTagName("data1");
|