Skip to content

Commit 30499a9

Browse files
committed
Client:优化请求界面对request及method的处理;优化自动生成代码界面及测试数据
1 parent 9dc9d63 commit 30499a9

File tree

3 files changed

+14
-12
lines changed

3 files changed

+14
-12
lines changed

APIJSON(Android)/APIJSON(ADT)/APIJSONTest/res/layout/auto_activity.xml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,11 @@
1515
android:id="@+id/tvAutoRequest"
1616
android:layout_width="0dp"
1717
android:layout_height="wrap_content"
18-
android:layout_marginRight="6dp"
1918
android:layout_weight="1"
2019
android:background="@null"
2120
android:gravity="top|left"
2221
android:hint="request"
23-
android:textSize="15sp" />
22+
android:textSize="14sp" />
2423

2524
<View
2625
android:layout_width="1dp"
@@ -31,12 +30,13 @@
3130
android:id="@+id/tvAutoResponse"
3231
android:layout_width="0dp"
3332
android:layout_height="wrap_content"
34-
android:layout_marginLeft="6dp"
33+
android:layout_margin="6dp"
3534
android:layout_weight="2"
3635
android:background="@null"
3736
android:gravity="top|left"
3837
android:hint="response"
39-
android:onClick="copy" />
38+
android:onClick="copy"
39+
android:textSize="14sp" />
4040
</LinearLayout>
4141
</ScrollView>
4242

APIJSON(Android)/APIJSON(ADT)/APIJSONTest/src/apijson/demo/ui/AutoActivity.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ protected void onCreate(Bundle savedInstanceState) {
6666

6767

6868

69-
String request = "{\"User\":{\"id\":38710},\"[]\":{\"count\":3,\"page\":1,\"Moment\":{\"userId@\":\"User/id\",\"@column\":\"id,userId,content\"}}}";
69+
String request = "{\"Moment\":{\"id\":551},\"[]\":{\"count\":3,\"page\":1,\"Comment\":{\"momentId@\":\"Moment/id\",\"@column\":\"id,userId,content\"}}}";
7070

7171
tvAutoRequest.setText(StringUtil.getString(JSON.format(request)));
7272

APIJSON(Android)/APIJSON(ADT)/APIJSONTest/src/apijson/demo/ui/RequestActivity.java

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -117,12 +117,14 @@ protected void onCreate(Bundle savedInstanceState) {
117117

118118
method = StringUtil.getTrimedString(method);
119119
url = StringUtil.getCorrectUrl(url);
120-
if (encoded == false) {
121-
try {
122-
request = URLEncoder.encode(request, StringUtil.UTF_8);
123-
} catch (UnsupportedEncodingException e) {
124-
e.printStackTrace();
125-
}
120+
if (encoded == false && request != null && request.contains("/")) {
121+
// try {//导致JSON.format(request)返回null,然后tvRequestResult就显示为null了
122+
// String s = URLEncoder.encode(new String(request), StringUtil.UTF_8);
123+
// request = s;
124+
// } catch (UnsupportedEncodingException e) {
125+
// e.printStackTrace();
126+
// }
127+
request = request.replaceAll("/", "%2F");
126128
}
127129

128130

@@ -172,7 +174,7 @@ private void request() {
172174
tvRequestResult.setText("requesting...\n\n url = " + fullUrl + "\n\n request = \n" + JSON.format(request) + "\n\n\n" + error);
173175
pbRequest.setVisibility(View.VISIBLE);
174176

175-
if ("get".equals(method)) {
177+
if ("get".equals(method) || "head".equals(method)) {
176178
HttpManager.getInstance().get(fullUrl, request, this);
177179
} else {
178180
HttpManager.getInstance().post(fullUrl, request, this);

0 commit comments

Comments
 (0)