Skip to content

Commit a907f71

Browse files
committed
Client:同步adt版至studio版
1 parent 4cf2f57 commit a907f71

File tree

11 files changed

+200
-113
lines changed

11 files changed

+200
-113
lines changed

APIJSON-Android/APIJSON-AndroidStudio/APIJSONApp/APIJSONLibrary/src/main/java/zuo/biao/apijson/StringUtil.java

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -737,23 +737,35 @@ public static String[] split(String s) {
737737
return split(s, null);
738738
}
739739
/**将s用split分割成String[]
740+
* trim = true;
740741
* @param s
741742
* @param split
742743
* @return
743744
*/
744745
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) {
745755
s = getString(s);
746756
if (s.isEmpty()) {
747757
return null;
748758
}
749759
if (isNotEmpty(split, false) == false) {
750760
split = ",";
751761
}
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+
}
757769
}
758770
return s.contains(split) ? s.split(split) : new String[]{s};
759771
}

APIJSON-Android/APIJSON-AndroidStudio/APIJSONApp/ZBLibrary/src/main/java/zuo/biao/library/util/SettingUtil.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -229,15 +229,15 @@ public static boolean noDisturb() {
229229
/**
230230
* TODO 改为你的正式服务器地址
231231
*/
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/";//正式服务器
233233
/**
234234
* TODO 改为你的正式服务器地址
235235
*/
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/";//正式服务器
237237
/**
238238
* TODO 改为你的测试服务器地址,如果有的话
239239
*/
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/";//测试服务器
241241

242242
/**获取当前服务器地址
243243
* isHttps = false

APIJSON-Android/APIJSON-AndroidStudio/APIJSONApp/app/src/main/java/apijson/demo/client/activity_fragment/MomentListActivity.java

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import android.content.Intent;
2020
import android.os.Bundle;
2121
import android.view.View;
22+
import android.widget.ImageView;
2223

2324
import com.alibaba.fastjson.JSONObject;
2425

@@ -134,9 +135,15 @@ protected void onCreate(Bundle savedInstanceState) {
134135

135136
//UI显示区(操作UI,但不存在数据获取或处理代码,也不存在事件监听代码)<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
136137

138+
private boolean isCurrentUser = false;
139+
140+
private ImageView ivMomentListForward;
137141
private MomentListFragment fragment;
138142
@Override
139143
public void initView() {//必须在onCreate方法内调用
144+
ivMomentListForward = (ImageView) findViewById(R.id.ivMomentListForward);
145+
ivMomentListForward.setVisibility(showSearch ? View.VISIBLE : View.GONE);
146+
140147
String title;
141148
switch (range) {
142149
case MomentListFragment.RANGE_ALL:
@@ -146,7 +153,14 @@ public void initView() {//必须在onCreate方法内调用
146153
// title = "动态";
147154
// break;
148155
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+
}
150164
break;
151165
case MomentListFragment.RANGE_USER_CIRCLE:
152166
title = "朋友圈";
@@ -158,10 +172,9 @@ public void initView() {//必须在onCreate方法内调用
158172
tvBaseTitle.setText(title);
159173
autoSetTitle();
160174

161-
findViewById(R.id.ivMomentListForward).setVisibility(showSearch ? View.VISIBLE : View.GONE);
162-
163175

164176
fragment = MomentListFragment.createInstance(range, id, search);
177+
fragment.setIsAdd(isCurrentUser);
165178

166179
fragmentManager
167180
.beginTransaction()

APIJSON-Android/APIJSON-AndroidStudio/APIJSONApp/app/src/main/java/apijson/demo/client/activity_fragment/MomentListFragment.java

Lines changed: 60 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
import apijson.demo.client.application.APIJSONApplication;
3838
import apijson.demo.client.base.BaseHttpListFragment;
3939
import apijson.demo.client.interfaces.TopBarMenuCallback;
40+
import apijson.demo.client.model.Moment;
4041
import apijson.demo.client.model.MomentItem;
4142
import apijson.demo.client.util.CommentUtil;
4243
import apijson.demo.client.util.HttpRequest;
@@ -204,7 +205,7 @@ public void refreshAdapter() {
204205
});
205206
}
206207

207-
208+
208209
private TextView leftMenu;
209210
@SuppressLint("InflateParams")
210211
@Override
@@ -261,6 +262,12 @@ public void initData() {//必须调用
261262

262263
}
263264

265+
private boolean isAdd = false;
266+
public void setIsAdd(boolean isAdd) {
267+
this.isAdd = isAdd;
268+
}
269+
270+
264271
@Override
265272
public void getListAsync(final int page) {
266273
HttpRequest.getMomentList(range, id, search, getCacheCount(), page, -page, this);
@@ -332,10 +339,17 @@ public void onDragBottom(boolean rightToLeft) {
332339
return;
333340
}
334341

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+
339353
}
340354
}
341355

@@ -346,6 +360,35 @@ public void onDataChanged() {
346360
}
347361
}
348362

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+
349392
//系统自带监听方法 <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
350393

351394

@@ -363,14 +406,19 @@ public void onActivityResult(int requestCode, int resultCode, Intent data) {
363406
case REQUEST_TO_EDIT_TEXT_INFO:
364407
if (data != null) {
365408
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));
371421
}
372-
toActivity(MomentListActivity.createIntent(context, range, id, search, false)
373-
.putExtra(INTENT_TITLE, "搜索" + split + value));
374422
}
375423
break;
376424
default:

APIJSON-Android/APIJSON-AndroidStudio/APIJSONApp/app/src/main/java/apijson/demo/client/activity_fragment/PasswordActivity.java

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ public Activity getActivity() {
8787

8888
public static final int TYPE_VERIFY = 0;
8989
public static final int TYPE_REGISTER = 1;
90-
public static final int TYPE_RESET = 3;
90+
public static final int TYPE_RESET = 2;
9191

9292
private int type = TYPE_VERIFY;
9393
private String phone;
@@ -212,7 +212,7 @@ private void getVerify() {
212212

213213
/**从服务器获取验证码
214214
*/
215-
private void getVerifyFromServer() {
215+
private void getVerifyFromServer(int type) {
216216
runUiThread(new Runnable() {
217217

218218
@Override
@@ -221,7 +221,7 @@ public void run() {
221221
}
222222
});
223223

224-
HttpRequest.getVerify(StringUtil.getTrimedString(etPasswordPhone), HTTP_GET_VERIFY, this);
224+
HttpRequest.getVerify(type, StringUtil.getTrimedString(etPasswordPhone), HTTP_GET_VERIFY, this);
225225
}
226226

227227
/**下一步
@@ -245,24 +245,28 @@ private void toNextStep() {
245245
case TYPE_REGISTER:
246246
register();
247247
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);
250253
break;
251254
}
252255
}
253256

254257
/**验证验证码
258+
* @param type
255259
* @param fromServer
256260
*/
257-
private boolean checkVerify(boolean fromServer) {
261+
private boolean checkVerify(int type, boolean fromServer) {
258262
if (EditTextUtil.isInputedCorrect(context, etPasswordPhone, EditTextUtil.TYPE_PHONE) == false
259263
|| EditTextUtil.isInputedCorrect(context, etPasswordVerify, EditTextUtil.TYPE_VERIFY) == false) {
260264
return false;
261265
}
262266

263267
if (fromServer) {
264268
showProgressDialog();
265-
HttpRequest.checkVerify(StringUtil.getTrimedString(etPasswordPhone),
269+
HttpRequest.checkVerify(type, StringUtil.getTrimedString(etPasswordPhone),
266270
StringUtil.getTrimedString(etPasswordVerify), HTTP_CHECK_VERIFY, this);
267271
}
268272

@@ -271,7 +275,7 @@ private boolean checkVerify(boolean fromServer) {
271275

272276

273277
private void register() {
274-
if (checkVerify(false) == false) {
278+
if (checkVerify(Verify.TYPE_REGISTER, false) == false) {
275279
return;
276280
}
277281
showProgressDialog();
@@ -357,11 +361,11 @@ public void run() {
357361
if (type == TYPE_REGISTER) {
358362
showShortToast("手机号已经注册");
359363
} else {
360-
getVerifyFromServer();
364+
getVerifyFromServer(type == TYPE_VERIFY ? Verify.TYPE_LOGIN : Verify.TYPE_PASSWORD);
361365
}
362366
} else {//手机号未被注册过
363367
if (type == TYPE_REGISTER) {
364-
getVerifyFromServer();
368+
getVerifyFromServer(Verify.TYPE_REGISTER);
365369
} else {
366370
showShortToast("手机号未注册");
367371
}

APIJSON-Android/APIJSON-AndroidStudio/APIJSONApp/app/src/main/java/apijson/demo/client/activity_fragment/UserListFragment.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -337,15 +337,15 @@ public void onDragBottom(boolean rightToLeft) {
337337
if (searchType <= 0) {
338338
searchType = EditTextInfoWindow.TYPE_PHONE;
339339
}
340-
if (searchType == EditTextInfoWindow.TYPE_NAME) {
340+
// if (searchType == EditTextInfoWindow.TYPE_NAME) {
341341
toActivity(EditTextInfoWindow.createIntent(context
342342
, EditTextInfoWindow.TYPE_NAME, "姓名", null),
343343
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+
// }
349349
}
350350

351351
}

APIJSON-Android/APIJSON-AndroidStudio/APIJSONApp/app/src/main/java/apijson/demo/client/model/Verify.java

Lines changed: 5 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,6 @@
1414

1515
package apijson.demo.client.model;
1616

17-
import zuo.biao.library.util.StringUtil;
18-
19-
2017
/**验证码类
2118
* @author Lemon
2219
*/
@@ -26,32 +23,15 @@ public class Verify extends apijson.demo.server.model.Verify {
2623
public Verify() {
2724
super();
2825
}
29-
public Verify(long phone) {
30-
super(phone);
26+
27+
public Verify(int type, String phone) {
28+
super(type, phone);
3129
}
32-
public Verify(String verify) {
33-
this();
34-
setVerify(verify);
35-
}
36-
30+
31+
3732
@Override
3833
public Long getId() {
3934
return value(super.getId());
4035
}
4136

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-
5737
}

0 commit comments

Comments
 (0)