| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 8aba5eb commit b06773f
35 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -192,6 +192,7 @@ public void onHttpResponse(int requestCode, String resultJson, Exception e) { | |||
| 192 | 192 | break; | |
| 193 | 193 | } | |
| 194 | 194 | } else { | |
| 195 | + user.setPhone(phone); | ||
| 195 | 196 | APIJSONApplication.getInstance().saveCurrentUser(user); | |
| 196 | 197 | if (APIJSONApplication.getInstance().isLoggedIn() == false) { | |
| 197 | 198 | showShortToast((requestCode == Login.TYPE_PASSWORD ? "密码" : "验证码") + "错误"); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -17,7 +17,6 @@ | |||
| 17 | 17 | import java.util.List; | |
| 18 | 18 | ||
| 19 | 19 | import zuo.biao.apijson.JSONResponse; | |
| 20 | - import zuo.biao.library.base.BaseHttpListActivity; | ||
| 21 | 20 | import zuo.biao.library.base.BaseView.OnDataChangedListener; | |
| 22 | 21 | import zuo.biao.library.interfaces.AdapterCallBack; | |
| 23 | 22 | import zuo.biao.library.interfaces.CacheCallBack; | |
@@ -45,6 +44,7 @@ | |||
| 45 | 44 | import apijson.demo.client.R; | |
| 46 | 45 | import apijson.demo.client.adapter.CommentAdapter; | |
| 47 | 46 | import apijson.demo.client.application.APIJSONApplication; | |
| 47 | + import apijson.demo.client.base.BaseHttpListActivity; | ||
| 48 | 48 | import apijson.demo.client.manager.HttpManager; | |
| 49 | 49 | import apijson.demo.client.model.Comment; | |
| 50 | 50 | import apijson.demo.client.model.CommentItem; | |
@@ -531,6 +531,9 @@ public void run() { | |||
| 531 | 531 | return; | |
| 532 | 532 | } | |
| 533 | 533 | ||
| 534 | + if (verifyHttpLogin(response.getCode()) == false) { | ||
| 535 | + return; | ||
| 536 | + } | ||
| 534 | 537 | ||
| 535 | 538 | JSONResponse comment = response.getJSONResponse(Comment.class.getSimpleName()); | |
| 536 | 539 | final boolean succeed = JSONResponse.isSuccess(comment); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -14,6 +14,19 @@ | |||
| 14 | 14 | ||
| 15 | 15 | package apijson.demo.client.activity_fragment; | |
| 16 | 16 | ||
| 17 | + import java.util.List; | ||
| 18 | + | ||
| 19 | + import zuo.biao.apijson.JSON; | ||
| 20 | + import zuo.biao.apijson.JSONRequest; | ||
| 21 | + import zuo.biao.apijson.JSONResponse; | ||
| 22 | + import zuo.biao.apijson.SQL; | ||
| 23 | + import zuo.biao.apijson.StringUtil; | ||
| 24 | + import zuo.biao.library.base.BaseView.OnDataChangedListener; | ||
| 25 | + import zuo.biao.library.interfaces.AdapterCallBack; | ||
| 26 | + import zuo.biao.library.interfaces.CacheCallBack; | ||
| 27 | + import zuo.biao.library.interfaces.OnBottomDragListener; | ||
| 28 | + import zuo.biao.library.manager.HttpManager.OnHttpResponseListener; | ||
| 29 | + import zuo.biao.library.ui.EditTextInfoWindow; | ||
| 17 | 30 | import android.annotation.SuppressLint; | |
| 18 | 31 | import android.app.Activity; | |
| 19 | 32 | import android.content.Intent; | |
@@ -27,11 +40,6 @@ | |||
| 27 | 40 | import android.widget.AdapterView.OnItemClickListener; | |
| 28 | 41 | import android.widget.ImageView; | |
| 29 | 42 | import android.widget.TextView; | |
| 30 | - | ||
| 31 | - import com.alibaba.fastjson.JSONObject; | ||
| 32 | - | ||
| 33 | - import java.util.List; | ||
| 34 | - | ||
| 35 | 43 | import apijson.demo.client.R; | |
| 36 | 44 | import apijson.demo.client.adapter.MomentAdapter; | |
| 37 | 45 | import apijson.demo.client.application.APIJSONApplication; | |
@@ -41,17 +49,8 @@ | |||
| 41 | 49 | import apijson.demo.client.model.MomentItem; | |
| 42 | 50 | import apijson.demo.client.util.CommentUtil; | |
| 43 | 51 | import apijson.demo.client.util.HttpRequest; | |
| 44 | - import zuo.biao.apijson.JSON; | ||
| 45 | - import zuo.biao.apijson.JSONRequest; | ||
| 46 | - import zuo.biao.apijson.JSONResponse; | ||
| 47 | - import zuo.biao.apijson.SQL; | ||
| 48 | - import zuo.biao.apijson.StringUtil; | ||
| 49 | - import zuo.biao.library.base.BaseView.OnDataChangedListener; | ||
| 50 | - import zuo.biao.library.interfaces.AdapterCallBack; | ||
| 51 | - import zuo.biao.library.interfaces.CacheCallBack; | ||
| 52 | - import zuo.biao.library.interfaces.OnBottomDragListener; | ||
| 53 | - import zuo.biao.library.manager.HttpManager.OnHttpResponseListener; | ||
| 54 | - import zuo.biao.library.ui.EditTextInfoWindow; | ||
| 52 | + | ||
| 53 | + import com.alibaba.fastjson.JSONObject; | ||
| 55 | 54 | ||
| 56 | 55 | /**用户列表界面fragment | |
| 57 | 56 | * @author Lemon | |
@@ -364,9 +363,12 @@ public void onDataChanged() { | |||
| 364 | 363 | ||
| 365 | 364 | @Override | |
| 366 | 365 | public void onHttpResponse(int requestCode, String resultJson, Exception e) { | |
| 366 | + JSONResponse response = new JSONResponse(resultJson); | ||
| 367 | + if ((range == RANGE_USER_CIRCLE || requestCode == HTTP_ADD) && verifyHttpLogin(response.getCode()) == false) { | ||
| 368 | + return; | ||
| 369 | + } | ||
| 367 | 370 | switch (requestCode) { | |
| 368 | 371 | case HTTP_ADD: | |
| 369 | - JSONResponse response = new JSONResponse(resultJson); | ||
| 370 | 372 | response = response.getJSONResponse(Moment.class.getSimpleName()); | |
| 371 | 373 | ||
| 372 | 374 | if (JSONResponse.isSuccess(response) == false) { | |
@@ -389,6 +391,8 @@ public void run() { | |||
| 389 | 391 | ||
| 390 | 392 | } | |
| 391 | 393 | ||
| 394 | + | ||
| 395 | + | ||
| 392 | 396 | //系统自带监听方法 <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< | |
| 393 | 397 | ||
| 394 | 398 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -133,9 +133,7 @@ public void run() { | |||
| 133 | 133 | @Override | |
| 134 | 134 | public void run() { | |
| 135 | 135 | ImageLoaderUtil.loadImage(ivQRCodeHead, user.getHead()); | |
| 136 | - tvQRCodeName.setText(StringUtil.getTrimedString( | ||
| 137 | - StringUtil.isNotEmpty(user.getName(), true) | ||
| 138 | - ? user.getName() : user.getPhone())); | ||
| 136 | + tvQRCodeName.setText(StringUtil.getTrimedString(user.getName())); | ||
| 139 | 137 | } | |
| 140 | 138 | }); | |
| 141 | 139 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -44,5 +44,10 @@ public void finish() { | |||
| 44 | 44 | super.finish(); | |
| 45 | 45 | overridePendingTransition(R.anim.fade, R.anim.hold); | |
| 46 | 46 | } | |
| 47 | + | ||
| 48 | + @Override | ||
| 49 | + public void onBackPressed() { | ||
| 50 | + //super.onBackPressed(); | ||
| 51 | + } | ||
| 47 | 52 | ||
| 48 | 53 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -38,6 +38,7 @@ | |||
| 38 | 38 | import apijson.demo.client.util.HttpRequest; | |
| 39 | 39 | import apijson.demo.client.util.MenuUtil; | |
| 40 | 40 | import apijson.demo.client.view.UserView; | |
| 41 | + import apijson.demo.server.model.Privacy; | ||
| 41 | 42 | import zuo.biao.apijson.JSONRequest; | |
| 42 | 43 | import zuo.biao.apijson.JSONResponse; | |
| 43 | 44 | import zuo.biao.library.base.BaseView.OnDataChangedListener; | |
@@ -188,12 +189,12 @@ private void setUser(User user_) { | |||
| 188 | 189 | * @param momentList_ | |
| 189 | 190 | */ | |
| 190 | 191 | private void setUser(User user_, List<Moment> momentList_) { | |
| 192 | + if (user_ == null) { | ||
| 193 | + Log.w(TAG, "setUser user_ == null >> user = new User();"); | ||
| 194 | + user_ = new User(); | ||
| 195 | + } | ||
| 191 | 196 | this.user = user_; | |
| 192 | 197 | this.momentList = momentList_; | |
| 193 | - if (user == null) { | ||
| 194 | - Log.w(TAG, "setUser user == null >> user = new User();"); | ||
| 195 | - user = new User(); | ||
| 196 | - } | ||
| 197 | 198 | if (momentList == null) { | |
| 198 | 199 | momentList = new ArrayList<>(); | |
| 199 | 200 | } | |
@@ -211,7 +212,6 @@ public void run() { | |||
| 211 | 212 | userView.bindView(user);//方式三 | |
| 212 | 213 | ||
| 213 | 214 | tvUserRemark.setText(StringUtil.getTrimedString(user.getHead())); | |
| 214 | - tvUserPhone.setText(StringUtil.getTrimedString(user.getPhone())); | ||
| 215 | 215 | ||
| 216 | 216 | if (adapter == null) { | |
| 217 | 217 | adapter = new GridAdapter(context); | |
@@ -223,6 +223,26 @@ public void run() { | |||
| 223 | 223 | }); | |
| 224 | 224 | } | |
| 225 | 225 | ||
| 226 | + | ||
| 227 | + private Privacy privacy; | ||
| 228 | + /**显示用户隐私信息 | ||
| 229 | + * @param privacy | ||
| 230 | + */ | ||
| 231 | + private void setPrivacy(Privacy privacy_) { | ||
| 232 | + if (privacy_ == null) { | ||
| 233 | + Log.w(TAG, "setUser user_ == null >> user = new User();"); | ||
| 234 | + privacy_ = new Privacy(); | ||
| 235 | + } | ||
| 236 | + this.privacy = privacy_; | ||
| 237 | + runUiThread(new Runnable() { | ||
| 238 | + | ||
| 239 | + @Override | ||
| 240 | + public void run() { | ||
| 241 | + tvUserPhone.setText(StringUtil.getTrimedString(privacy.getPhone())); | ||
| 242 | + } | ||
| 243 | + }); | ||
| 244 | + } | ||
| 245 | + | ||
| 226 | 246 | /**裁剪图片 | |
| 227 | 247 | * @param path | |
| 228 | 248 | */ | |
@@ -270,7 +290,7 @@ public void onDataChanged() { | |||
| 270 | 290 | bottomMenuView.bindView(MenuUtil.getMenuList(MenuUtil.USER, id, ! User.isFriend(currentUser, id))); | |
| 271 | 291 | } | |
| 272 | 292 | ||
| 273 | - runThread(TAG + "run", new Runnable() { | ||
| 293 | + runThread(TAG + "onDataChanged", new Runnable() { | ||
| 274 | 294 | ||
| 275 | 295 | @Override | |
| 276 | 296 | public void run() { | |
@@ -284,10 +304,12 @@ public void run() { | |||
| 284 | 304 | @Override | |
| 285 | 305 | public void run() { | |
| 286 | 306 | setUser(user, momentList); | |
| 307 | + setPrivacy(null); | ||
| 287 | 308 | } | |
| 288 | 309 | }); | |
| 289 | 310 | ||
| 290 | 311 | HttpRequest.getUser(id, ! isOnEditMode, HTTP_GET, UserActivity.this); | |
| 312 | + HttpRequest.getPrivacy(id, HTTP_GET_PRIVACY, UserActivity.this); | ||
| 291 | 313 | } | |
| 292 | 314 | }); | |
| 293 | 315 | ||
@@ -386,8 +408,8 @@ public void onClick(View v) { | |||
| 386 | 408 | break; | |
| 387 | 409 | case R.id.tvUserViewTag: | |
| 388 | 410 | if (isOnEditMode) { | |
| 389 | - toActivity(EditTextInfoActivity.createIntent(context, "标签" | ||
| 390 | - , StringUtil.getTrimedString(tvUserPhone)), REQUEST_TO_EDIT_TEXT_INFO_TAG); | ||
| 411 | + toActivity(EditTextInfoWindow.createIntent(context | ||
| 412 | + , "标签", user.getTag()), REQUEST_TO_EDIT_TEXT_INFO_TAG, false); | ||
| 391 | 413 | } else { | |
| 392 | 414 | CommonUtil.copyText(context, user.getTag()); | |
| 393 | 415 | } | |
@@ -442,6 +464,7 @@ public void onBottomMenuItemClick(int intentCode) { | |||
| 442 | 464 | //对应HttpRequest.getUser(id, 0, UserActivity.this); <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< | |
| 443 | 465 | ||
| 444 | 466 | protected static final int HTTP_GET = 1; | |
| 467 | + protected static final int HTTP_GET_PRIVACY = 5; | ||
| 445 | 468 | protected static final int HTTP_ADD = 2; | |
| 446 | 469 | protected static final int HTTP_DELETE = 3; | |
| 447 | 470 | protected static final int HTTP_PUT = 4; | |
@@ -466,8 +489,14 @@ public void onHttpResponse(int requestCode, String resultJson, Exception e) { | |||
| 466 | 489 | } | |
| 467 | 490 | setUser(user, response.getList(Moment.class.getSimpleName() + "[]", Moment.class)); | |
| 468 | 491 | break; | |
| 492 | + case HTTP_GET_PRIVACY: | ||
| 493 | + setPrivacy(response.getObject(Privacy.class)); | ||
| 494 | + break; | ||
| 469 | 495 | case HTTP_ADD: | |
| 470 | 496 | case HTTP_DELETE: | |
| 497 | + if (verifyHttpLogin(response.getCode()) == false) { | ||
| 498 | + return; | ||
| 499 | + } | ||
| 471 | 500 | if (isSucceed) { | |
| 472 | 501 | showShortToast(requestCode == HTTP_ADD ? R.string.add_succeed : R.string.delete_succeed); | |
| 473 | 502 | sendBroadcast(new Intent(ActionUtil.ACTION_RELOAD_CURRENT_USER)); | |
@@ -476,6 +505,9 @@ public void onHttpResponse(int requestCode, String resultJson, Exception e) { | |||
| 476 | 505 | } | |
| 477 | 506 | break; | |
| 478 | 507 | case HTTP_PUT: | |
| 508 | + if (verifyHttpLogin(response.getCode()) == false) { | ||
| 509 | + return; | ||
| 510 | + } | ||
| 479 | 511 | if (isSucceed) { | |
| 480 | 512 | isDataChanged = false; | |
| 481 | 513 | sendBroadcast(new Intent(ActionUtil.ACTION_RELOAD_CURRENT_USER)); | |
@@ -515,7 +547,7 @@ public void onClick(View v) { | |||
| 515 | 547 | break; | |
| 516 | 548 | case R.id.llUserPhone: | |
| 517 | 549 | toActivity(EditTextInfoWindow.createIntent(context, EditTextInfoWindow.TYPE_PHONE | |
| 518 | - , "手机", user.getPhone()), REQUEST_TO_EDIT_TEXT_INFO_PHONE, false); | ||
| 550 | + , "手机", privacy.getPhone()), REQUEST_TO_EDIT_TEXT_INFO_PHONE, false); | ||
| 519 | 551 | break; | |
| 520 | 552 | default: | |
| 521 | 553 | break; | |
@@ -579,7 +611,7 @@ public void onActivityResult(int requestCode, int resultCode, Intent data) { | |||
| 579 | 611 | user.setName(value); | |
| 580 | 612 | break; | |
| 581 | 613 | case REQUEST_TO_EDIT_TEXT_INFO_PHONE: | |
| 582 | - user.setPhone(value); | ||
| 614 | + privacy.setPhone(value); | ||
| 583 | 615 | break; | |
| 584 | 616 | case REQUEST_TO_EDIT_TEXT_INFO_REMARK: | |
| 585 | 617 | user.setHead(value); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -358,6 +358,16 @@ public void onDataChanged() { | |||
| 358 | 358 | } | |
| 359 | 359 | } | |
| 360 | 360 | ||
| 361 | + | ||
| 362 | + @Override | ||
| 363 | + public void onHttpResponse(int requestCode, String resultJson, Exception e) { | ||
| 364 | + JSONResponse response = new JSONResponse(resultJson); | ||
| 365 | + if ((range == RANGE_USER_FRIEND) && verifyHttpLogin(response.getCode()) == false) { | ||
| 366 | + return; | ||
| 367 | + } | ||
| 368 | + super.onHttpResponse(requestCode, resultJson, e); | ||
| 369 | + } | ||
| 370 | + | ||
| 361 | 371 | //系统自带监听方法 <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< | |
| 362 | 372 | ||
| 363 | 373 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -15,7 +15,6 @@ | |||
| 15 | 15 | package apijson.demo.client.activity_fragment; | |
| 16 | 16 | ||
| 17 | 17 | import zuo.biao.apijson.JSONResponse; | |
| 18 | - import zuo.biao.library.base.BaseActivity; | ||
| 19 | 18 | import zuo.biao.library.interfaces.OnBottomDragListener; | |
| 20 | 19 | import zuo.biao.library.manager.HttpManager.OnHttpResponseListener; | |
| 21 | 20 | import zuo.biao.library.ui.EditTextInfoActivity; | |
@@ -29,6 +28,7 @@ | |||
| 29 | 28 | import android.view.View.OnClickListener; | |
| 30 | 29 | import android.widget.TextView; | |
| 31 | 30 | import apijson.demo.client.R; | |
| 31 | + import apijson.demo.client.base.BaseActivity; | ||
| 32 | 32 | import apijson.demo.client.util.HttpRequest; | |
| 33 | 33 | import apijson.demo.server.model.Privacy; | |
| 34 | 34 | ||
@@ -166,6 +166,10 @@ public void onHttpResponse(final int requestCode, final String resultJson, Excep | |||
| 166 | 166 | public void run() { | |
| 167 | 167 | ||
| 168 | 168 | JSONResponse response = new JSONResponse(resultJson); | |
| 169 | + if (verifyHttpLogin(response.getCode()) == false) { | ||
| 170 | + return; | ||
| 171 | + } | ||
| 172 | + | ||
| 169 | 173 | isSucceed = JSONResponse.isSuccess(response); | |
| 170 | 174 | ||
| 171 | 175 | dismissProgressDialog(); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -75,6 +75,10 @@ public void saveCurrentUser(User user) { | |||
| 75 | 75 | return; | |
| 76 | 76 | } | |
| 77 | 77 | ||
| 78 | + if (currentUser != null && user.getId().equals(currentUser.getId()) | ||
| 79 | + && StringUtil.isNotEmpty(user.getPhone(), true) == false) { | ||
| 80 | + user.setPhone(currentUser.getPhone()); | ||
| 81 | + } | ||
| 78 | 82 | currentUser = user; | |
| 79 | 83 | DataManager.getInstance().saveCurrentUser(currentUser); | |
| 80 | 84 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -14,6 +14,7 @@ | |||
| 14 | 14 | ||
| 15 | 15 | package apijson.demo.client.base; | |
| 16 | 16 | ||
| 17 | + import zuo.biao.apijson.JSONResponse; | ||
| 17 | 18 | import zuo.biao.library.base.BaseBroadcastReceiver; | |
| 18 | 19 | import zuo.biao.library.base.BaseView.OnDataChangedListener; | |
| 19 | 20 | import zuo.biao.library.util.Log; | |
@@ -48,7 +49,17 @@ private void setCurrentUser() { | |||
| 48 | 49 | currentUserId = currentUser == null ? 0 : currentUser.getId(); | |
| 49 | 50 | isLoggedIn = isCurrentUserCorrect(); | |
| 50 | 51 | } | |
| 51 | - | ||
| 52 | + | ||
| 53 | + protected boolean verifyHttpLogin(int code) { | ||
| 54 | + if (isAlive() == false) { | ||
| 55 | + return true; | ||
| 56 | + } | ||
| 57 | + if (code == JSONResponse.CODE_NOT_LOGGED_IN) { | ||
| 58 | + APIJSONApplication.getInstance().logout(); | ||
| 59 | + setCurrentUser(); | ||
| 60 | + } | ||
| 61 | + return verifyLogin(); | ||
| 62 | + } | ||
| 52 | 63 | protected static boolean isCurrentUser(long userId) { | |
| 53 | 64 | return APIJSONApplication.getInstance().isCurrentUser(userId); | |
| 54 | 65 | } | |
| Back | FazBrowse Home | New Git URL |
0 commit comments