| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 4cf2f57 commit a907f71
11 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -737,23 +737,35 @@ public static String[] split(String s) { | |||
| 737 | 737 | return split(s, null); | |
| 738 | 738 | } | |
| 739 | 739 | /**将s用split分割成String[] | |
| 740 | + * trim = true; | ||
| 740 | 741 | * @param s | |
| 741 | 742 | * @param split | |
| 742 | 743 | * @return | |
| 743 | 744 | */ | |
| 744 | 745 | public static String[] split(String s, String split) { | |
| 746 | + return split(s, split, true); | ||
| 747 | + } | ||
| 748 | + /**将s用split分割成String[] | ||
| 749 | + * @param s | ||
| 750 | + * @param split | ||
| 751 | + * @param trim 去掉前后两端的split | ||
| 752 | + * @return | ||
| 753 | + */ | ||
| 754 | + public static String[] split(String s, String split, boolean trim) { | ||
| 745 | 755 | s = getString(s); | |
| 746 | 756 | if (s.isEmpty()) { | |
| 747 | 757 | return null; | |
| 748 | 758 | } | |
| 749 | 759 | if (isNotEmpty(split, false) == false) { | |
| 750 | 760 | split = ","; | |
| 751 | 761 | } | |
| 752 | - while (s.startsWith(split)) { | ||
| 753 | - s = s.substring(split.length()); | ||
| 754 | - } | ||
| 755 | - while (s.endsWith(split)) { | ||
| 756 | - s = s.substring(0, s.length() - split.length()); | ||
| 762 | + if (trim) { | ||
| 763 | + while (s.startsWith(split)) { | ||
| 764 | + s = s.substring(split.length()); | ||
| 765 | + } | ||
| 766 | + while (s.endsWith(split)) { | ||
| 767 | + s = s.substring(0, s.length() - split.length()); | ||
| 768 | + } | ||
| 757 | 769 | } | |
| 758 | 770 | return s.contains(split) ? s.split(split) : new String[]{s}; | |
| 759 | 771 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -229,15 +229,15 @@ public static boolean noDisturb() { | |||
| 229 | 229 | /** | |
| 230 | 230 | * TODO 改为你的正式服务器地址 | |
| 231 | 231 | */ | |
| 232 | - public static final String URL_SERVER_ADDRESS_NORMAL_HTTP = "http://139.196.140.118:8080/";//正式服务器 | ||
| 232 | + public static final String URL_SERVER_ADDRESS_NORMAL_HTTP = "http://39.108.143.172:8080/";//正式服务器 | ||
| 233 | 233 | /** | |
| 234 | 234 | * TODO 改为你的正式服务器地址 | |
| 235 | 235 | */ | |
| 236 | - public static final String URL_SERVER_ADDRESS_NORMAL_HTTPS = "http://192.168.43.52:8080/";//正式服务器 | ||
| 236 | + public static final String URL_SERVER_ADDRESS_NORMAL_HTTPS = "http://39.108.143.172:8080/";//正式服务器 | ||
| 237 | 237 | /** | |
| 238 | 238 | * TODO 改为你的测试服务器地址,如果有的话 | |
| 239 | 239 | */ | |
| 240 | - public static final String URL_SERVER_ADDRESS_TEST = "http://192.168.0.118:8080/";//测试服务器 | ||
| 240 | + public static final String URL_SERVER_ADDRESS_TEST = "http://192.168.0.100:8080/";//测试服务器 | ||
| 241 | 241 | ||
| 242 | 242 | /**获取当前服务器地址 | |
| 243 | 243 | * isHttps = false | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -19,6 +19,7 @@ | |||
| 19 | 19 | import android.content.Intent; | |
| 20 | 20 | import android.os.Bundle; | |
| 21 | 21 | import android.view.View; | |
| 22 | + import android.widget.ImageView; | ||
| 22 | 23 | ||
| 23 | 24 | import com.alibaba.fastjson.JSONObject; | |
| 24 | 25 | ||
@@ -134,9 +135,15 @@ protected void onCreate(Bundle savedInstanceState) { | |||
| 134 | 135 | ||
| 135 | 136 | //UI显示区(操作UI,但不存在数据获取或处理代码,也不存在事件监听代码)<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< | |
| 136 | 137 | ||
| 138 | + private boolean isCurrentUser = false; | ||
| 139 | + | ||
| 140 | + private ImageView ivMomentListForward; | ||
| 137 | 141 | private MomentListFragment fragment; | |
| 138 | 142 | @Override | |
| 139 | 143 | public void initView() {//必须在onCreate方法内调用 | |
| 144 | + ivMomentListForward = (ImageView) findViewById(R.id.ivMomentListForward); | ||
| 145 | + ivMomentListForward.setVisibility(showSearch ? View.VISIBLE : View.GONE); | ||
| 146 | + | ||
| 140 | 147 | String title; | |
| 141 | 148 | switch (range) { | |
| 142 | 149 | case MomentListFragment.RANGE_ALL: | |
@@ -146,7 +153,14 @@ public void initView() {//必须在onCreate方法内调用 | |||
| 146 | 153 | // title = "动态"; | |
| 147 | 154 | // break; | |
| 148 | 155 | case MomentListFragment.RANGE_USER: | |
| 149 | - title = APIJSONApplication.getInstance().isCurrentUser(id) ? "我的动态" : "TA的动态"; | ||
| 156 | + isCurrentUser = APIJSONApplication.getInstance().isCurrentUser(id); | ||
| 157 | + title = isCurrentUser ? "我的动态" : "TA的动态"; | ||
| 158 | + if (isCurrentUser) { | ||
| 159 | + ivMomentListForward.setVisibility(View.VISIBLE); | ||
| 160 | + ivMomentListForward.setImageResource(R.drawable.add); | ||
| 161 | + } else { | ||
| 162 | + ivMomentListForward.setVisibility(View.GONE); | ||
| 163 | + } | ||
| 150 | 164 | break; | |
| 151 | 165 | case MomentListFragment.RANGE_USER_CIRCLE: | |
| 152 | 166 | title = "朋友圈"; | |
@@ -158,10 +172,9 @@ public void initView() {//必须在onCreate方法内调用 | |||
| 158 | 172 | tvBaseTitle.setText(title); | |
| 159 | 173 | autoSetTitle(); | |
| 160 | 174 | ||
| 161 | - findViewById(R.id.ivMomentListForward).setVisibility(showSearch ? View.VISIBLE : View.GONE); | ||
| 162 | - | ||
| 163 | 175 | ||
| 164 | 176 | fragment = MomentListFragment.createInstance(range, id, search); | |
| 177 | + fragment.setIsAdd(isCurrentUser); | ||
| 165 | 178 | ||
| 166 | 179 | fragmentManager | |
| 167 | 180 | .beginTransaction() | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -37,6 +37,7 @@ | |||
| 37 | 37 | import apijson.demo.client.application.APIJSONApplication; | |
| 38 | 38 | import apijson.demo.client.base.BaseHttpListFragment; | |
| 39 | 39 | import apijson.demo.client.interfaces.TopBarMenuCallback; | |
| 40 | + import apijson.demo.client.model.Moment; | ||
| 40 | 41 | import apijson.demo.client.model.MomentItem; | |
| 41 | 42 | import apijson.demo.client.util.CommentUtil; | |
| 42 | 43 | import apijson.demo.client.util.HttpRequest; | |
@@ -204,7 +205,7 @@ public void refreshAdapter() { | |||
| 204 | 205 | }); | |
| 205 | 206 | } | |
| 206 | 207 | ||
| 207 | - | ||
| 208 | + | ||
| 208 | 209 | private TextView leftMenu; | |
| 209 | 210 | @SuppressLint("InflateParams") | |
| 210 | 211 | @Override | |
@@ -261,6 +262,12 @@ public void initData() {//必须调用 | |||
| 261 | 262 | ||
| 262 | 263 | } | |
| 263 | 264 | ||
| 265 | + private boolean isAdd = false; | ||
| 266 | + public void setIsAdd(boolean isAdd) { | ||
| 267 | + this.isAdd = isAdd; | ||
| 268 | + } | ||
| 269 | + | ||
| 270 | + | ||
| 264 | 271 | @Override | |
| 265 | 272 | public void getListAsync(final int page) { | |
| 266 | 273 | HttpRequest.getMomentList(range, id, search, getCacheCount(), page, -page, this); | |
@@ -332,10 +339,17 @@ public void onDragBottom(boolean rightToLeft) { | |||
| 332 | 339 | return; | |
| 333 | 340 | } | |
| 334 | 341 | ||
| 335 | - showShortToast("输入为空则查看全部"); | ||
| 336 | - toActivity(EditTextInfoWindow.createIntent(context | ||
| 337 | - , EditTextInfoWindow.TYPE_NAME, "关键词", null), | ||
| 338 | - REQUEST_TO_EDIT_TEXT_INFO, false); | ||
| 342 | + if (isAdd) { | ||
| 343 | + toActivity(EditTextInfoWindow.createIntent(context | ||
| 344 | + , EditTextInfoWindow.TYPE_NOTE, "发动态", "说点什么吧~"), | ||
| 345 | + REQUEST_TO_EDIT_TEXT_INFO, false); | ||
| 346 | + } else { | ||
| 347 | + showShortToast("输入为空则查看全部"); | ||
| 348 | + toActivity(EditTextInfoWindow.createIntent(context | ||
| 349 | + , EditTextInfoWindow.TYPE_NAME, "关键词", null), | ||
| 350 | + REQUEST_TO_EDIT_TEXT_INFO, false); | ||
| 351 | + } | ||
| 352 | + | ||
| 339 | 353 | } | |
| 340 | 354 | } | |
| 341 | 355 | ||
@@ -346,6 +360,35 @@ public void onDataChanged() { | |||
| 346 | 360 | } | |
| 347 | 361 | } | |
| 348 | 362 | ||
| 363 | + private static final int HTTP_ADD = 1; | ||
| 364 | + | ||
| 365 | + @Override | ||
| 366 | + public void onHttpResponse(int requestCode, String resultJson, Exception e) { | ||
| 367 | + switch (requestCode) { | ||
| 368 | + case HTTP_ADD: | ||
| 369 | + JSONResponse response = new JSONResponse(resultJson); | ||
| 370 | + response = response.getJSONResponse(Moment.class.getSimpleName()); | ||
| 371 | + | ||
| 372 | + if (JSONResponse.isSuccess(response) == false) { | ||
| 373 | + showShortToast("发布失败,请检查网络后重试"); | ||
| 374 | + } else { | ||
| 375 | + runUiThread(new Runnable() { | ||
| 376 | + | ||
| 377 | + @Override | ||
| 378 | + public void run() { | ||
| 379 | + showShortToast("发布成功"); | ||
| 380 | + lvBaseList.onRefresh(); | ||
| 381 | + } | ||
| 382 | + }); | ||
| 383 | + } | ||
| 384 | + break; | ||
| 385 | + default: | ||
| 386 | + super.onHttpResponse(requestCode, resultJson, e); | ||
| 387 | + break; | ||
| 388 | + } | ||
| 389 | + | ||
| 390 | + } | ||
| 391 | + | ||
| 349 | 392 | //系统自带监听方法 <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< | |
| 350 | 393 | ||
| 351 | 394 | ||
@@ -363,14 +406,19 @@ public void onActivityResult(int requestCode, int resultCode, Intent data) { | |||
| 363 | 406 | case REQUEST_TO_EDIT_TEXT_INFO: | |
| 364 | 407 | if (data != null) { | |
| 365 | 408 | String value = StringUtil.getString(data.getStringExtra(EditTextInfoWindow.RESULT_VALUE)); | |
| 366 | - String split = ""; | ||
| 367 | - JSONRequest search = new JSONRequest(); | ||
| 368 | - if (StringUtil.isNotEmpty(value, true)) { | ||
| 369 | - split = ":"; | ||
| 370 | - search.putsSearch(HttpRequest.CONTENT, value, SQL.SEARCH_TYPE_CONTAIN_ORDER); | ||
| 409 | + | ||
| 410 | + if (isAdd) { | ||
| 411 | + HttpRequest.addMoment(value, HTTP_ADD, this); | ||
| 412 | + } else { | ||
| 413 | + String split = ""; | ||
| 414 | + JSONRequest search = new JSONRequest(); | ||
| 415 | + if (StringUtil.isNotEmpty(value, true)) { | ||
| 416 | + split = ":"; | ||
| 417 | + search.putsSearch(HttpRequest.CONTENT, value, SQL.SEARCH_TYPE_CONTAIN_ORDER); | ||
| 418 | + } | ||
| 419 | + toActivity(MomentListActivity.createIntent(context, range, id, search, false) | ||
| 420 | + .putExtra(INTENT_TITLE, "搜索" + split + value)); | ||
| 371 | 421 | } | |
| 372 | - toActivity(MomentListActivity.createIntent(context, range, id, search, false) | ||
| 373 | - .putExtra(INTENT_TITLE, "搜索" + split + value)); | ||
| 374 | 422 | } | |
| 375 | 423 | break; | |
| 376 | 424 | default: | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -87,7 +87,7 @@ public Activity getActivity() { | |||
| 87 | 87 | ||
| 88 | 88 | public static final int TYPE_VERIFY = 0; | |
| 89 | 89 | public static final int TYPE_REGISTER = 1; | |
| 90 | - public static final int TYPE_RESET = 3; | ||
| 90 | + public static final int TYPE_RESET = 2; | ||
| 91 | 91 | ||
| 92 | 92 | private int type = TYPE_VERIFY; | |
| 93 | 93 | private String phone; | |
@@ -212,7 +212,7 @@ private void getVerify() { | |||
| 212 | 212 | ||
| 213 | 213 | /**从服务器获取验证码 | |
| 214 | 214 | */ | |
| 215 | - private void getVerifyFromServer() { | ||
| 215 | + private void getVerifyFromServer(int type) { | ||
| 216 | 216 | runUiThread(new Runnable() { | |
| 217 | 217 | ||
| 218 | 218 | @Override | |
@@ -221,7 +221,7 @@ public void run() { | |||
| 221 | 221 | } | |
| 222 | 222 | }); | |
| 223 | 223 | ||
| 224 | - HttpRequest.getVerify(StringUtil.getTrimedString(etPasswordPhone), HTTP_GET_VERIFY, this); | ||
| 224 | + HttpRequest.getVerify(type, StringUtil.getTrimedString(etPasswordPhone), HTTP_GET_VERIFY, this); | ||
| 225 | 225 | } | |
| 226 | 226 | ||
| 227 | 227 | /**下一步 | |
@@ -245,24 +245,28 @@ private void toNextStep() { | |||
| 245 | 245 | case TYPE_REGISTER: | |
| 246 | 246 | register(); | |
| 247 | 247 | break; | |
| 248 | - default: | ||
| 249 | - checkVerify(true); | ||
| 248 | + case TYPE_VERIFY: | ||
| 249 | + checkVerify(Verify.TYPE_LOGIN, true); | ||
| 250 | + break; | ||
| 251 | + case TYPE_RESET: | ||
| 252 | + checkVerify(Verify.TYPE_PASSWORD, true); | ||
| 250 | 253 | break; | |
| 251 | 254 | } | |
| 252 | 255 | } | |
| 253 | 256 | ||
| 254 | 257 | /**验证验证码 | |
| 258 | + * @param type | ||
| 255 | 259 | * @param fromServer | |
| 256 | 260 | */ | |
| 257 | - private boolean checkVerify(boolean fromServer) { | ||
| 261 | + private boolean checkVerify(int type, boolean fromServer) { | ||
| 258 | 262 | if (EditTextUtil.isInputedCorrect(context, etPasswordPhone, EditTextUtil.TYPE_PHONE) == false | |
| 259 | 263 | || EditTextUtil.isInputedCorrect(context, etPasswordVerify, EditTextUtil.TYPE_VERIFY) == false) { | |
| 260 | 264 | return false; | |
| 261 | 265 | } | |
| 262 | 266 | ||
| 263 | 267 | if (fromServer) { | |
| 264 | 268 | showProgressDialog(); | |
| 265 | - HttpRequest.checkVerify(StringUtil.getTrimedString(etPasswordPhone), | ||
| 269 | + HttpRequest.checkVerify(type, StringUtil.getTrimedString(etPasswordPhone), | ||
| 266 | 270 | StringUtil.getTrimedString(etPasswordVerify), HTTP_CHECK_VERIFY, this); | |
| 267 | 271 | } | |
| 268 | 272 | ||
@@ -271,7 +275,7 @@ private boolean checkVerify(boolean fromServer) { | |||
| 271 | 275 | ||
| 272 | 276 | ||
| 273 | 277 | private void register() { | |
| 274 | - if (checkVerify(false) == false) { | ||
| 278 | + if (checkVerify(Verify.TYPE_REGISTER, false) == false) { | ||
| 275 | 279 | return; | |
| 276 | 280 | } | |
| 277 | 281 | showProgressDialog(); | |
@@ -357,11 +361,11 @@ public void run() { | |||
| 357 | 361 | if (type == TYPE_REGISTER) { | |
| 358 | 362 | showShortToast("手机号已经注册"); | |
| 359 | 363 | } else { | |
| 360 | - getVerifyFromServer(); | ||
| 364 | + getVerifyFromServer(type == TYPE_VERIFY ? Verify.TYPE_LOGIN : Verify.TYPE_PASSWORD); | ||
| 361 | 365 | } | |
| 362 | 366 | } else {//手机号未被注册过 | |
| 363 | 367 | if (type == TYPE_REGISTER) { | |
| 364 | - getVerifyFromServer(); | ||
| 368 | + getVerifyFromServer(Verify.TYPE_REGISTER); | ||
| 365 | 369 | } else { | |
| 366 | 370 | showShortToast("手机号未注册"); | |
| 367 | 371 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -337,15 +337,15 @@ public void onDragBottom(boolean rightToLeft) { | |||
| 337 | 337 | if (searchType <= 0) { | |
| 338 | 338 | searchType = EditTextInfoWindow.TYPE_PHONE; | |
| 339 | 339 | } | |
| 340 | - if (searchType == EditTextInfoWindow.TYPE_NAME) { | ||
| 340 | + // if (searchType == EditTextInfoWindow.TYPE_NAME) { | ||
| 341 | 341 | toActivity(EditTextInfoWindow.createIntent(context | |
| 342 | 342 | , EditTextInfoWindow.TYPE_NAME, "姓名", null), | |
| 343 | 343 | REQUEST_TO_EDIT_TEXT_INFO_SEARCH, false); | |
| 344 | - } else { | ||
| 345 | - toActivity(EditTextInfoWindow.createIntent(context | ||
| 346 | - , EditTextInfoWindow.TYPE_PHONE, "手机号", null), | ||
| 347 | - REQUEST_TO_EDIT_TEXT_INFO_ADD, false); | ||
| 348 | - } | ||
| 344 | + // } else { | ||
| 345 | + // toActivity(EditTextInfoWindow.createIntent(context | ||
| 346 | + // , EditTextInfoWindow.TYPE_PHONE, "手机号", null), | ||
| 347 | + // REQUEST_TO_EDIT_TEXT_INFO_ADD, false); | ||
| 348 | + // } | ||
| 349 | 349 | } | |
| 350 | 350 | ||
| 351 | 351 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -14,9 +14,6 @@ | |||
| 14 | 14 | ||
| 15 | 15 | package apijson.demo.client.model; | |
| 16 | 16 | ||
| 17 | - import zuo.biao.library.util.StringUtil; | ||
| 18 | - | ||
| 19 | - | ||
| 20 | 17 | /**验证码类 | |
| 21 | 18 | * @author Lemon | |
| 22 | 19 | */ | |
@@ -26,32 +23,15 @@ public class Verify extends apijson.demo.server.model.Verify { | |||
| 26 | 23 | public Verify() { | |
| 27 | 24 | super(); | |
| 28 | 25 | } | |
| 29 | - public Verify(long phone) { | ||
| 30 | - super(phone); | ||
| 26 | + | ||
| 27 | + public Verify(int type, String phone) { | ||
| 28 | + super(type, phone); | ||
| 31 | 29 | } | |
| 32 | - public Verify(String verify) { | ||
| 33 | - this(); | ||
| 34 | - setVerify(verify); | ||
| 35 | - } | ||
| 36 | - | ||
| 30 | + | ||
| 31 | + | ||
| 37 | 32 | @Override | |
| 38 | 33 | public Long getId() { | |
| 39 | 34 | return value(super.getId()); | |
| 40 | 35 | } | |
| 41 | 36 | ||
| 42 | - /**服务器用id作为phone | ||
| 43 | - * @return | ||
| 44 | - */ | ||
| 45 | - public String getPhone() { | ||
| 46 | - return "" + getId(); | ||
| 47 | - } | ||
| 48 | - public Verify setPhone(String phone) { | ||
| 49 | - setId(Long.valueOf(0 + StringUtil.getNumber(phone))); | ||
| 50 | - return this; | ||
| 51 | - } | ||
| 52 | - public Verify setPhone(Long phone) { | ||
| 53 | - setId(Long.valueOf(0 + StringUtil.getNumber(phone))); | ||
| 54 | - return this; | ||
| 55 | - } | ||
| 56 | - | ||
| 57 | 37 | } | |
| Back | FazBrowse Home | New Git URL |
0 commit comments