From b697c0ec364215feb61e53338bc3dab00a5d2c90 Mon Sep 17 00:00:00 2001 From: TommyLemon <1184482681@qq.com> Date: Sun, 5 May 2019 00:13:14 +0800 Subject: [PATCH] =?UTF-8?q?Android:APIJSONApp=20=E5=BC=95=E5=85=A5=20Kotli?= =?UTF-8?q?n=EF=BC=9B=E6=96=B0=E5=A2=9E=E6=B5=8B=E8=AF=95=E8=87=AA?= =?UTF-8?q?=E5=8A=A8=E7=94=9F=E6=88=90=E4=BB=A3=E7=A0=81=E7=9A=84=20TestRe?= =?UTF-8?q?questAndResponse=20=E7=9A=84=20Java=20=E5=92=8C=20Kotlin=20?= =?UTF-8?q?=E7=9A=84=E5=B7=A5=E5=85=B7=E7=B1=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../APIJSONApp/APIJSONLibrary/build.gradle | 1 + APIJSON-Android/APIJSONApp/app/build.gradle | 5 + .../activity_fragment/MainTabActivity.java | 52 ++-- .../TestRequestAndResponse.kt | 231 ++++++++++++++++ .../TestRequestAndResponseJava.java | 260 ++++++++++++++++++ APIJSON-Android/APIJSONApp/build.gradle | 2 + 6 files changed, 535 insertions(+), 16 deletions(-) create mode 100644 APIJSON-Android/APIJSONApp/app/src/main/java/apijson/demo/client/activity_fragment/TestRequestAndResponse.kt create mode 100644 APIJSON-Android/APIJSONApp/app/src/main/java/apijson/demo/client/activity_fragment/TestRequestAndResponseJava.java diff --git a/APIJSON-Android/APIJSONApp/APIJSONLibrary/build.gradle b/APIJSON-Android/APIJSONApp/APIJSONLibrary/build.gradle index 6f78ee4c7..b6e4a7321 100644 --- a/APIJSON-Android/APIJSONApp/APIJSONLibrary/build.gradle +++ b/APIJSON-Android/APIJSONApp/APIJSONLibrary/build.gradle @@ -23,4 +23,5 @@ dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) testCompile 'junit:junit:4.12' compile files('libs/fastjson-1.2.24.jar') + } diff --git a/APIJSON-Android/APIJSONApp/app/build.gradle b/APIJSON-Android/APIJSONApp/app/build.gradle index 32baf9d68..51ee84be6 100644 --- a/APIJSON-Android/APIJSONApp/app/build.gradle +++ b/APIJSON-Android/APIJSONApp/app/build.gradle @@ -1,5 +1,9 @@ apply plugin: 'com.android.application' +apply plugin: 'kotlin-android' + +apply plugin: 'kotlin-android-extensions' + android { compileSdkVersion 23 buildToolsVersion '23.0.2' @@ -23,6 +27,7 @@ android { dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) testCompile 'junit:junit:4.12' + compile "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" compile project(':QRCodeLibrary') compile project(':ZBLibrary') } diff --git a/APIJSON-Android/APIJSONApp/app/src/main/java/apijson/demo/client/activity_fragment/MainTabActivity.java b/APIJSON-Android/APIJSONApp/app/src/main/java/apijson/demo/client/activity_fragment/MainTabActivity.java index ea9a618e1..ac10e559d 100755 --- a/APIJSON-Android/APIJSONApp/app/src/main/java/apijson/demo/client/activity_fragment/MainTabActivity.java +++ b/APIJSON-Android/APIJSONApp/app/src/main/java/apijson/demo/client/activity_fragment/MainTabActivity.java @@ -14,14 +14,6 @@ package apijson.demo.client.activity_fragment; -import zuo.biao.apijson.JSONResponse; -import zuo.biao.library.base.BaseBroadcastReceiver; -import zuo.biao.library.interfaces.OnBottomDragListener; -import zuo.biao.library.manager.HttpManager.OnHttpResponseListener; -import zuo.biao.library.ui.EditTextInfoWindow; -import zuo.biao.library.util.Log; -import zuo.biao.library.util.SettingUtil; -import zuo.biao.library.util.StringUtil; import android.app.Activity; import android.content.BroadcastReceiver; import android.content.Context; @@ -31,6 +23,7 @@ import android.view.KeyEvent; import android.view.View; import android.view.ViewGroup; + import apijson.demo.client.R; import apijson.demo.client.application.APIJSONApplication; import apijson.demo.client.base.BaseBottomTabActivity; @@ -38,6 +31,15 @@ import apijson.demo.client.model.User; import apijson.demo.client.util.ActionUtil; import apijson.demo.client.util.HttpRequest; +import zuo.biao.apijson.JSON; +import zuo.biao.apijson.JSONResponse; +import zuo.biao.library.base.BaseBroadcastReceiver; +import zuo.biao.library.interfaces.OnBottomDragListener; +import zuo.biao.library.manager.HttpManager.OnHttpResponseListener; +import zuo.biao.library.ui.EditTextInfoWindow; +import zuo.biao.library.util.Log; +import zuo.biao.library.util.SettingUtil; +import zuo.biao.library.util.StringUtil; /**应用主页 * @author Lemon @@ -77,14 +79,32 @@ protected void onCreate(Bundle savedInstanceState) { initEvent(); //功能归类分区方法,必须调用>>>>>>>>>> - + BaseBroadcastReceiver.register(context, receiver , new String[]{ACTION_EXIT_APP, ActionUtil.ACTION_RELOAD_CURRENT_USER}); - + if (SettingUtil.isOnTestMode) { showShortToast("测试服务器\n" + HttpRequest.URL_BASE); } + + + HttpRequest.get(JSON.parseObject(JSON.toJSONString(TestRequestAndResponseJava.request()), zuo.biao.apijson.JSONObject.class), 0, new OnHttpResponseListener() { + @Override + public void onHttpResponse(int requestCode, String resultJson, Exception e) { + TestRequestAndResponseJava.response(resultJson); + } + }); + + + HttpRequest.get(JSON.parseObject(JSON.toJSONString(TestRequestAndResponseKt.request()), zuo.biao.apijson.JSONObject.class), 0, new OnHttpResponseListener() { + @Override + public void onHttpResponse(int requestCode, String resultJson, Exception e) { + TestRequestAndResponseKt.response(resultJson); + } + }); + + } @@ -156,7 +176,7 @@ protected void selectTab(int position) { llMainTabRightContainer.addView(right); } - + verifyLogin(); } @@ -180,12 +200,12 @@ protected void selectTab(int position) { @Override public void initData() {// 必须调用 super.initData(); - + if (isCurrentUserCorrect() == false) { reloadAll(); } } - + @Override protected void reloadAll() { @@ -232,7 +252,7 @@ public void initEvent() {// 必须调用 public void onDragBottom(boolean rightToLeft) { if (fragments[currentPosition] instanceof OnBottomDragListener) { ((OnBottomDragListener) fragments[currentPosition]).onDragBottom(rightToLeft); - } + } } @@ -299,9 +319,9 @@ public void onReceive(Context context, Intent intent) { finish(); return; } - + if (ActionUtil.ACTION_RELOAD_CURRENT_USER.equals(action)) { - reloadAll();// fragmentManager show remove等都会崩溃 + reloadAll();// fragmentManager show remove等都会崩溃 } } }; diff --git a/APIJSON-Android/APIJSONApp/app/src/main/java/apijson/demo/client/activity_fragment/TestRequestAndResponse.kt b/APIJSON-Android/APIJSONApp/app/src/main/java/apijson/demo/client/activity_fragment/TestRequestAndResponse.kt new file mode 100644 index 000000000..410657ec2 --- /dev/null +++ b/APIJSON-Android/APIJSONApp/app/src/main/java/apijson/demo/client/activity_fragment/TestRequestAndResponse.kt @@ -0,0 +1,231 @@ +package apijson.demo.client.activity_fragment + +import com.alibaba.fastjson.JSONArray +import com.alibaba.fastjson.JSONObject +import zuo.biao.apijson.JSON +import java.util.* + +fun request(): Map { + return mapOf( + "emptyList" to ArrayList(), + "[]" to mapOf( + "count" to 5, + "page" to 0, + "join" to "&/User:owner/id@", + "Moment" to HashMap(), + "User:owner" to mapOf( + "id{}" to listOf(82001, 82002), + "id@" to "/Moment/userId", + "@column" to "id,name,head" + ), + "User:praiseUser[]" to mapOf( + "count" to 10, + "User" to mapOf( + "id{}@" to "[]/Moment/praiseUserIdList", + "@column" to "id,name" + ) + ), + "CommentItem[]" to mapOf( + "count" to 6, + "join" to ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> + + + //pictureList<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< + var pictureList1: JSONArray? = moment.getJSONArray("pictureList") + if (pictureList1 == null) { + pictureList1 = JSONArray() + } + + var item2: String? + for (i1 in 0..pictureList1.size - 1) { + item2 = pictureList1.getString(i1) + if (item2 == null) { + continue + } + println("\nitem1 = pictureList1[" + i1 + "] = \n" + item2 + "\n\n") + //TODO 你的代码 + + }//pictureList>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> + + //Moment>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> + + + //User:owner<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< + var owner: JSONObject? = item.getJSONObject("User:owner") + if (owner == null) { + owner = JSONObject() + } + + var id2 = owner.getLongValue("id") + println("owner.id = " + id); + var name = owner.getString("name") + println("owner.name = " + name); + var head = owner.getString("head") + println("owner.head = " + head); + //User:owner>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> + + + //User:praiseUser[]<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< + var praiseUserList1: JSONArray? = item.getJSONArray("User:praiseUser[]") + if (praiseUserList1 == null) { + praiseUserList1 = JSONArray() + } + + var item3: JSONObject? + for (i1 in 0..praiseUserList1.size - 1) { + item3 = praiseUserList1.getJSONObject(i1) + if (item3 == null) { + continue + } + println("\nitem3 = praiseUserList1[" + i1 + "] = \n" + item3 + "\n\n") + //TODO 你的代码 + + var id = item3.getLongValue("id") + println("item3.id = " + id); + var name = item3.getString("name") + println("item3.name = " + name); + }//User:praiseUser[]>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> + + + //CommentItem[]<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< + var commentItemList1: JSONArray? = item.getJSONArray("CommentItem[]") + if (commentItemList1 == null) { + commentItemList1 = JSONArray() + } + + var item4: JSONObject? + for (i1 in 0..commentItemList1.size - 1) { + item4 = commentItemList1.getJSONObject(i1) + if (item4 == null) { + continue + } + println("\nitem4 = commentItemList1[" + i1 + "] = \n" + item4 + "\n\n") + //TODO 你的代码 + + + //Comment<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< + var comment: JSONObject? = item4.getJSONObject("Comment") + if (comment == null) { + comment = JSONObject() + } + + var id3 = comment.getLongValue("id") + println("comment.id3 = " + id3); + var toId = comment.getLongValue("toId") + println("comment.toId = " + toId); + var userId = comment.getLongValue("userId") + println("comment.userId = " + userId); + var momentId = comment.getLongValue("momentId") + println("comment.momentId = " + momentId); + var date = comment.getString("date") + println("comment.date = " + date); + var content = comment.getString("content") + println("comment.content = " + content); + //Comment>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> + + + //User:publisher<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< + var publisher: JSONObject? = item4.getJSONObject("User:publisher") + if (publisher == null) { + publisher = JSONObject() + } + + var id4 = publisher.getLongValue("id") + println("publisher.id4 = " + id4); + var name = publisher.getString("name") + println("publisher.name = " + name); + //User:publisher>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> + + }//CommentItem[]>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> + + }//[]>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> + + +//emptyList<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< + var emptyList: JSONArray? = response.getJSONArray("emptyList") + if (emptyList == null) { + emptyList = JSONArray() + } + + var item5: Any? + for (i in 0..emptyList.size - 1) { + item5 = emptyList.get(i) + if (item5 == null) { + continue + } + println("\nitem5 = emptyList[" + i + "] = \n" + item5 + "\n\n") + //TODO 你的代码 + + }//emptyList>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> + + var code = response.getIntValue("code") + println("response.code = " + code); + var msg = response.getString("msg") + println("response.msg = " + msg); + +} \ No newline at end of file diff --git a/APIJSON-Android/APIJSONApp/app/src/main/java/apijson/demo/client/activity_fragment/TestRequestAndResponseJava.java b/APIJSON-Android/APIJSONApp/app/src/main/java/apijson/demo/client/activity_fragment/TestRequestAndResponseJava.java new file mode 100644 index 000000000..0eabca45a --- /dev/null +++ b/APIJSON-Android/APIJSONApp/app/src/main/java/apijson/demo/client/activity_fragment/TestRequestAndResponseJava.java @@ -0,0 +1,260 @@ +package apijson.demo.client.activity_fragment; + +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; + +import java.util.LinkedHashMap; +import java.util.Map; + +import zuo.biao.apijson.JSON; + +public class TestRequestAndResponseJava { + + public static Map request() { + Map request = new LinkedHashMap<>(); + request.put("emptyList", new Object[]{}); + { //[]<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< + Map item = new LinkedHashMap<>(); + item.put("count", 5); + item.put("page", 0); + item.put("join", "&/User/id@"); + { //Moment<<<<<<<<<<<<<<<<<<<<<<<<<<<<< + Map moment = new LinkedHashMap<>(); + item.put("Moment", moment); + } //Moment>>>>>>>>>>>>>>>>>>>>>>>>>>>>> + { //User<<<<<<<<<<<<<<<<<<<<<<<<<<<<< + Map user = new LinkedHashMap<>(); + user.put("id{}", new Object[]{82001, 82002}); + user.put("id@", "/Moment/userId"); + user.put("@column", "id,name,head"); + item.put("User", user); + } //User>>>>>>>>>>>>>>>>>>>>>>>>>>>>> + { //User[]<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< + Map userItem2 = new LinkedHashMap<>(); + userItem2.put("count", 10); + { //User<<<<<<<<<<<<<<<<<<<<<<<<<<<<< + Map user = new LinkedHashMap<>(); + user.put("id{}@", "[]/Moment/praiseUserIdList"); + user.put("@column", "id,name"); + userItem2.put("User", user); + } //User>>>>>>>>>>>>>>>>>>>>>>>>>>>>> + item.put("User[]", userItem2); + } //User[]>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> + { //[]<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< + Map item2 = new LinkedHashMap<>(); + item2.put("count", 6); + item2.put("join", " comment = new LinkedHashMap<>(); + comment.put("@order", "date+"); + comment.put("momentId@", "[]/Moment/id"); + item2.put("Comment", comment); + } //Comment>>>>>>>>>>>>>>>>>>>>>>>>>>>>> + { //User<<<<<<<<<<<<<<<<<<<<<<<<<<<<< + Map user = new LinkedHashMap<>(); + user.put("id@", "/Comment/userId"); + user.put("@column", "id,name"); + item2.put("User", user); + } //User>>>>>>>>>>>>>>>>>>>>>>>>>>>>> + item.put("[]", item2); + } //[]>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> + request.put("[]", item); + } //[]>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> + + return request; + } + + public static void response(String resultJson) { + JSONObject response = JSON.parseObject(resultJson); + + + { //[]<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< + JSONArray list = response.getJSONArray("[]"); + if (list == null) { + list = new JSONArray(); + } + + JSONObject item; + for (int i = 0; i < list.size(); i ++) { + item = list.getJSONObject(i); + if (item == null) { + continue; + } + System.out.println("\nitem = list[" + i + "] = \n" + item + "\n\n"); + //TODO 你的代码 + + + { //Moment<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< + JSONObject moment = item.getJSONObject("Moment"); + if (moment == null) { + moment = new JSONObject(); + } + + long id = moment.getLongValue("id"); + System.out.println("moment.id = " + id); + long userId = moment.getLongValue("userId"); + System.out.println("moment.userId = " + userId); + String date = moment.getString("date"); + System.out.println("moment.date = " + date); + String content = moment.getString("content"); + System.out.println("moment.content = " + content); + + { //praiseUserIdList<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< + JSONArray praiseUserIdList3 = moment.getJSONArray("praiseUserIdList"); + if (praiseUserIdList3 == null) { + praiseUserIdList3 = new JSONArray(); + } + + Integer item3; + for (int i3 = 0; i3 < praiseUserIdList3.size(); i3 ++) { + item3 = praiseUserIdList3.getInteger(i3); + if (item3 == null) { + continue; + } + System.out.println("\nitem3 = praiseUserIdList3[" + i3 + "] = \n" + item3 + "\n\n"); + //TODO 你的代码 + + } + } //praiseUserIdList>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> + + + { //pictureList<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< + JSONArray pictureList3 = moment.getJSONArray("pictureList"); + if (pictureList3 == null) { + pictureList3 = new JSONArray(); + } + + String item3; + for (int i3 = 0; i3 < pictureList3.size(); i3 ++) { + item3 = pictureList3.getString(i3); + if (item3 == null) { + continue; + } + System.out.println("\nitem3 = pictureList3[" + i3 + "] = \n" + item3 + "\n\n"); + //TODO 你的代码 + + } + } //pictureList>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> + + } //Moment>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> + + + { //User<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< + JSONObject user = item.getJSONObject("User"); + if (user == null) { + user = new JSONObject(); + } + + long id = user.getLongValue("id"); + System.out.println("user.id = " + id); + String name = user.getString("name"); + System.out.println("user.name = " + name); + String head = user.getString("head"); + System.out.println("user.head = " + head); + } //User>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> + + + { //User[]<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< + JSONArray userList2 = item.getJSONArray("User[]"); + if (userList2 == null) { + userList2 = new JSONArray(); + } + + JSONObject item2; + for (int i2 = 0; i2 < userList2.size(); i2 ++) { + item2 = userList2.getJSONObject(i2); + if (item2 == null) { + continue; + } + System.out.println("\nitem2 = userList2[" + i2 + "] = \n" + item2 + "\n\n"); + //TODO 你的代码 + + long id = item2.getLongValue("id"); + System.out.println("item2.id = " + id); + String name = item2.getString("name"); + System.out.println("item2.name = " + name); + } + } //User[]>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> + + + { //[]<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< + JSONArray list2 = item.getJSONArray("[]"); + if (list2 == null) { + list2 = new JSONArray(); + } + + JSONObject item2; + for (int i2 = 0; i2 < list2.size(); i2 ++) { + item2 = list2.getJSONObject(i2); + if (item2 == null) { + continue; + } + System.out.println("\nitem2 = list2[" + i2 + "] = \n" + item2 + "\n\n"); + //TODO 你的代码 + + + { //Comment<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< + JSONObject comment = item2.getJSONObject("Comment"); + if (comment == null) { + comment = new JSONObject(); + } + + long id = comment.getLongValue("id"); + System.out.println("comment.id = " + id); + long toId = comment.getLongValue("toId"); + System.out.println("comment.toId = " + toId); + long userId = comment.getLongValue("userId"); + System.out.println("comment.userId = " + userId); + long momentId = comment.getLongValue("momentId"); + System.out.println("comment.momentId = " + momentId); + String date = comment.getString("date"); + System.out.println("comment.date = " + date); + String content = comment.getString("content"); + System.out.println("comment.content = " + content); + } //Comment>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> + + + { //User<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< + JSONObject user = item2.getJSONObject("User"); + if (user == null) { + user = new JSONObject(); + } + + long id = user.getLongValue("id"); + System.out.println("user.id = " + id); + String name = user.getString("name"); + System.out.println("user.name = " + name); + } //User>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> + + } + } //[]>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> + + } + } //[]>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> + + + { //list<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< + JSONArray list = response.getJSONArray("list"); + if (list == null) { + list = new JSONArray(); + } + + Object item; + for (int i = 0; i < list.size(); i ++) { + item = list.get(i); + if (item == null) { + continue; + } + System.out.println("\nitem = list[" + i + "] = \n" + item + "\n\n"); + //TODO 你的代码 + + } + } //list>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> + + int code = response.getIntValue("code"); + System.out.println("response.code = " + code); + String msg = response.getString("msg"); + System.out.println("response.msg = " + msg); + } + +} diff --git a/APIJSON-Android/APIJSONApp/build.gradle b/APIJSON-Android/APIJSONApp/build.gradle index 99bea1db2..63195ff14 100644 --- a/APIJSON-Android/APIJSONApp/build.gradle +++ b/APIJSON-Android/APIJSONApp/build.gradle @@ -1,11 +1,13 @@ // Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { + ext.kotlin_version = '1.2.50' repositories { jcenter() } dependencies { classpath 'com.android.tools.build:gradle:2.1.2' + classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files