| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 656ece9 commit b697c0e
6 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -23,4 +23,5 @@ dependencies { | |||
| 23 | 23 | compile fileTree(dir: 'libs', include: ['*.jar']) | |
| 24 | 24 | testCompile 'junit:junit:4.12' | |
| 25 | 25 | compile files('libs/fastjson-1.2.24.jar') | |
| 26 | + | ||
| 26 | 27 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,5 +1,9 @@ | |||
| 1 | 1 | apply plugin: 'com.android.application' | |
| 2 | 2 | ||
| 3 | + apply plugin: 'kotlin-android' | ||
| 4 | + | ||
| 5 | + apply plugin: 'kotlin-android-extensions' | ||
| 6 | + | ||
| 3 | 7 | android { | |
| 4 | 8 | compileSdkVersion 23 | |
| 5 | 9 | buildToolsVersion '23.0.2' | |
@@ -23,6 +27,7 @@ android { | |||
| 23 | 27 | dependencies { | |
| 24 | 28 | compile fileTree(dir: 'libs', include: ['*.jar']) | |
| 25 | 29 | testCompile 'junit:junit:4.12' | |
| 30 | + compile "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" | ||
| 26 | 31 | compile project(':QRCodeLibrary') | |
| 27 | 32 | compile project(':ZBLibrary') | |
| 28 | 33 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -14,14 +14,6 @@ | |||
| 14 | 14 | ||
| 15 | 15 | package apijson.demo.client.activity_fragment; | |
| 16 | 16 | ||
| 17 | - import zuo.biao.apijson.JSONResponse; | ||
| 18 | - import zuo.biao.library.base.BaseBroadcastReceiver; | ||
| 19 | - import zuo.biao.library.interfaces.OnBottomDragListener; | ||
| 20 | - import zuo.biao.library.manager.HttpManager.OnHttpResponseListener; | ||
| 21 | - import zuo.biao.library.ui.EditTextInfoWindow; | ||
| 22 | - import zuo.biao.library.util.Log; | ||
| 23 | - import zuo.biao.library.util.SettingUtil; | ||
| 24 | - import zuo.biao.library.util.StringUtil; | ||
| 25 | 17 | import android.app.Activity; | |
| 26 | 18 | import android.content.BroadcastReceiver; | |
| 27 | 19 | import android.content.Context; | |
@@ -31,13 +23,23 @@ | |||
| 31 | 23 | import android.view.KeyEvent; | |
| 32 | 24 | import android.view.View; | |
| 33 | 25 | import android.view.ViewGroup; | |
| 26 | + | ||
| 34 | 27 | import apijson.demo.client.R; | |
| 35 | 28 | import apijson.demo.client.application.APIJSONApplication; | |
| 36 | 29 | import apijson.demo.client.base.BaseBottomTabActivity; | |
| 37 | 30 | import apijson.demo.client.interfaces.TopBarMenuCallback; | |
| 38 | 31 | import apijson.demo.client.model.User; | |
| 39 | 32 | import apijson.demo.client.util.ActionUtil; | |
| 40 | 33 | import apijson.demo.client.util.HttpRequest; | |
| 34 | + import zuo.biao.apijson.JSON; | ||
| 35 | + import zuo.biao.apijson.JSONResponse; | ||
| 36 | + import zuo.biao.library.base.BaseBroadcastReceiver; | ||
| 37 | + import zuo.biao.library.interfaces.OnBottomDragListener; | ||
| 38 | + import zuo.biao.library.manager.HttpManager.OnHttpResponseListener; | ||
| 39 | + import zuo.biao.library.ui.EditTextInfoWindow; | ||
| 40 | + import zuo.biao.library.util.Log; | ||
| 41 | + import zuo.biao.library.util.SettingUtil; | ||
| 42 | + import zuo.biao.library.util.StringUtil; | ||
| 41 | 43 | ||
| 42 | 44 | /**应用主页 | |
| 43 | 45 | * @author Lemon | |
@@ -77,14 +79,32 @@ protected void onCreate(Bundle savedInstanceState) { | |||
| 77 | 79 | initEvent(); | |
| 78 | 80 | //功能归类分区方法,必须调用>>>>>>>>>> | |
| 79 | 81 | ||
| 80 | - | ||
| 82 | + | ||
| 81 | 83 | BaseBroadcastReceiver.register(context, receiver | |
| 82 | 84 | , new String[]{ACTION_EXIT_APP, ActionUtil.ACTION_RELOAD_CURRENT_USER}); | |
| 83 | 85 | ||
| 84 | - | ||
| 86 | + | ||
| 85 | 87 | if (SettingUtil.isOnTestMode) { | |
| 86 | 88 | showShortToast("测试服务器\n" + HttpRequest.URL_BASE); | |
| 87 | 89 | } | |
| 90 | + | ||
| 91 | + | ||
| 92 | + HttpRequest.get(JSON.parseObject(JSON.toJSONString(TestRequestAndResponseJava.request()), zuo.biao.apijson.JSONObject.class), 0, new OnHttpResponseListener() { | ||
| 93 | + @Override | ||
| 94 | + public void onHttpResponse(int requestCode, String resultJson, Exception e) { | ||
| 95 | + TestRequestAndResponseJava.response(resultJson); | ||
| 96 | + } | ||
| 97 | + }); | ||
| 98 | + | ||
| 99 | + | ||
| 100 | + HttpRequest.get(JSON.parseObject(JSON.toJSONString(TestRequestAndResponseKt.request()), zuo.biao.apijson.JSONObject.class), 0, new OnHttpResponseListener() { | ||
| 101 | + @Override | ||
| 102 | + public void onHttpResponse(int requestCode, String resultJson, Exception e) { | ||
| 103 | + TestRequestAndResponseKt.response(resultJson); | ||
| 104 | + } | ||
| 105 | + }); | ||
| 106 | + | ||
| 107 | + | ||
| 88 | 108 | } | |
| 89 | 109 | ||
| 90 | 110 | ||
@@ -156,7 +176,7 @@ protected void selectTab(int position) { | |||
| 156 | 176 | llMainTabRightContainer.addView(right); | |
| 157 | 177 | } | |
| 158 | 178 | ||
| 159 | - | ||
| 179 | + | ||
| 160 | 180 | verifyLogin(); | |
| 161 | 181 | } | |
| 162 | 182 | ||
@@ -180,12 +200,12 @@ protected void selectTab(int position) { | |||
| 180 | 200 | @Override | |
| 181 | 201 | public void initData() {// 必须调用 | |
| 182 | 202 | super.initData(); | |
| 183 | - | ||
| 203 | + | ||
| 184 | 204 | if (isCurrentUserCorrect() == false) { | |
| 185 | 205 | reloadAll(); | |
| 186 | 206 | } | |
| 187 | 207 | } | |
| 188 | - | ||
| 208 | + | ||
| 189 | 209 | ||
| 190 | 210 | @Override | |
| 191 | 211 | protected void reloadAll() { | |
@@ -232,7 +252,7 @@ public void initEvent() {// 必须调用 | |||
| 232 | 252 | public void onDragBottom(boolean rightToLeft) { | |
| 233 | 253 | if (fragments[currentPosition] instanceof OnBottomDragListener) { | |
| 234 | 254 | ((OnBottomDragListener) fragments[currentPosition]).onDragBottom(rightToLeft); | |
| 235 | - } | ||
| 255 | + } | ||
| 236 | 256 | } | |
| 237 | 257 | ||
| 238 | 258 | ||
@@ -299,9 +319,9 @@ public void onReceive(Context context, Intent intent) { | |||
| 299 | 319 | finish(); | |
| 300 | 320 | return; | |
| 301 | 321 | } | |
| 302 | - | ||
| 322 | + | ||
| 303 | 323 | if (ActionUtil.ACTION_RELOAD_CURRENT_USER.equals(action)) { | |
| 304 | - reloadAll();// fragmentManager show remove等都会崩溃 | ||
| 324 | + reloadAll();// fragmentManager show remove等都会崩溃 | ||
| 305 | 325 | } | |
| 306 | 326 | } | |
| 307 | 327 | }; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,231 @@ | |||
| 1 | + package apijson.demo.client.activity_fragment | ||
| 2 | + | ||
| 3 | + import com.alibaba.fastjson.JSONArray | ||
| 4 | + import com.alibaba.fastjson.JSONObject | ||
| 5 | + import zuo.biao.apijson.JSON | ||
| 6 | + import java.util.* | ||
| 7 | + | ||
| 8 | + fun request(): Map<String, Any> { | ||
| 9 | + return mapOf( | ||
| 10 | + "emptyList" to ArrayList<Any>(), | ||
| 11 | + "[]" to mapOf( | ||
| 12 | + "count" to 5, | ||
| 13 | + "page" to 0, | ||
| 14 | + "join" to "&/User:owner/id@", | ||
| 15 | + "Moment" to HashMap<String, Any>(), | ||
| 16 | + "User:owner" to mapOf( | ||
| 17 | + "id{}" to listOf(82001, 82002), | ||
| 18 | + "id@" to "/Moment/userId", | ||
| 19 | + "@column" to "id,name,head" | ||
| 20 | + ), | ||
| 21 | + "User:praiseUser[]" to mapOf( | ||
| 22 | + "count" to 10, | ||
| 23 | + "User" to mapOf( | ||
| 24 | + "id{}@" to "[]/Moment/praiseUserIdList", | ||
| 25 | + "@column" to "id,name" | ||
| 26 | + ) | ||
| 27 | + ), | ||
| 28 | + "CommentItem[]" to mapOf( | ||
| 29 | + "count" to 6, | ||
| 30 | + "join" to "</User:publisher/id@", | ||
| 31 | + "Comment" to mapOf( | ||
| 32 | + "@order" to "date+", | ||
| 33 | + "momentId@" to "[]/Moment/id" | ||
| 34 | + ), | ||
| 35 | + "User:publisher" to mapOf( | ||
| 36 | + "id@" to "/Comment/userId", | ||
| 37 | + "@column" to "id,name" | ||
| 38 | + ) | ||
| 39 | + ) | ||
| 40 | + ) | ||
| 41 | + ) | ||
| 42 | + } | ||
| 43 | + | ||
| 44 | + fun response(resultJson: String?) { | ||
| 45 | + | ||
| 46 | + var response: JSONObject = JSON.parseObject(resultJson) | ||
| 47 | + | ||
| 48 | + | ||
| 49 | + //[]<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< | ||
| 50 | + var list: JSONArray? = response.getJSONArray("[]") | ||
| 51 | + if (list == null) { | ||
| 52 | + list = JSONArray() | ||
| 53 | + } | ||
| 54 | + | ||
| 55 | + var item: JSONObject? | ||
| 56 | + for (i in 0..list.size - 1) { | ||
| 57 | + item = list.getJSONObject(i) | ||
| 58 | + if (item == null) { | ||
| 59 | + continue | ||
| 60 | + } | ||
| 61 | + println("\nitem = list[" + i + "] = \n" + item + "\n\n") | ||
| 62 | + //TODO 你的代码 | ||
| 63 | + | ||
| 64 | + | ||
| 65 | + //Moment<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< | ||
| 66 | + var moment: JSONObject? = item.getJSONObject("Moment") | ||
| 67 | + if (moment == null) { | ||
| 68 | + moment = JSONObject() | ||
| 69 | + } | ||
| 70 | + | ||
| 71 | + var id = moment.getLongValue("id") | ||
| 72 | + println("moment.id = " + id); | ||
| 73 | + var userId = moment.getLongValue("userId") | ||
| 74 | + println("moment.userId = " + userId); | ||
| 75 | + var date = moment.getString("date") | ||
| 76 | + println("moment.date = " + date); | ||
| 77 | + var content = moment.getString("content") | ||
| 78 | + println("moment.content = " + content); | ||
| 79 | + | ||
| 80 | + //praiseUserIdList<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< | ||
| 81 | + var praiseUserIdList1: JSONArray? = moment.getJSONArray("praiseUserIdList") | ||
| 82 | + if (praiseUserIdList1 == null) { | ||
| 83 | + praiseUserIdList1 = JSONArray() | ||
| 84 | + } | ||
| 85 | + | ||
| 86 | + var item1: Int? | ||
| 87 | + for (i1 in 0..praiseUserIdList1.size - 1) { | ||
| 88 | + item1 = praiseUserIdList1.getInteger(i1) | ||
| 89 | + if (item1 == null) { | ||
| 90 | + continue | ||
| 91 | + } | ||
| 92 | + println("\nitem1 = praiseUserIdList1[" + i1 + "] = \n" + item1 + "\n\n") | ||
| 93 | + //TODO 你的代码 | ||
| 94 | + | ||
| 95 | + }//praiseUserIdList>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> | ||
| 96 | + | ||
| 97 | + | ||
| 98 | + //pictureList<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< | ||
| 99 | + var pictureList1: JSONArray? = moment.getJSONArray("pictureList") | ||
| 100 | + if (pictureList1 == null) { | ||
| 101 | + pictureList1 = JSONArray() | ||
| 102 | + } | ||
| 103 | + | ||
| 104 | + var item2: String? | ||
| 105 | + for (i1 in 0..pictureList1.size - 1) { | ||
| 106 | + item2 = pictureList1.getString(i1) | ||
| 107 | + if (item2 == null) { | ||
| 108 | + continue | ||
| 109 | + } | ||
| 110 | + println("\nitem1 = pictureList1[" + i1 + "] = \n" + item2 + "\n\n") | ||
| 111 | + //TODO 你的代码 | ||
| 112 | + | ||
| 113 | + }//pictureList>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> | ||
| 114 | + | ||
| 115 | + //Moment>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> | ||
| 116 | + | ||
| 117 | + | ||
| 118 | + //User:owner<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< | ||
| 119 | + var owner: JSONObject? = item.getJSONObject("User:owner") | ||
| 120 | + if (owner == null) { | ||
| 121 | + owner = JSONObject() | ||
| 122 | + } | ||
| 123 | + | ||
| 124 | + var id2 = owner.getLongValue("id") | ||
| 125 | + println("owner.id = " + id); | ||
| 126 | + var name = owner.getString("name") | ||
| 127 | + println("owner.name = " + name); | ||
| 128 | + var head = owner.getString("head") | ||
| 129 | + println("owner.head = " + head); | ||
| 130 | + //User:owner>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> | ||
| 131 | + | ||
| 132 | + | ||
| 133 | + //User:praiseUser[]<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< | ||
| 134 | + var praiseUserList1: JSONArray? = item.getJSONArray("User:praiseUser[]") | ||
| 135 | + if (praiseUserList1 == null) { | ||
| 136 | + praiseUserList1 = JSONArray() | ||
| 137 | + } | ||
| 138 | + | ||
| 139 | + var item3: JSONObject? | ||
| 140 | + for (i1 in 0..praiseUserList1.size - 1) { | ||
| 141 | + item3 = praiseUserList1.getJSONObject(i1) | ||
| 142 | + if (item3 == null) { | ||
| 143 | + continue | ||
| 144 | + } | ||
| 145 | + println("\nitem3 = praiseUserList1[" + i1 + "] = \n" + item3 + "\n\n") | ||
| 146 | + //TODO 你的代码 | ||
| 147 | + | ||
| 148 | + var id = item3.getLongValue("id") | ||
| 149 | + println("item3.id = " + id); | ||
| 150 | + var name = item3.getString("name") | ||
| 151 | + println("item3.name = " + name); | ||
| 152 | + }//User:praiseUser[]>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> | ||
| 153 | + | ||
| 154 | + | ||
| 155 | + //CommentItem[]<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< | ||
| 156 | + var commentItemList1: JSONArray? = item.getJSONArray("CommentItem[]") | ||
| 157 | + if (commentItemList1 == null) { | ||
| 158 | + commentItemList1 = JSONArray() | ||
| 159 | + } | ||
| 160 | + | ||
| 161 | + var item4: JSONObject? | ||
| 162 | + for (i1 in 0..commentItemList1.size - 1) { | ||
| 163 | + item4 = commentItemList1.getJSONObject(i1) | ||
| 164 | + if (item4 == null) { | ||
| 165 | + continue | ||
| 166 | + } | ||
| 167 | + println("\nitem4 = commentItemList1[" + i1 + "] = \n" + item4 + "\n\n") | ||
| 168 | + //TODO 你的代码 | ||
| 169 | + | ||
| 170 | + | ||
| 171 | + //Comment<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< | ||
| 172 | + var comment: JSONObject? = item4.getJSONObject("Comment") | ||
| 173 | + if (comment == null) { | ||
| 174 | + comment = JSONObject() | ||
| 175 | + } | ||
| 176 | + | ||
| 177 | + var id3 = comment.getLongValue("id") | ||
| 178 | + println("comment.id3 = " + id3); | ||
| 179 | + var toId = comment.getLongValue("toId") | ||
| 180 | + println("comment.toId = " + toId); | ||
| 181 | + var userId = comment.getLongValue("userId") | ||
| 182 | + println("comment.userId = " + userId); | ||
| 183 | + var momentId = comment.getLongValue("momentId") | ||
| 184 | + println("comment.momentId = " + momentId); | ||
| 185 | + var date = comment.getString("date") | ||
| 186 | + println("comment.date = " + date); | ||
| 187 | + var content = comment.getString("content") | ||
| 188 | + println("comment.content = " + content); | ||
| 189 | + //Comment>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> | ||
| 190 | + | ||
| 191 | + | ||
| 192 | + //User:publisher<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< | ||
| 193 | + var publisher: JSONObject? = item4.getJSONObject("User:publisher") | ||
| 194 | + if (publisher == null) { | ||
| 195 | + publisher = JSONObject() | ||
| 196 | + } | ||
| 197 | + | ||
| 198 | + var id4 = publisher.getLongValue("id") | ||
| 199 | + println("publisher.id4 = " + id4); | ||
| 200 | + var name = publisher.getString("name") | ||
| 201 | + println("publisher.name = " + name); | ||
| 202 | + //User:publisher>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> | ||
| 203 | + | ||
| 204 | + }//CommentItem[]>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> | ||
| 205 | + | ||
| 206 | + }//[]>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> | ||
| 207 | + | ||
| 208 | + | ||
| 209 | + //emptyList<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< | ||
| 210 | + var emptyList: JSONArray? = response.getJSONArray("emptyList") | ||
| 211 | + if (emptyList == null) { | ||
| 212 | + emptyList = JSONArray() | ||
| 213 | + } | ||
| 214 | + | ||
| 215 | + var item5: Any? | ||
| 216 | + for (i in 0..emptyList.size - 1) { | ||
| 217 | + item5 = emptyList.get(i) | ||
| 218 | + if (item5 == null) { | ||
| 219 | + continue | ||
| 220 | + } | ||
| 221 | + println("\nitem5 = emptyList[" + i + "] = \n" + item5 + "\n\n") | ||
| 222 | + //TODO 你的代码 | ||
| 223 | + | ||
| 224 | + }//emptyList>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> | ||
| 225 | + | ||
| 226 | + var code = response.getIntValue("code") | ||
| 227 | + println("response.code = " + code); | ||
| 228 | + var msg = response.getString("msg") | ||
| 229 | + println("response.msg = " + msg); | ||
| 230 | + | ||
| 231 | + } | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments