Commit 15bd869561e68bfaa76ce4e847abc1b566965190
1 parent
bb076c6230
Exists in
master
修复头像个人信息接口问题
Showing
6 changed files
with
124 additions
and
18 deletions
Show diff stats
PersonalCenter/app/src/main/java/com/hjx/personalcenter/activity/ChoiseTextBookActivity.java
| ... | ... | @@ -61,11 +61,11 @@ public class ChoiseTextBookActivity extends AppCompatActivity implements View.On |
| 61 | 61 | jsonObject = new JSONObject((String) msg.obj); |
| 62 | 62 | status = jsonObject.optString("status"); |
| 63 | 63 | if (status.equals("1")) { |
| 64 | + AlertUtils.showToast(ChoiseTextBookActivity.this, "您已经填写了保卡信息,请到主界面确认您的保卡信息是否正确!"); | |
| 64 | 65 | Intent intent = new Intent(); |
| 65 | 66 | intent.setClass(ChoiseTextBookActivity.this, TheStartPageActivity.class); |
| 66 | 67 | ChoiseTextBookActivity.this.startActivity(intent); |
| 67 | 68 | overridePendingTransition(R.anim.rightin, R.anim.rightout); |
| 68 | - finish(); | |
| 69 | 69 | } else if (status.equals("2001")) { |
| 70 | 70 | ElectronicCardDialog.getInstance().show(getSupportFragmentManager(), "ElectronicCardDialog"); |
| 71 | 71 | } | ... | ... |
PersonalCenter/app/src/main/java/com/hjx/personalcenter/activity/MainActivity.java
| ... | ... | @@ -99,8 +99,7 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe |
| 99 | 99 | tv_sex.setText("女"); |
| 100 | 100 | iv_sex.setImageResource(R.mipmap.women); |
| 101 | 101 | } |
| 102 | - String imageurl = SaveParam.getInstance().getLoginParam(MainActivity.this,SaveParam.HEADURL); | |
| 103 | - mSimpleDraweeView.setImageURI(imageurl); | |
| 102 | + mSimpleDraweeView.setImageURI(cardinfoBean.getPortrait()); | |
| 104 | 103 | break; |
| 105 | 104 | case HttpCode.SIGN: |
| 106 | 105 | SignInfo.DataBean dataBean = (SignInfo.DataBean)msg.obj; |
| ... | ... | @@ -124,6 +123,8 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe |
| 124 | 123 | initData(); |
| 125 | 124 | initLister(); |
| 126 | 125 | updateVersion(); |
| 126 | +// String devicenumber = GetDevicesUtil.getDevicesInfo(this).getDeviceNumber(); | |
| 127 | +// Log.e("test","......."+devicenumber); | |
| 127 | 128 | } |
| 128 | 129 | //////版本更新 |
| 129 | 130 | private void updateVersion() { |
| ... | ... | @@ -359,7 +360,9 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe |
| 359 | 360 | //回调头像监听 |
| 360 | 361 | @Override |
| 361 | 362 | public void heard(Context context, View v,int headpitiaon) { |
| 362 | - String picUrl; | |
| 363 | + String picUrl = ""; | |
| 364 | + String userID = SaveParam.getInstance().getLoginParam(this,"userId"); | |
| 365 | + String typeaccount = SaveParam.getInstance().getCustomizeParam(this,SaveParam.ACCOUNT); | |
| 363 | 366 | switch (v.getId()){ |
| 364 | 367 | //选择默认图片 |
| 365 | 368 | case R.id.oktakephone: |
| ... | ... | @@ -367,21 +370,43 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe |
| 367 | 370 | mSimpleDraweeView.setImageDrawable(null); |
| 368 | 371 | mSimpleDraweeView.setImageResource(R.mipmap.default_avatar1); |
| 369 | 372 | picUrl = "http://hjxprodbucket.oss.aliyuncs.com/static/upload/boss_api/announcement/2017-08-29/61e8d8cf-651f-49c9-beb2-ff1387af390a.png"; |
| 373 | + try { | |
| 374 | + HttpManager.getInstance().headerdeft(this, userID,typeaccount,picUrl); | |
| 375 | + } catch (UnsupportedEncodingException e) { | |
| 376 | + e.printStackTrace(); | |
| 377 | + } | |
| 370 | 378 | }else if (headpitiaon==2){ |
| 371 | 379 | mSimpleDraweeView.setImageDrawable(null); |
| 372 | 380 | mSimpleDraweeView.setImageResource(R.mipmap.default_avatar2); |
| 373 | 381 | picUrl = "http://hjxprodbucket.oss.aliyuncs.com/static/upload/boss_api/announcement/2017-08-29/8480ff7b-42f1-4d64-b848-c8f4f3afd385.png"; |
| 382 | + try { | |
| 383 | + HttpManager.getInstance().headerdeft(this, userID,typeaccount,picUrl); | |
| 384 | + } catch (UnsupportedEncodingException e) { | |
| 385 | + e.printStackTrace(); | |
| 386 | + } | |
| 374 | 387 | }else if (headpitiaon==3){ |
| 375 | 388 | mSimpleDraweeView.setImageDrawable(null); |
| 376 | 389 | mSimpleDraweeView.setImageResource(R.mipmap.default_avatar3); |
| 377 | 390 | picUrl = "http://hjxprodbucket.oss.aliyuncs.com/static/upload/boss_api/announcement/2017-08-29/184112f4-bfe0-4db8-bc1e-6212755b241c.png"; |
| 391 | + try { | |
| 392 | + HttpManager.getInstance().headerdeft(this, userID,typeaccount,picUrl); | |
| 393 | + } catch (UnsupportedEncodingException e) { | |
| 394 | + e.printStackTrace(); | |
| 395 | + } | |
| 378 | 396 | }else if (headpitiaon==4){ |
| 379 | 397 | mSimpleDraweeView.setImageDrawable(null); |
| 380 | 398 | mSimpleDraweeView.setImageResource(R.mipmap.default_avatar4); |
| 381 | - picUrl = "http://hjxprodbucket.oss.aliyuncs.com/static/upload/boss_api/announcement/2017-08-29/e31c9e11-9276-4bf4-a162-b66272fdc351.png "; | |
| 382 | - }else if (headpitiaon==0){ | |
| 383 | - AlertUtils.showToast(this, "你还没有设置头像 "); | |
| 399 | + picUrl = "http://hjxprodbucket.oss.aliyuncs.com/static/upload/boss_api/announcement/2017-08-29/e31c9e11-9276-4bf4-a162-b66272fdc351.png"; | |
| 400 | + try { | |
| 401 | + HttpManager.getInstance().headerdeft(this, userID,typeaccount,picUrl); | |
| 402 | + } catch (UnsupportedEncodingException e) { | |
| 403 | + e.printStackTrace(); | |
| 404 | + } | |
| 405 | + }else{ | |
| 406 | + mSimpleDraweeView.setImageDrawable(null); | |
| 407 | + mSimpleDraweeView.setImageResource(R.mipmap.header_default);; | |
| 384 | 408 | } |
| 409 | + | |
| 385 | 410 | break; |
| 386 | 411 | case R.id.canceltakephone: |
| 387 | 412 | ... | ... |
PersonalCenter/app/src/main/java/com/hjx/personalcenter/customdialog/ElectronicCardDialog.java
| ... | ... | @@ -8,6 +8,7 @@ import android.view.Gravity; |
| 8 | 8 | import android.view.LayoutInflater; |
| 9 | 9 | import android.view.View; |
| 10 | 10 | import android.view.ViewGroup; |
| 11 | +import android.widget.ImageView; | |
| 11 | 12 | |
| 12 | 13 | import com.hjx.personalcenter.R; |
| 13 | 14 | import com.hjx.personalcenter.activity.ElectronicCardValidationActivity; |
| ... | ... | @@ -19,6 +20,7 @@ import com.mylhyl.circledialog.res.values.CircleDimen; |
| 19 | 20 | */ |
| 20 | 21 | |
| 21 | 22 | public class ElectronicCardDialog extends BaseCircleDialog { |
| 23 | + private ImageView cancel; | |
| 22 | 24 | public static ElectronicCardDialog getInstance() { |
| 23 | 25 | ElectronicCardDialog dialogFragment = new ElectronicCardDialog(); |
| 24 | 26 | dialogFragment.setCanceledBack(true); |
| ... | ... | @@ -46,6 +48,12 @@ public class ElectronicCardDialog extends BaseCircleDialog { |
| 46 | 48 | |
| 47 | 49 | } |
| 48 | 50 | }); |
| 51 | + getView().findViewById(R.id.cancel).setOnClickListener(new View.OnClickListener() { | |
| 52 | + @Override | |
| 53 | + public void onClick(View v) { | |
| 54 | + dismiss(); | |
| 55 | + } | |
| 56 | + }); | |
| 49 | 57 | |
| 50 | 58 | } |
| 51 | 59 | ... | ... |
PersonalCenter/app/src/main/java/com/hjx/personalcenter/http/HttpManager.java
| ... | ... | @@ -1141,11 +1141,7 @@ public class HttpManager { |
| 1141 | 1141 | try { |
| 1142 | 1142 | JSONObject jsonObject = new JSONObject(new String(arg2)); |
| 1143 | 1143 | int status = jsonObject.optInt("status"); |
| 1144 | - if (status == 0) { | |
| 1145 | - AlertUtils.showToast(mContext, "你好,服务器异常,请稍后再试!"); | |
| 1146 | - } else if(status == 1000){ | |
| 1147 | - AlertUtils.showToast(mContext, "您还没有子账户哦"); | |
| 1148 | - }else { | |
| 1144 | + if (status == 1) { | |
| 1149 | 1145 | ChildsInfo childsInfo = GsonTool.getPerson(new String(arg2), ChildsInfo.class);//解析json数据 |
| 1150 | 1146 | Log.e("test", "子账户信息" + childsInfo); |
| 1151 | 1147 | List<ChildsInfo.DataBean> schoolInfoBeanList = childsInfo.getData(); |
| ... | ... | @@ -1155,6 +1151,9 @@ public class HttpManager { |
| 1155 | 1151 | msg.obj = schoolInfoBeanList; |
| 1156 | 1152 | handler.sendMessage(msg); |
| 1157 | 1153 | |
| 1154 | + }else { | |
| 1155 | + AlertUtils.showToast(mContext, "你好,服务器异常,请稍后再试!"); | |
| 1156 | + | |
| 1158 | 1157 | } |
| 1159 | 1158 | } catch (JSONException e) { |
| 1160 | 1159 | e.printStackTrace(); |
| ... | ... | @@ -1461,7 +1460,7 @@ public class HttpManager { |
| 1461 | 1460 | } |
| 1462 | 1461 | |
| 1463 | 1462 | /** |
| 1464 | - * 头像 | |
| 1463 | + * 头像拍张 | |
| 1465 | 1464 | * |
| 1466 | 1465 | * @param mContext |
| 1467 | 1466 | * @param userId |
| ... | ... | @@ -1469,8 +1468,6 @@ public class HttpManager { |
| 1469 | 1468 | * @throws UnsupportedEncodingException |
| 1470 | 1469 | */ |
| 1471 | 1470 | public void header(final Context mContext, String userId, String type, String img) throws UnsupportedEncodingException { |
| 1472 | -// mProgress = DialogPermission.showProgress(mContext, null, "正在上传头像...", | |
| 1473 | -// false, true, null); | |
| 1474 | 1471 | File file = new File(img); |
| 1475 | 1472 | if (file.exists() && file.length() > 0) { |
| 1476 | 1473 | RequestParams params = new RequestParams(); |
| ... | ... | @@ -1481,11 +1478,11 @@ public class HttpManager { |
| 1481 | 1478 | } catch (FileNotFoundException e) { |
| 1482 | 1479 | e.printStackTrace(); |
| 1483 | 1480 | } |
| 1484 | - Log.e("test", "onSuccess" + params); | |
| 1481 | + Log.e("test", "params" + params); | |
| 1482 | + HttpClient.getInstance().setTimeout(5 * 1000); | |
| 1485 | 1483 | HttpClient.getInstance().post(HttpUrl.headerURL, params, new AsyncHttpResponseHandler() { |
| 1486 | 1484 | @Override |
| 1487 | 1485 | public void onSuccess(int i, Header[] headers, byte[] bytes) { |
| 1488 | - closeProgress(); | |
| 1489 | 1486 | Log.e("test", "onSuccess" + new String(bytes)); |
| 1490 | 1487 | try { |
| 1491 | 1488 | JSONObject jsonObject = new JSONObject(new String(bytes)); |
| ... | ... | @@ -1535,6 +1532,70 @@ public class HttpManager { |
| 1535 | 1532 | Toast.makeText(mContext, "文件不存在", Toast.LENGTH_LONG).show(); |
| 1536 | 1533 | } |
| 1537 | 1534 | } |
| 1535 | + /** | |
| 1536 | + * 头像默认 | |
| 1537 | + * | |
| 1538 | + * @param mContext | |
| 1539 | + * @param userId | |
| 1540 | + * @param | |
| 1541 | + * @throws UnsupportedEncodingException | |
| 1542 | + */ | |
| 1543 | + public void headerdeft(final Context mContext, String userId, String type,String defaultImg) throws UnsupportedEncodingException { | |
| 1544 | + RequestParams params = new RequestParams(); | |
| 1545 | + params.put("userId", userId); | |
| 1546 | + params.put("type", type); | |
| 1547 | + params.put("defaultImg", defaultImg); | |
| 1548 | + Log.e("test", "params" + params); | |
| 1549 | + HttpClient.getInstance().setTimeout(5 * 1000); | |
| 1550 | + HttpClient.getInstance().post(HttpUrl.headerdefaultURL, params, new AsyncHttpResponseHandler() { | |
| 1551 | + @Override | |
| 1552 | + public void onSuccess(int i, Header[] headers, byte[] bytes) { | |
| 1553 | + Log.e("test", "onSuccess" + new String(bytes)); | |
| 1554 | + try { | |
| 1555 | + JSONObject jsonObject = new JSONObject(new String(bytes)); | |
| 1556 | + String status = jsonObject.optString("status"); | |
| 1557 | + JSONObject jsonObject1 =jsonObject.getJSONObject("data"); | |
| 1558 | + String imagUrl = jsonObject1.optString("imgUrl"); | |
| 1559 | + SaveParam.getInstance().saveLoginParam(mContext,SaveParam.HEADURL,imagUrl); | |
| 1560 | + if (status.equals("1")) { | |
| 1561 | + Toast.makeText(mContext, "头像上传成功。", Toast.LENGTH_LONG).show(); | |
| 1562 | + } else { | |
| 1563 | + AlertUtils.showToast(mContext, "你好,服务器异常,请稍后重试"); | |
| 1564 | + } | |
| 1565 | + } catch (JSONException e) { | |
| 1566 | + e.printStackTrace(); | |
| 1567 | + } | |
| 1568 | + } | |
| 1569 | + | |
| 1570 | + @Override | |
| 1571 | + public void onFailure(int i, Header[] headers, byte[] bytes, Throwable throwable) { | |
| 1572 | + closeProgress(); | |
| 1573 | + Log.e("test", "错误信息" + new String(bytes)); | |
| 1574 | + new CircleDialog.Builder((FragmentActivity) mContext) | |
| 1575 | + .setCanceledOnTouchOutside(false) | |
| 1576 | + .setCancelable(false) | |
| 1577 | + .setWidth(0.5f) | |
| 1578 | + .configText(new ConfigText() { | |
| 1579 | + @Override | |
| 1580 | + public void onConfig(TextParams params) { | |
| 1581 | + params.gravity = Gravity.CENTER; | |
| 1582 | + params.padding = new int[]{50, 50, 50, 50}; | |
| 1583 | + } | |
| 1584 | + }) | |
| 1585 | + .setText("当前无网络,请检查网络设置") | |
| 1586 | + .setNegative("继续使用", null) | |
| 1587 | + .setPositive("设置网络", new View.OnClickListener() { | |
| 1588 | + @Override | |
| 1589 | + public void onClick(View v) { | |
| 1590 | + Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 | |
| 1591 | + mContext.startActivity(intent); | |
| 1592 | + } | |
| 1593 | + }) | |
| 1594 | + .show(); | |
| 1595 | + | |
| 1596 | + } | |
| 1597 | + }); | |
| 1598 | + } | |
| 1538 | 1599 | |
| 1539 | 1600 | |
| 1540 | 1601 | /** | ... | ... |
PersonalCenter/app/src/main/java/com/hjx/personalcenter/http/HttpUrl.java
| ... | ... | @@ -37,6 +37,8 @@ public class HttpUrl { |
| 37 | 37 | public static String changechildUserURL=GetDomain()+"/childUser/update";//切换子账户 |
| 38 | 38 | public static String updateappURL=GetDomain()+"/general/release/version";//系统升级 |
| 39 | 39 | public static String headerURL=GetDomain()+"/profile/picture/update";//头像上传 |
| 40 | + public static String headerdefaultURL=GetDomain()+"/profile/picture/default";//默认头像上传 | |
| 41 | + | |
| 40 | 42 | |
| 41 | 43 | |
| 42 | 44 | ... | ... |
PersonalCenter/app/src/main/java/com/hjx/personalcenter/util/GetDevicesUtil.java
| ... | ... | @@ -3,6 +3,8 @@ package com.hjx.personalcenter.util; |
| 3 | 3 | import android.content.Context; |
| 4 | 4 | import android.net.wifi.WifiInfo; |
| 5 | 5 | import android.net.wifi.WifiManager; |
| 6 | +import android.provider.Settings; | |
| 7 | +import android.telephony.TelephonyManager; | |
| 6 | 8 | import android.util.Log; |
| 7 | 9 | |
| 8 | 10 | import com.hjx.personalcenter.model.DeviceInfo; |
| ... | ... | @@ -29,7 +31,15 @@ public class GetDevicesUtil { |
| 29 | 31 | } |
| 30 | 32 | |
| 31 | 33 | private static String getCPUSerial(Context context) { |
| 32 | - return MachineUtil.getMachineCode(context); | |
| 34 | + String cpuAddress = null; | |
| 35 | + TelephonyManager mTelephony = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); | |
| 36 | + if (mTelephony.getDeviceId() != null) { | |
| 37 | + cpuAddress = mTelephony.getDeviceId(); | |
| 38 | + } else { | |
| 39 | + //android.provider.Settings; | |
| 40 | + cpuAddress = Settings.Secure.getString(context.getApplicationContext().getContentResolver(), Settings.Secure.ANDROID_ID); | |
| 41 | + } | |
| 42 | + return cpuAddress; | |
| 33 | 43 | } |
| 34 | 44 | |
| 35 | 45 | private static String getMacAddress(Context mContext){ | ... | ... |