Skip to content

Commit e7538f0

Browse files
committed
不带路径的json都可获取到正确值
1 parent 46c4d47 commit e7538f0

14 files changed

Lines changed: 118 additions & 100 deletions

File tree

‎APIJSON(Android)/gen/zuo/biao/apijson/R.java‎

Lines changed: 9 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,6 @@ public static final class attr {
1212
}
1313
public static final class dimen {
1414
/** Default screen margins, per the Android Design guidelines.
15-
16-
Example customization of dimensions originally defined in res/values/dimens.xml
17-
(such as screen margins) for screens with more than 820dp of available width. This
18-
would include 7" and 10" devices in landscape (~960dp and ~1280dp respectively).
19-
2015
*/
2116
public static final int activity_horizontal_margin=0x7f040000;
2217
public static final int activity_vertical_margin=0x7f040001;
@@ -25,27 +20,25 @@ public static final class drawable {
2520
public static final int ic_launcher=0x7f020000;
2621
}
2722
public static final class id {
28-
public static final int action_settings=0x7f080004;
29-
public static final int etMainRequest=0x7f080000;
30-
public static final int etQueryUri=0x7f080003;
31-
public static final int pbQuery=0x7f080002;
32-
public static final int tvQueryResult=0x7f080001;
23+
public static final int btnQueryQuery=0x7f070004;
24+
public static final int etMainRequest=0x7f070000;
25+
public static final int etQueryUri=0x7f070003;
26+
public static final int pbQuery=0x7f070002;
27+
public static final int tvQueryResult=0x7f070001;
3328
}
3429
public static final class layout {
3530
public static final int main_activity=0x7f030000;
3631
public static final int query_activity=0x7f030001;
3732
public static final int select_activity=0x7f030002;
3833
}
39-
public static final class menu {
40-
public static final int main=0x7f070000;
41-
}
4234
public static final class string {
4335
public static final int action_settings=0x7f050003;
4436
public static final int app_name=0x7f050000;
4537
public static final int app_version=0x7f050001;
46-
public static final int demo_array=0x7f050005;
47-
public static final int demo_complex=0x7f050006;
48-
public static final int demo_rely=0x7f050004;
38+
public static final int demo_array=0x7f050006;
39+
public static final int demo_complex=0x7f050007;
40+
public static final int demo_rely=0x7f050005;
41+
public static final int demo_single=0x7f050004;
4942
public static final int hello_world=0x7f050002;
5043
}
5144
public static final class style {
@@ -58,17 +51,6 @@ public static final class style {
5851
res/values-vXX/styles.xml, while customizations related to
5952
backward-compatibility can go here.
6053
61-
62-
Base application theme for API 11+. This theme completely replaces
63-
AppBaseTheme from res/values/styles.xml on API 11+ devices.
64-
65-
API 11 theme customizations can go here.
66-
67-
Base application theme for API 14+. This theme completely replaces
68-
AppBaseTheme from BOTH res/values/styles.xml and
69-
res/values-v11/styles.xml on API 14+ devices.
70-
71-
API 14 theme customizations can go here.
7254
*/
7355
public static final int AppBaseTheme=0x7f060000;
7456
/** Application theme.

‎APIJSON(Android)/res/layout/query_activity.xml‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
<TextView
1515
android:id="@+id/tvQueryResult"
1616
style="@style/select_json"
17-
android:hint="requesting..."
17+
android:hint="result"
1818
android:padding="@dimen/activity_horizontal_margin"
1919
android:textIsSelectable="true" />
2020
</LinearLayout>
@@ -30,19 +30,20 @@
3030
android:id="@+id/pbQuery"
3131
android:layout_width="wrap_content"
3232
android:layout_height="wrap_content" />
33-
33+
3434
<EditText
3535
android:id="@+id/etQueryUri"
3636
style="@style/select_name"
3737
android:layout_gravity="bottom"
3838
android:layout_weight="1"
39+
android:gravity="top|left"
3940
android:padding="0dp"
4041
android:text="uri" />
4142

4243
<Button
44+
android:id="@+id/btnQueryQuery"
4345
android:layout_width="90dp"
4446
android:layout_height="45dp"
45-
android:onClick="query"
4647
android:text="Query" />
4748
</LinearLayout>
4849

‎APIJSON(Android)/res/layout/select_activity.xml‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,15 @@
88
style="@style/match_match"
99
android:orientation="vertical" >
1010

11+
<TextView
12+
style="@style/select_name"
13+
android:text="Single" />
14+
15+
<Button
16+
style="@style/select_json"
17+
android:onClick="selectSingle"
18+
android:text="@string/demo_single" />
19+
1120
<TextView
1221
style="@style/select_name"
1322
android:text="Rely" />

‎APIJSON(Android)/res/menu/main.xml‎

Lines changed: 0 additions & 11 deletions
This file was deleted.

‎APIJSON(Android)/res/values-v11/styles.xml‎

Lines changed: 0 additions & 11 deletions
This file was deleted.

‎APIJSON(Android)/res/values-v14/styles.xml‎

Lines changed: 0 additions & 12 deletions
This file was deleted.

‎APIJSON(Android)/res/values-w820dp/dimens.xml‎

Lines changed: 0 additions & 10 deletions
This file was deleted.

‎APIJSON(Android)/res/values/strings.xml‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@
55
<string name="app_version">1.0</string>
66
<string name="hello_world">Hello world!</string>
77
<string name="action_settings">Settings</string>
8-
<string name="demo_rely">{\n&#160;\"User\":{\n&#160;&#160;\"id\":38710\n&#160;},\n&#160;\"Work\":{\n&#160;&#160;\"userId\":\"User/id\"\n&#160;}\n}</string>
9-
<string name="demo_array">{\n&#160;\"User[]\":{\n&#160;&#160;\"count\":10,\n&#160;&#160;\"User\":{\n&#160;&#160;&#160;\"sex\":0\n&#160;&#160;}\n&#160;}\n}</string>
10-
<string name="demo_complex">{\n&#160;\"[]\":{\n&#160;&#160;\"count\":5,\n&#160;&#160;\"User\":{\n&#160;&#160;&#160;\"sex\":0\n&#160;&#160;},\n&#160;&#160;\"Work\":{\n&#160;&#160;&#160;\"userId\":\"/User/id\"\n&#160;&#160;},\n&#160;&#160;\"Comment[]\":{\n&#160;&#160;&#160;\"count\":3,\n&#160;&#160;&#160;\"Comment\":{\n&#160;&#160;&#160;&#160;\"workId\":\"[]/Work/id\"\n&#160;&#160;&#160;&#160;}\n&#160;&#160;}\n&#160;}\n}</string>
8+
<string name="demo_single">{\n&#160;&#160;&#160;\"User\":{\n&#160;&#160;&#160;&#160;&#160;&#160;\"id\":38710\n&#160;&#160;&#160;}\n}</string>
9+
<string name="demo_rely">{\n&#160;&#160;&#160;\"User\":{\n&#160;&#160;&#160;&#160;&#160;&#160;\"id\":38710\n&#160;&#160;&#160;},\n&#160;&#160;&#160;\"Work\":{\n&#160;&#160;&#160;&#160;&#160;&#160;\"userId\":\"User/id\"\n&#160;&#160;&#160;}\n}</string>
10+
<string name="demo_array">{\n&#160;&#160;&#160;\"User[]\":{\n&#160;&#160;&#160;&#160;&#160;&#160;\"count\":10,\n&#160;&#160;&#160;&#160;&#160;&#160;\"User\":{\n&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;\"sex\":0\n&#160;&#160;&#160;&#160;&#160;&#160;}\n&#160;&#160;&#160;}\n}</string>
11+
<string name="demo_complex">{\n&#160;&#160;&#160;\"[]\":{\n&#160;&#160;&#160;&#160;&#160;&#160;\"count\":5,\n&#160;&#160;&#160;&#160;&#160;&#160;\"User\":{\n&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;\"sex\":0\n&#160;&#160;&#160;&#160;&#160;&#160;},\n&#160;&#160;&#160;&#160;&#160;&#160;\"Work\":{\n&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;\"userId\":\"/User/id\"\n&#160;&#160;&#160;&#160;&#160;&#160;},\n&#160;&#160;&#160;&#160;&#160;&#160;\"Comment[]\":{\n&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;\"count\":3,\n&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;\"Comment\":{\n&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;\"workId\":\"[]/Work/id\"\n&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;}\n&#160;&#160;&#160;&#160;&#160;&#160;}\n&#160;&#160;&#160;}\n}</string>
1112

1213
</resources>

‎APIJSON(Android)/res/values/styles.xml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
Base application theme, dependent on API level. This theme is replaced
55
by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
66
-->
7-
<style name="AppBaseTheme" parent="android:Theme.Light">
7+
<style name="AppBaseTheme" parent="android:Theme.Holo.Light">
88
<!--
99
Theme customizations available in newer API levels can go in
1010
res/values-vXX/styles.xml, while customizations related to

‎APIJSON(Android)/src/zuo/biao/apijson/HttpManager.java‎

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -93,18 +93,20 @@ public synchronized static HttpManager getInstance() {
9393
* 在发起请求的类中可以用requestCode来区分各个请求
9494
* @param listener
9595
*/
96-
public void get(final String url, final String request, final OnHttpResponseListener listener) {
97-
96+
public void get(final String url_, final String request, final OnHttpResponseListener listener) {
97+
Log.d(TAG, "get url_ = " + url_ + "; request = " + request + " >>>");
9898
new AsyncTask<Void, Void, Exception>() {
9999

100100
String result;
101101
@Override
102102
protected Exception doInBackground(Void... params) {
103-
104-
StringBuffer sb = new StringBuffer();
105-
sb.append(StringUtil.getNoBlankString(url));
106103
try {
107-
OkHttpClient client = getHttpClient(url + URLEncoder.encode(request, UTF_8));
104+
String url = StringUtil.getNoBlankString(url_)
105+
+ URLEncoder.encode(StringUtil.getNoBlankString(request), UTF_8);
106+
StringBuffer sb = new StringBuffer();
107+
sb.append(url);
108+
109+
OkHttpClient client = getHttpClient(url);
108110
if (client == null) {
109111
return new Exception(TAG + ".get AsyncTask.doInBackground client == null >> return;");
110112
}
@@ -141,7 +143,7 @@ protected void onPostExecute(Exception exception) {
141143
* 在发起请求的类中可以用requestCode来区分各个请求
142144
* @param listener
143145
*/
144-
public void post(final String url, final String request, final OnHttpResponseListener listener) {
146+
public void post(final String url_, final String request, final OnHttpResponseListener listener) {
145147

146148
new AsyncTask<Void, Void, Exception>() {
147149

@@ -150,9 +152,11 @@ public void post(final String url, final String request, final OnHttpResponseLis
150152
protected Exception doInBackground(Void... params) {
151153

152154
FormEncodingBuilder fBuilder = new FormEncodingBuilder();
153-
154155
try {
155-
OkHttpClient client = getHttpClient(url + URLEncoder.encode(request, UTF_8));
156+
String url = StringUtil.getNoBlankString(url_)
157+
+ URLEncoder.encode(StringUtil.getNoBlankString(request), UTF_8);
158+
159+
OkHttpClient client = getHttpClient(url);
156160
if (client == null) {
157161
return new Exception(TAG + ".post AsyncTask.doInBackground client == null >> return;");
158162
}

0 commit comments

Comments
 (0)