Commit c7ea65ea71770a8879597f76fb1d3475bfa36017
1 parent
9cbee19cbb
Exists in
master
版本跟新接口
Showing
18 changed files
with
532 additions
and
62 deletions
Show diff stats
PersonalCenter/app/build.gradle
PersonalCenter/app/src/main/java/com/hjx/personalcenter/activity/FeedBackActivity.java
PersonalCenter/app/src/main/java/com/hjx/personalcenter/activity/MainActivity.java
| ... | ... | @@ -36,6 +36,7 @@ import com.hjx.personalcenter.http.HttpManager; |
| 36 | 36 | import com.hjx.personalcenter.interfaces.DialogCallBack; |
| 37 | 37 | import com.hjx.personalcenter.model.PesonalInfo; |
| 38 | 38 | import com.hjx.personalcenter.model.SignInfo; |
| 39 | +import com.hjx.personalcenter.update.UpdateChecker; | |
| 39 | 40 | import com.hjx.personalcenter.util.AlertUtils; |
| 40 | 41 | import com.hjx.personalcenter.util.CropUtils; |
| 41 | 42 | import com.hjx.personalcenter.util.DialogPermission; |
| ... | ... | @@ -119,6 +120,14 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe |
| 119 | 120 | initView(); |
| 120 | 121 | initData(); |
| 121 | 122 | initLister(); |
| 123 | + updateVersion(); | |
| 124 | + } | |
| 125 | +//////版本更新 | |
| 126 | + private void updateVersion() { | |
| 127 | + UpdateChecker updateChecker = new UpdateChecker(this); | |
| 128 | + updateChecker.checkForUpdates(); | |
| 129 | + | |
| 130 | + | |
| 122 | 131 | } |
| 123 | 132 | |
| 124 | 133 | private void initView() { |
| ... | ... | @@ -340,21 +349,26 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe |
| 340 | 349 | //回调头像监听 |
| 341 | 350 | @Override |
| 342 | 351 | public void heard(Context context, View v,int headpitiaon) { |
| 352 | + String picUrl; | |
| 343 | 353 | switch (v.getId()){ |
| 344 | 354 | //选择默认图片 |
| 345 | 355 | case R.id.oktakephone: |
| 346 | 356 | if (headpitiaon==1){ |
| 347 | 357 | mSimpleDraweeView.setImageDrawable(null); |
| 348 | 358 | mSimpleDraweeView.setImageResource(R.mipmap.default_avatar1); |
| 359 | + picUrl = "http://hjxprodbucket.oss.aliyuncs.com/static/upload/boss_api/announcement/2017-08-29/61e8d8cf-651f-49c9-beb2-ff1387af390a.png"; | |
| 349 | 360 | }else if (headpitiaon==2){ |
| 350 | 361 | mSimpleDraweeView.setImageDrawable(null); |
| 351 | 362 | mSimpleDraweeView.setImageResource(R.mipmap.default_avatar2); |
| 363 | + picUrl = "http://hjxprodbucket.oss.aliyuncs.com/static/upload/boss_api/announcement/2017-08-29/8480ff7b-42f1-4d64-b848-c8f4f3afd385.png"; | |
| 352 | 364 | }else if (headpitiaon==3){ |
| 353 | 365 | mSimpleDraweeView.setImageDrawable(null); |
| 354 | 366 | mSimpleDraweeView.setImageResource(R.mipmap.default_avatar3); |
| 367 | + picUrl = "http://hjxprodbucket.oss.aliyuncs.com/static/upload/boss_api/announcement/2017-08-29/184112f4-bfe0-4db8-bc1e-6212755b241c.png"; | |
| 355 | 368 | }else if (headpitiaon==4){ |
| 356 | 369 | mSimpleDraweeView.setImageDrawable(null); |
| 357 | 370 | mSimpleDraweeView.setImageResource(R.mipmap.default_avatar4); |
| 371 | + picUrl = "http://hjxprodbucket.oss.aliyuncs.com/static/upload/boss_api/announcement/2017-08-29/e31c9e11-9276-4bf4-a162-b66272fdc351.png "; | |
| 358 | 372 | }else if (headpitiaon==0){ |
| 359 | 373 | AlertUtils.showToast(this, "你还没有设置头像 "); |
| 360 | 374 | } | ... | ... |
PersonalCenter/app/src/main/java/com/hjx/personalcenter/activity/RegisterInfoActivity.java
| ... | ... | @@ -111,7 +111,7 @@ public class RegisterInfoActivity extends AppCompatActivity implements View.OnCl |
| 111 | 111 | String register8 = et_school.getText().toString().trim(); |
| 112 | 112 | try { |
| 113 | 113 | long auserID = Long.parseLong(userID); |
| 114 | - HttpManager.getInstance().addchildAccountinfo(RegisterInfoActivity.this,auserID,"", | |
| 114 | + HttpManager.getInstance().addchildAccountinfo(RegisterInfoActivity.this,auserID,"http://hjxprodbucket.oss.aliyuncs.com/static/upload/boss_api/announcement/2017-08-29/a00de899-2f6d-43fb-9e30-71883842540e.png", | |
| 115 | 115 | register5,register7,register8,register6); |
| 116 | 116 | |
| 117 | 117 | } catch (NumberFormatException e) { | ... | ... |
PersonalCenter/app/src/main/java/com/hjx/personalcenter/adapter/AccountChildsAdapter.java
| ... | ... | @@ -6,9 +6,9 @@ import android.support.v7.widget.RecyclerView; |
| 6 | 6 | import android.view.LayoutInflater; |
| 7 | 7 | import android.view.View; |
| 8 | 8 | import android.view.ViewGroup; |
| 9 | -import android.widget.ImageView; | |
| 10 | 9 | import android.widget.TextView; |
| 11 | 10 | |
| 11 | +import com.facebook.drawee.view.SimpleDraweeView; | |
| 12 | 12 | import com.hjx.personalcenter.R; |
| 13 | 13 | import com.hjx.personalcenter.http.HttpManager; |
| 14 | 14 | import com.hjx.personalcenter.model.ChildsInfo; |
| ... | ... | @@ -59,7 +59,7 @@ public class AccountChildsAdapter extends RecyclerView.Adapter<AccountChildsAdap |
| 59 | 59 | public void onBindViewHolder(AccountChildsHolder holder, int position) { |
| 60 | 60 | final ChildsInfo.DataBean bean = specailList.get(position); |
| 61 | 61 | if (bean != null) { |
| 62 | - holder.iv_child_head.setImageResource(R.mipmap.header_default); | |
| 62 | + holder.mSimpleDraweeView.setImageURI(bean.getImage()); | |
| 63 | 63 | holder.iv_child_name.setText(bean.getName()); |
| 64 | 64 | holder.iv_child_grade.setText(bean.getGrade()); |
| 65 | 65 | holder.iv_child_school.setText(bean.getSchool()); |
| ... | ... | @@ -116,12 +116,12 @@ public class AccountChildsAdapter extends RecyclerView.Adapter<AccountChildsAdap |
| 116 | 116 | } |
| 117 | 117 | |
| 118 | 118 | class AccountChildsHolder extends RecyclerView.ViewHolder { |
| 119 | - ImageView iv_child_head; | |
| 119 | + SimpleDraweeView mSimpleDraweeView; | |
| 120 | 120 | TextView iv_child_name, iv_child_grade, iv_child_school, iv_child_adress, |
| 121 | 121 | delete_account,chang_account; |
| 122 | 122 | public AccountChildsHolder(View itemView) { |
| 123 | 123 | super(itemView); |
| 124 | - iv_child_head = (ImageView) itemView.findViewById(R.id.iv_child_head); | |
| 124 | + mSimpleDraweeView = (SimpleDraweeView) itemView.findViewById(R.id.iv_child_head); | |
| 125 | 125 | iv_child_name = (TextView) itemView.findViewById(R.id.iv_child_name); |
| 126 | 126 | iv_child_grade = (TextView) itemView.findViewById(R.id.iv_child_grade); |
| 127 | 127 | iv_child_school = (TextView) itemView.findViewById(R.id.iv_child_school); | ... | ... |
PersonalCenter/app/src/main/java/com/hjx/personalcenter/adapter/GalleryAdapter.java
| ... | ... | @@ -5,9 +5,9 @@ import android.support.v7.widget.RecyclerView; |
| 5 | 5 | import android.view.LayoutInflater; |
| 6 | 6 | import android.view.View; |
| 7 | 7 | import android.view.ViewGroup; |
| 8 | -import android.widget.ImageView; | |
| 9 | 8 | import android.widget.TextView; |
| 10 | 9 | |
| 10 | +import com.facebook.drawee.view.SimpleDraweeView; | |
| 11 | 11 | import com.hjx.personalcenter.R; |
| 12 | 12 | |
| 13 | 13 | import java.util.List; |
| ... | ... | @@ -32,7 +32,7 @@ public class GalleryAdapter extends |
| 32 | 32 | super(arg0); |
| 33 | 33 | } |
| 34 | 34 | |
| 35 | - ImageView mImg; | |
| 35 | + SimpleDraweeView mSimpleDraweeView; | |
| 36 | 36 | TextView mTxt; |
| 37 | 37 | } |
| 38 | 38 | |
| ... | ... | @@ -52,7 +52,7 @@ public class GalleryAdapter extends |
| 52 | 52 | viewGroup, false); |
| 53 | 53 | ViewHolder viewHolder = new ViewHolder(view); |
| 54 | 54 | |
| 55 | - viewHolder.mImg = (ImageView) view | |
| 55 | + viewHolder.mSimpleDraweeView = (SimpleDraweeView) view | |
| 56 | 56 | .findViewById(R.id.id_index_gallery_item_image); |
| 57 | 57 | return viewHolder; |
| 58 | 58 | } |
| ... | ... | @@ -63,7 +63,7 @@ public class GalleryAdapter extends |
| 63 | 63 | @Override |
| 64 | 64 | public void onBindViewHolder(final ViewHolder viewHolder, final int i) |
| 65 | 65 | { |
| 66 | - viewHolder.mImg.setImageResource(mDatas.get(i)); | |
| 66 | + viewHolder.mSimpleDraweeView.setImageResource(mDatas.get(i)); | |
| 67 | 67 | } |
| 68 | 68 | |
| 69 | 69 | } |
| 70 | 70 | \ No newline at end of file | ... | ... |
PersonalCenter/app/src/main/java/com/hjx/personalcenter/fragment/PresonInfoFragment.java
| ... | ... | @@ -32,9 +32,7 @@ import com.hjx.personalcenter.model.SchoolInfo; |
| 32 | 32 | import com.hjx.personalcenter.util.AlertUtils; |
| 33 | 33 | import com.hjx.personalcenter.util.BrithdayStar; |
| 34 | 34 | import com.mylhyl.circledialog.CircleDialog; |
| 35 | -import com.mylhyl.circledialog.callback.ConfigButton; | |
| 36 | 35 | import com.mylhyl.circledialog.callback.ConfigDialog; |
| 37 | -import com.mylhyl.circledialog.params.ButtonParams; | |
| 38 | 36 | import com.mylhyl.circledialog.params.DialogParams; |
| 39 | 37 | |
| 40 | 38 | import org.apache.http.util.TextUtils; |
| ... | ... | @@ -143,14 +141,6 @@ public class PresonInfoFragment extends Fragment implements View.OnClickListener |
| 143 | 141 | |
| 144 | 142 | } |
| 145 | 143 | }) |
| 146 | - .setNegative("取消", null) | |
| 147 | - .configNegative(new ConfigButton() { | |
| 148 | - @Override | |
| 149 | - public void onConfig(ButtonParams params) { | |
| 150 | - //取消按钮字体颜色 | |
| 151 | - params.textColor = Color.RED; | |
| 152 | - } | |
| 153 | - }) | |
| 154 | 144 | .show(); |
| 155 | 145 | break; |
| 156 | 146 | case R.id.tv_useinfo_adress: | ... | ... |
PersonalCenter/app/src/main/java/com/hjx/personalcenter/http/HttpCode.java
PersonalCenter/app/src/main/java/com/hjx/personalcenter/http/HttpManager.java
| ... | ... | @@ -2,7 +2,6 @@ package com.hjx.personalcenter.http; |
| 2 | 2 | |
| 3 | 3 | import android.app.Activity; |
| 4 | 4 | import android.app.ProgressDialog; |
| 5 | -import android.content.ComponentName; | |
| 6 | 5 | import android.content.Context; |
| 7 | 6 | import android.content.Intent; |
| 8 | 7 | import android.os.Handler; |
| ... | ... | @@ -20,6 +19,7 @@ import com.hjx.personalcenter.activity.LoginAndRegisterActivity; |
| 20 | 19 | import com.hjx.personalcenter.activity.TheStartPageActivity; |
| 21 | 20 | import com.hjx.personalcenter.db.SaveParam; |
| 22 | 21 | import com.hjx.personalcenter.gson.GsonTool; |
| 22 | +import com.hjx.personalcenter.model.AppVersion; | |
| 23 | 23 | import com.hjx.personalcenter.model.CardInfo; |
| 24 | 24 | import com.hjx.personalcenter.model.ChildsInfo; |
| 25 | 25 | import com.hjx.personalcenter.model.CityInfo; |
| ... | ... | @@ -635,23 +635,21 @@ public class HttpManager { |
| 635 | 635 | new CircleDialog.Builder((FragmentActivity) mContext) |
| 636 | 636 | .setCanceledOnTouchOutside(false) |
| 637 | 637 | .setCancelable(false) |
| 638 | + .setWidth(0.5f) | |
| 638 | 639 | .configText(new ConfigText() { |
| 639 | 640 | @Override |
| 640 | 641 | public void onConfig(TextParams params) { |
| 641 | 642 | params.gravity = Gravity.CENTER; |
| 642 | - params.padding = new int[]{250, 50, 250, 50}; | |
| 643 | + params.padding = new int[]{50, 50, 50, 50}; | |
| 643 | 644 | } |
| 644 | 645 | }) |
| 645 | 646 | .setText("当前无网络,请检查网络设置") |
| 646 | - .setNegative("取消", null) | |
| 647 | - .setPositive("确定", new View.OnClickListener() { | |
| 647 | + .setNegative("继续使用", null) | |
| 648 | + .setPositive("设置网络", new View.OnClickListener() { | |
| 648 | 649 | @Override |
| 649 | 650 | public void onClick(View v) { |
| 650 | - Intent intent = new Intent("/"); | |
| 651 | - ComponentName cm = new ComponentName("com.android.settings","com.android.settings.WirelessSettings"); | |
| 652 | - intent.setComponent(cm); | |
| 653 | - intent.setAction("android.intent.action.VIEW"); | |
| 654 | - ((Activity) mContext).startActivityForResult( intent , 0); | |
| 651 | + Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 | |
| 652 | + mContext.startActivity(intent); | |
| 655 | 653 | } |
| 656 | 654 | }) |
| 657 | 655 | .show(); |
| ... | ... | @@ -1296,6 +1294,61 @@ public class HttpManager { |
| 1296 | 1294 | }); |
| 1297 | 1295 | |
| 1298 | 1296 | } |
| 1297 | + /** | |
| 1298 | + * 系统升级 | |
| 1299 | + * @param mContext | |
| 1300 | + * @param pid | |
| 1301 | + * appName | |
| 1302 | + * | |
| 1303 | + */ | |
| 1304 | + public void updateAPP(final Context mContext, String pid , String appName, final Handler handler) { | |
| 1305 | + mProgress = DialogPermission.showProgress(mContext, null, "正在切换子账户...", | |
| 1306 | + false, true, null); | |
| 1307 | + HttpClient.getInstance().setTimeout(5 * 1000); | |
| 1308 | + HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); | |
| 1309 | + HttpClient.getInstance().get(HttpUrl.updateappURL+ "?pid=" + pid+"&appName="+ appName, new AsyncHttpResponseHandler() { | |
| 1310 | + @Override | |
| 1311 | + public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { | |
| 1312 | + closeProgress(); | |
| 1313 | + Log.e("test", "版本升级信息" + new String(arg2)); | |
| 1314 | + AppVersion appVersion = GsonTool.getPerson(new String(arg2), AppVersion.class);//解析json数据 | |
| 1315 | + Message msg = Message.obtain(); | |
| 1316 | + msg.what = HttpCode.APPUPDATE_SUCESS; | |
| 1317 | + msg.obj = appVersion; | |
| 1318 | + handler.sendMessage(msg); | |
| 1319 | + | |
| 1320 | + | |
| 1321 | + } | |
| 1322 | + | |
| 1323 | + @Override | |
| 1324 | + public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { | |
| 1325 | + closeProgress(); | |
| 1326 | + Log.e("test", "错误信息" + new String(arg2)); | |
| 1327 | + new CircleDialog.Builder((FragmentActivity) mContext) | |
| 1328 | + .setCanceledOnTouchOutside(false) | |
| 1329 | + .setCancelable(false) | |
| 1330 | + .setWidth(0.5f) | |
| 1331 | + .configText(new ConfigText() { | |
| 1332 | + @Override | |
| 1333 | + public void onConfig(TextParams params) { | |
| 1334 | + params.gravity = Gravity.CENTER; | |
| 1335 | + params.padding = new int[]{50, 50, 50, 50}; | |
| 1336 | + } | |
| 1337 | + }) | |
| 1338 | + .setText("当前无网络,请检查网络设置") | |
| 1339 | + .setNegative("继续使用", null) | |
| 1340 | + .setPositive("设置网络", new View.OnClickListener() { | |
| 1341 | + @Override | |
| 1342 | + public void onClick(View v) { | |
| 1343 | + Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 | |
| 1344 | + mContext.startActivity(intent); | |
| 1345 | + } | |
| 1346 | + }) | |
| 1347 | + .show(); | |
| 1348 | + } | |
| 1349 | + }); | |
| 1350 | + | |
| 1351 | + } | |
| 1299 | 1352 | |
| 1300 | 1353 | |
| 1301 | 1354 | ... | ... |
PersonalCenter/app/src/main/java/com/hjx/personalcenter/http/HttpUrl.java
| ... | ... | @@ -35,6 +35,7 @@ public class HttpUrl { |
| 35 | 35 | public static String deletechildUserURL=GetDomain()+"/childUser/delete";//删除子账户 |
| 36 | 36 | public static String addchildUserURL=GetDomain()+"/childUser/addChildUser";//添加子账户 |
| 37 | 37 | public static String changechildUserURL=GetDomain()+"/childUser/update";//切换子账户 |
| 38 | + public static String updateappURL=GetDomain()+"/general/release/version";//系统升级 | |
| 38 | 39 | |
| 39 | 40 | |
| 40 | 41 | ... | ... |
PersonalCenter/app/src/main/java/com/hjx/personalcenter/model/AppVersion.java
| ... | ... | @@ -0,0 +1,154 @@ |
| 1 | +package com.hjx.personalcenter.model; | |
| 2 | + | |
| 3 | +import java.io.Serializable; | |
| 4 | + | |
| 5 | +/** | |
| 6 | + * Created by h on 2017/8/29. | |
| 7 | + */ | |
| 8 | + | |
| 9 | +public class AppVersion implements Serializable{ | |
| 10 | + | |
| 11 | + /** | |
| 12 | + * version_name : 1.7.1.201608028708 | |
| 13 | + * versioncode : 176 | |
| 14 | + * pid : com.ozing.appstore | |
| 15 | + * downloads : | |
| 16 | + * app_name : 应用商城 | |
| 17 | + * msg : 919,929,939界面优化 | |
| 18 | + * url : http://hjxprodbucket.oss.aliyuncs.com/static/upload/app/pad/2016-08-18/AppStore-816.apk | |
| 19 | + * forceupdate : false | |
| 20 | + * size : 4805 | |
| 21 | + * encrypted : false | |
| 22 | + * encryptedUrl : | |
| 23 | + * order : | |
| 24 | + * visiable : true | |
| 25 | + * release_date : 1471449600000 | |
| 26 | + */ | |
| 27 | + | |
| 28 | + private String version_name; | |
| 29 | + private int versioncode; | |
| 30 | + private String pid; | |
| 31 | + private String downloads; | |
| 32 | + private String app_name; | |
| 33 | + private String msg; | |
| 34 | + private String url; | |
| 35 | + private String forceupdate; | |
| 36 | + private int size; | |
| 37 | + private boolean encrypted; | |
| 38 | + private String encryptedUrl; | |
| 39 | + private String order; | |
| 40 | + private String visiable; | |
| 41 | + private long release_date; | |
| 42 | + | |
| 43 | + public String getVersion_name() { | |
| 44 | + return version_name; | |
| 45 | + } | |
| 46 | + | |
| 47 | + public void setVersion_name(String version_name) { | |
| 48 | + this.version_name = version_name; | |
| 49 | + } | |
| 50 | + | |
| 51 | + public int getVersioncode() { | |
| 52 | + return versioncode; | |
| 53 | + } | |
| 54 | + | |
| 55 | + public void setVersioncode(int versioncode) { | |
| 56 | + this.versioncode = versioncode; | |
| 57 | + } | |
| 58 | + | |
| 59 | + public String getPid() { | |
| 60 | + return pid; | |
| 61 | + } | |
| 62 | + | |
| 63 | + public void setPid(String pid) { | |
| 64 | + this.pid = pid; | |
| 65 | + } | |
| 66 | + | |
| 67 | + public String getDownloads() { | |
| 68 | + return downloads; | |
| 69 | + } | |
| 70 | + | |
| 71 | + public void setDownloads(String downloads) { | |
| 72 | + this.downloads = downloads; | |
| 73 | + } | |
| 74 | + | |
| 75 | + public String getApp_name() { | |
| 76 | + return app_name; | |
| 77 | + } | |
| 78 | + | |
| 79 | + public void setApp_name(String app_name) { | |
| 80 | + this.app_name = app_name; | |
| 81 | + } | |
| 82 | + | |
| 83 | + public String getMsg() { | |
| 84 | + return msg; | |
| 85 | + } | |
| 86 | + | |
| 87 | + public void setMsg(String msg) { | |
| 88 | + this.msg = msg; | |
| 89 | + } | |
| 90 | + | |
| 91 | + public String getUrl() { | |
| 92 | + return url; | |
| 93 | + } | |
| 94 | + | |
| 95 | + public void setUrl(String url) { | |
| 96 | + this.url = url; | |
| 97 | + } | |
| 98 | + | |
| 99 | + public String getForceupdate() { | |
| 100 | + return forceupdate; | |
| 101 | + } | |
| 102 | + | |
| 103 | + public void setForceupdate(String forceupdate) { | |
| 104 | + this.forceupdate = forceupdate; | |
| 105 | + } | |
| 106 | + | |
| 107 | + public int getSize() { | |
| 108 | + return size; | |
| 109 | + } | |
| 110 | + | |
| 111 | + public void setSize(int size) { | |
| 112 | + this.size = size; | |
| 113 | + } | |
| 114 | + | |
| 115 | + public boolean isEncrypted() { | |
| 116 | + return encrypted; | |
| 117 | + } | |
| 118 | + | |
| 119 | + public void setEncrypted(boolean encrypted) { | |
| 120 | + this.encrypted = encrypted; | |
| 121 | + } | |
| 122 | + | |
| 123 | + public String getEncryptedUrl() { | |
| 124 | + return encryptedUrl; | |
| 125 | + } | |
| 126 | + | |
| 127 | + public void setEncryptedUrl(String encryptedUrl) { | |
| 128 | + this.encryptedUrl = encryptedUrl; | |
| 129 | + } | |
| 130 | + | |
| 131 | + public String getOrder() { | |
| 132 | + return order; | |
| 133 | + } | |
| 134 | + | |
| 135 | + public void setOrder(String order) { | |
| 136 | + this.order = order; | |
| 137 | + } | |
| 138 | + | |
| 139 | + public String getVisiable() { | |
| 140 | + return visiable; | |
| 141 | + } | |
| 142 | + | |
| 143 | + public void setVisiable(String visiable) { | |
| 144 | + this.visiable = visiable; | |
| 145 | + } | |
| 146 | + | |
| 147 | + public long getRelease_date() { | |
| 148 | + return release_date; | |
| 149 | + } | |
| 150 | + | |
| 151 | + public void setRelease_date(long release_date) { | |
| 152 | + this.release_date = release_date; | |
| 153 | + } | |
| 154 | +} | ... | ... |
PersonalCenter/app/src/main/java/com/hjx/personalcenter/update/DownloadService.java
| ... | ... | @@ -0,0 +1,61 @@ |
| 1 | +package com.hjx.personalcenter.update; | |
| 2 | + | |
| 3 | +/** | |
| 4 | + * Created by l on 2017/7/17. | |
| 5 | + */ | |
| 6 | + | |
| 7 | + | |
| 8 | +import android.app.IntentService; | |
| 9 | +import android.content.Intent; | |
| 10 | +import android.os.Bundle; | |
| 11 | +import android.os.ResultReceiver; | |
| 12 | + | |
| 13 | +import java.io.BufferedInputStream; | |
| 14 | +import java.io.FileOutputStream; | |
| 15 | +import java.io.IOException; | |
| 16 | +import java.io.InputStream; | |
| 17 | +import java.io.OutputStream; | |
| 18 | +import java.net.URL; | |
| 19 | +import java.net.URLConnection; | |
| 20 | + | |
| 21 | +public class DownloadService extends IntentService { | |
| 22 | + public static final int UPDATE_PROGRESS = 8344; | |
| 23 | + public DownloadService() { | |
| 24 | + super("DownloadService"); | |
| 25 | + } | |
| 26 | + @Override | |
| 27 | + protected void onHandleIntent(Intent intent) { | |
| 28 | + String urlToDownload = intent.getStringExtra("url"); | |
| 29 | + String fileDestination = intent.getStringExtra("dest"); | |
| 30 | + ResultReceiver receiver = (ResultReceiver) intent.getParcelableExtra("receiver"); | |
| 31 | + try { | |
| 32 | + URL url = new URL(urlToDownload); | |
| 33 | + URLConnection connection = url.openConnection(); | |
| 34 | + connection.connect(); | |
| 35 | + // this will be useful so that you can show a typical 0-100% progress bar | |
| 36 | + int fileLength = connection.getContentLength(); | |
| 37 | + // download the file | |
| 38 | + InputStream input = new BufferedInputStream(connection.getInputStream()); | |
| 39 | + OutputStream output = new FileOutputStream(fileDestination); | |
| 40 | + byte data[] = new byte[100]; | |
| 41 | + long total = 0; | |
| 42 | + int count; | |
| 43 | + while ((count = input.read(data)) != -1) { | |
| 44 | + total += count; | |
| 45 | + // publishing the progress.... | |
| 46 | + Bundle resultData = new Bundle(); | |
| 47 | + resultData.putInt("progress" ,(int) (total * 100 / fileLength)); | |
| 48 | + receiver.send(UPDATE_PROGRESS, resultData); | |
| 49 | + output.write(data, 0, count); | |
| 50 | + } | |
| 51 | + output.flush(); | |
| 52 | + output.close(); | |
| 53 | + input.close(); | |
| 54 | + } catch (IOException e) { | |
| 55 | + e.printStackTrace(); | |
| 56 | + } | |
| 57 | + Bundle resultData = new Bundle(); | |
| 58 | + resultData.putInt("progress" ,100); | |
| 59 | + receiver.send(UPDATE_PROGRESS, resultData); | |
| 60 | + } | |
| 61 | +} | |
| 0 | 62 | \ No newline at end of file | ... | ... |
PersonalCenter/app/src/main/java/com/hjx/personalcenter/update/UpdateChecker.java
| ... | ... | @@ -0,0 +1,191 @@ |
| 1 | +package com.hjx.personalcenter.update; | |
| 2 | + | |
| 3 | +/** | |
| 4 | + * Created by l on 2017/7/17. | |
| 5 | + */ | |
| 6 | + | |
| 7 | +import android.app.Activity; | |
| 8 | +import android.app.ProgressDialog; | |
| 9 | +import android.content.Context; | |
| 10 | +import android.content.DialogInterface; | |
| 11 | +import android.content.Intent; | |
| 12 | +import android.content.pm.PackageManager; | |
| 13 | +import android.net.Uri; | |
| 14 | +import android.os.Bundle; | |
| 15 | +import android.os.Environment; | |
| 16 | +import android.os.Handler; | |
| 17 | +import android.os.Message; | |
| 18 | +import android.os.ResultReceiver; | |
| 19 | +import android.support.v4.app.FragmentActivity; | |
| 20 | +import android.view.View; | |
| 21 | + | |
| 22 | +import com.hjx.personalcenter.http.HttpCode; | |
| 23 | +import com.hjx.personalcenter.http.HttpManager; | |
| 24 | +import com.hjx.personalcenter.model.AppVersion; | |
| 25 | +import com.mylhyl.circledialog.CircleDialog; | |
| 26 | + | |
| 27 | +import java.io.File; | |
| 28 | + | |
| 29 | +public class UpdateChecker{ | |
| 30 | + private static final String TAG = "UpdateChecker"; | |
| 31 | + private Context mContext; | |
| 32 | + //检查版本信息的线程 | |
| 33 | + private Thread mThread; | |
| 34 | + | |
| 35 | + private AppVersion mAppVersion; | |
| 36 | + //下载apk的对话框 | |
| 37 | + private ProgressDialog mProgressDialog; | |
| 38 | + | |
| 39 | + private File apkFile; | |
| 40 | + | |
| 41 | + | |
| 42 | + public UpdateChecker(Context context) { | |
| 43 | + mContext = context; | |
| 44 | + // instantiate it within the onCreate method | |
| 45 | + mProgressDialog = new ProgressDialog(context); | |
| 46 | + mProgressDialog.setMessage("正在下载"); | |
| 47 | + mProgressDialog.setIndeterminate(false); | |
| 48 | + mProgressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL); | |
| 49 | + mProgressDialog.setCancelable(true); | |
| 50 | + mProgressDialog.setOnCancelListener(new DialogInterface.OnCancelListener() { | |
| 51 | + @Override | |
| 52 | + public void onCancel(DialogInterface dialog) { | |
| 53 | + | |
| 54 | + } | |
| 55 | + }); | |
| 56 | + mProgressDialog.setOnDismissListener(new DialogInterface.OnDismissListener() { | |
| 57 | + @Override | |
| 58 | + public void onDismiss(DialogInterface dialog) { | |
| 59 | + // TODO Auto-generated method stub | |
| 60 | + | |
| 61 | + } | |
| 62 | + }); | |
| 63 | + } | |
| 64 | + | |
| 65 | + public void checkForUpdates() { | |
| 66 | + | |
| 67 | + final Handler handler = new Handler(){ | |
| 68 | + public void handleMessage(Message msg) { | |
| 69 | + if (msg.what == HttpCode.APPUPDATE_SUCESS) { | |
| 70 | + mAppVersion = (AppVersion) msg.obj; | |
| 71 | + try{ | |
| 72 | + int versionCode = mContext.getPackageManager().getPackageInfo(mContext.getPackageName(), 0).versionCode; | |
| 73 | + if (mAppVersion.getVersioncode() > versionCode) { | |
| 74 | + if(mAppVersion.isEncrypted()){ | |
| 75 | + showForceUpdateDialog(); | |
| 76 | + }else{ | |
| 77 | + showUpdateDialog(); | |
| 78 | + } | |
| 79 | + } else { | |
| 80 | + //Toast.makeText(mContext, "已经是最新版本", Toast.LENGTH_SHORT).show(); | |
| 81 | + } | |
| 82 | + }catch (PackageManager.NameNotFoundException ignored) { | |
| 83 | + // | |
| 84 | + } | |
| 85 | + } | |
| 86 | + } | |
| 87 | + }; | |
| 88 | + | |
| 89 | + mThread = new Thread() { | |
| 90 | + @Override | |
| 91 | + public void run() { | |
| 92 | + try { | |
| 93 | + HttpManager.getInstance().updateAPP(mContext,"com.hjx.personalcenter","呼叫老师安卓Pad",handler); | |
| 94 | + }catch (Exception e){ | |
| 95 | + e.printStackTrace(); | |
| 96 | + } | |
| 97 | + | |
| 98 | + } | |
| 99 | + }; | |
| 100 | + mThread.start(); | |
| 101 | + } | |
| 102 | + | |
| 103 | + private void showForceUpdateDialog() { | |
| 104 | + new CircleDialog.Builder((FragmentActivity)mContext) | |
| 105 | + .setCanceledOnTouchOutside(false) | |
| 106 | + .setCancelable(false) | |
| 107 | + .setWidth(0.5f) | |
| 108 | + .setTitle("升级提示") | |
| 109 | + .setNegative("取消", new View.OnClickListener() { | |
| 110 | + @Override | |
| 111 | + public void onClick(View v) { | |
| 112 | + ((Activity)mContext).finish(); | |
| 113 | + | |
| 114 | + } | |
| 115 | + }) | |
| 116 | + .setPositive("确定", new View.OnClickListener() { | |
| 117 | + @Override | |
| 118 | + public void onClick(View v) { | |
| 119 | + downLoadApk(); | |
| 120 | + } | |
| 121 | + }) | |
| 122 | + .show(); | |
| 123 | + } | |
| 124 | + | |
| 125 | + private void showUpdateDialog() { | |
| 126 | + new CircleDialog.Builder((FragmentActivity)mContext) | |
| 127 | + .setCanceledOnTouchOutside(false) | |
| 128 | + .setCancelable(false) | |
| 129 | + .setWidth(0.5f) | |
| 130 | + .setTitle("升级提示") | |
| 131 | + .setNegative("取消", null) | |
| 132 | + .setPositive("确定", new View.OnClickListener() { | |
| 133 | + @Override | |
| 134 | + public void onClick(View v) { | |
| 135 | + downLoadApk(); | |
| 136 | + } | |
| 137 | + }) | |
| 138 | + .show(); | |
| 139 | + } | |
| 140 | + | |
| 141 | + private void downLoadApk() { | |
| 142 | + String apkUrl = mAppVersion.getUrl(); | |
| 143 | + String dir = mContext.getExternalFilesDir( "apk").getAbsolutePath(); | |
| 144 | + File folder = Environment.getExternalStoragePublicDirectory(dir); | |
| 145 | + if(folder.exists() && folder.isDirectory()) { | |
| 146 | + //do nothing | |
| 147 | + }else { | |
| 148 | + folder.mkdirs(); | |
| 149 | + } | |
| 150 | + String filename = apkUrl.substring(apkUrl.lastIndexOf("/"),apkUrl.length()); | |
| 151 | + String destinationFilePath = dir + "/" + filename; | |
| 152 | + apkFile = new File(destinationFilePath); | |
| 153 | + if(mAppVersion.isEncrypted()){ | |
| 154 | + mProgressDialog.setCancelable(false); | |
| 155 | + } | |
| 156 | + mProgressDialog.show(); | |
| 157 | + Intent intent = new Intent(mContext, DownloadService.class); | |
| 158 | + intent.putExtra("url", apkUrl); | |
| 159 | + intent.putExtra("dest", destinationFilePath); | |
| 160 | + intent.putExtra("receiver", new DownloadReceiver(new Handler())); | |
| 161 | + mContext.startService(intent); | |
| 162 | + } | |
| 163 | + | |
| 164 | + private class DownloadReceiver extends ResultReceiver{ | |
| 165 | + public DownloadReceiver(Handler handler) { | |
| 166 | + super(handler); | |
| 167 | + } | |
| 168 | + @Override | |
| 169 | + protected void onReceiveResult(int resultCode, Bundle resultData) { | |
| 170 | + super.onReceiveResult(resultCode, resultData); | |
| 171 | + if (resultCode == DownloadService.UPDATE_PROGRESS) { | |
| 172 | + int progress = resultData.getInt("progress"); | |
| 173 | + mProgressDialog.setProgress(progress); | |
| 174 | + if (progress == 100) { | |
| 175 | + mProgressDialog.dismiss(); | |
| 176 | + //如果没有设置SDCard写权限,或者没有sdcard,apk文件保存在内存中,需要授予权限才能安装 | |
| 177 | + String[] command = {"chmod","777",apkFile.toString()}; | |
| 178 | + try{ | |
| 179 | + ProcessBuilder builder = new ProcessBuilder(command); | |
| 180 | + builder.start(); | |
| 181 | + Intent intent = new Intent(Intent.ACTION_VIEW); | |
| 182 | + intent.setDataAndType(Uri.fromFile(apkFile), "application/vnd.android.package-archive"); | |
| 183 | + mContext.startActivity(intent); | |
| 184 | + }catch (Exception e){ | |
| 185 | + e.printStackTrace(); | |
| 186 | + } | |
| 187 | + } | |
| 188 | + } | |
| 189 | + } | |
| 190 | + } | |
| 191 | +} | |
| 0 | 192 | \ No newline at end of file | ... | ... |
PersonalCenter/app/src/main/res/drawable/search_clear.xml
| ... | ... | @@ -0,0 +1,5 @@ |
| 1 | +<?xml version="1.0" encoding="UTF-8"?> | |
| 2 | +<selector xmlns:android="http://schemas.android.com/apk/res/android"> | |
| 3 | + <item android:drawable="@drawable/search_clear_normal" android:state_pressed="false"/> | |
| 4 | + <item android:drawable="@drawable/search_clear_pressed" android:state_pressed="true"/> | |
| 5 | +</selector> | ... | ... |
PersonalCenter/app/src/main/res/layout/activity_change_preson_info.xml
PersonalCenter/app/src/main/res/layout/fragment_changge_presonal_info.xml
| ... | ... | @@ -9,14 +9,14 @@ |
| 9 | 9 | <LinearLayout |
| 10 | 10 | android:layout_width="wrap_content" |
| 11 | 11 | android:layout_height="wrap_content" |
| 12 | - android:layout_marginTop="60dp" | |
| 12 | + android:layout_marginTop="80dp" | |
| 13 | 13 | android:orientation="horizontal"> |
| 14 | 14 | |
| 15 | 15 | <View |
| 16 | 16 | android:layout_width="450dp" |
| 17 | 17 | android:layout_height="0.7dp" |
| 18 | 18 | android:layout_marginLeft="150dp" |
| 19 | - android:background="@color/electronic_text"> | |
| 19 | + android:background="@color/cutoff_line"> | |
| 20 | 20 | |
| 21 | 21 | </View> |
| 22 | 22 | |
| ... | ... | @@ -24,7 +24,7 @@ |
| 24 | 24 | android:layout_width="450dp" |
| 25 | 25 | android:layout_height="0.7dp" |
| 26 | 26 | android:layout_marginLeft="80dp" |
| 27 | - android:background="@color/electronic_text"> | |
| 27 | + android:background="@color/cutoff_line"> | |
| 28 | 28 | |
| 29 | 29 | </View> |
| 30 | 30 | |
| ... | ... | @@ -48,7 +48,6 @@ |
| 48 | 48 | android:layout_width="wrap_content" |
| 49 | 49 | android:layout_height="wrap_content" |
| 50 | 50 | android:text="昵称" |
| 51 | - android:textColor="@color/pickerview_wheelview_textcolor_center" | |
| 52 | 51 | android:textSize="22sp" /> |
| 53 | 52 | |
| 54 | 53 | <EditText |
| ... | ... | @@ -73,7 +72,6 @@ |
| 73 | 72 | android:layout_width="wrap_content" |
| 74 | 73 | android:layout_height="wrap_content" |
| 75 | 74 | android:text="地区" |
| 76 | - android:textColor="@color/pickerview_wheelview_textcolor_center" | |
| 77 | 75 | android:textSize="22sp" /> |
| 78 | 76 | |
| 79 | 77 | <TextView |
| ... | ... | @@ -105,7 +103,7 @@ |
| 105 | 103 | android:layout_width="450dp" |
| 106 | 104 | android:layout_height="0.7dp" |
| 107 | 105 | android:layout_marginLeft="150dp" |
| 108 | - android:background="@color/electronic_text"> | |
| 106 | + android:background="@color/cutoff_line"> | |
| 109 | 107 | |
| 110 | 108 | </View> |
| 111 | 109 | |
| ... | ... | @@ -113,7 +111,7 @@ |
| 113 | 111 | android:layout_width="450dp" |
| 114 | 112 | android:layout_height="0.7dp" |
| 115 | 113 | android:layout_marginLeft="80dp" |
| 116 | - android:background="@color/electronic_text"> | |
| 114 | + android:background="@color/cutoff_line"> | |
| 117 | 115 | |
| 118 | 116 | </View> |
| 119 | 117 | |
| ... | ... | @@ -137,7 +135,6 @@ |
| 137 | 135 | android:layout_width="wrap_content" |
| 138 | 136 | android:layout_height="wrap_content" |
| 139 | 137 | android:text="性别" |
| 140 | - android:textColor="@color/pickerview_wheelview_textcolor_center" | |
| 141 | 138 | android:textSize="22sp" /> |
| 142 | 139 | |
| 143 | 140 | <TextView |
| ... | ... | @@ -195,7 +192,7 @@ |
| 195 | 192 | android:layout_width="450dp" |
| 196 | 193 | android:layout_height="0.7dp" |
| 197 | 194 | android:layout_marginLeft="150dp" |
| 198 | - android:background="@color/electronic_text"> | |
| 195 | + android:background="@color/cutoff_line"> | |
| 199 | 196 | |
| 200 | 197 | </View> |
| 201 | 198 | |
| ... | ... | @@ -203,7 +200,7 @@ |
| 203 | 200 | android:layout_width="450dp" |
| 204 | 201 | android:layout_height="0.7dp" |
| 205 | 202 | android:layout_marginLeft="80dp" |
| 206 | - android:background="@color/electronic_text"> | |
| 203 | + android:background="@color/cutoff_line"> | |
| 207 | 204 | |
| 208 | 205 | </View> |
| 209 | 206 | |
| ... | ... | @@ -228,7 +225,6 @@ |
| 228 | 225 | android:layout_width="wrap_content" |
| 229 | 226 | android:layout_height="wrap_content" |
| 230 | 227 | android:text="生日" |
| 231 | - android:textColor="@color/pickerview_wheelview_textcolor_center" | |
| 232 | 228 | android:textSize="22sp" /> |
| 233 | 229 | |
| 234 | 230 | <TextView |
| ... | ... | @@ -255,7 +251,6 @@ |
| 255 | 251 | android:layout_width="wrap_content" |
| 256 | 252 | android:layout_height="wrap_content" |
| 257 | 253 | android:text="年级" |
| 258 | - android:textColor="@color/pickerview_wheelview_textcolor_center" | |
| 259 | 254 | android:textSize="22sp" /> |
| 260 | 255 | |
| 261 | 256 | <TextView |
| ... | ... | @@ -285,7 +280,7 @@ |
| 285 | 280 | android:layout_width="450dp" |
| 286 | 281 | android:layout_height="0.7dp" |
| 287 | 282 | android:layout_marginLeft="150dp" |
| 288 | - android:background="@color/electronic_text"> | |
| 283 | + android:background="@color/cutoff_line"> | |
| 289 | 284 | |
| 290 | 285 | </View> |
| 291 | 286 | |
| ... | ... | @@ -293,7 +288,7 @@ |
| 293 | 288 | android:layout_width="450dp" |
| 294 | 289 | android:layout_height="0.7dp" |
| 295 | 290 | android:layout_marginLeft="80dp" |
| 296 | - android:background="@color/electronic_text"> | |
| 291 | + android:background="@color/cutoff_line"> | |
| 297 | 292 | |
| 298 | 293 | </View> |
| 299 | 294 | |
| ... | ... | @@ -318,7 +313,6 @@ |
| 318 | 313 | android:layout_width="wrap_content" |
| 319 | 314 | android:layout_height="wrap_content" |
| 320 | 315 | android:text="Q Q" |
| 321 | - android:textColor="@color/pickerview_wheelview_textcolor_center" | |
| 322 | 316 | android:textSize="22sp" /> |
| 323 | 317 | |
| 324 | 318 | <EditText |
| ... | ... | @@ -343,7 +337,6 @@ |
| 343 | 337 | android:layout_width="wrap_content" |
| 344 | 338 | android:layout_height="wrap_content" |
| 345 | 339 | android:text="学校" |
| 346 | - android:textColor="@color/pickerview_wheelview_textcolor_center" | |
| 347 | 340 | android:textSize="22sp" /> |
| 348 | 341 | |
| 349 | 342 | <TextView |
| ... | ... | @@ -375,7 +368,7 @@ |
| 375 | 368 | android:layout_width="450dp" |
| 376 | 369 | android:layout_height="0.7dp" |
| 377 | 370 | android:layout_marginLeft="150dp" |
| 378 | - android:background="@color/electronic_text"> | |
| 371 | + android:background="@color/cutoff_line"> | |
| 379 | 372 | |
| 380 | 373 | </View> |
| 381 | 374 | |
| ... | ... | @@ -383,7 +376,7 @@ |
| 383 | 376 | android:layout_width="450dp" |
| 384 | 377 | android:layout_height="0.7dp" |
| 385 | 378 | android:layout_marginLeft="80dp" |
| 386 | - android:background="@color/electronic_text"> | |
| 379 | + android:background="@color/cutoff_line"> | |
| 387 | 380 | |
| 388 | 381 | </View> |
| 389 | 382 | ... | ... |
PersonalCenter/app/src/main/res/layout/recycler_childaccunt_item_view.xml
| 1 | 1 | <?xml version="1.0" encoding="utf-8"?> |
| 2 | 2 | <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" |
| 3 | - android:orientation="vertical" android:layout_width="415dp" | |
| 3 | + xmlns:fresco="http://schemas.android.com/apk/res-auto" | |
| 4 | + android:orientation="vertical" | |
| 5 | + android:layout_width="415dp" | |
| 4 | 6 | android:layout_height="match_parent"> |
| 5 | 7 | <LinearLayout |
| 6 | 8 | android:layout_width="wrap_content" |
| ... | ... | @@ -12,13 +14,15 @@ |
| 12 | 14 | android:layout_width="wrap_content" |
| 13 | 15 | android:layout_height="wrap_content" |
| 14 | 16 | android:orientation="horizontal"> |
| 15 | - | |
| 16 | - <ImageView | |
| 17 | + <com.facebook.drawee.view.SimpleDraweeView | |
| 17 | 18 | android:id="@+id/iv_child_head" |
| 18 | - android:layout_width="wrap_content" | |
| 19 | - android:layout_height="wrap_content" | |
| 19 | + android:layout_width="60dp" | |
| 20 | + android:layout_height="60dp" | |
| 20 | 21 | android:layout_margin="10dp" |
| 21 | - android:src="@mipmap/header_default" /> | |
| 22 | + fresco:placeholderImage="@mipmap/header_default" | |
| 23 | + fresco:roundAsCircle="true" | |
| 24 | + fresco:placeholderImageScaleType="fitCenter" /> | |
| 25 | + | |
| 22 | 26 | |
| 23 | 27 | <LinearLayout |
| 24 | 28 | android:layout_width="0dp" | ... | ... |
PersonalCenter/app/src/main/res/layout/recycler_study_tem_view.xml
| ... | ... | @@ -2,17 +2,17 @@ |
| 2 | 2 | <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" |
| 3 | 3 | android:layout_width="120dp" |
| 4 | 4 | android:layout_height="120dp" |
| 5 | - > | |
| 6 | - | |
| 7 | - <ImageView | |
| 5 | + xmlns:fresco="http://schemas.android.com/apk/res-auto"> | |
| 6 | + <com.facebook.drawee.view.SimpleDraweeView | |
| 8 | 7 | android:id="@+id/id_index_gallery_item_image" |
| 9 | - android:layout_width="80dp" | |
| 10 | - android:layout_height="80dp" | |
| 8 | + android:layout_width="60dp" | |
| 9 | + android:layout_height="60dp" | |
| 10 | + android:scaleType="centerCrop" | |
| 11 | 11 | android:layout_alignParentTop="true" |
| 12 | 12 | android:layout_centerHorizontal="true" |
| 13 | - android:layout_margin="5dp" | |
| 14 | - android:scaleType="centerCrop" /> | |
| 15 | - | |
| 13 | + fresco:placeholderImage="@mipmap/header_default" | |
| 14 | + fresco:roundAsCircle="true" | |
| 15 | + fresco:placeholderImageScaleType="fitCenter" /> | |
| 16 | 16 | <TextView |
| 17 | 17 | android:id="@+id/id_index_gallery_item_text" |
| 18 | 18 | android:layout_width="wrap_content" | ... | ... |