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
| 1 | package com.hjx.personalcenter.activity; | 1 | package com.hjx.personalcenter.activity; |
| 2 | 2 | ||
| 3 | import android.content.Intent; | 3 | import android.content.Intent; |
| 4 | import android.os.Bundle; | 4 | import android.os.Bundle; |
| 5 | import android.os.Handler; | 5 | import android.os.Handler; |
| 6 | import android.os.Message; | 6 | import android.os.Message; |
| 7 | import android.support.v7.app.AppCompatActivity; | 7 | import android.support.v7.app.AppCompatActivity; |
| 8 | import android.view.View; | 8 | import android.view.View; |
| 9 | import android.widget.Button; | 9 | import android.widget.Button; |
| 10 | import android.widget.GridView; | 10 | import android.widget.GridView; |
| 11 | import android.widget.ImageView; | 11 | import android.widget.ImageView; |
| 12 | import android.widget.SimpleAdapter; | 12 | import android.widget.SimpleAdapter; |
| 13 | 13 | ||
| 14 | import com.hjx.personalcenter.R; | 14 | import com.hjx.personalcenter.R; |
| 15 | import com.hjx.personalcenter.customdialog.ElectronicCardDialog; | 15 | import com.hjx.personalcenter.customdialog.ElectronicCardDialog; |
| 16 | import com.hjx.personalcenter.db.SaveParam; | 16 | import com.hjx.personalcenter.db.SaveParam; |
| 17 | import com.hjx.personalcenter.http.HttpCode; | 17 | import com.hjx.personalcenter.http.HttpCode; |
| 18 | import com.hjx.personalcenter.http.HttpManager; | 18 | import com.hjx.personalcenter.http.HttpManager; |
| 19 | import com.hjx.personalcenter.util.AlertUtils; | 19 | import com.hjx.personalcenter.util.AlertUtils; |
| 20 | 20 | ||
| 21 | import org.json.JSONException; | 21 | import org.json.JSONException; |
| 22 | import org.json.JSONObject; | 22 | import org.json.JSONObject; |
| 23 | 23 | ||
| 24 | import java.util.ArrayList; | 24 | import java.util.ArrayList; |
| 25 | import java.util.HashMap; | 25 | import java.util.HashMap; |
| 26 | import java.util.List; | 26 | import java.util.List; |
| 27 | import java.util.Map; | 27 | import java.util.Map; |
| 28 | 28 | ||
| 29 | /** | 29 | /** |
| 30 | * 选择教材 | 30 | * 选择教材 |
| 31 | * Created by h on 2017/8/10. | 31 | * Created by h on 2017/8/10. |
| 32 | */ | 32 | */ |
| 33 | 33 | ||
| 34 | public class ChoiseTextBookActivity extends AppCompatActivity implements View.OnClickListener { | 34 | public class ChoiseTextBookActivity extends AppCompatActivity implements View.OnClickListener { |
| 35 | private GridView gridView; | 35 | private GridView gridView; |
| 36 | private Button btn_ok; | 36 | private Button btn_ok; |
| 37 | private ImageView cancel; | 37 | private ImageView cancel; |
| 38 | private List<Map<String, Object>> data_list; | 38 | private List<Map<String, Object>> data_list; |
| 39 | private SimpleAdapter sim_adapter; | 39 | private SimpleAdapter sim_adapter; |
| 40 | // 图片封装为一个数组 | 40 | // 图片封装为一个数组 |
| 41 | private int[] icon = {R.mipmap.ic_launcher, R.mipmap.ic_launcher, | 41 | private int[] icon = {R.mipmap.ic_launcher, R.mipmap.ic_launcher, |
| 42 | R.mipmap.ic_launcher, R.mipmap.ic_launcher, R.mipmap.ic_launcher, | 42 | R.mipmap.ic_launcher, R.mipmap.ic_launcher, R.mipmap.ic_launcher, |
| 43 | R.mipmap.ic_launcher, R.mipmap.ic_launcher, R.mipmap.ic_launcher, | 43 | R.mipmap.ic_launcher, R.mipmap.ic_launcher, R.mipmap.ic_launcher, |
| 44 | R.mipmap.ic_launcher}; | 44 | R.mipmap.ic_launcher}; |
| 45 | private String[] subject = {"语文", "数学", "英语", "物理", "化学", "生物", "政治", | 45 | private String[] subject = {"语文", "数学", "英语", "物理", "化学", "生物", "政治", |
| 46 | "历史", "地理"}; | 46 | "历史", "地理"}; |
| 47 | private String[] publish = {"人民教育出版社", "人民教育出版社", "人民教育出版社", | 47 | private String[] publish = {"人民教育出版社", "人民教育出版社", "人民教育出版社", |
| 48 | "人民教育出版社", "人民教育出版社", "人民教育出版社", "人民教育出版社", | 48 | "人民教育出版社", "人民教育出版社", "人民教育出版社", "人民教育出版社", |
| 49 | "人民教育出版社", "人民教育出版社"}; | 49 | "人民教育出版社", "人民教育出版社"}; |
| 50 | 50 | ||
| 51 | 51 | ||
| 52 | Handler handler = new Handler() { | 52 | Handler handler = new Handler() { |
| 53 | @Override | 53 | @Override |
| 54 | public void handleMessage(Message msg) { | 54 | public void handleMessage(Message msg) { |
| 55 | super.handleMessage(msg); | 55 | super.handleMessage(msg); |
| 56 | JSONObject jsonObject; | 56 | JSONObject jsonObject; |
| 57 | String status; | 57 | String status; |
| 58 | switch (msg.what) { | 58 | switch (msg.what) { |
| 59 | case HttpCode.CHECKCARD: | 59 | case HttpCode.CHECKCARD: |
| 60 | try { | 60 | try { |
| 61 | jsonObject = new JSONObject((String) msg.obj); | 61 | jsonObject = new JSONObject((String) msg.obj); |
| 62 | status = jsonObject.optString("status"); | 62 | status = jsonObject.optString("status"); |
| 63 | if (status.equals("1")) { | 63 | if (status.equals("1")) { |
| 64 | AlertUtils.showToast(ChoiseTextBookActivity.this, "您已经填写了保卡信息,请到主界面确认您的保卡信息是否正确!"); | ||
| 64 | Intent intent = new Intent(); | 65 | Intent intent = new Intent(); |
| 65 | intent.setClass(ChoiseTextBookActivity.this, TheStartPageActivity.class); | 66 | intent.setClass(ChoiseTextBookActivity.this, TheStartPageActivity.class); |
| 66 | ChoiseTextBookActivity.this.startActivity(intent); | 67 | ChoiseTextBookActivity.this.startActivity(intent); |
| 67 | overridePendingTransition(R.anim.rightin, R.anim.rightout); | 68 | overridePendingTransition(R.anim.rightin, R.anim.rightout); |
| 68 | finish(); | ||
| 69 | } else if (status.equals("2001")) { | 69 | } else if (status.equals("2001")) { |
| 70 | ElectronicCardDialog.getInstance().show(getSupportFragmentManager(), "ElectronicCardDialog"); | 70 | ElectronicCardDialog.getInstance().show(getSupportFragmentManager(), "ElectronicCardDialog"); |
| 71 | } | 71 | } |
| 72 | 72 | ||
| 73 | } catch (JSONException e) { | 73 | } catch (JSONException e) { |
| 74 | e.printStackTrace(); | 74 | e.printStackTrace(); |
| 75 | } | 75 | } |
| 76 | 76 | ||
| 77 | break; | 77 | break; |
| 78 | 78 | ||
| 79 | } | 79 | } |
| 80 | 80 | ||
| 81 | } | 81 | } |
| 82 | }; | 82 | }; |
| 83 | 83 | ||
| 84 | @Override | 84 | @Override |
| 85 | protected void onCreate(Bundle savedInstanceState) { | 85 | protected void onCreate(Bundle savedInstanceState) { |
| 86 | super.onCreate(savedInstanceState); | 86 | super.onCreate(savedInstanceState); |
| 87 | setContentView(R.layout.activity_choisetextbook); | 87 | setContentView(R.layout.activity_choisetextbook); |
| 88 | initView(); | 88 | initView(); |
| 89 | initData(); | 89 | initData(); |
| 90 | initLister(); | 90 | initLister(); |
| 91 | } | 91 | } |
| 92 | 92 | ||
| 93 | private void initView() { | 93 | private void initView() { |
| 94 | gridView = (GridView) findViewById(R.id.grideview); | 94 | gridView = (GridView) findViewById(R.id.grideview); |
| 95 | cancel = (ImageView) findViewById(R.id.cancel); | 95 | cancel = (ImageView) findViewById(R.id.cancel); |
| 96 | btn_ok = (Button) findViewById(R.id.btn_ok); | 96 | btn_ok = (Button) findViewById(R.id.btn_ok); |
| 97 | } | 97 | } |
| 98 | 98 | ||
| 99 | private void initData() { | 99 | private void initData() { |
| 100 | data_list = new ArrayList<Map<String, Object>>(); | 100 | data_list = new ArrayList<Map<String, Object>>(); |
| 101 | getData(); | 101 | getData(); |
| 102 | String[] from = {"image", "text", "text1"}; | 102 | String[] from = {"image", "text", "text1"}; |
| 103 | int[] to = {R.id.image, R.id.text}; | 103 | int[] to = {R.id.image, R.id.text}; |
| 104 | sim_adapter = new SimpleAdapter(this, data_list, R.layout.activity_choisetextbook_items, from, to); | 104 | sim_adapter = new SimpleAdapter(this, data_list, R.layout.activity_choisetextbook_items, from, to); |
| 105 | //配置适配器 | 105 | //配置适配器 |
| 106 | gridView.setAdapter(sim_adapter); | 106 | gridView.setAdapter(sim_adapter); |
| 107 | 107 | ||
| 108 | } | 108 | } |
| 109 | 109 | ||
| 110 | private void initLister() { | 110 | private void initLister() { |
| 111 | btn_ok.setOnClickListener(this); | 111 | btn_ok.setOnClickListener(this); |
| 112 | cancel.setOnClickListener(this); | 112 | cancel.setOnClickListener(this); |
| 113 | 113 | ||
| 114 | } | 114 | } |
| 115 | 115 | ||
| 116 | public List<Map<String, Object>> getData() { | 116 | public List<Map<String, Object>> getData() { |
| 117 | //cion和iconName的长度是相同的,这里任选其一都可以 | 117 | //cion和iconName的长度是相同的,这里任选其一都可以 |
| 118 | for (int i = 0; i < icon.length; i++) { | 118 | for (int i = 0; i < icon.length; i++) { |
| 119 | Map<String, Object> map = new HashMap<String, Object>(); | 119 | Map<String, Object> map = new HashMap<String, Object>(); |
| 120 | map.put("image", icon[i]); | 120 | map.put("image", icon[i]); |
| 121 | map.put("text", subject[i]); | 121 | map.put("text", subject[i]); |
| 122 | map.put("text1", publish[i]); | 122 | map.put("text1", publish[i]); |
| 123 | data_list.add(map); | 123 | data_list.add(map); |
| 124 | } | 124 | } |
| 125 | 125 | ||
| 126 | return data_list; | 126 | return data_list; |
| 127 | } | 127 | } |
| 128 | 128 | ||
| 129 | @Override | 129 | @Override |
| 130 | public void onClick(View v) { | 130 | public void onClick(View v) { |
| 131 | switch (v.getId()) { | 131 | switch (v.getId()) { |
| 132 | case R.id.btn_ok: | 132 | case R.id.btn_ok: |
| 133 | String userID = SaveParam.getInstance().getLoginParam(this, "userId"); | 133 | String userID = SaveParam.getInstance().getLoginParam(this, "userId"); |
| 134 | try { | 134 | try { |
| 135 | if (userID == null) { | 135 | if (userID == null) { |
| 136 | AlertUtils.showToast(ChoiseTextBookActivity.this, "连接超时请重新登录!"); | 136 | AlertUtils.showToast(ChoiseTextBookActivity.this, "连接超时请重新登录!"); |
| 137 | 137 | ||
| 138 | } else { | 138 | } else { |
| 139 | long auserID = Long.parseLong(userID); | 139 | long auserID = Long.parseLong(userID); |
| 140 | HttpManager.getInstance().cardinfocheck(this, auserID, handler); | 140 | HttpManager.getInstance().cardinfocheck(this, auserID, handler); |
| 141 | } | 141 | } |
| 142 | 142 | ||
| 143 | } catch (NumberFormatException e) { | 143 | } catch (NumberFormatException e) { |
| 144 | e.printStackTrace(); | 144 | e.printStackTrace(); |
| 145 | } | 145 | } |
| 146 | 146 | ||
| 147 | break; | 147 | break; |
| 148 | case R.id.cancel: | 148 | case R.id.cancel: |
| 149 | finish(); | 149 | finish(); |
| 150 | break; | 150 | break; |
| 151 | } | 151 | } |
| 152 | 152 | ||
| 153 | } | 153 | } |
| 154 | } | 154 | } |
PersonalCenter/app/src/main/java/com/hjx/personalcenter/activity/MainActivity.java
| 1 | package com.hjx.personalcenter.activity; | 1 | package com.hjx.personalcenter.activity; |
| 2 | 2 | ||
| 3 | import android.content.Context; | 3 | import android.content.Context; |
| 4 | import android.content.Intent; | 4 | import android.content.Intent; |
| 5 | import android.content.pm.PackageManager; | 5 | import android.content.pm.PackageManager; |
| 6 | import android.net.Uri; | 6 | import android.net.Uri; |
| 7 | import android.os.Build; | 7 | import android.os.Build; |
| 8 | import android.os.Bundle; | 8 | import android.os.Bundle; |
| 9 | import android.os.Handler; | 9 | import android.os.Handler; |
| 10 | import android.os.Message; | 10 | import android.os.Message; |
| 11 | import android.provider.MediaStore; | 11 | import android.provider.MediaStore; |
| 12 | import android.support.annotation.NonNull; | 12 | import android.support.annotation.NonNull; |
| 13 | import android.support.v4.content.FileProvider; | 13 | import android.support.v4.content.FileProvider; |
| 14 | import android.support.v7.app.AppCompatActivity; | 14 | import android.support.v7.app.AppCompatActivity; |
| 15 | import android.support.v7.widget.LinearLayoutManager; | 15 | import android.support.v7.widget.LinearLayoutManager; |
| 16 | import android.support.v7.widget.RecyclerView; | 16 | import android.support.v7.widget.RecyclerView; |
| 17 | import android.view.KeyEvent; | 17 | import android.view.KeyEvent; |
| 18 | import android.view.View; | 18 | import android.view.View; |
| 19 | import android.widget.ImageView; | 19 | import android.widget.ImageView; |
| 20 | import android.widget.LinearLayout; | 20 | import android.widget.LinearLayout; |
| 21 | import android.widget.TextView; | 21 | import android.widget.TextView; |
| 22 | import android.widget.Toast; | 22 | import android.widget.Toast; |
| 23 | 23 | ||
| 24 | import com.facebook.drawee.backends.pipeline.Fresco; | 24 | import com.facebook.drawee.backends.pipeline.Fresco; |
| 25 | import com.facebook.drawee.generic.GenericDraweeHierarchy; | 25 | import com.facebook.drawee.generic.GenericDraweeHierarchy; |
| 26 | import com.facebook.drawee.generic.GenericDraweeHierarchyBuilder; | 26 | import com.facebook.drawee.generic.GenericDraweeHierarchyBuilder; |
| 27 | import com.facebook.drawee.generic.RoundingParams; | 27 | import com.facebook.drawee.generic.RoundingParams; |
| 28 | import com.facebook.drawee.interfaces.DraweeController; | 28 | import com.facebook.drawee.interfaces.DraweeController; |
| 29 | import com.facebook.drawee.view.SimpleDraweeView; | 29 | import com.facebook.drawee.view.SimpleDraweeView; |
| 30 | import com.hjx.personalcenter.R; | 30 | import com.hjx.personalcenter.R; |
| 31 | import com.hjx.personalcenter.adapter.GalleryAdapter; | 31 | import com.hjx.personalcenter.adapter.GalleryAdapter; |
| 32 | import com.hjx.personalcenter.customdialog.HeadDialog; | 32 | import com.hjx.personalcenter.customdialog.HeadDialog; |
| 33 | import com.hjx.personalcenter.db.SaveParam; | 33 | import com.hjx.personalcenter.db.SaveParam; |
| 34 | import com.hjx.personalcenter.http.HttpCode; | 34 | import com.hjx.personalcenter.http.HttpCode; |
| 35 | import com.hjx.personalcenter.http.HttpManager; | 35 | import com.hjx.personalcenter.http.HttpManager; |
| 36 | import com.hjx.personalcenter.interfaces.DialogCallBack; | 36 | import com.hjx.personalcenter.interfaces.DialogCallBack; |
| 37 | import com.hjx.personalcenter.model.PesonalInfo; | 37 | import com.hjx.personalcenter.model.PesonalInfo; |
| 38 | import com.hjx.personalcenter.model.SignInfo; | 38 | import com.hjx.personalcenter.model.SignInfo; |
| 39 | import com.hjx.personalcenter.update.UpdateChecker; | 39 | import com.hjx.personalcenter.update.UpdateChecker; |
| 40 | import com.hjx.personalcenter.util.AlertUtils; | 40 | import com.hjx.personalcenter.util.AlertUtils; |
| 41 | import com.hjx.personalcenter.util.CropUtils; | 41 | import com.hjx.personalcenter.util.CropUtils; |
| 42 | import com.hjx.personalcenter.util.DialogPermission; | 42 | import com.hjx.personalcenter.util.DialogPermission; |
| 43 | import com.hjx.personalcenter.util.FileUtil; | 43 | import com.hjx.personalcenter.util.FileUtil; |
| 44 | import com.hjx.personalcenter.util.PermissionUtil; | 44 | import com.hjx.personalcenter.util.PermissionUtil; |
| 45 | import com.hjx.personalcenter.util.SharedPreferenceMark; | 45 | import com.hjx.personalcenter.util.SharedPreferenceMark; |
| 46 | import com.mylhyl.circledialog.CircleDialog; | 46 | import com.mylhyl.circledialog.CircleDialog; |
| 47 | import com.mylhyl.circledialog.callback.ConfigInput; | 47 | import com.mylhyl.circledialog.callback.ConfigInput; |
| 48 | import com.mylhyl.circledialog.params.InputParams; | 48 | import com.mylhyl.circledialog.params.InputParams; |
| 49 | import com.mylhyl.circledialog.view.listener.OnInputClickListener; | 49 | import com.mylhyl.circledialog.view.listener.OnInputClickListener; |
| 50 | import com.zaaach.toprightmenu.MenuItem; | 50 | import com.zaaach.toprightmenu.MenuItem; |
| 51 | import com.zaaach.toprightmenu.TopRightMenu; | 51 | import com.zaaach.toprightmenu.TopRightMenu; |
| 52 | 52 | ||
| 53 | import java.io.File; | 53 | import java.io.File; |
| 54 | import java.io.UnsupportedEncodingException; | 54 | import java.io.UnsupportedEncodingException; |
| 55 | import java.util.ArrayList; | 55 | import java.util.ArrayList; |
| 56 | import java.util.Arrays; | 56 | import java.util.Arrays; |
| 57 | import java.util.List; | 57 | import java.util.List; |
| 58 | 58 | ||
| 59 | public class MainActivity extends AppCompatActivity implements View.OnClickListener, DialogCallBack.CallBackView { | 59 | public class MainActivity extends AppCompatActivity implements View.OnClickListener, DialogCallBack.CallBackView { |
| 60 | private ImageView iv_imformatioan, iv_look_card, iv_setting, iv_sign, iv_sex; | 60 | private ImageView iv_imformatioan, iv_look_card, iv_setting, iv_sign, iv_sex; |
| 61 | private TextView tv_edit_presoninfo, tv_sign, | 61 | private TextView tv_edit_presoninfo, tv_sign, |
| 62 | tv_username, tv_username1, tv_mygad, tv_sex, tv_useinfo_adress, tv_useinfo_birthday, | 62 | tv_username, tv_username1, tv_mygad, tv_sex, tv_useinfo_adress, tv_useinfo_birthday, |
| 63 | tv_useinfo_qq, tv_useinfo_school, tv_useinfo_gender; | 63 | tv_useinfo_qq, tv_useinfo_school, tv_useinfo_gender; |
| 64 | private LinearLayout linel_mycuoti, linel_mynote, linel_mycollege, linel_myclass; | 64 | private LinearLayout linel_mycuoti, linel_mynote, linel_mycollege, linel_myclass; |
| 65 | private TopRightMenu mTopRightMenu; | 65 | private TopRightMenu mTopRightMenu; |
| 66 | //水平滑动 | 66 | //水平滑动 |
| 67 | private RecyclerView mRecyclerView; | 67 | private RecyclerView mRecyclerView; |
| 68 | private GalleryAdapter RecyclerViewadapter; | 68 | private GalleryAdapter RecyclerViewadapter; |
| 69 | private List<Integer> mDatas = new ArrayList<Integer>(Arrays.asList(R.mipmap.default_avatar2, | 69 | private List<Integer> mDatas = new ArrayList<Integer>(Arrays.asList(R.mipmap.default_avatar2, |
| 70 | R.mipmap.default_avatar2, R.mipmap.default_avatar2, R.mipmap.default_avatar2)); | 70 | R.mipmap.default_avatar2, R.mipmap.default_avatar2, R.mipmap.default_avatar2)); |
| 71 | private boolean showIcon = true; | 71 | private boolean showIcon = true; |
| 72 | private boolean dimBg = true; | 72 | private boolean dimBg = true; |
| 73 | private boolean needAnim = true; | 73 | private boolean needAnim = true; |
| 74 | private static final int REQUEST_CODE_TAKE_PHOTO = 1; | 74 | private static final int REQUEST_CODE_TAKE_PHOTO = 1; |
| 75 | private static final int REQUEST_CODE_ALBUM = 2; | 75 | private static final int REQUEST_CODE_ALBUM = 2; |
| 76 | private static final int REQUEST_CODE_CROUP_PHOTO = 3; | 76 | private static final int REQUEST_CODE_CROUP_PHOTO = 3; |
| 77 | SimpleDraweeView mSimpleDraweeView; | 77 | SimpleDraweeView mSimpleDraweeView; |
| 78 | private File file; | 78 | private File file; |
| 79 | private Uri uri; | 79 | private Uri uri; |
| 80 | Handler handler = new Handler(){ | 80 | Handler handler = new Handler(){ |
| 81 | @Override | 81 | @Override |
| 82 | public void handleMessage(Message msg) { | 82 | public void handleMessage(Message msg) { |
| 83 | super.handleMessage(msg); | 83 | super.handleMessage(msg); |
| 84 | switch (msg.what){ | 84 | switch (msg.what){ |
| 85 | case HttpCode.GETINFO: | 85 | case HttpCode.GETINFO: |
| 86 | PesonalInfo.DataBean cardinfoBean =(PesonalInfo.DataBean)msg.obj; | 86 | PesonalInfo.DataBean cardinfoBean =(PesonalInfo.DataBean)msg.obj; |
| 87 | tv_username.setText(cardinfoBean.getNickName()); | 87 | tv_username.setText(cardinfoBean.getNickName()); |
| 88 | tv_username1.setText(cardinfoBean.getNickName()); | 88 | tv_username1.setText(cardinfoBean.getNickName()); |
| 89 | tv_useinfo_adress.setText(cardinfoBean.getRegion().getRegionName()); | 89 | tv_useinfo_adress.setText(cardinfoBean.getRegion().getRegionName()); |
| 90 | tv_useinfo_birthday.setText(cardinfoBean.getBirthday()); | 90 | tv_useinfo_birthday.setText(cardinfoBean.getBirthday()); |
| 91 | tv_useinfo_qq.setText(cardinfoBean.getQq()); | 91 | tv_useinfo_qq.setText(cardinfoBean.getQq()); |
| 92 | tv_useinfo_school.setText(cardinfoBean.getSchool().getSchoolName()); | 92 | tv_useinfo_school.setText(cardinfoBean.getSchool().getSchoolName()); |
| 93 | tv_useinfo_gender.setText(cardinfoBean.getGrade().getGradeName()); | 93 | tv_useinfo_gender.setText(cardinfoBean.getGrade().getGradeName()); |
| 94 | String sex = cardinfoBean.getGender(); | 94 | String sex = cardinfoBean.getGender(); |
| 95 | if ("0".equals(sex)){ | 95 | if ("0".equals(sex)){ |
| 96 | tv_sex.setText("男"); | 96 | tv_sex.setText("男"); |
| 97 | iv_sex.setImageResource(R.mipmap.men); | 97 | iv_sex.setImageResource(R.mipmap.men); |
| 98 | }else { | 98 | }else { |
| 99 | tv_sex.setText("女"); | 99 | tv_sex.setText("女"); |
| 100 | iv_sex.setImageResource(R.mipmap.women); | 100 | iv_sex.setImageResource(R.mipmap.women); |
| 101 | } | 101 | } |
| 102 | String imageurl = SaveParam.getInstance().getLoginParam(MainActivity.this,SaveParam.HEADURL); | 102 | mSimpleDraweeView.setImageURI(cardinfoBean.getPortrait()); |
| 103 | mSimpleDraweeView.setImageURI(imageurl); | ||
| 104 | break; | 103 | break; |
| 105 | case HttpCode.SIGN: | 104 | case HttpCode.SIGN: |
| 106 | SignInfo.DataBean dataBean = (SignInfo.DataBean)msg.obj; | 105 | SignInfo.DataBean dataBean = (SignInfo.DataBean)msg.obj; |
| 107 | if (dataBean.getSignature()==null){ | 106 | if (dataBean.getSignature()==null){ |
| 108 | tv_sign.setText("你还未设置个性签名"); | 107 | tv_sign.setText("你还未设置个性签名"); |
| 109 | }else { | 108 | }else { |
| 110 | tv_sign.setText(dataBean.getSignature()); | 109 | tv_sign.setText(dataBean.getSignature()); |
| 111 | } | 110 | } |
| 112 | 111 | ||
| 113 | break; | 112 | break; |
| 114 | } | 113 | } |
| 115 | } | 114 | } |
| 116 | }; | 115 | }; |
| 117 | 116 | ||
| 118 | @Override | 117 | @Override |
| 119 | protected void onCreate(Bundle savedInstanceState) { | 118 | protected void onCreate(Bundle savedInstanceState) { |
| 120 | super.onCreate(savedInstanceState); | 119 | super.onCreate(savedInstanceState); |
| 121 | Fresco.initialize(this); | 120 | Fresco.initialize(this); |
| 122 | setContentView(R.layout.activity_main); | 121 | setContentView(R.layout.activity_main); |
| 123 | initView(); | 122 | initView(); |
| 124 | initData(); | 123 | initData(); |
| 125 | initLister(); | 124 | initLister(); |
| 126 | updateVersion(); | 125 | updateVersion(); |
| 126 | // String devicenumber = GetDevicesUtil.getDevicesInfo(this).getDeviceNumber(); | ||
| 127 | // Log.e("test","......."+devicenumber); | ||
| 127 | } | 128 | } |
| 128 | //////版本更新 | 129 | //////版本更新 |
| 129 | private void updateVersion() { | 130 | private void updateVersion() { |
| 130 | UpdateChecker updateChecker = new UpdateChecker(this); | 131 | UpdateChecker updateChecker = new UpdateChecker(this); |
| 131 | updateChecker.checkForUpdates(); | 132 | updateChecker.checkForUpdates(); |
| 132 | 133 | ||
| 133 | 134 | ||
| 134 | } | 135 | } |
| 135 | 136 | ||
| 136 | private void initView() { | 137 | private void initView() { |
| 137 | iv_imformatioan = (ImageView) findViewById(R.id.iv_imformatioan); | 138 | iv_imformatioan = (ImageView) findViewById(R.id.iv_imformatioan); |
| 138 | iv_look_card = (ImageView) findViewById(R.id.iv_look_card); | 139 | iv_look_card = (ImageView) findViewById(R.id.iv_look_card); |
| 139 | tv_edit_presoninfo = (TextView) findViewById(R.id.tv_edit_presoninfo); | 140 | tv_edit_presoninfo = (TextView) findViewById(R.id.tv_edit_presoninfo); |
| 140 | iv_setting = (ImageView) findViewById(R.id.iv_setting); | 141 | iv_setting = (ImageView) findViewById(R.id.iv_setting); |
| 141 | iv_sign = (ImageView) findViewById(R.id.iv_sign); | 142 | iv_sign = (ImageView) findViewById(R.id.iv_sign); |
| 142 | tv_sign = (TextView) findViewById(R.id.tv_sign); | 143 | tv_sign = (TextView) findViewById(R.id.tv_sign); |
| 143 | //头像 | 144 | //头像 |
| 144 | mSimpleDraweeView = (SimpleDraweeView) findViewById(R.id.iv_head); | 145 | mSimpleDraweeView = (SimpleDraweeView) findViewById(R.id.iv_head); |
| 145 | //初始化个人信息 | 146 | //初始化个人信息 |
| 146 | iv_sex = (ImageView) findViewById(R.id.iv_sex); | 147 | iv_sex = (ImageView) findViewById(R.id.iv_sex); |
| 147 | tv_username = (TextView) findViewById(R.id.tv_username); | 148 | tv_username = (TextView) findViewById(R.id.tv_username); |
| 148 | tv_username1 = (TextView) findViewById(R.id.tv_username1); | 149 | tv_username1 = (TextView) findViewById(R.id.tv_username1); |
| 149 | tv_mygad = (TextView) findViewById(R.id.tv_mygad); | 150 | tv_mygad = (TextView) findViewById(R.id.tv_mygad); |
| 150 | tv_sex = (TextView) findViewById(R.id.tv_sex); | 151 | tv_sex = (TextView) findViewById(R.id.tv_sex); |
| 151 | tv_useinfo_adress = (TextView) findViewById(R.id.tv_useinfo_adress); | 152 | tv_useinfo_adress = (TextView) findViewById(R.id.tv_useinfo_adress); |
| 152 | tv_useinfo_birthday = (TextView) findViewById(R.id.tv_useinfo_birthday); | 153 | tv_useinfo_birthday = (TextView) findViewById(R.id.tv_useinfo_birthday); |
| 153 | tv_useinfo_qq = (TextView) findViewById(R.id.tv_useinfo_qq); | 154 | tv_useinfo_qq = (TextView) findViewById(R.id.tv_useinfo_qq); |
| 154 | tv_useinfo_school = (TextView) findViewById(R.id.tv_useinfo_school); | 155 | tv_useinfo_school = (TextView) findViewById(R.id.tv_useinfo_school); |
| 155 | tv_useinfo_gender = (TextView) findViewById(R.id.tv_useinfo_gender); | 156 | tv_useinfo_gender = (TextView) findViewById(R.id.tv_useinfo_gender); |
| 156 | //跳转其他应用 | 157 | //跳转其他应用 |
| 157 | linel_mycuoti = (LinearLayout) findViewById(R.id.linel_mycuoti); | 158 | linel_mycuoti = (LinearLayout) findViewById(R.id.linel_mycuoti); |
| 158 | linel_mynote = (LinearLayout) findViewById(R.id.linel_mynote); | 159 | linel_mynote = (LinearLayout) findViewById(R.id.linel_mynote); |
| 159 | linel_mycollege = (LinearLayout) findViewById(R.id.linel_mycollege); | 160 | linel_mycollege = (LinearLayout) findViewById(R.id.linel_mycollege); |
| 160 | linel_myclass = (LinearLayout) findViewById(R.id.linel_myclass); | 161 | linel_myclass = (LinearLayout) findViewById(R.id.linel_myclass); |
| 161 | // | 162 | // |
| 162 | mRecyclerView = (RecyclerView) findViewById(R.id.id_recyclerview_horizontal); | 163 | mRecyclerView = (RecyclerView) findViewById(R.id.id_recyclerview_horizontal); |
| 163 | 164 | ||
| 164 | } | 165 | } |
| 165 | 166 | ||
| 166 | 167 | ||
| 167 | private void initData() { | 168 | private void initData() { |
| 168 | //加载最近学习视频 | 169 | //加载最近学习视频 |
| 169 | 170 | ||
| 170 | 171 | ||
| 171 | //设置布局管理器 | 172 | //设置布局管理器 |
| 172 | LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this); | 173 | LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this); |
| 173 | linearLayoutManager.setOrientation(LinearLayoutManager.HORIZONTAL); | 174 | linearLayoutManager.setOrientation(LinearLayoutManager.HORIZONTAL); |
| 174 | mRecyclerView.setLayoutManager(linearLayoutManager); | 175 | mRecyclerView.setLayoutManager(linearLayoutManager); |
| 175 | //设置适配器 | 176 | //设置适配器 |
| 176 | RecyclerViewadapter = new GalleryAdapter(this, mDatas); | 177 | RecyclerViewadapter = new GalleryAdapter(this, mDatas); |
| 177 | mRecyclerView.setAdapter(RecyclerViewadapter); | 178 | mRecyclerView.setAdapter(RecyclerViewadapter); |
| 178 | 179 | ||
| 179 | //加载个人信息 | 180 | //加载个人信息 |
| 180 | String xiongzuo = SaveParam.getInstance().getLoginParam(this,SaveParam.CONSTELLATION); | 181 | String xiongzuo = SaveParam.getInstance().getLoginParam(this,SaveParam.CONSTELLATION); |
| 181 | if (xiongzuo==null){ | 182 | if (xiongzuo==null){ |
| 182 | tv_mygad.setText(""); | 183 | tv_mygad.setText(""); |
| 183 | }else { | 184 | }else { |
| 184 | tv_mygad.setText(xiongzuo); | 185 | tv_mygad.setText(xiongzuo); |
| 185 | } | 186 | } |
| 186 | //加载版本信息 | 187 | //加载版本信息 |
| 187 | 188 | ||
| 188 | 189 | ||
| 189 | //获取个性签名 | 190 | //获取个性签名 |
| 190 | String userID = SaveParam.getInstance().getLoginParam(this,"userId"); | 191 | String userID = SaveParam.getInstance().getLoginParam(this,"userId"); |
| 191 | String typeaccount = SaveParam.getInstance().getCustomizeParam(this,SaveParam.ACCOUNT); | 192 | String typeaccount = SaveParam.getInstance().getCustomizeParam(this,SaveParam.ACCOUNT); |
| 192 | try { | 193 | try { |
| 193 | long auserID = Long.parseLong(userID); | 194 | long auserID = Long.parseLong(userID); |
| 194 | int typeaccount1=Integer.parseInt(typeaccount); | 195 | int typeaccount1=Integer.parseInt(typeaccount); |
| 195 | HttpManager.getInstance().getsignatures(MainActivity.this,auserID,typeaccount1,handler); | 196 | HttpManager.getInstance().getsignatures(MainActivity.this,auserID,typeaccount1,handler); |
| 196 | 197 | ||
| 197 | } catch (NumberFormatException e) { | 198 | } catch (NumberFormatException e) { |
| 198 | e.printStackTrace(); | 199 | e.printStackTrace(); |
| 199 | } | 200 | } |
| 200 | 201 | ||
| 201 | 202 | ||
| 202 | 203 | ||
| 203 | //初始化图片 | 204 | //初始化图片 |
| 204 | file = new File(FileUtil.getCachePath(this), "user-avatar.jpg"); | 205 | file = new File(FileUtil.getCachePath(this), "user-avatar.jpg"); |
| 205 | if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N) { | 206 | if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N) { |
| 206 | uri = Uri.fromFile(file); | 207 | uri = Uri.fromFile(file); |
| 207 | } else { | 208 | } else { |
| 208 | //通过FileProvider创建一个content类型的Uri(android 7.0需要这样的方法跨应用访问) | 209 | //通过FileProvider创建一个content类型的Uri(android 7.0需要这样的方法跨应用访问) |
| 209 | uri = FileProvider.getUriForFile(MyApplication.getContext(), "com.hjx.personalcenter", file); | 210 | uri = FileProvider.getUriForFile(MyApplication.getContext(), "com.hjx.personalcenter", file); |
| 210 | } | 211 | } |
| 211 | 212 | ||
| 212 | } | 213 | } |
| 213 | 214 | ||
| 214 | private void initLister() { | 215 | private void initLister() { |
| 215 | iv_imformatioan.setOnClickListener(this); | 216 | iv_imformatioan.setOnClickListener(this); |
| 216 | iv_look_card.setOnClickListener(this); | 217 | iv_look_card.setOnClickListener(this); |
| 217 | tv_edit_presoninfo.setOnClickListener(this); | 218 | tv_edit_presoninfo.setOnClickListener(this); |
| 218 | iv_setting.setOnClickListener(this); | 219 | iv_setting.setOnClickListener(this); |
| 219 | iv_sign.setOnClickListener(this); | 220 | iv_sign.setOnClickListener(this); |
| 220 | mSimpleDraweeView.setOnClickListener(this); | 221 | mSimpleDraweeView.setOnClickListener(this); |
| 221 | linel_mycuoti.setOnClickListener(this); | 222 | linel_mycuoti.setOnClickListener(this); |
| 222 | linel_mynote.setOnClickListener(this); | 223 | linel_mynote.setOnClickListener(this); |
| 223 | linel_mycollege.setOnClickListener(this); | 224 | linel_mycollege.setOnClickListener(this); |
| 224 | linel_myclass.setOnClickListener(this); | 225 | linel_myclass.setOnClickListener(this); |
| 225 | 226 | ||
| 226 | } | 227 | } |
| 227 | 228 | ||
| 228 | @Override | 229 | @Override |
| 229 | public void onClick(View v) { | 230 | public void onClick(View v) { |
| 230 | switch (v.getId()) { | 231 | switch (v.getId()) { |
| 231 | case R.id.iv_imformatioan: | 232 | case R.id.iv_imformatioan: |
| 232 | Intent intent = new Intent(); | 233 | Intent intent = new Intent(); |
| 233 | intent.setClass(MainActivity.this, FeedBackActivity.class); | 234 | intent.setClass(MainActivity.this, FeedBackActivity.class); |
| 234 | startActivity(intent); | 235 | startActivity(intent); |
| 235 | overridePendingTransition(R.anim.rightin, R.anim.rightout); | 236 | overridePendingTransition(R.anim.rightin, R.anim.rightout); |
| 236 | break; | 237 | break; |
| 237 | case R.id.iv_look_card: | 238 | case R.id.iv_look_card: |
| 238 | Intent lookintent = new Intent(); | 239 | Intent lookintent = new Intent(); |
| 239 | lookintent.setClass(MainActivity.this, ElectronicCardLookInfoActivity.class); | 240 | lookintent.setClass(MainActivity.this, ElectronicCardLookInfoActivity.class); |
| 240 | startActivity(lookintent); | 241 | startActivity(lookintent); |
| 241 | overridePendingTransition(R.anim.rightin, R.anim.rightout); | 242 | overridePendingTransition(R.anim.rightin, R.anim.rightout); |
| 242 | break; | 243 | break; |
| 243 | case R.id.tv_edit_presoninfo: | 244 | case R.id.tv_edit_presoninfo: |
| 244 | Intent editintent = new Intent(); | 245 | Intent editintent = new Intent(); |
| 245 | editintent.setClass(MainActivity.this, ChangePresonalInfoActivity.class); | 246 | editintent.setClass(MainActivity.this, ChangePresonalInfoActivity.class); |
| 246 | startActivity(editintent); | 247 | startActivity(editintent); |
| 247 | overridePendingTransition(R.anim.rightin, R.anim.rightout); | 248 | overridePendingTransition(R.anim.rightin, R.anim.rightout); |
| 248 | break; | 249 | break; |
| 249 | case R.id.iv_head: | 250 | case R.id.iv_head: |
| 250 | HeadDialog.getInstance(this).show(getSupportFragmentManager(), "HeadDialog"); | 251 | HeadDialog.getInstance(this).show(getSupportFragmentManager(), "HeadDialog"); |
| 251 | break; | 252 | break; |
| 252 | case R.id.iv_setting: | 253 | case R.id.iv_setting: |
| 253 | mTopRightMenu = new TopRightMenu(MainActivity.this); | 254 | mTopRightMenu = new TopRightMenu(MainActivity.this); |
| 254 | List<MenuItem> menuItems = new ArrayList<>(); | 255 | List<MenuItem> menuItems = new ArrayList<>(); |
| 255 | menuItems.add(new MenuItem(R.mipmap.blank, "切换账户")); | 256 | menuItems.add(new MenuItem(R.mipmap.blank, "切换账户")); |
| 256 | menuItems.add(new MenuItem(R.mipmap.blank, "账户管理")); | 257 | menuItems.add(new MenuItem(R.mipmap.blank, "账户管理")); |
| 257 | mTopRightMenu | 258 | mTopRightMenu |
| 258 | .setHeight(150) //默认高度480 | 259 | .setHeight(150) //默认高度480 |
| 259 | .setWidth(320) //默认宽度wrap_content | 260 | .setWidth(320) //默认宽度wrap_content |
| 260 | .showIcon(showIcon) //显示菜单图标,默认为true | 261 | .showIcon(showIcon) //显示菜单图标,默认为true |
| 261 | .dimBackground(dimBg) //背景变暗,默认为true | 262 | .dimBackground(dimBg) //背景变暗,默认为true |
| 262 | .needAnimationStyle(needAnim) //显示动画,默认为true | 263 | .needAnimationStyle(needAnim) //显示动画,默认为true |
| 263 | .setAnimationStyle(R.style.TRM_ANIM_STYLE) //默认为R.style.TRM_ANIM_STYLE | 264 | .setAnimationStyle(R.style.TRM_ANIM_STYLE) //默认为R.style.TRM_ANIM_STYLE |
| 264 | .setOnMenuItemClickListener(new TopRightMenu.OnMenuItemClickListener() { | 265 | .setOnMenuItemClickListener(new TopRightMenu.OnMenuItemClickListener() { |
| 265 | @Override | 266 | @Override |
| 266 | public void onMenuItemClick(int position) { | 267 | public void onMenuItemClick(int position) { |
| 267 | switch (position) { | 268 | switch (position) { |
| 268 | case 0: | 269 | case 0: |
| 269 | //清除数据 | 270 | //清除数据 |
| 270 | SaveParam.getInstance().clearData(MainActivity.this); | 271 | SaveParam.getInstance().clearData(MainActivity.this); |
| 271 | Intent settingintent = new Intent(); | 272 | Intent settingintent = new Intent(); |
| 272 | settingintent.setClass(MainActivity.this, LoginAndRegisterActivity.class); | 273 | settingintent.setClass(MainActivity.this, LoginAndRegisterActivity.class); |
| 273 | startActivity(settingintent); | 274 | startActivity(settingintent); |
| 274 | overridePendingTransition(R.anim.rightin, R.anim.rightout); | 275 | overridePendingTransition(R.anim.rightin, R.anim.rightout); |
| 275 | finish(); | 276 | finish(); |
| 276 | break; | 277 | break; |
| 277 | case 1: | 278 | case 1: |
| 278 | Intent accontMintent = new Intent(); | 279 | Intent accontMintent = new Intent(); |
| 279 | accontMintent.setClass(MainActivity.this, AccountManagementActivity.class); | 280 | accontMintent.setClass(MainActivity.this, AccountManagementActivity.class); |
| 280 | startActivity(accontMintent); | 281 | startActivity(accontMintent); |
| 281 | overridePendingTransition(R.anim.rightin, R.anim.rightout); | 282 | overridePendingTransition(R.anim.rightin, R.anim.rightout); |
| 282 | break; | 283 | break; |
| 283 | } | 284 | } |
| 284 | } | 285 | } |
| 285 | }) | 286 | }) |
| 286 | .addMenuList(menuItems) | 287 | .addMenuList(menuItems) |
| 287 | .showAsDropDown(iv_setting, -250, 0); | 288 | .showAsDropDown(iv_setting, -250, 0); |
| 288 | break; | 289 | break; |
| 289 | case R.id.iv_sign: | 290 | case R.id.iv_sign: |
| 290 | new CircleDialog.Builder(this) | 291 | new CircleDialog.Builder(this) |
| 291 | .setCanceledOnTouchOutside(false) | 292 | .setCanceledOnTouchOutside(false) |
| 292 | .setCancelable(true) | 293 | .setCancelable(true) |
| 293 | .setTitle("个性签名") | 294 | .setTitle("个性签名") |
| 294 | .setInputHint("请输入个性签名") | 295 | .setInputHint("请输入个性签名") |
| 295 | .setWidth(0.5f) | 296 | .setWidth(0.5f) |
| 296 | .configInput(new ConfigInput() { | 297 | .configInput(new ConfigInput() { |
| 297 | @Override | 298 | @Override |
| 298 | public void onConfig(InputParams params) { | 299 | public void onConfig(InputParams params) { |
| 299 | // params.inputBackgroundResourceId = R.drawable.bg_input; | 300 | // params.inputBackgroundResourceId = R.drawable.bg_input; |
| 300 | } | 301 | } |
| 301 | }) | 302 | }) |
| 302 | .setNegative("取消", null) | 303 | .setNegative("取消", null) |
| 303 | .setPositiveInput("确定", new OnInputClickListener() { | 304 | .setPositiveInput("确定", new OnInputClickListener() { |
| 304 | @Override | 305 | @Override |
| 305 | public void onClick(String text, View v) { | 306 | public void onClick(String text, View v) { |
| 306 | if (text.equals("")) { | 307 | if (text.equals("")) { |
| 307 | AlertUtils.showToast(MainActivity.this, "请输入个性签名"); | 308 | AlertUtils.showToast(MainActivity.this, "请输入个性签名"); |
| 308 | } else { | 309 | } else { |
| 309 | try { | 310 | try { |
| 310 | String typeaccount = SaveParam.getInstance().getCustomizeParam(MainActivity.this,SaveParam.ACCOUNT); | 311 | String typeaccount = SaveParam.getInstance().getCustomizeParam(MainActivity.this,SaveParam.ACCOUNT); |
| 311 | String userID = SaveParam.getInstance().getLoginParam(MainActivity.this,"userId"); | 312 | String userID = SaveParam.getInstance().getLoginParam(MainActivity.this,"userId"); |
| 312 | long auserID = Long.parseLong(userID); | 313 | long auserID = Long.parseLong(userID); |
| 313 | int typeaccount1=Integer.parseInt(typeaccount); | 314 | int typeaccount1=Integer.parseInt(typeaccount); |
| 314 | HttpManager.getInstance().changsignature(MainActivity.this,auserID,typeaccount1,text); | 315 | HttpManager.getInstance().changsignature(MainActivity.this,auserID,typeaccount1,text); |
| 315 | } catch (NumberFormatException e) { | 316 | } catch (NumberFormatException e) { |
| 316 | e.printStackTrace(); | 317 | e.printStackTrace(); |
| 317 | } | 318 | } |
| 318 | 319 | ||
| 319 | tv_sign.setText(text); | 320 | tv_sign.setText(text); |
| 320 | } | 321 | } |
| 321 | 322 | ||
| 322 | } | 323 | } |
| 323 | }) | 324 | }) |
| 324 | .show(); | 325 | .show(); |
| 325 | break; | 326 | break; |
| 326 | case R.id.linel_mycuoti: | 327 | case R.id.linel_mycuoti: |
| 327 | AlertUtils.showToast(this, "hhahahah "); | 328 | AlertUtils.showToast(this, "hhahahah "); |
| 328 | break; | 329 | break; |
| 329 | case R.id.linel_mynote: | 330 | case R.id.linel_mynote: |
| 330 | AlertUtils.showToast(this, "hhahahah "); | 331 | AlertUtils.showToast(this, "hhahahah "); |
| 331 | break; | 332 | break; |
| 332 | case R.id.linel_mycollege: | 333 | case R.id.linel_mycollege: |
| 333 | AlertUtils.showToast(this, "hhahahah "); | 334 | AlertUtils.showToast(this, "hhahahah "); |
| 334 | break; | 335 | break; |
| 335 | case R.id.linel_myclass: | 336 | case R.id.linel_myclass: |
| 336 | AlertUtils.showToast(this, "hhahahah "); | 337 | AlertUtils.showToast(this, "hhahahah "); |
| 337 | break; | 338 | break; |
| 338 | } | 339 | } |
| 339 | 340 | ||
| 340 | } | 341 | } |
| 341 | 342 | ||
| 342 | @Override | 343 | @Override |
| 343 | protected void onResume() { | 344 | protected void onResume() { |
| 344 | super.onResume(); | 345 | super.onResume(); |
| 345 | String userID = SaveParam.getInstance().getLoginParam(this,"userId"); | 346 | String userID = SaveParam.getInstance().getLoginParam(this,"userId"); |
| 346 | String typeaccount = SaveParam.getInstance().getCustomizeParam(this,SaveParam.ACCOUNT); | 347 | String typeaccount = SaveParam.getInstance().getCustomizeParam(this,SaveParam.ACCOUNT); |
| 347 | try { | 348 | try { |
| 348 | long auserID = Long.parseLong(userID); | 349 | long auserID = Long.parseLong(userID); |
| 349 | int typeaccount1=Integer.parseInt(typeaccount); | 350 | int typeaccount1=Integer.parseInt(typeaccount); |
| 350 | //获取个人信息 | 351 | //获取个人信息 |
| 351 | HttpManager.getInstance().getpresonalinfo(MainActivity.this,auserID,typeaccount1,handler); | 352 | HttpManager.getInstance().getpresonalinfo(MainActivity.this,auserID,typeaccount1,handler); |
| 352 | 353 | ||
| 353 | } catch (NumberFormatException e) { | 354 | } catch (NumberFormatException e) { |
| 354 | e.printStackTrace(); | 355 | e.printStackTrace(); |
| 355 | } | 356 | } |
| 356 | 357 | ||
| 357 | } | 358 | } |
| 358 | 359 | ||
| 359 | //回调头像监听 | 360 | //回调头像监听 |
| 360 | @Override | 361 | @Override |
| 361 | public void heard(Context context, View v,int headpitiaon) { | 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 | switch (v.getId()){ | 366 | switch (v.getId()){ |
| 364 | //选择默认图片 | 367 | //选择默认图片 |
| 365 | case R.id.oktakephone: | 368 | case R.id.oktakephone: |
| 366 | if (headpitiaon==1){ | 369 | if (headpitiaon==1){ |
| 367 | mSimpleDraweeView.setImageDrawable(null); | 370 | mSimpleDraweeView.setImageDrawable(null); |
| 368 | mSimpleDraweeView.setImageResource(R.mipmap.default_avatar1); | 371 | mSimpleDraweeView.setImageResource(R.mipmap.default_avatar1); |
| 369 | picUrl = "http://hjxprodbucket.oss.aliyuncs.com/static/upload/boss_api/announcement/2017-08-29/61e8d8cf-651f-49c9-beb2-ff1387af390a.png"; | 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 | }else if (headpitiaon==2){ | 378 | }else if (headpitiaon==2){ |
| 371 | mSimpleDraweeView.setImageDrawable(null); | 379 | mSimpleDraweeView.setImageDrawable(null); |
| 372 | mSimpleDraweeView.setImageResource(R.mipmap.default_avatar2); | 380 | mSimpleDraweeView.setImageResource(R.mipmap.default_avatar2); |
| 373 | picUrl = "http://hjxprodbucket.oss.aliyuncs.com/static/upload/boss_api/announcement/2017-08-29/8480ff7b-42f1-4d64-b848-c8f4f3afd385.png"; | 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 | }else if (headpitiaon==3){ | 387 | }else if (headpitiaon==3){ |
| 375 | mSimpleDraweeView.setImageDrawable(null); | 388 | mSimpleDraweeView.setImageDrawable(null); |
| 376 | mSimpleDraweeView.setImageResource(R.mipmap.default_avatar3); | 389 | mSimpleDraweeView.setImageResource(R.mipmap.default_avatar3); |
| 377 | picUrl = "http://hjxprodbucket.oss.aliyuncs.com/static/upload/boss_api/announcement/2017-08-29/184112f4-bfe0-4db8-bc1e-6212755b241c.png"; | 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 | }else if (headpitiaon==4){ | 396 | }else if (headpitiaon==4){ |
| 379 | mSimpleDraweeView.setImageDrawable(null); | 397 | mSimpleDraweeView.setImageDrawable(null); |
| 380 | mSimpleDraweeView.setImageResource(R.mipmap.default_avatar4); | 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 "; | 399 | 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){ | 400 | try { |
| 383 | AlertUtils.showToast(this, "你还没有设置头像 "); | 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 | break; | 410 | break; |
| 386 | case R.id.canceltakephone: | 411 | case R.id.canceltakephone: |
| 387 | 412 | ||
| 388 | break; | 413 | break; |
| 389 | //拍摄和相册 | 414 | //拍摄和相册 |
| 390 | case R.id.take_pic: | 415 | case R.id.take_pic: |
| 391 | if (PermissionUtil.hasCameraPermission(MainActivity.this)) { | 416 | if (PermissionUtil.hasCameraPermission(MainActivity.this)) { |
| 392 | uploadAvatarFromPhotoRequest(); | 417 | uploadAvatarFromPhotoRequest(); |
| 393 | } | 418 | } |
| 394 | 419 | ||
| 395 | break; | 420 | break; |
| 396 | case R.id.xiangce: | 421 | case R.id.xiangce: |
| 397 | uploadAvatarFromAlbumRequest(); | 422 | uploadAvatarFromAlbumRequest(); |
| 398 | break; | 423 | break; |
| 399 | 424 | ||
| 400 | } | 425 | } |
| 401 | 426 | ||
| 402 | } | 427 | } |
| 403 | 428 | ||
| 404 | //照相 | 429 | //照相 |
| 405 | private void uploadAvatarFromPhotoRequest() { | 430 | private void uploadAvatarFromPhotoRequest() { |
| 406 | Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); | 431 | Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); |
| 407 | intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); | 432 | intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); |
| 408 | intent.putExtra(MediaStore.Images.Media.ORIENTATION, 0); | 433 | intent.putExtra(MediaStore.Images.Media.ORIENTATION, 0); |
| 409 | intent.putExtra(MediaStore.EXTRA_OUTPUT, uri); | 434 | intent.putExtra(MediaStore.EXTRA_OUTPUT, uri); |
| 410 | startActivityForResult(intent, REQUEST_CODE_TAKE_PHOTO); | 435 | startActivityForResult(intent, REQUEST_CODE_TAKE_PHOTO); |
| 411 | } | 436 | } |
| 412 | 437 | ||
| 413 | //选择图库 | 438 | //选择图库 |
| 414 | private void uploadAvatarFromAlbumRequest() { | 439 | private void uploadAvatarFromAlbumRequest() { |
| 415 | Intent photoPickerIntent = new Intent(Intent.ACTION_PICK); | 440 | Intent photoPickerIntent = new Intent(Intent.ACTION_PICK); |
| 416 | photoPickerIntent.setType("image/*"); | 441 | photoPickerIntent.setType("image/*"); |
| 417 | startActivityForResult(photoPickerIntent, REQUEST_CODE_ALBUM); | 442 | startActivityForResult(photoPickerIntent, REQUEST_CODE_ALBUM); |
| 418 | } | 443 | } |
| 419 | //回掉 | 444 | //回掉 |
| 420 | @Override | 445 | @Override |
| 421 | protected void onActivityResult(int requestCode, int resultCode, Intent data) { | 446 | protected void onActivityResult(int requestCode, int resultCode, Intent data) { |
| 422 | super.onActivityResult(requestCode, resultCode, data); | 447 | super.onActivityResult(requestCode, resultCode, data); |
| 423 | if (resultCode != -1) { | 448 | if (resultCode != -1) { |
| 424 | return; | 449 | return; |
| 425 | } | 450 | } |
| 426 | if (requestCode == REQUEST_CODE_ALBUM && data != null) { | 451 | if (requestCode == REQUEST_CODE_ALBUM && data != null) { |
| 427 | Uri newUri; | 452 | Uri newUri; |
| 428 | if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N) { | 453 | if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N) { |
| 429 | newUri = Uri.parse("file:///" + CropUtils.getPath(this, data.getData())); | 454 | newUri = Uri.parse("file:///" + CropUtils.getPath(this, data.getData())); |
| 430 | } else { | 455 | } else { |
| 431 | newUri = data.getData(); | 456 | newUri = data.getData(); |
| 432 | } | 457 | } |
| 433 | if (newUri != null) { | 458 | if (newUri != null) { |
| 434 | startPhotoZoom(newUri); | 459 | startPhotoZoom(newUri); |
| 435 | } else { | 460 | } else { |
| 436 | Toast.makeText(this, "没有得到相册图片", Toast.LENGTH_LONG).show(); | 461 | Toast.makeText(this, "没有得到相册图片", Toast.LENGTH_LONG).show(); |
| 437 | } | 462 | } |
| 438 | } else if (requestCode == REQUEST_CODE_TAKE_PHOTO) { | 463 | } else if (requestCode == REQUEST_CODE_TAKE_PHOTO) { |
| 439 | startPhotoZoom(uri); | 464 | startPhotoZoom(uri); |
| 440 | } else if (requestCode == REQUEST_CODE_CROUP_PHOTO) { | 465 | } else if (requestCode == REQUEST_CODE_CROUP_PHOTO) { |
| 441 | uploadAvatarFromPhoto(); | 466 | uploadAvatarFromPhoto(); |
| 442 | } | 467 | } |
| 443 | } | 468 | } |
| 444 | 469 | ||
| 445 | private void uploadAvatarFromPhoto() { | 470 | private void uploadAvatarFromPhoto() { |
| 446 | compressAndUploadAvatar(file.getPath()); | 471 | compressAndUploadAvatar(file.getPath()); |
| 447 | 472 | ||
| 448 | } | 473 | } |
| 449 | private void compressAndUploadAvatar(String fileSrc) { | 474 | private void compressAndUploadAvatar(String fileSrc) { |
| 450 | 475 | ||
| 451 | 476 | ||
| 452 | //上传到服务器 | 477 | //上传到服务器 |
| 453 | 478 | ||
| 454 | final File cover = FileUtil.getSmallBitmap(this, fileSrc); | 479 | final File cover = FileUtil.getSmallBitmap(this, fileSrc); |
| 455 | String mimeType = "image/*"; | 480 | String mimeType = "image/*"; |
| 456 | //requestBody = RequestBody.create(MediaType.parse(mimeType), file); | 481 | //requestBody = RequestBody.create(MediaType.parse(mimeType), file); |
| 457 | //String fileName = cover.getName(); | 482 | //String fileName = cover.getName(); |
| 458 | String userID = SaveParam.getInstance().getLoginParam(this,"userId"); | 483 | String userID = SaveParam.getInstance().getLoginParam(this,"userId"); |
| 459 | String typeaccount = SaveParam.getInstance().getCustomizeParam(this,SaveParam.ACCOUNT); | 484 | String typeaccount = SaveParam.getInstance().getCustomizeParam(this,SaveParam.ACCOUNT); |
| 460 | 485 | ||
| 461 | //上传头像 | 486 | //上传头像 |
| 462 | 487 | ||
| 463 | try { | 488 | try { |
| 464 | HttpManager.getInstance().header(this, userID,typeaccount,file.getPath()); | 489 | HttpManager.getInstance().header(this, userID,typeaccount,file.getPath()); |
| 465 | } catch (UnsupportedEncodingException e) { | 490 | } catch (UnsupportedEncodingException e) { |
| 466 | e.printStackTrace(); | 491 | e.printStackTrace(); |
| 467 | } | 492 | } |
| 468 | 493 | ||
| 469 | //photo = MultipartBody.Part.createFormData("portrait", fileName.substring(fileName.lastIndexOf("/") + 1, fileName.length()), requestBody); | 494 | //photo = MultipartBody.Part.createFormData("portrait", fileName.substring(fileName.lastIndexOf("/") + 1, fileName.length()), requestBody); |
| 470 | //Fresco设置圆形头像 | 495 | //Fresco设置圆形头像 |
| 471 | GenericDraweeHierarchyBuilder builder = new GenericDraweeHierarchyBuilder(getResources()); | 496 | GenericDraweeHierarchyBuilder builder = new GenericDraweeHierarchyBuilder(getResources()); |
| 472 | GenericDraweeHierarchy hierarchy = builder | 497 | GenericDraweeHierarchy hierarchy = builder |
| 473 | .setDesiredAspectRatio(1f) | 498 | .setDesiredAspectRatio(1f) |
| 474 | .setFailureImage(R.mipmap.blank) | 499 | .setFailureImage(R.mipmap.blank) |
| 475 | //圆形头像 | 500 | //圆形头像 |
| 476 | .setRoundingParams(RoundingParams.asCircle()) | 501 | .setRoundingParams(RoundingParams.asCircle()) |
| 477 | .build(); | 502 | .build(); |
| 478 | 503 | ||
| 479 | //加载本地图片 | 504 | //加载本地图片 |
| 480 | Uri uri = Uri.fromFile(cover); | 505 | Uri uri = Uri.fromFile(cover); |
| 481 | DraweeController controller = Fresco.newDraweeControllerBuilder() | 506 | DraweeController controller = Fresco.newDraweeControllerBuilder() |
| 482 | .setOldController(mSimpleDraweeView.getController()) | 507 | .setOldController(mSimpleDraweeView.getController()) |
| 483 | .setUri(uri) | 508 | .setUri(uri) |
| 484 | .build(); | 509 | .build(); |
| 485 | mSimpleDraweeView.setHierarchy(hierarchy); | 510 | mSimpleDraweeView.setHierarchy(hierarchy); |
| 486 | mSimpleDraweeView.setController(controller); | 511 | mSimpleDraweeView.setController(controller); |
| 487 | 512 | ||
| 488 | } | 513 | } |
| 489 | 514 | ||
| 490 | public void startPhotoZoom(Uri uri) { | 515 | public void startPhotoZoom(Uri uri) { |
| 491 | Intent intent = new Intent("com.android.camera.action.CROP"); | 516 | Intent intent = new Intent("com.android.camera.action.CROP"); |
| 492 | intent.setDataAndType(uri, "image/*"); | 517 | intent.setDataAndType(uri, "image/*"); |
| 493 | intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); | 518 | intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); |
| 494 | intent.putExtra("crop", "true");// crop=true 有这句才能出来最后的裁剪页面. | 519 | intent.putExtra("crop", "true");// crop=true 有这句才能出来最后的裁剪页面. |
| 495 | intent.putExtra("aspectX", 1);// 这两项为裁剪框的比例. | 520 | intent.putExtra("aspectX", 1);// 这两项为裁剪框的比例. |
| 496 | intent.putExtra("aspectY", 1);// x:y=1:1 | 521 | intent.putExtra("aspectY", 1);// x:y=1:1 |
| 497 | // intent.putExtra("outputX", 400);//图片输出大小 | 522 | // intent.putExtra("outputX", 400);//图片输出大小 |
| 498 | // intent.putExtra("outputY", 400); | 523 | // intent.putExtra("outputY", 400); |
| 499 | intent.putExtra("output", Uri.fromFile(file)); | 524 | intent.putExtra("output", Uri.fromFile(file)); |
| 500 | intent.putExtra("outputFormat", "JPEG");// 返回格式 | 525 | intent.putExtra("outputFormat", "JPEG");// 返回格式 |
| 501 | startActivityForResult(intent, REQUEST_CODE_CROUP_PHOTO); | 526 | startActivityForResult(intent, REQUEST_CODE_CROUP_PHOTO); |
| 502 | } | 527 | } |
| 503 | 528 | ||
| 504 | @Override | 529 | @Override |
| 505 | public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) { | 530 | public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) { |
| 506 | switch (requestCode) { | 531 | switch (requestCode) { |
| 507 | 532 | ||
| 508 | case PermissionUtil.REQUEST_SHOWCAMERA: | 533 | case PermissionUtil.REQUEST_SHOWCAMERA: |
| 509 | if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) { | 534 | if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) { |
| 510 | // Permission Granted | 535 | // Permission Granted |
| 511 | uploadAvatarFromPhotoRequest(); | 536 | uploadAvatarFromPhotoRequest(); |
| 512 | 537 | ||
| 513 | } else { | 538 | } else { |
| 514 | if (!SharedPreferenceMark.getHasShowCamera()) { | 539 | if (!SharedPreferenceMark.getHasShowCamera()) { |
| 515 | SharedPreferenceMark.setHasShowCamera(true); | 540 | SharedPreferenceMark.setHasShowCamera(true); |
| 516 | new DialogPermission(this, "关闭摄像头权限影响扫描功能"); | 541 | new DialogPermission(this, "关闭摄像头权限影响扫描功能"); |
| 517 | 542 | ||
| 518 | } else { | 543 | } else { |
| 519 | Toast.makeText(this, "未获取摄像头权限", Toast.LENGTH_SHORT) | 544 | Toast.makeText(this, "未获取摄像头权限", Toast.LENGTH_SHORT) |
| 520 | .show(); | 545 | .show(); |
| 521 | } | 546 | } |
| 522 | } | 547 | } |
| 523 | break; | 548 | break; |
| 524 | default: | 549 | default: |
| 525 | super.onRequestPermissionsResult(requestCode, permissions, grantResults); | 550 | super.onRequestPermissionsResult(requestCode, permissions, grantResults); |
| 526 | } | 551 | } |
| 527 | } | 552 | } |
| 528 | private long exitTime = 0; | 553 | private long exitTime = 0; |
| 529 | @Override | 554 | @Override |
| 530 | public boolean onKeyDown(int keyCode, KeyEvent event) { | 555 | public boolean onKeyDown(int keyCode, KeyEvent event) { |
| 531 | if (keyCode == KeyEvent.KEYCODE_BACK) { | 556 | if (keyCode == KeyEvent.KEYCODE_BACK) { |
| 532 | if ((System.currentTimeMillis() - exitTime) > 2000) { | 557 | if ((System.currentTimeMillis() - exitTime) > 2000) { |
| 533 | Toast.makeText(getApplicationContext(), "再按一次退出程序", | 558 | Toast.makeText(getApplicationContext(), "再按一次退出程序", |
| 534 | Toast.LENGTH_SHORT).show(); | 559 | Toast.LENGTH_SHORT).show(); |
| 535 | exitTime = System.currentTimeMillis(); | 560 | exitTime = System.currentTimeMillis(); |
| 536 | } else { | 561 | } else { |
| 537 | finish(); | 562 | finish(); |
| 538 | System.exit(0); | 563 | System.exit(0); |
| 539 | } | 564 | } |
| 540 | return false; | 565 | return false; |
| 541 | } | 566 | } |
| 542 | return super.onKeyDown(keyCode, event); | 567 | return super.onKeyDown(keyCode, event); |
| 543 | } | 568 | } |
| 544 | } | 569 | } |
PersonalCenter/app/src/main/java/com/hjx/personalcenter/customdialog/ElectronicCardDialog.java
| 1 | package com.hjx.personalcenter.customdialog; | 1 | package com.hjx.personalcenter.customdialog; |
| 2 | 2 | ||
| 3 | import android.content.Context; | 3 | import android.content.Context; |
| 4 | import android.content.Intent; | 4 | import android.content.Intent; |
| 5 | import android.graphics.Color; | 5 | import android.graphics.Color; |
| 6 | import android.os.Bundle; | 6 | import android.os.Bundle; |
| 7 | import android.view.Gravity; | 7 | import android.view.Gravity; |
| 8 | import android.view.LayoutInflater; | 8 | import android.view.LayoutInflater; |
| 9 | import android.view.View; | 9 | import android.view.View; |
| 10 | import android.view.ViewGroup; | 10 | import android.view.ViewGroup; |
| 11 | import android.widget.ImageView; | ||
| 11 | 12 | ||
| 12 | import com.hjx.personalcenter.R; | 13 | import com.hjx.personalcenter.R; |
| 13 | import com.hjx.personalcenter.activity.ElectronicCardValidationActivity; | 14 | import com.hjx.personalcenter.activity.ElectronicCardValidationActivity; |
| 14 | import com.mylhyl.circledialog.BaseCircleDialog; | 15 | import com.mylhyl.circledialog.BaseCircleDialog; |
| 15 | import com.mylhyl.circledialog.res.values.CircleDimen; | 16 | import com.mylhyl.circledialog.res.values.CircleDimen; |
| 16 | 17 | ||
| 17 | /** | 18 | /** |
| 18 | * Created by h on 2017/8/10. | 19 | * Created by h on 2017/8/10. |
| 19 | */ | 20 | */ |
| 20 | 21 | ||
| 21 | public class ElectronicCardDialog extends BaseCircleDialog { | 22 | public class ElectronicCardDialog extends BaseCircleDialog { |
| 23 | private ImageView cancel; | ||
| 22 | public static ElectronicCardDialog getInstance() { | 24 | public static ElectronicCardDialog getInstance() { |
| 23 | ElectronicCardDialog dialogFragment = new ElectronicCardDialog(); | 25 | ElectronicCardDialog dialogFragment = new ElectronicCardDialog(); |
| 24 | dialogFragment.setCanceledBack(true); | 26 | dialogFragment.setCanceledBack(true); |
| 25 | dialogFragment.setCanceledOnTouchOutside(true); | 27 | dialogFragment.setCanceledOnTouchOutside(true); |
| 26 | dialogFragment.setRadius(CircleDimen.RADIUS); | 28 | dialogFragment.setRadius(CircleDimen.RADIUS); |
| 27 | dialogFragment.setWidth(0.8f); | 29 | dialogFragment.setWidth(0.8f); |
| 28 | dialogFragment.setGravity(Gravity.CENTER); | 30 | dialogFragment.setGravity(Gravity.CENTER); |
| 29 | dialogFragment.setBackgroundColor(Color.WHITE); | 31 | dialogFragment.setBackgroundColor(Color.WHITE); |
| 30 | return dialogFragment; | 32 | return dialogFragment; |
| 31 | } | 33 | } |
| 32 | @Override | 34 | @Override |
| 33 | public View createView(Context context, LayoutInflater inflater, ViewGroup container) { | 35 | public View createView(Context context, LayoutInflater inflater, ViewGroup container) { |
| 34 | return inflater.inflate(R.layout.custom_adilog_electroniccard, container, false); | 36 | return inflater.inflate(R.layout.custom_adilog_electroniccard, container, false); |
| 35 | } | 37 | } |
| 36 | @Override | 38 | @Override |
| 37 | public void onActivityCreated(Bundle savedInstanceState) { | 39 | public void onActivityCreated(Bundle savedInstanceState) { |
| 38 | super.onActivityCreated(savedInstanceState); | 40 | super.onActivityCreated(savedInstanceState); |
| 39 | getView().findViewById(R.id.fill_card).setOnClickListener(new View.OnClickListener() { | 41 | getView().findViewById(R.id.fill_card).setOnClickListener(new View.OnClickListener() { |
| 40 | @Override | 42 | @Override |
| 41 | public void onClick(View v) { | 43 | public void onClick(View v) { |
| 42 | Intent intent = new Intent(); | 44 | Intent intent = new Intent(); |
| 43 | intent.setClass(getActivity(),ElectronicCardValidationActivity.class); | 45 | intent.setClass(getActivity(),ElectronicCardValidationActivity.class); |
| 44 | startActivity(intent); | 46 | startActivity(intent); |
| 45 | getActivity().overridePendingTransition(R.anim.rightin, R.anim.rightout); | 47 | getActivity().overridePendingTransition(R.anim.rightin, R.anim.rightout); |
| 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 | ||
| 52 | } | 60 | } |
| 53 | 61 |
PersonalCenter/app/src/main/java/com/hjx/personalcenter/http/HttpManager.java
| 1 | package com.hjx.personalcenter.http; | 1 | package com.hjx.personalcenter.http; |
| 2 | 2 | ||
| 3 | import android.app.Activity; | 3 | import android.app.Activity; |
| 4 | import android.app.ProgressDialog; | 4 | import android.app.ProgressDialog; |
| 5 | import android.content.Context; | 5 | import android.content.Context; |
| 6 | import android.content.Intent; | 6 | import android.content.Intent; |
| 7 | import android.os.Handler; | 7 | import android.os.Handler; |
| 8 | import android.os.Message; | 8 | import android.os.Message; |
| 9 | import android.provider.Settings; | 9 | import android.provider.Settings; |
| 10 | import android.support.v4.app.FragmentActivity; | 10 | import android.support.v4.app.FragmentActivity; |
| 11 | import android.util.Log; | 11 | import android.util.Log; |
| 12 | import android.view.Gravity; | 12 | import android.view.Gravity; |
| 13 | import android.view.View; | 13 | import android.view.View; |
| 14 | import android.widget.Toast; | 14 | import android.widget.Toast; |
| 15 | 15 | ||
| 16 | import com.google.gson.Gson; | 16 | import com.google.gson.Gson; |
| 17 | import com.hjx.personalcenter.R; | 17 | import com.hjx.personalcenter.R; |
| 18 | import com.hjx.personalcenter.activity.LoginAndRegisterActivity; | 18 | import com.hjx.personalcenter.activity.LoginAndRegisterActivity; |
| 19 | import com.hjx.personalcenter.activity.TheStartPageActivity; | 19 | import com.hjx.personalcenter.activity.TheStartPageActivity; |
| 20 | import com.hjx.personalcenter.db.SaveParam; | 20 | import com.hjx.personalcenter.db.SaveParam; |
| 21 | import com.hjx.personalcenter.gson.GsonTool; | 21 | import com.hjx.personalcenter.gson.GsonTool; |
| 22 | import com.hjx.personalcenter.model.AppVersion; | 22 | import com.hjx.personalcenter.model.AppVersion; |
| 23 | import com.hjx.personalcenter.model.CardInfo; | 23 | import com.hjx.personalcenter.model.CardInfo; |
| 24 | import com.hjx.personalcenter.model.ChildsInfo; | 24 | import com.hjx.personalcenter.model.ChildsInfo; |
| 25 | import com.hjx.personalcenter.model.CityInfo; | 25 | import com.hjx.personalcenter.model.CityInfo; |
| 26 | import com.hjx.personalcenter.model.CountyInfo; | 26 | import com.hjx.personalcenter.model.CountyInfo; |
| 27 | import com.hjx.personalcenter.model.GradeInfo; | 27 | import com.hjx.personalcenter.model.GradeInfo; |
| 28 | import com.hjx.personalcenter.model.PesonalInfo; | 28 | import com.hjx.personalcenter.model.PesonalInfo; |
| 29 | import com.hjx.personalcenter.model.ProvinceInfo; | 29 | import com.hjx.personalcenter.model.ProvinceInfo; |
| 30 | import com.hjx.personalcenter.model.SchoolInfo; | 30 | import com.hjx.personalcenter.model.SchoolInfo; |
| 31 | import com.hjx.personalcenter.model.SignInfo; | 31 | import com.hjx.personalcenter.model.SignInfo; |
| 32 | import com.hjx.personalcenter.util.AlertUtils; | 32 | import com.hjx.personalcenter.util.AlertUtils; |
| 33 | import com.hjx.personalcenter.util.DialogPermission; | 33 | import com.hjx.personalcenter.util.DialogPermission; |
| 34 | import com.loopj.android.http.AsyncHttpResponseHandler; | 34 | import com.loopj.android.http.AsyncHttpResponseHandler; |
| 35 | import com.loopj.android.http.JsonHttpResponseHandler; | 35 | import com.loopj.android.http.JsonHttpResponseHandler; |
| 36 | import com.loopj.android.http.RequestParams; | 36 | import com.loopj.android.http.RequestParams; |
| 37 | import com.mylhyl.circledialog.CircleDialog; | 37 | import com.mylhyl.circledialog.CircleDialog; |
| 38 | import com.mylhyl.circledialog.callback.ConfigText; | 38 | import com.mylhyl.circledialog.callback.ConfigText; |
| 39 | import com.mylhyl.circledialog.params.TextParams; | 39 | import com.mylhyl.circledialog.params.TextParams; |
| 40 | 40 | ||
| 41 | import org.apache.http.Header; | 41 | import org.apache.http.Header; |
| 42 | import org.apache.http.entity.ByteArrayEntity; | 42 | import org.apache.http.entity.ByteArrayEntity; |
| 43 | import org.apache.http.message.BasicHeader; | 43 | import org.apache.http.message.BasicHeader; |
| 44 | import org.apache.http.protocol.HTTP; | 44 | import org.apache.http.protocol.HTTP; |
| 45 | import org.json.JSONException; | 45 | import org.json.JSONException; |
| 46 | import org.json.JSONObject; | 46 | import org.json.JSONObject; |
| 47 | 47 | ||
| 48 | import java.io.File; | 48 | import java.io.File; |
| 49 | import java.io.FileNotFoundException; | 49 | import java.io.FileNotFoundException; |
| 50 | import java.io.UnsupportedEncodingException; | 50 | import java.io.UnsupportedEncodingException; |
| 51 | import java.util.ArrayList; | 51 | import java.util.ArrayList; |
| 52 | import java.util.List; | 52 | import java.util.List; |
| 53 | 53 | ||
| 54 | public class HttpManager { | 54 | public class HttpManager { |
| 55 | private static HttpManager instance; | 55 | private static HttpManager instance; |
| 56 | private ProgressDialog mProgress = null; | 56 | private ProgressDialog mProgress = null; |
| 57 | 57 | ||
| 58 | public static HttpManager getInstance() { | 58 | public static HttpManager getInstance() { |
| 59 | if (instance == null) { | 59 | if (instance == null) { |
| 60 | instance = new HttpManager(); | 60 | instance = new HttpManager(); |
| 61 | } | 61 | } |
| 62 | return instance; | 62 | return instance; |
| 63 | } | 63 | } |
| 64 | 64 | ||
| 65 | 65 | ||
| 66 | //登录接口 | 66 | //登录接口 |
| 67 | 67 | ||
| 68 | public void login(final String username, final String password, final Context mContext, final Handler handler) { | 68 | public void login(final String username, final String password, final Context mContext, final Handler handler) { |
| 69 | mProgress = DialogPermission.showProgress(mContext, null, "正在登录...", | 69 | mProgress = DialogPermission.showProgress(mContext, null, "正在登录...", |
| 70 | false, true, null); | 70 | false, true, null); |
| 71 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); | 71 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); |
| 72 | HttpClient.getInstance().get(HttpUrl.loginUrl + "?username=" + username + "&password=" + password, new AsyncHttpResponseHandler() { | 72 | HttpClient.getInstance().get(HttpUrl.loginUrl + "?username=" + username + "&password=" + password, new AsyncHttpResponseHandler() { |
| 73 | @Override | 73 | @Override |
| 74 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { | 74 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { |
| 75 | closeProgress(); | 75 | closeProgress(); |
| 76 | Message msg = Message.obtain(); | 76 | Message msg = Message.obtain(); |
| 77 | msg.what = HttpCode.LOGIN_SUCESS; | 77 | msg.what = HttpCode.LOGIN_SUCESS; |
| 78 | msg.obj = new String(arg2); | 78 | msg.obj = new String(arg2); |
| 79 | handler.sendMessage(msg); | 79 | handler.sendMessage(msg); |
| 80 | 80 | ||
| 81 | 81 | ||
| 82 | } | 82 | } |
| 83 | 83 | ||
| 84 | @Override | 84 | @Override |
| 85 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { | 85 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { |
| 86 | closeProgress(); | 86 | closeProgress(); |
| 87 | new CircleDialog.Builder((FragmentActivity) mContext) | 87 | new CircleDialog.Builder((FragmentActivity) mContext) |
| 88 | .setCanceledOnTouchOutside(false) | 88 | .setCanceledOnTouchOutside(false) |
| 89 | .setCancelable(false) | 89 | .setCancelable(false) |
| 90 | .setWidth(0.5f) | 90 | .setWidth(0.5f) |
| 91 | .configText(new ConfigText() { | 91 | .configText(new ConfigText() { |
| 92 | @Override | 92 | @Override |
| 93 | public void onConfig(TextParams params) { | 93 | public void onConfig(TextParams params) { |
| 94 | params.gravity = Gravity.CENTER; | 94 | params.gravity = Gravity.CENTER; |
| 95 | params.padding = new int[]{50, 50, 50, 50}; | 95 | params.padding = new int[]{50, 50, 50, 50}; |
| 96 | } | 96 | } |
| 97 | }) | 97 | }) |
| 98 | .setText("当前无网络,请检查网络设置") | 98 | .setText("当前无网络,请检查网络设置") |
| 99 | .setNegative("继续使用", null) | 99 | .setNegative("继续使用", null) |
| 100 | .setPositive("设置网络", new View.OnClickListener() { | 100 | .setPositive("设置网络", new View.OnClickListener() { |
| 101 | @Override | 101 | @Override |
| 102 | public void onClick(View v) { | 102 | public void onClick(View v) { |
| 103 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 | 103 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 |
| 104 | mContext.startActivity(intent); | 104 | mContext.startActivity(intent); |
| 105 | } | 105 | } |
| 106 | }) | 106 | }) |
| 107 | .show(); | 107 | .show(); |
| 108 | } | 108 | } |
| 109 | }); | 109 | }); |
| 110 | } | 110 | } |
| 111 | 111 | ||
| 112 | //注册接口 | 112 | //注册接口 |
| 113 | public void register(final Context context, String username, String password, String smscode, String source, final Handler handler) { | 113 | public void register(final Context context, String username, String password, String smscode, String source, final Handler handler) { |
| 114 | mProgress = DialogPermission.showProgress(context, null, "正在注册...", | 114 | mProgress = DialogPermission.showProgress(context, null, "正在注册...", |
| 115 | false, true, null); | 115 | false, true, null); |
| 116 | JSONObject jsonObject = new JSONObject(); | 116 | JSONObject jsonObject = new JSONObject(); |
| 117 | ByteArrayEntity entity = null; | 117 | ByteArrayEntity entity = null; |
| 118 | try { | 118 | try { |
| 119 | jsonObject.put(HttpKey.USERNAME, username); | 119 | jsonObject.put(HttpKey.USERNAME, username); |
| 120 | jsonObject.put(HttpKey.PASSWORD, password); | 120 | jsonObject.put(HttpKey.PASSWORD, password); |
| 121 | jsonObject.put(HttpKey.SMSCODE, smscode); | 121 | jsonObject.put(HttpKey.SMSCODE, smscode); |
| 122 | jsonObject.put(HttpKey.SOURCE, source); | 122 | jsonObject.put(HttpKey.SOURCE, source); |
| 123 | Log.e("test", "jsonObject" + jsonObject); | 123 | Log.e("test", "jsonObject" + jsonObject); |
| 124 | entity = new ByteArrayEntity(jsonObject.toString().getBytes("UTF-8")); | 124 | entity = new ByteArrayEntity(jsonObject.toString().getBytes("UTF-8")); |
| 125 | entity.setContentType(new BasicHeader(HTTP.CONTENT_TYPE, "application/json")); | 125 | entity.setContentType(new BasicHeader(HTTP.CONTENT_TYPE, "application/json")); |
| 126 | } catch (JSONException e) { | 126 | } catch (JSONException e) { |
| 127 | e.printStackTrace(); | 127 | e.printStackTrace(); |
| 128 | } catch (UnsupportedEncodingException e) { | 128 | } catch (UnsupportedEncodingException e) { |
| 129 | e.printStackTrace(); | 129 | e.printStackTrace(); |
| 130 | } | 130 | } |
| 131 | HttpClient.getInstance().addHeader("Accept", "*/*"); | 131 | HttpClient.getInstance().addHeader("Accept", "*/*"); |
| 132 | HttpClient.getInstance().post(context, HttpUrl.registeredUrl, entity, "application/json", new JsonHttpResponseHandler() { | 132 | HttpClient.getInstance().post(context, HttpUrl.registeredUrl, entity, "application/json", new JsonHttpResponseHandler() { |
| 133 | @Override | 133 | @Override |
| 134 | public void onSuccess(int statusCode, Header[] headers, JSONObject response) { | 134 | public void onSuccess(int statusCode, Header[] headers, JSONObject response) { |
| 135 | super.onSuccess(statusCode, headers, response); | 135 | super.onSuccess(statusCode, headers, response); |
| 136 | closeProgress(); | 136 | closeProgress(); |
| 137 | Log.e("test", "onSuccess" + response); | 137 | Log.e("test", "onSuccess" + response); |
| 138 | Message msg = Message.obtain(); | 138 | Message msg = Message.obtain(); |
| 139 | msg.what = HttpCode.REGISTERED_SUCESS; | 139 | msg.what = HttpCode.REGISTERED_SUCESS; |
| 140 | msg.obj = response; | 140 | msg.obj = response; |
| 141 | handler.sendMessage(msg); | 141 | handler.sendMessage(msg); |
| 142 | 142 | ||
| 143 | } | 143 | } |
| 144 | 144 | ||
| 145 | @Override | 145 | @Override |
| 146 | public void onFailure(int statusCode, Header[] headers, Throwable throwable, JSONObject errorResponse) { | 146 | public void onFailure(int statusCode, Header[] headers, Throwable throwable, JSONObject errorResponse) { |
| 147 | super.onFailure(statusCode, headers, throwable, errorResponse); | 147 | super.onFailure(statusCode, headers, throwable, errorResponse); |
| 148 | closeProgress(); | 148 | closeProgress(); |
| 149 | Log.e("test", "onFailure" + errorResponse); | 149 | Log.e("test", "onFailure" + errorResponse); |
| 150 | new CircleDialog.Builder((FragmentActivity) context) | 150 | new CircleDialog.Builder((FragmentActivity) context) |
| 151 | .setCanceledOnTouchOutside(false) | 151 | .setCanceledOnTouchOutside(false) |
| 152 | .setCancelable(false) | 152 | .setCancelable(false) |
| 153 | .setWidth(0.5f) | 153 | .setWidth(0.5f) |
| 154 | .configText(new ConfigText() { | 154 | .configText(new ConfigText() { |
| 155 | @Override | 155 | @Override |
| 156 | public void onConfig(TextParams params) { | 156 | public void onConfig(TextParams params) { |
| 157 | params.gravity = Gravity.CENTER; | 157 | params.gravity = Gravity.CENTER; |
| 158 | params.padding = new int[]{50, 50, 50, 50}; | 158 | params.padding = new int[]{50, 50, 50, 50}; |
| 159 | } | 159 | } |
| 160 | }) | 160 | }) |
| 161 | .setText("当前无网络,请检查网络设置") | 161 | .setText("当前无网络,请检查网络设置") |
| 162 | .setNegative("继续使用", null) | 162 | .setNegative("继续使用", null) |
| 163 | .setPositive("设置网络", new View.OnClickListener() { | 163 | .setPositive("设置网络", new View.OnClickListener() { |
| 164 | @Override | 164 | @Override |
| 165 | public void onClick(View v) { | 165 | public void onClick(View v) { |
| 166 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 | 166 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 |
| 167 | context.startActivity(intent); | 167 | context.startActivity(intent); |
| 168 | } | 168 | } |
| 169 | }) | 169 | }) |
| 170 | .show(); | 170 | .show(); |
| 171 | } | 171 | } |
| 172 | 172 | ||
| 173 | }); | 173 | }); |
| 174 | } | 174 | } |
| 175 | 175 | ||
| 176 | //注册验证码 | 176 | //注册验证码 |
| 177 | public void authCode(final String type, final String mobile, final Handler handler, final Context mContext) { | 177 | public void authCode(final String type, final String mobile, final Handler handler, final Context mContext) { |
| 178 | RequestParams params = new RequestParams(); | 178 | RequestParams params = new RequestParams(); |
| 179 | params.put(HttpKey.TYPE, type); | 179 | params.put(HttpKey.TYPE, type); |
| 180 | params.put(HttpKey.MOBIL, mobile); | 180 | params.put(HttpKey.MOBIL, mobile); |
| 181 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); | 181 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); |
| 182 | HttpClient.getInstance().post(HttpUrl.authCodedUrl, params, new JsonHttpResponseHandler() { | 182 | HttpClient.getInstance().post(HttpUrl.authCodedUrl, params, new JsonHttpResponseHandler() { |
| 183 | 183 | ||
| 184 | @Override | 184 | @Override |
| 185 | public void onSuccess(int statusCode, Header[] headers, JSONObject response) { | 185 | public void onSuccess(int statusCode, Header[] headers, JSONObject response) { |
| 186 | Log.e("test", "onSuccess-----" + response); | 186 | Log.e("test", "onSuccess-----" + response); |
| 187 | Message msg = Message.obtain(); | 187 | Message msg = Message.obtain(); |
| 188 | msg.what = HttpCode.AUTHCODE_SUCESS; | 188 | msg.what = HttpCode.AUTHCODE_SUCESS; |
| 189 | msg.obj = response; | 189 | msg.obj = response; |
| 190 | handler.sendMessage(msg); | 190 | handler.sendMessage(msg); |
| 191 | } | 191 | } |
| 192 | 192 | ||
| 193 | @Override | 193 | @Override |
| 194 | public void onFailure(int statusCode, Header[] headers, Throwable throwable, JSONObject errorResponse) { | 194 | public void onFailure(int statusCode, Header[] headers, Throwable throwable, JSONObject errorResponse) { |
| 195 | new CircleDialog.Builder((FragmentActivity) mContext) | 195 | new CircleDialog.Builder((FragmentActivity) mContext) |
| 196 | .setCanceledOnTouchOutside(false) | 196 | .setCanceledOnTouchOutside(false) |
| 197 | .setCancelable(false) | 197 | .setCancelable(false) |
| 198 | .setWidth(0.5f) | 198 | .setWidth(0.5f) |
| 199 | .configText(new ConfigText() { | 199 | .configText(new ConfigText() { |
| 200 | @Override | 200 | @Override |
| 201 | public void onConfig(TextParams params) { | 201 | public void onConfig(TextParams params) { |
| 202 | params.gravity = Gravity.CENTER; | 202 | params.gravity = Gravity.CENTER; |
| 203 | params.padding = new int[]{50, 50, 50, 50}; | 203 | params.padding = new int[]{50, 50, 50, 50}; |
| 204 | } | 204 | } |
| 205 | }) | 205 | }) |
| 206 | .setText("当前无网络,请检查网络设置") | 206 | .setText("当前无网络,请检查网络设置") |
| 207 | .setNegative("继续使用", null) | 207 | .setNegative("继续使用", null) |
| 208 | .setPositive("设置网络", new View.OnClickListener() { | 208 | .setPositive("设置网络", new View.OnClickListener() { |
| 209 | @Override | 209 | @Override |
| 210 | public void onClick(View v) { | 210 | public void onClick(View v) { |
| 211 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 | 211 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 |
| 212 | mContext.startActivity(intent); | 212 | mContext.startActivity(intent); |
| 213 | } | 213 | } |
| 214 | }) | 214 | }) |
| 215 | .show(); | 215 | .show(); |
| 216 | } | 216 | } |
| 217 | }); | 217 | }); |
| 218 | } | 218 | } |
| 219 | 219 | ||
| 220 | 220 | ||
| 221 | //手机号是否注册 | 221 | //手机号是否注册 |
| 222 | public void isregistered(final String mobile, final Handler handler, final Context mContext) { | 222 | public void isregistered(final String mobile, final Handler handler, final Context mContext) { |
| 223 | RequestParams params = new RequestParams(); | 223 | RequestParams params = new RequestParams(); |
| 224 | params.put(HttpKey.USERNAME, mobile); | 224 | params.put(HttpKey.USERNAME, mobile); |
| 225 | HttpClient.getInstance().get(HttpUrl.isRegiterUrl + "?mobile=" + mobile, new JsonHttpResponseHandler() { | 225 | HttpClient.getInstance().get(HttpUrl.isRegiterUrl + "?mobile=" + mobile, new JsonHttpResponseHandler() { |
| 226 | @Override | 226 | @Override |
| 227 | public void onSuccess(int statusCode, Header[] headers, JSONObject response) { | 227 | public void onSuccess(int statusCode, Header[] headers, JSONObject response) { |
| 228 | Log.e("test", "isregistered" + response.toString()); | 228 | Log.e("test", "isregistered" + response.toString()); |
| 229 | Message msg = Message.obtain(); | 229 | Message msg = Message.obtain(); |
| 230 | msg.what = HttpCode.IS_REFISTER; | 230 | msg.what = HttpCode.IS_REFISTER; |
| 231 | msg.obj = response; | 231 | msg.obj = response; |
| 232 | handler.sendMessage(msg); | 232 | handler.sendMessage(msg); |
| 233 | 233 | ||
| 234 | } | 234 | } |
| 235 | 235 | ||
| 236 | @Override | 236 | @Override |
| 237 | public void onFailure(int statusCode, Header[] headers, Throwable throwable, JSONObject errorResponse) { | 237 | public void onFailure(int statusCode, Header[] headers, Throwable throwable, JSONObject errorResponse) { |
| 238 | new CircleDialog.Builder((FragmentActivity) mContext) | 238 | new CircleDialog.Builder((FragmentActivity) mContext) |
| 239 | .setCanceledOnTouchOutside(false) | 239 | .setCanceledOnTouchOutside(false) |
| 240 | .setCancelable(false) | 240 | .setCancelable(false) |
| 241 | .setWidth(0.5f) | 241 | .setWidth(0.5f) |
| 242 | .configText(new ConfigText() { | 242 | .configText(new ConfigText() { |
| 243 | @Override | 243 | @Override |
| 244 | public void onConfig(TextParams params) { | 244 | public void onConfig(TextParams params) { |
| 245 | params.gravity = Gravity.CENTER; | 245 | params.gravity = Gravity.CENTER; |
| 246 | params.padding = new int[]{50, 50, 50, 50}; | 246 | params.padding = new int[]{50, 50, 50, 50}; |
| 247 | } | 247 | } |
| 248 | }) | 248 | }) |
| 249 | .setText("当前无网络,请检查网络设置") | 249 | .setText("当前无网络,请检查网络设置") |
| 250 | .setNegative("继续使用", null) | 250 | .setNegative("继续使用", null) |
| 251 | .setPositive("设置网络", new View.OnClickListener() { | 251 | .setPositive("设置网络", new View.OnClickListener() { |
| 252 | @Override | 252 | @Override |
| 253 | public void onClick(View v) { | 253 | public void onClick(View v) { |
| 254 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 | 254 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 |
| 255 | mContext.startActivity(intent); | 255 | mContext.startActivity(intent); |
| 256 | } | 256 | } |
| 257 | }) | 257 | }) |
| 258 | .show(); | 258 | .show(); |
| 259 | 259 | ||
| 260 | } | 260 | } |
| 261 | }); | 261 | }); |
| 262 | } | 262 | } |
| 263 | 263 | ||
| 264 | //修改密码 | 264 | //修改密码 |
| 265 | public void changepwd(final Context context, String username, String old_pwd1, String newpassword3) { | 265 | public void changepwd(final Context context, String username, String old_pwd1, String newpassword3) { |
| 266 | RequestParams params = new RequestParams(); | 266 | RequestParams params = new RequestParams(); |
| 267 | params.put(HttpKey.USERNAME, username); | 267 | params.put(HttpKey.USERNAME, username); |
| 268 | params.put(HttpKey.OLDPASS, old_pwd1); | 268 | params.put(HttpKey.OLDPASS, old_pwd1); |
| 269 | params.put(HttpKey.NEWPASS, newpassword3); | 269 | params.put(HttpKey.NEWPASS, newpassword3); |
| 270 | HttpClient.getInstance().addHeader("Accept", "*/*"); | 270 | HttpClient.getInstance().addHeader("Accept", "*/*"); |
| 271 | HttpClient.getInstance().setTimeout(10 * 1000); | 271 | HttpClient.getInstance().setTimeout(10 * 1000); |
| 272 | HttpClient.getInstance().post(HttpUrl.changepassword, params, new AsyncHttpResponseHandler() { | 272 | HttpClient.getInstance().post(HttpUrl.changepassword, params, new AsyncHttpResponseHandler() { |
| 273 | @Override | 273 | @Override |
| 274 | public void onSuccess(int i, Header[] headers, byte[] bytes) { | 274 | public void onSuccess(int i, Header[] headers, byte[] bytes) { |
| 275 | try { | 275 | try { |
| 276 | JSONObject jsonObject = new JSONObject(new String(bytes)); | 276 | JSONObject jsonObject = new JSONObject(new String(bytes)); |
| 277 | String status = jsonObject.optString("status"); | 277 | String status = jsonObject.optString("status"); |
| 278 | if (status.equals("100")) { | 278 | if (status.equals("100")) { |
| 279 | Log.e("test", "onSuccess" + new String(bytes)); | 279 | Log.e("test", "onSuccess" + new String(bytes)); |
| 280 | Toast.makeText(context, "密码修改成功!", Toast.LENGTH_LONG).show(); | 280 | Toast.makeText(context, "密码修改成功!", Toast.LENGTH_LONG).show(); |
| 281 | SaveParam.getInstance().clearData((Activity) context); | 281 | SaveParam.getInstance().clearData((Activity) context); |
| 282 | Intent intent = new Intent(); | 282 | Intent intent = new Intent(); |
| 283 | intent.setClass(context, LoginAndRegisterActivity.class); | 283 | intent.setClass(context, LoginAndRegisterActivity.class); |
| 284 | ((Activity) context).startActivity(intent); | 284 | ((Activity) context).startActivity(intent); |
| 285 | ((Activity) context).finish(); | 285 | ((Activity) context).finish(); |
| 286 | } else { | 286 | } else { |
| 287 | Toast.makeText(context, "密码修改失败!", Toast.LENGTH_LONG).show(); | 287 | Toast.makeText(context, "密码修改失败!", Toast.LENGTH_LONG).show(); |
| 288 | } | 288 | } |
| 289 | } catch (JSONException e) { | 289 | } catch (JSONException e) { |
| 290 | e.printStackTrace(); | 290 | e.printStackTrace(); |
| 291 | } | 291 | } |
| 292 | } | 292 | } |
| 293 | 293 | ||
| 294 | @Override | 294 | @Override |
| 295 | public void onFailure(int i, Header[] headers, byte[] bytes, Throwable throwable) { | 295 | public void onFailure(int i, Header[] headers, byte[] bytes, Throwable throwable) { |
| 296 | Log.e("test", "onFailure" + new String(bytes)); | 296 | Log.e("test", "onFailure" + new String(bytes)); |
| 297 | new CircleDialog.Builder((FragmentActivity) context) | 297 | new CircleDialog.Builder((FragmentActivity) context) |
| 298 | .setCanceledOnTouchOutside(false) | 298 | .setCanceledOnTouchOutside(false) |
| 299 | .setCancelable(false) | 299 | .setCancelable(false) |
| 300 | .setWidth(0.5f) | 300 | .setWidth(0.5f) |
| 301 | .configText(new ConfigText() { | 301 | .configText(new ConfigText() { |
| 302 | @Override | 302 | @Override |
| 303 | public void onConfig(TextParams params) { | 303 | public void onConfig(TextParams params) { |
| 304 | params.gravity = Gravity.CENTER; | 304 | params.gravity = Gravity.CENTER; |
| 305 | params.padding = new int[]{50, 50, 50, 50}; | 305 | params.padding = new int[]{50, 50, 50, 50}; |
| 306 | } | 306 | } |
| 307 | }) | 307 | }) |
| 308 | .setText("当前无网络,请检查网络设置") | 308 | .setText("当前无网络,请检查网络设置") |
| 309 | .setNegative("继续使用", null) | 309 | .setNegative("继续使用", null) |
| 310 | .setPositive("设置网络", new View.OnClickListener() { | 310 | .setPositive("设置网络", new View.OnClickListener() { |
| 311 | @Override | 311 | @Override |
| 312 | public void onClick(View v) { | 312 | public void onClick(View v) { |
| 313 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 | 313 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 |
| 314 | context.startActivity(intent); | 314 | context.startActivity(intent); |
| 315 | } | 315 | } |
| 316 | }) | 316 | }) |
| 317 | .show(); | 317 | .show(); |
| 318 | } | 318 | } |
| 319 | }); | 319 | }); |
| 320 | 320 | ||
| 321 | } | 321 | } |
| 322 | 322 | ||
| 323 | //忘记密码 | 323 | //忘记密码 |
| 324 | public void forgetpassword(final Context context, String forot_pwd_phone1, String forot_pwd_pwd3, String forot_pwd_anthcode1, Handler handler) { | 324 | public void forgetpassword(final Context context, String forot_pwd_phone1, String forot_pwd_pwd3, String forot_pwd_anthcode1, Handler handler) { |
| 325 | RequestParams params = new RequestParams(); | 325 | RequestParams params = new RequestParams(); |
| 326 | params.put(HttpKey.USERNAME, forot_pwd_phone1); | 326 | params.put(HttpKey.USERNAME, forot_pwd_phone1); |
| 327 | params.put(HttpKey.PASSWORD, forot_pwd_pwd3); | 327 | params.put(HttpKey.PASSWORD, forot_pwd_pwd3); |
| 328 | params.put(HttpKey.AUTHCODE, forot_pwd_anthcode1); | 328 | params.put(HttpKey.AUTHCODE, forot_pwd_anthcode1); |
| 329 | HttpClient.getInstance().addHeader("Accept", "*/*"); | 329 | HttpClient.getInstance().addHeader("Accept", "*/*"); |
| 330 | HttpClient.getInstance().post(HttpUrl.forgetpassword, params, new AsyncHttpResponseHandler() { | 330 | HttpClient.getInstance().post(HttpUrl.forgetpassword, params, new AsyncHttpResponseHandler() { |
| 331 | @Override | 331 | @Override |
| 332 | public void onSuccess(int i, Header[] headers, byte[] bytes) { | 332 | public void onSuccess(int i, Header[] headers, byte[] bytes) { |
| 333 | try { | 333 | try { |
| 334 | JSONObject jsonObject = new JSONObject(new String(bytes)); | 334 | JSONObject jsonObject = new JSONObject(new String(bytes)); |
| 335 | String status = jsonObject.optString("status"); | 335 | String status = jsonObject.optString("status"); |
| 336 | if (status.equals("100")) { | 336 | if (status.equals("100")) { |
| 337 | Log.e("test", "onSuccess" + new String(bytes)); | 337 | Log.e("test", "onSuccess" + new String(bytes)); |
| 338 | Toast.makeText(context, "密码修改成功!", Toast.LENGTH_LONG).show(); | 338 | Toast.makeText(context, "密码修改成功!", Toast.LENGTH_LONG).show(); |
| 339 | ((Activity) context).finish(); | 339 | ((Activity) context).finish(); |
| 340 | } else { | 340 | } else { |
| 341 | Toast.makeText(context, "密码修改失败!", Toast.LENGTH_LONG).show(); | 341 | Toast.makeText(context, "密码修改失败!", Toast.LENGTH_LONG).show(); |
| 342 | } | 342 | } |
| 343 | } catch (JSONException e) { | 343 | } catch (JSONException e) { |
| 344 | e.printStackTrace(); | 344 | e.printStackTrace(); |
| 345 | } | 345 | } |
| 346 | } | 346 | } |
| 347 | 347 | ||
| 348 | @Override | 348 | @Override |
| 349 | public void onFailure(int i, Header[] headers, byte[] bytes, Throwable throwable) { | 349 | public void onFailure(int i, Header[] headers, byte[] bytes, Throwable throwable) { |
| 350 | Log.e("test", "onFailure" + new String(bytes)); | 350 | Log.e("test", "onFailure" + new String(bytes)); |
| 351 | new CircleDialog.Builder((FragmentActivity) context) | 351 | new CircleDialog.Builder((FragmentActivity) context) |
| 352 | .setCanceledOnTouchOutside(false) | 352 | .setCanceledOnTouchOutside(false) |
| 353 | .setCancelable(false) | 353 | .setCancelable(false) |
| 354 | .setWidth(0.5f) | 354 | .setWidth(0.5f) |
| 355 | .configText(new ConfigText() { | 355 | .configText(new ConfigText() { |
| 356 | @Override | 356 | @Override |
| 357 | public void onConfig(TextParams params) { | 357 | public void onConfig(TextParams params) { |
| 358 | params.gravity = Gravity.CENTER; | 358 | params.gravity = Gravity.CENTER; |
| 359 | params.padding = new int[]{50, 50, 50, 50}; | 359 | params.padding = new int[]{50, 50, 50, 50}; |
| 360 | } | 360 | } |
| 361 | }) | 361 | }) |
| 362 | .setText("当前无网络,请检查网络设置") | 362 | .setText("当前无网络,请检查网络设置") |
| 363 | .setNegative("继续使用", null) | 363 | .setNegative("继续使用", null) |
| 364 | .setPositive("设置网络", new View.OnClickListener() { | 364 | .setPositive("设置网络", new View.OnClickListener() { |
| 365 | @Override | 365 | @Override |
| 366 | public void onClick(View v) { | 366 | public void onClick(View v) { |
| 367 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 | 367 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 |
| 368 | context.startActivity(intent); | 368 | context.startActivity(intent); |
| 369 | } | 369 | } |
| 370 | }) | 370 | }) |
| 371 | .show(); | 371 | .show(); |
| 372 | } | 372 | } |
| 373 | }); | 373 | }); |
| 374 | 374 | ||
| 375 | } | 375 | } |
| 376 | 376 | ||
| 377 | //保存用户登录信息 | 377 | //保存用户登录信息 |
| 378 | public void saveLoginInfo(Context context, String username, String password, String access_token, String loginStatus, String userId) { | 378 | public void saveLoginInfo(Context context, String username, String password, String access_token, String loginStatus, String userId) { |
| 379 | SaveParam.getInstance().saveLoginParam(context, "username", username); | 379 | SaveParam.getInstance().saveLoginParam(context, "username", username); |
| 380 | SaveParam.getInstance().saveLoginParam(context, "password", password); | 380 | SaveParam.getInstance().saveLoginParam(context, "password", password); |
| 381 | SaveParam.getInstance().saveLoginParam(context, "access_token", access_token); | 381 | SaveParam.getInstance().saveLoginParam(context, "access_token", access_token); |
| 382 | SaveParam.getInstance().saveLoginParam(context, "login", loginStatus); | 382 | SaveParam.getInstance().saveLoginParam(context, "login", loginStatus); |
| 383 | SaveParam.getInstance().saveLoginParam(context, "userId", userId); | 383 | SaveParam.getInstance().saveLoginParam(context, "userId", userId); |
| 384 | 384 | ||
| 385 | 385 | ||
| 386 | } | 386 | } |
| 387 | 387 | ||
| 388 | //提交保卡信息 | 388 | //提交保卡信息 |
| 389 | public void subcardinfo(final Context context, long userId, String customerName, String customerAddress, | 389 | public void subcardinfo(final Context context, long userId, String customerName, String customerAddress, |
| 390 | String buyAddress, String buyTime, String alterSaleCall, | 390 | String buyAddress, String buyTime, String alterSaleCall, |
| 391 | String productModel, String deviceNumber, String macAddress, | 391 | String productModel, String deviceNumber, String macAddress, |
| 392 | String mobilePhone) { | 392 | String mobilePhone) { |
| 393 | mProgress = DialogPermission.showProgress(context, null, "正在绑定保卡...", | 393 | mProgress = DialogPermission.showProgress(context, null, "正在绑定保卡...", |
| 394 | false, true, null); | 394 | false, true, null); |
| 395 | RequestParams params = new RequestParams(); | 395 | RequestParams params = new RequestParams(); |
| 396 | 396 | ||
| 397 | params.put(HttpKey.USEID, userId); | 397 | params.put(HttpKey.USEID, userId); |
| 398 | params.put(HttpKey.CUSTOMENAME, customerName); | 398 | params.put(HttpKey.CUSTOMENAME, customerName); |
| 399 | params.put(HttpKey.CUSTOMADRESS, customerAddress); | 399 | params.put(HttpKey.CUSTOMADRESS, customerAddress); |
| 400 | params.put(HttpKey.BUYADREES, buyAddress); | 400 | params.put(HttpKey.BUYADREES, buyAddress); |
| 401 | params.put(HttpKey.BUYTIME, buyTime); | 401 | params.put(HttpKey.BUYTIME, buyTime); |
| 402 | params.put(HttpKey.ALTERSALECALL, alterSaleCall); | 402 | params.put(HttpKey.ALTERSALECALL, alterSaleCall); |
| 403 | params.put(HttpKey.PRODUCTMODEL, productModel); | 403 | params.put(HttpKey.PRODUCTMODEL, productModel); |
| 404 | params.put(HttpKey.DEVICENUMBER, deviceNumber); | 404 | params.put(HttpKey.DEVICENUMBER, deviceNumber); |
| 405 | params.put(HttpKey.MACADRESS, macAddress); | 405 | params.put(HttpKey.MACADRESS, macAddress); |
| 406 | params.put(HttpKey.MOBILPHONE, mobilePhone); | 406 | params.put(HttpKey.MOBILPHONE, mobilePhone); |
| 407 | 407 | ||
| 408 | HttpClient.getInstance().addHeader("Accept", "*/*"); | 408 | HttpClient.getInstance().addHeader("Accept", "*/*"); |
| 409 | 409 | ||
| 410 | Log.e("test", "params" + params); | 410 | Log.e("test", "params" + params); |
| 411 | HttpClient.getInstance().setTimeout(5 * 1000); | 411 | HttpClient.getInstance().setTimeout(5 * 1000); |
| 412 | HttpClient.getInstance().post(context, HttpUrl.subcardinfo, params, new AsyncHttpResponseHandler() { | 412 | HttpClient.getInstance().post(context, HttpUrl.subcardinfo, params, new AsyncHttpResponseHandler() { |
| 413 | @Override | 413 | @Override |
| 414 | public void onSuccess(int i, Header[] headers, byte[] bytes) { | 414 | public void onSuccess(int i, Header[] headers, byte[] bytes) { |
| 415 | JSONObject jsonObject = null; | 415 | JSONObject jsonObject = null; |
| 416 | closeProgress(); | 416 | closeProgress(); |
| 417 | try { | 417 | try { |
| 418 | jsonObject = new JSONObject(new String(bytes)); | 418 | jsonObject = new JSONObject(new String(bytes)); |
| 419 | String status = jsonObject.optString("status"); | 419 | String status = jsonObject.optString("status"); |
| 420 | if (status.equals("1")) { | 420 | if (status.equals("1")) { |
| 421 | Log.e("test", "onSuccess" + jsonObject); | 421 | Log.e("test", "onSuccess" + jsonObject); |
| 422 | Toast.makeText(context, "保卡绑定成功!", Toast.LENGTH_LONG).show(); | 422 | Toast.makeText(context, "保卡绑定成功!", Toast.LENGTH_LONG).show(); |
| 423 | Intent intent = new Intent(); | 423 | Intent intent = new Intent(); |
| 424 | intent.setClass((Activity) context, TheStartPageActivity.class); | 424 | intent.setClass((Activity) context, TheStartPageActivity.class); |
| 425 | ((Activity) context).startActivity(intent); | 425 | ((Activity) context).startActivity(intent); |
| 426 | ((Activity) context).overridePendingTransition(R.anim.rightin, R.anim.rightout); | 426 | ((Activity) context).overridePendingTransition(R.anim.rightin, R.anim.rightout); |
| 427 | ((Activity) context).finish(); | 427 | ((Activity) context).finish(); |
| 428 | } else { | 428 | } else { |
| 429 | Toast.makeText(context, "保卡绑定失败!", Toast.LENGTH_LONG).show(); | 429 | Toast.makeText(context, "保卡绑定失败!", Toast.LENGTH_LONG).show(); |
| 430 | } | 430 | } |
| 431 | } catch (JSONException e) { | 431 | } catch (JSONException e) { |
| 432 | e.printStackTrace(); | 432 | e.printStackTrace(); |
| 433 | } | 433 | } |
| 434 | 434 | ||
| 435 | 435 | ||
| 436 | } | 436 | } |
| 437 | 437 | ||
| 438 | @Override | 438 | @Override |
| 439 | public void onFailure(int i, Header[] headers, byte[] bytes, Throwable throwable) { | 439 | public void onFailure(int i, Header[] headers, byte[] bytes, Throwable throwable) { |
| 440 | Log.e("test", "onFailure" + (throwable)); | 440 | Log.e("test", "onFailure" + (throwable)); |
| 441 | closeProgress(); | 441 | closeProgress(); |
| 442 | new CircleDialog.Builder((FragmentActivity) context) | 442 | new CircleDialog.Builder((FragmentActivity) context) |
| 443 | .setCanceledOnTouchOutside(false) | 443 | .setCanceledOnTouchOutside(false) |
| 444 | .setCancelable(false) | 444 | .setCancelable(false) |
| 445 | .setWidth(0.5f) | 445 | .setWidth(0.5f) |
| 446 | .configText(new ConfigText() { | 446 | .configText(new ConfigText() { |
| 447 | @Override | 447 | @Override |
| 448 | public void onConfig(TextParams params) { | 448 | public void onConfig(TextParams params) { |
| 449 | params.gravity = Gravity.CENTER; | 449 | params.gravity = Gravity.CENTER; |
| 450 | params.padding = new int[]{50, 50, 50, 50}; | 450 | params.padding = new int[]{50, 50, 50, 50}; |
| 451 | } | 451 | } |
| 452 | }) | 452 | }) |
| 453 | .setText("当前无网络,请检查网络设置") | 453 | .setText("当前无网络,请检查网络设置") |
| 454 | .setNegative("继续使用", null) | 454 | .setNegative("继续使用", null) |
| 455 | .setPositive("设置网络", new View.OnClickListener() { | 455 | .setPositive("设置网络", new View.OnClickListener() { |
| 456 | @Override | 456 | @Override |
| 457 | public void onClick(View v) { | 457 | public void onClick(View v) { |
| 458 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 | 458 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 |
| 459 | context.startActivity(intent); | 459 | context.startActivity(intent); |
| 460 | } | 460 | } |
| 461 | }) | 461 | }) |
| 462 | .show(); | 462 | .show(); |
| 463 | 463 | ||
| 464 | } | 464 | } |
| 465 | }); | 465 | }); |
| 466 | 466 | ||
| 467 | } | 467 | } |
| 468 | 468 | ||
| 469 | //获取保卡信息 | 469 | //获取保卡信息 |
| 470 | public void getcardinfo(final Context mContext, long userId, final Handler handler) { | 470 | public void getcardinfo(final Context mContext, long userId, final Handler handler) { |
| 471 | mProgress = DialogPermission.showProgress(mContext, null, "正在获取保卡信息...", | 471 | mProgress = DialogPermission.showProgress(mContext, null, "正在获取保卡信息...", |
| 472 | false, true, null); | 472 | false, true, null); |
| 473 | HttpClient.getInstance().setTimeout(5 * 1000); | 473 | HttpClient.getInstance().setTimeout(5 * 1000); |
| 474 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); | 474 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); |
| 475 | HttpClient.getInstance().get(HttpUrl.getcardinfo + "?userId=" + userId, new AsyncHttpResponseHandler() { | 475 | HttpClient.getInstance().get(HttpUrl.getcardinfo + "?userId=" + userId, new AsyncHttpResponseHandler() { |
| 476 | @Override | 476 | @Override |
| 477 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { | 477 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { |
| 478 | closeProgress(); | 478 | closeProgress(); |
| 479 | Log.e("test", "保卡信息" + new String(arg2)); | 479 | Log.e("test", "保卡信息" + new String(arg2)); |
| 480 | try { | 480 | try { |
| 481 | JSONObject jsonObject = new JSONObject(new String(arg2)); | 481 | JSONObject jsonObject = new JSONObject(new String(arg2)); |
| 482 | int status = jsonObject.optInt("status"); | 482 | int status = jsonObject.optInt("status"); |
| 483 | if (status == 1) { | 483 | if (status == 1) { |
| 484 | CardInfo cardInfo = GsonTool.getPerson(new String(arg2), CardInfo.class);//解析json数据 | 484 | CardInfo cardInfo = GsonTool.getPerson(new String(arg2), CardInfo.class);//解析json数据 |
| 485 | CardInfo.DataBean schoolInfoBeanList = cardInfo.getData(); | 485 | CardInfo.DataBean schoolInfoBeanList = cardInfo.getData(); |
| 486 | Message msg = Message.obtain(); | 486 | Message msg = Message.obtain(); |
| 487 | msg.what = HttpCode.SUCHCARDINFO; | 487 | msg.what = HttpCode.SUCHCARDINFO; |
| 488 | msg.obj = schoolInfoBeanList; | 488 | msg.obj = schoolInfoBeanList; |
| 489 | handler.sendMessage(msg); | 489 | handler.sendMessage(msg); |
| 490 | 490 | ||
| 491 | 491 | ||
| 492 | } else { | 492 | } else { |
| 493 | AlertUtils.showToast(mContext, "你好,服务器异常,请稍后重试!"); | 493 | AlertUtils.showToast(mContext, "你好,服务器异常,请稍后重试!"); |
| 494 | 494 | ||
| 495 | } | 495 | } |
| 496 | } catch (JSONException e) { | 496 | } catch (JSONException e) { |
| 497 | e.printStackTrace(); | 497 | e.printStackTrace(); |
| 498 | } | 498 | } |
| 499 | 499 | ||
| 500 | } | 500 | } |
| 501 | 501 | ||
| 502 | @Override | 502 | @Override |
| 503 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { | 503 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { |
| 504 | closeProgress(); | 504 | closeProgress(); |
| 505 | new CircleDialog.Builder((FragmentActivity) mContext) | 505 | new CircleDialog.Builder((FragmentActivity) mContext) |
| 506 | .setCanceledOnTouchOutside(false) | 506 | .setCanceledOnTouchOutside(false) |
| 507 | .setCancelable(false) | 507 | .setCancelable(false) |
| 508 | .setWidth(0.5f) | 508 | .setWidth(0.5f) |
| 509 | .configText(new ConfigText() { | 509 | .configText(new ConfigText() { |
| 510 | @Override | 510 | @Override |
| 511 | public void onConfig(TextParams params) { | 511 | public void onConfig(TextParams params) { |
| 512 | params.gravity = Gravity.CENTER; | 512 | params.gravity = Gravity.CENTER; |
| 513 | params.padding = new int[]{50, 50, 50, 50}; | 513 | params.padding = new int[]{50, 50, 50, 50}; |
| 514 | } | 514 | } |
| 515 | }) | 515 | }) |
| 516 | .setText("当前无网络,请检查网络设置") | 516 | .setText("当前无网络,请检查网络设置") |
| 517 | .setNegative("继续使用", null) | 517 | .setNegative("继续使用", null) |
| 518 | .setPositive("设置网络", new View.OnClickListener() { | 518 | .setPositive("设置网络", new View.OnClickListener() { |
| 519 | @Override | 519 | @Override |
| 520 | public void onClick(View v) { | 520 | public void onClick(View v) { |
| 521 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 | 521 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 |
| 522 | mContext.startActivity(intent); | 522 | mContext.startActivity(intent); |
| 523 | } | 523 | } |
| 524 | }) | 524 | }) |
| 525 | .show(); | 525 | .show(); |
| 526 | } | 526 | } |
| 527 | }); | 527 | }); |
| 528 | } | 528 | } |
| 529 | 529 | ||
| 530 | //修改保卡信息电话 | 530 | //修改保卡信息电话 |
| 531 | public void changecardinfophone(final Context mContext, long userId, final String customerPhone, String authCode) { | 531 | public void changecardinfophone(final Context mContext, long userId, final String customerPhone, String authCode) { |
| 532 | RequestParams params = new RequestParams(); | 532 | RequestParams params = new RequestParams(); |
| 533 | params.put("userId", userId); | 533 | params.put("userId", userId); |
| 534 | params.put("customerPhone", customerPhone); | 534 | params.put("customerPhone", customerPhone); |
| 535 | params.put("authCode", authCode); | 535 | params.put("authCode", authCode); |
| 536 | HttpClient.getInstance().addHeader("Accept", "*/*"); | 536 | HttpClient.getInstance().addHeader("Accept", "*/*"); |
| 537 | HttpClient.getInstance().post(HttpUrl.changecardinfo, params, new AsyncHttpResponseHandler() { | 537 | HttpClient.getInstance().post(HttpUrl.changecardinfo, params, new AsyncHttpResponseHandler() { |
| 538 | @Override | 538 | @Override |
| 539 | public void onSuccess(int i, Header[] headers, byte[] bytes) { | 539 | public void onSuccess(int i, Header[] headers, byte[] bytes) { |
| 540 | try { | 540 | try { |
| 541 | JSONObject jsonObject = new JSONObject(new String(bytes)); | 541 | JSONObject jsonObject = new JSONObject(new String(bytes)); |
| 542 | String status = jsonObject.optString("status"); | 542 | String status = jsonObject.optString("status"); |
| 543 | if (status.equals("1")) { | 543 | if (status.equals("1")) { |
| 544 | Toast.makeText(mContext, "手机号修改成功", Toast.LENGTH_LONG).show(); | 544 | Toast.makeText(mContext, "手机号修改成功", Toast.LENGTH_LONG).show(); |
| 545 | SaveParam.getInstance().saveCustomizeParam(mContext, SaveParam.CARDPHONE, customerPhone); | 545 | SaveParam.getInstance().saveCustomizeParam(mContext, SaveParam.CARDPHONE, customerPhone); |
| 546 | ((Activity) mContext).finish(); | 546 | ((Activity) mContext).finish(); |
| 547 | } else if (status.equals("1001")) { | 547 | } else if (status.equals("1001")) { |
| 548 | Toast.makeText(mContext, "验证码输入错误", Toast.LENGTH_LONG).show(); | 548 | Toast.makeText(mContext, "验证码输入错误", Toast.LENGTH_LONG).show(); |
| 549 | } else { | 549 | } else { |
| 550 | AlertUtils.showToast(mContext, "您好,服务器异常,请稍后重试"); | 550 | AlertUtils.showToast(mContext, "您好,服务器异常,请稍后重试"); |
| 551 | } | 551 | } |
| 552 | } catch (JSONException e) { | 552 | } catch (JSONException e) { |
| 553 | e.printStackTrace(); | 553 | e.printStackTrace(); |
| 554 | } | 554 | } |
| 555 | } | 555 | } |
| 556 | 556 | ||
| 557 | @Override | 557 | @Override |
| 558 | public void onFailure(int i, Header[] headers, byte[] bytes, Throwable throwable) { | 558 | public void onFailure(int i, Header[] headers, byte[] bytes, Throwable throwable) { |
| 559 | Log.e("test", "onFailure" + new String(bytes)); | 559 | Log.e("test", "onFailure" + new String(bytes)); |
| 560 | new CircleDialog.Builder((FragmentActivity) mContext) | 560 | new CircleDialog.Builder((FragmentActivity) mContext) |
| 561 | .setCanceledOnTouchOutside(false) | 561 | .setCanceledOnTouchOutside(false) |
| 562 | .setCancelable(false) | 562 | .setCancelable(false) |
| 563 | .setWidth(0.5f) | 563 | .setWidth(0.5f) |
| 564 | .configText(new ConfigText() { | 564 | .configText(new ConfigText() { |
| 565 | @Override | 565 | @Override |
| 566 | public void onConfig(TextParams params) { | 566 | public void onConfig(TextParams params) { |
| 567 | params.gravity = Gravity.CENTER; | 567 | params.gravity = Gravity.CENTER; |
| 568 | params.padding = new int[]{50, 50, 50, 50}; | 568 | params.padding = new int[]{50, 50, 50, 50}; |
| 569 | } | 569 | } |
| 570 | }) | 570 | }) |
| 571 | .setText("当前无网络,请检查网络设置") | 571 | .setText("当前无网络,请检查网络设置") |
| 572 | .setNegative("继续使用", null) | 572 | .setNegative("继续使用", null) |
| 573 | .setPositive("设置网络", new View.OnClickListener() { | 573 | .setPositive("设置网络", new View.OnClickListener() { |
| 574 | @Override | 574 | @Override |
| 575 | public void onClick(View v) { | 575 | public void onClick(View v) { |
| 576 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 | 576 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 |
| 577 | mContext.startActivity(intent); | 577 | mContext.startActivity(intent); |
| 578 | } | 578 | } |
| 579 | }) | 579 | }) |
| 580 | .show(); | 580 | .show(); |
| 581 | } | 581 | } |
| 582 | }); | 582 | }); |
| 583 | } | 583 | } |
| 584 | 584 | ||
| 585 | //修改保卡信息地址 | 585 | //修改保卡信息地址 |
| 586 | public void changecardadressinfo(final Context mContext, long userId, final String customerPhone, String authCode, final String customerAddress) { | 586 | public void changecardadressinfo(final Context mContext, long userId, final String customerPhone, String authCode, final String customerAddress) { |
| 587 | RequestParams params = new RequestParams(); | 587 | RequestParams params = new RequestParams(); |
| 588 | params.put("userId", userId); | 588 | params.put("userId", userId); |
| 589 | params.put("customerPhone", customerPhone); | 589 | params.put("customerPhone", customerPhone); |
| 590 | params.put("authCode", authCode); | 590 | params.put("authCode", authCode); |
| 591 | params.put("customerAddress", customerAddress); | 591 | params.put("customerAddress", customerAddress); |
| 592 | HttpClient.getInstance().addHeader("Accept", "*/*"); | 592 | HttpClient.getInstance().addHeader("Accept", "*/*"); |
| 593 | HttpClient.getInstance().post(HttpUrl.changecardinfo, params, new AsyncHttpResponseHandler() { | 593 | HttpClient.getInstance().post(HttpUrl.changecardinfo, params, new AsyncHttpResponseHandler() { |
| 594 | @Override | 594 | @Override |
| 595 | public void onSuccess(int i, Header[] headers, byte[] bytes) { | 595 | public void onSuccess(int i, Header[] headers, byte[] bytes) { |
| 596 | try { | 596 | try { |
| 597 | JSONObject jsonObject = new JSONObject(new String(bytes)); | 597 | JSONObject jsonObject = new JSONObject(new String(bytes)); |
| 598 | String status = jsonObject.optString("status"); | 598 | String status = jsonObject.optString("status"); |
| 599 | if (status.equals("1")) { | 599 | if (status.equals("1")) { |
| 600 | Toast.makeText(mContext, "手机号修改成功", Toast.LENGTH_LONG).show(); | 600 | Toast.makeText(mContext, "手机号修改成功", Toast.LENGTH_LONG).show(); |
| 601 | SaveParam.getInstance().saveCustomizeParam(mContext, SaveParam.ADRESSCUNSTEM, customerAddress); | 601 | SaveParam.getInstance().saveCustomizeParam(mContext, SaveParam.ADRESSCUNSTEM, customerAddress); |
| 602 | ((Activity) mContext).finish(); | 602 | ((Activity) mContext).finish(); |
| 603 | } else { | 603 | } else { |
| 604 | AlertUtils.showToast(mContext, "您好,服务器异常,请稍后重试"); | 604 | AlertUtils.showToast(mContext, "您好,服务器异常,请稍后重试"); |
| 605 | } | 605 | } |
| 606 | } catch (JSONException e) { | 606 | } catch (JSONException e) { |
| 607 | e.printStackTrace(); | 607 | e.printStackTrace(); |
| 608 | } | 608 | } |
| 609 | } | 609 | } |
| 610 | 610 | ||
| 611 | @Override | 611 | @Override |
| 612 | public void onFailure(int i, Header[] headers, byte[] bytes, Throwable throwable) { | 612 | public void onFailure(int i, Header[] headers, byte[] bytes, Throwable throwable) { |
| 613 | Log.e("test", "onFailure" + new String(bytes)); | 613 | Log.e("test", "onFailure" + new String(bytes)); |
| 614 | new CircleDialog.Builder((FragmentActivity) mContext) | 614 | new CircleDialog.Builder((FragmentActivity) mContext) |
| 615 | .setCanceledOnTouchOutside(false) | 615 | .setCanceledOnTouchOutside(false) |
| 616 | .setCancelable(false) | 616 | .setCancelable(false) |
| 617 | .setWidth(0.5f) | 617 | .setWidth(0.5f) |
| 618 | .configText(new ConfigText() { | 618 | .configText(new ConfigText() { |
| 619 | @Override | 619 | @Override |
| 620 | public void onConfig(TextParams params) { | 620 | public void onConfig(TextParams params) { |
| 621 | params.gravity = Gravity.CENTER; | 621 | params.gravity = Gravity.CENTER; |
| 622 | params.padding = new int[]{50, 50, 50, 50}; | 622 | params.padding = new int[]{50, 50, 50, 50}; |
| 623 | } | 623 | } |
| 624 | }) | 624 | }) |
| 625 | .setText("当前无网络,请检查网络设置") | 625 | .setText("当前无网络,请检查网络设置") |
| 626 | .setNegative("继续使用", null) | 626 | .setNegative("继续使用", null) |
| 627 | .setPositive("设置网络", new View.OnClickListener() { | 627 | .setPositive("设置网络", new View.OnClickListener() { |
| 628 | @Override | 628 | @Override |
| 629 | public void onClick(View v) { | 629 | public void onClick(View v) { |
| 630 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 | 630 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 |
| 631 | mContext.startActivity(intent); | 631 | mContext.startActivity(intent); |
| 632 | } | 632 | } |
| 633 | }) | 633 | }) |
| 634 | .show(); | 634 | .show(); |
| 635 | } | 635 | } |
| 636 | }); | 636 | }); |
| 637 | } | 637 | } |
| 638 | 638 | ||
| 639 | //验证是否保卡信息 | 639 | //验证是否保卡信息 |
| 640 | public void cardinfocheck(final Context mContext, long userId, final Handler handler) { | 640 | public void cardinfocheck(final Context mContext, long userId, final Handler handler) { |
| 641 | mProgress = DialogPermission.showProgress(mContext, null, "正在验证保卡信息...", | 641 | mProgress = DialogPermission.showProgress(mContext, null, "正在验证保卡信息...", |
| 642 | false, true, null); | 642 | false, true, null); |
| 643 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); | 643 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); |
| 644 | HttpClient.getInstance().get(HttpUrl.cardcheck + "?userId=" + userId, new AsyncHttpResponseHandler() { | 644 | HttpClient.getInstance().get(HttpUrl.cardcheck + "?userId=" + userId, new AsyncHttpResponseHandler() { |
| 645 | @Override | 645 | @Override |
| 646 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { | 646 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { |
| 647 | Log.e("test", "---" + new String(arg2)); | 647 | Log.e("test", "---" + new String(arg2)); |
| 648 | closeProgress(); | 648 | closeProgress(); |
| 649 | Message msg = Message.obtain(); | 649 | Message msg = Message.obtain(); |
| 650 | msg.what = HttpCode.CHECKCARD; | 650 | msg.what = HttpCode.CHECKCARD; |
| 651 | msg.obj = new String(arg2); | 651 | msg.obj = new String(arg2); |
| 652 | handler.sendMessage(msg); | 652 | handler.sendMessage(msg); |
| 653 | 653 | ||
| 654 | 654 | ||
| 655 | } | 655 | } |
| 656 | 656 | ||
| 657 | @Override | 657 | @Override |
| 658 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { | 658 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { |
| 659 | closeProgress(); | 659 | closeProgress(); |
| 660 | new CircleDialog.Builder((FragmentActivity) mContext) | 660 | new CircleDialog.Builder((FragmentActivity) mContext) |
| 661 | .setCanceledOnTouchOutside(false) | 661 | .setCanceledOnTouchOutside(false) |
| 662 | .setCancelable(false) | 662 | .setCancelable(false) |
| 663 | .setWidth(0.5f) | 663 | .setWidth(0.5f) |
| 664 | .configText(new ConfigText() { | 664 | .configText(new ConfigText() { |
| 665 | @Override | 665 | @Override |
| 666 | public void onConfig(TextParams params) { | 666 | public void onConfig(TextParams params) { |
| 667 | params.gravity = Gravity.CENTER; | 667 | params.gravity = Gravity.CENTER; |
| 668 | params.padding = new int[]{50, 50, 50, 50}; | 668 | params.padding = new int[]{50, 50, 50, 50}; |
| 669 | } | 669 | } |
| 670 | }) | 670 | }) |
| 671 | .setText("当前无网络,请检查网络设置") | 671 | .setText("当前无网络,请检查网络设置") |
| 672 | .setNegative("继续使用", null) | 672 | .setNegative("继续使用", null) |
| 673 | .setPositive("设置网络", new View.OnClickListener() { | 673 | .setPositive("设置网络", new View.OnClickListener() { |
| 674 | @Override | 674 | @Override |
| 675 | public void onClick(View v) { | 675 | public void onClick(View v) { |
| 676 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 | 676 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 |
| 677 | mContext.startActivity(intent); | 677 | mContext.startActivity(intent); |
| 678 | } | 678 | } |
| 679 | }) | 679 | }) |
| 680 | .show(); | 680 | .show(); |
| 681 | //Toast.makeText(mContext, "请检查网络。。" + arg3, Toast.LENGTH_LONG).show(); | 681 | //Toast.makeText(mContext, "请检查网络。。" + arg3, Toast.LENGTH_LONG).show(); |
| 682 | } | 682 | } |
| 683 | }); | 683 | }); |
| 684 | } | 684 | } |
| 685 | 685 | ||
| 686 | ///获取年级 | 686 | ///获取年级 |
| 687 | public void getgrade(final Context mContext, final Handler handler) { | 687 | public void getgrade(final Context mContext, final Handler handler) { |
| 688 | HttpClient.getInstance().addHeader("Accept", "application/json"); | 688 | HttpClient.getInstance().addHeader("Accept", "application/json"); |
| 689 | HttpClient.getInstance().get(HttpUrl.gradesUrl, new AsyncHttpResponseHandler() { | 689 | HttpClient.getInstance().get(HttpUrl.gradesUrl, new AsyncHttpResponseHandler() { |
| 690 | @Override | 690 | @Override |
| 691 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { | 691 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { |
| 692 | Log.e("test", "年级" + new String(arg2)); | 692 | Log.e("test", "年级" + new String(arg2)); |
| 693 | GradeInfo gradeInfo = GsonTool.getPerson(new String(arg2), GradeInfo.class);//解析json数据 | 693 | GradeInfo gradeInfo = GsonTool.getPerson(new String(arg2), GradeInfo.class);//解析json数据 |
| 694 | List<GradeInfo.DataBean.ChildrenBean> gradeInfoLists = new ArrayList<GradeInfo.DataBean.ChildrenBean>(); | 694 | List<GradeInfo.DataBean.ChildrenBean> gradeInfoLists = new ArrayList<GradeInfo.DataBean.ChildrenBean>(); |
| 695 | for (int i = 0; i < gradeInfo.getData().size() - 2; i++) { | 695 | for (int i = 0; i < gradeInfo.getData().size() - 2; i++) { |
| 696 | String name = gradeInfo.getData().get(i).getName(); | 696 | String name = gradeInfo.getData().get(i).getName(); |
| 697 | int id = gradeInfo.getData().get(i).getId(); | 697 | int id = gradeInfo.getData().get(i).getId(); |
| 698 | List<GradeInfo.DataBean.ChildrenBean> gradeinfoList = gradeInfo.getData().get(i).getChildren(); | 698 | List<GradeInfo.DataBean.ChildrenBean> gradeinfoList = gradeInfo.getData().get(i).getChildren(); |
| 699 | for (int j = 0; j < gradeinfoList.size(); j++) { | 699 | for (int j = 0; j < gradeinfoList.size(); j++) { |
| 700 | String secondname = gradeinfoList.get(j).getName(); | 700 | String secondname = gradeinfoList.get(j).getName(); |
| 701 | int secondid = gradeinfoList.get(j).getId(); | 701 | int secondid = gradeinfoList.get(j).getId(); |
| 702 | GradeInfo.DataBean.ChildrenBean dataBean = new GradeInfo.DataBean.ChildrenBean(); | 702 | GradeInfo.DataBean.ChildrenBean dataBean = new GradeInfo.DataBean.ChildrenBean(); |
| 703 | dataBean.setName(secondname); | 703 | dataBean.setName(secondname); |
| 704 | dataBean.setId(secondid); | 704 | dataBean.setId(secondid); |
| 705 | gradeInfoLists.add(dataBean); | 705 | gradeInfoLists.add(dataBean); |
| 706 | } | 706 | } |
| 707 | 707 | ||
| 708 | } | 708 | } |
| 709 | 709 | ||
| 710 | Message message = Message.obtain(); | 710 | Message message = Message.obtain(); |
| 711 | message.what = HttpCode.GRADER; | 711 | message.what = HttpCode.GRADER; |
| 712 | message.obj = gradeInfoLists; | 712 | message.obj = gradeInfoLists; |
| 713 | handler.sendMessage(message); | 713 | handler.sendMessage(message); |
| 714 | 714 | ||
| 715 | 715 | ||
| 716 | } | 716 | } |
| 717 | 717 | ||
| 718 | @Override | 718 | @Override |
| 719 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { | 719 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { |
| 720 | new CircleDialog.Builder((FragmentActivity) mContext) | 720 | new CircleDialog.Builder((FragmentActivity) mContext) |
| 721 | .setCanceledOnTouchOutside(false) | 721 | .setCanceledOnTouchOutside(false) |
| 722 | .setCancelable(false) | 722 | .setCancelable(false) |
| 723 | .setWidth(0.5f) | 723 | .setWidth(0.5f) |
| 724 | .configText(new ConfigText() { | 724 | .configText(new ConfigText() { |
| 725 | @Override | 725 | @Override |
| 726 | public void onConfig(TextParams params) { | 726 | public void onConfig(TextParams params) { |
| 727 | params.gravity = Gravity.CENTER; | 727 | params.gravity = Gravity.CENTER; |
| 728 | params.padding = new int[]{50, 50, 50, 50}; | 728 | params.padding = new int[]{50, 50, 50, 50}; |
| 729 | } | 729 | } |
| 730 | }) | 730 | }) |
| 731 | .setText("当前无网络,请检查网络设置") | 731 | .setText("当前无网络,请检查网络设置") |
| 732 | .setNegative("继续使用", null) | 732 | .setNegative("继续使用", null) |
| 733 | .setPositive("设置网络", new View.OnClickListener() { | 733 | .setPositive("设置网络", new View.OnClickListener() { |
| 734 | @Override | 734 | @Override |
| 735 | public void onClick(View v) { | 735 | public void onClick(View v) { |
| 736 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 | 736 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 |
| 737 | mContext.startActivity(intent); | 737 | mContext.startActivity(intent); |
| 738 | } | 738 | } |
| 739 | }) | 739 | }) |
| 740 | .show(); | 740 | .show(); |
| 741 | } | 741 | } |
| 742 | }); | 742 | }); |
| 743 | } | 743 | } |
| 744 | 744 | ||
| 745 | /** | 745 | /** |
| 746 | * 获取学校 | 746 | * 获取学校 |
| 747 | * | 747 | * |
| 748 | * @param mContext | 748 | * @param mContext |
| 749 | * @param regionId | 749 | * @param regionId |
| 750 | * @param gradeId | 750 | * @param gradeId |
| 751 | * @param handler | 751 | * @param handler |
| 752 | */ | 752 | */ |
| 753 | public void getschool(final Context mContext, int regionId, int gradeId, final Handler handler) { | 753 | public void getschool(final Context mContext, int regionId, int gradeId, final Handler handler) { |
| 754 | HttpClient.getInstance().addHeader("Accept", "application/json"); | 754 | HttpClient.getInstance().addHeader("Accept", "application/json"); |
| 755 | HttpClient.getInstance().get(HttpUrl.schoolUrl + "?regionId=" + regionId + "&gradeId=" + gradeId, new AsyncHttpResponseHandler() { | 755 | HttpClient.getInstance().get(HttpUrl.schoolUrl + "?regionId=" + regionId + "&gradeId=" + gradeId, new AsyncHttpResponseHandler() { |
| 756 | @Override | 756 | @Override |
| 757 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { | 757 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { |
| 758 | Log.e("test", "学校" + new String(arg2)); | 758 | Log.e("test", "学校" + new String(arg2)); |
| 759 | try { | 759 | try { |
| 760 | JSONObject jsonObject = new JSONObject(new String(arg2)); | 760 | JSONObject jsonObject = new JSONObject(new String(arg2)); |
| 761 | int status = jsonObject.optInt("status"); | 761 | int status = jsonObject.optInt("status"); |
| 762 | if (status == 1) { | 762 | if (status == 1) { |
| 763 | SchoolInfo schoolInfo = GsonTool.getPerson(new String(arg2), SchoolInfo.class);//解析json数据 | 763 | SchoolInfo schoolInfo = GsonTool.getPerson(new String(arg2), SchoolInfo.class);//解析json数据 |
| 764 | List<SchoolInfo.DataBean> schoolInfoBeanList = schoolInfo.getData(); | 764 | List<SchoolInfo.DataBean> schoolInfoBeanList = schoolInfo.getData(); |
| 765 | Message message = Message.obtain(); | 765 | Message message = Message.obtain(); |
| 766 | message.what = HttpCode.SCHOOL; | 766 | message.what = HttpCode.SCHOOL; |
| 767 | message.obj = schoolInfoBeanList; | 767 | message.obj = schoolInfoBeanList; |
| 768 | handler.sendMessage(message); | 768 | handler.sendMessage(message); |
| 769 | 769 | ||
| 770 | 770 | ||
| 771 | } else { | 771 | } else { |
| 772 | AlertUtils.showToast(mContext, "你好,服务器异常,请稍后重试!"); | 772 | AlertUtils.showToast(mContext, "你好,服务器异常,请稍后重试!"); |
| 773 | 773 | ||
| 774 | } | 774 | } |
| 775 | } catch (JSONException e) { | 775 | } catch (JSONException e) { |
| 776 | e.printStackTrace(); | 776 | e.printStackTrace(); |
| 777 | } | 777 | } |
| 778 | 778 | ||
| 779 | } | 779 | } |
| 780 | 780 | ||
| 781 | @Override | 781 | @Override |
| 782 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { | 782 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { |
| 783 | new CircleDialog.Builder((FragmentActivity) mContext) | 783 | new CircleDialog.Builder((FragmentActivity) mContext) |
| 784 | .setCanceledOnTouchOutside(false) | 784 | .setCanceledOnTouchOutside(false) |
| 785 | .setCancelable(false) | 785 | .setCancelable(false) |
| 786 | .setWidth(0.5f) | 786 | .setWidth(0.5f) |
| 787 | .configText(new ConfigText() { | 787 | .configText(new ConfigText() { |
| 788 | @Override | 788 | @Override |
| 789 | public void onConfig(TextParams params) { | 789 | public void onConfig(TextParams params) { |
| 790 | params.gravity = Gravity.CENTER; | 790 | params.gravity = Gravity.CENTER; |
| 791 | params.padding = new int[]{50, 50, 50, 50}; | 791 | params.padding = new int[]{50, 50, 50, 50}; |
| 792 | } | 792 | } |
| 793 | }) | 793 | }) |
| 794 | .setText("当前无网络,请检查网络设置") | 794 | .setText("当前无网络,请检查网络设置") |
| 795 | .setNegative("继续使用", null) | 795 | .setNegative("继续使用", null) |
| 796 | .setPositive("设置网络", new View.OnClickListener() { | 796 | .setPositive("设置网络", new View.OnClickListener() { |
| 797 | @Override | 797 | @Override |
| 798 | public void onClick(View v) { | 798 | public void onClick(View v) { |
| 799 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 | 799 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 |
| 800 | mContext.startActivity(intent); | 800 | mContext.startActivity(intent); |
| 801 | } | 801 | } |
| 802 | }) | 802 | }) |
| 803 | .show(); | 803 | .show(); |
| 804 | } | 804 | } |
| 805 | }); | 805 | }); |
| 806 | } | 806 | } |
| 807 | 807 | ||
| 808 | 808 | ||
| 809 | /** | 809 | /** |
| 810 | * 获取个人信息 | 810 | * 获取个人信息 |
| 811 | * | 811 | * |
| 812 | * @param mContext | 812 | * @param mContext |
| 813 | * @param userId | 813 | * @param userId |
| 814 | * @param handler | 814 | * @param handler |
| 815 | */ | 815 | */ |
| 816 | public void getpresonalinfo(final Context mContext, long userId, int type, final Handler handler) { | 816 | public void getpresonalinfo(final Context mContext, long userId, int type, final Handler handler) { |
| 817 | mProgress = DialogPermission.showProgress(mContext, null, "正在获取个人信息...", | 817 | mProgress = DialogPermission.showProgress(mContext, null, "正在获取个人信息...", |
| 818 | false, true, null); | 818 | false, true, null); |
| 819 | HttpClient.getInstance().addHeader("Accept", "application/json"); | 819 | HttpClient.getInstance().addHeader("Accept", "application/json"); |
| 820 | HttpClient.getInstance().setConnectTimeout(5 * 1000); | 820 | HttpClient.getInstance().setConnectTimeout(5 * 1000); |
| 821 | HttpClient.getInstance().get(HttpUrl.getpresonalinfo + "?userId=" + userId + "&type=" + type, new AsyncHttpResponseHandler() { | 821 | HttpClient.getInstance().get(HttpUrl.getpresonalinfo + "?userId=" + userId + "&type=" + type, new AsyncHttpResponseHandler() { |
| 822 | @Override | 822 | @Override |
| 823 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { | 823 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { |
| 824 | closeProgress(); | 824 | closeProgress(); |
| 825 | Log.e("test", "个人信息" + new String(arg2)); | 825 | Log.e("test", "个人信息" + new String(arg2)); |
| 826 | try { | 826 | try { |
| 827 | JSONObject jsonObject = new JSONObject(new String(arg2)); | 827 | JSONObject jsonObject = new JSONObject(new String(arg2)); |
| 828 | int status = jsonObject.optInt("status"); | 828 | int status = jsonObject.optInt("status"); |
| 829 | if (status == 1) { | 829 | if (status == 1) { |
| 830 | PesonalInfo pesonalInfo = GsonTool.getPerson(new String(arg2), PesonalInfo.class);//解析json数据 | 830 | PesonalInfo pesonalInfo = GsonTool.getPerson(new String(arg2), PesonalInfo.class);//解析json数据 |
| 831 | PesonalInfo.DataBean pesonalInfoBeanList = pesonalInfo.getData(); | 831 | PesonalInfo.DataBean pesonalInfoBeanList = pesonalInfo.getData(); |
| 832 | Message message = Message.obtain(); | 832 | Message message = Message.obtain(); |
| 833 | message.what = HttpCode.GETINFO; | 833 | message.what = HttpCode.GETINFO; |
| 834 | message.obj = pesonalInfoBeanList; | 834 | message.obj = pesonalInfoBeanList; |
| 835 | handler.sendMessage(message); | 835 | handler.sendMessage(message); |
| 836 | 836 | ||
| 837 | 837 | ||
| 838 | } else { | 838 | } else { |
| 839 | AlertUtils.showToast(mContext, "你好,服务器异常,请稍后重试!"); | 839 | AlertUtils.showToast(mContext, "你好,服务器异常,请稍后重试!"); |
| 840 | 840 | ||
| 841 | } | 841 | } |
| 842 | } catch (JSONException e) { | 842 | } catch (JSONException e) { |
| 843 | e.printStackTrace(); | 843 | e.printStackTrace(); |
| 844 | } | 844 | } |
| 845 | 845 | ||
| 846 | 846 | ||
| 847 | } | 847 | } |
| 848 | 848 | ||
| 849 | @Override | 849 | @Override |
| 850 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { | 850 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { |
| 851 | closeProgress(); | 851 | closeProgress(); |
| 852 | new CircleDialog.Builder((FragmentActivity) mContext) | 852 | new CircleDialog.Builder((FragmentActivity) mContext) |
| 853 | .setCanceledOnTouchOutside(false) | 853 | .setCanceledOnTouchOutside(false) |
| 854 | .setCancelable(false) | 854 | .setCancelable(false) |
| 855 | .setWidth(0.5f) | 855 | .setWidth(0.5f) |
| 856 | .configText(new ConfigText() { | 856 | .configText(new ConfigText() { |
| 857 | @Override | 857 | @Override |
| 858 | public void onConfig(TextParams params) { | 858 | public void onConfig(TextParams params) { |
| 859 | params.gravity = Gravity.CENTER; | 859 | params.gravity = Gravity.CENTER; |
| 860 | params.padding = new int[]{50, 50, 50, 50}; | 860 | params.padding = new int[]{50, 50, 50, 50}; |
| 861 | } | 861 | } |
| 862 | }) | 862 | }) |
| 863 | .setText("当前无网络,请检查网络设置") | 863 | .setText("当前无网络,请检查网络设置") |
| 864 | .setNegative("继续使用", null) | 864 | .setNegative("继续使用", null) |
| 865 | .setPositive("设置网络", new View.OnClickListener() { | 865 | .setPositive("设置网络", new View.OnClickListener() { |
| 866 | @Override | 866 | @Override |
| 867 | public void onClick(View v) { | 867 | public void onClick(View v) { |
| 868 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 | 868 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 |
| 869 | mContext.startActivity(intent); | 869 | mContext.startActivity(intent); |
| 870 | } | 870 | } |
| 871 | }) | 871 | }) |
| 872 | .show(); | 872 | .show(); |
| 873 | } | 873 | } |
| 874 | }); | 874 | }); |
| 875 | } | 875 | } |
| 876 | 876 | ||
| 877 | //修改个人信息 | 877 | //修改个人信息 |
| 878 | public void changepresonalinfo(final Context mContext, Long id, int type | 878 | public void changepresonalinfo(final Context mContext, Long id, int type |
| 879 | , String name, String birthday, int gradeId, long regionId, | 879 | , String name, String birthday, int gradeId, long regionId, |
| 880 | Object schoolId, String qq, String gender | 880 | Object schoolId, String qq, String gender |
| 881 | , String regionName, String devicenumber) throws UnsupportedEncodingException { | 881 | , String regionName, String devicenumber) throws UnsupportedEncodingException { |
| 882 | mProgress = DialogPermission.showProgress(mContext, null, "正在保存个人信息...", | 882 | mProgress = DialogPermission.showProgress(mContext, null, "正在保存个人信息...", |
| 883 | false, true, null); | 883 | false, true, null); |
| 884 | RequestParams params = new RequestParams(); | 884 | RequestParams params = new RequestParams(); |
| 885 | 885 | ||
| 886 | params.put(HttpKey.USEID, id); | 886 | params.put(HttpKey.USEID, id); |
| 887 | params.put(HttpKey.TYPE, type); | 887 | params.put(HttpKey.TYPE, type); |
| 888 | params.put(HttpKey.NAME, name); | 888 | params.put(HttpKey.NAME, name); |
| 889 | params.put(HttpKey.BIRDays, birthday); | 889 | params.put(HttpKey.BIRDays, birthday); |
| 890 | params.put(HttpKey.GRADE, gradeId); | 890 | params.put(HttpKey.GRADE, gradeId); |
| 891 | params.put(HttpKey.REGION, regionId); | 891 | params.put(HttpKey.REGION, regionId); |
| 892 | params.put(HttpKey.SCHOOL, schoolId); | 892 | params.put(HttpKey.SCHOOL, schoolId); |
| 893 | params.put(HttpKey.QQ, qq); | 893 | params.put(HttpKey.QQ, qq); |
| 894 | params.put(HttpKey.GENDER, gender); | 894 | params.put(HttpKey.GENDER, gender); |
| 895 | params.put(HttpKey.REGIONNAME, regionName); | 895 | params.put(HttpKey.REGIONNAME, regionName); |
| 896 | params.put(HttpKey.DEVINUMBER, devicenumber); | 896 | params.put(HttpKey.DEVINUMBER, devicenumber); |
| 897 | Log.e("test", "个人信息" + params); | 897 | Log.e("test", "个人信息" + params); |
| 898 | HttpClient.getInstance().addHeader("Accept", "*/*"); | 898 | HttpClient.getInstance().addHeader("Accept", "*/*"); |
| 899 | HttpClient.getInstance().post(mContext, HttpUrl.changepresonalinfo, params, new JsonHttpResponseHandler() { | 899 | HttpClient.getInstance().post(mContext, HttpUrl.changepresonalinfo, params, new JsonHttpResponseHandler() { |
| 900 | @Override | 900 | @Override |
| 901 | public void onSuccess(int statusCode, Header[] headers, JSONObject response) { | 901 | public void onSuccess(int statusCode, Header[] headers, JSONObject response) { |
| 902 | super.onSuccess(statusCode, headers, response); | 902 | super.onSuccess(statusCode, headers, response); |
| 903 | closeProgress(); | 903 | closeProgress(); |
| 904 | String status = response.optString("status"); | 904 | String status = response.optString("status"); |
| 905 | if (status.equals("1")) { | 905 | if (status.equals("1")) { |
| 906 | Toast.makeText(mContext, "个人信息保存成功", Toast.LENGTH_LONG).show(); | 906 | Toast.makeText(mContext, "个人信息保存成功", Toast.LENGTH_LONG).show(); |
| 907 | ((Activity) mContext).finish(); | 907 | ((Activity) mContext).finish(); |
| 908 | } else { | 908 | } else { |
| 909 | AlertUtils.showToast(mContext, "您好,服务器异常,请稍后重试"); | 909 | AlertUtils.showToast(mContext, "您好,服务器异常,请稍后重试"); |
| 910 | } | 910 | } |
| 911 | 911 | ||
| 912 | } | 912 | } |
| 913 | 913 | ||
| 914 | @Override | 914 | @Override |
| 915 | public void onFailure(int statusCode, Header[] headers, Throwable throwable, JSONObject errorResponse) { | 915 | public void onFailure(int statusCode, Header[] headers, Throwable throwable, JSONObject errorResponse) { |
| 916 | super.onFailure(statusCode, headers, throwable, errorResponse); | 916 | super.onFailure(statusCode, headers, throwable, errorResponse); |
| 917 | closeProgress(); | 917 | closeProgress(); |
| 918 | Log.e("test", "onFailure" + errorResponse); | 918 | Log.e("test", "onFailure" + errorResponse); |
| 919 | new CircleDialog.Builder((FragmentActivity) mContext) | 919 | new CircleDialog.Builder((FragmentActivity) mContext) |
| 920 | .setCanceledOnTouchOutside(false) | 920 | .setCanceledOnTouchOutside(false) |
| 921 | .setCancelable(false) | 921 | .setCancelable(false) |
| 922 | .setWidth(0.5f) | 922 | .setWidth(0.5f) |
| 923 | .configText(new ConfigText() { | 923 | .configText(new ConfigText() { |
| 924 | @Override | 924 | @Override |
| 925 | public void onConfig(TextParams params) { | 925 | public void onConfig(TextParams params) { |
| 926 | params.gravity = Gravity.CENTER; | 926 | params.gravity = Gravity.CENTER; |
| 927 | params.padding = new int[]{50, 50, 50, 50}; | 927 | params.padding = new int[]{50, 50, 50, 50}; |
| 928 | } | 928 | } |
| 929 | }) | 929 | }) |
| 930 | .setText("当前无网络,请检查网络设置") | 930 | .setText("当前无网络,请检查网络设置") |
| 931 | .setNegative("继续使用", null) | 931 | .setNegative("继续使用", null) |
| 932 | .setPositive("设置网络", new View.OnClickListener() { | 932 | .setPositive("设置网络", new View.OnClickListener() { |
| 933 | @Override | 933 | @Override |
| 934 | public void onClick(View v) { | 934 | public void onClick(View v) { |
| 935 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 | 935 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 |
| 936 | mContext.startActivity(intent); | 936 | mContext.startActivity(intent); |
| 937 | } | 937 | } |
| 938 | }) | 938 | }) |
| 939 | .show(); | 939 | .show(); |
| 940 | } | 940 | } |
| 941 | 941 | ||
| 942 | }); | 942 | }); |
| 943 | } | 943 | } |
| 944 | 944 | ||
| 945 | //修改个性签名 | 945 | //修改个性签名 |
| 946 | public void changsignature(final Context mContext, long userId, int type, final String signature) { | 946 | public void changsignature(final Context mContext, long userId, int type, final String signature) { |
| 947 | RequestParams params = new RequestParams(); | 947 | RequestParams params = new RequestParams(); |
| 948 | params.put("userId", userId); | 948 | params.put("userId", userId); |
| 949 | params.put("type", type); | 949 | params.put("type", type); |
| 950 | params.put("signature", signature); | 950 | params.put("signature", signature); |
| 951 | HttpClient.getInstance().addHeader("Accept", "*/*"); | 951 | HttpClient.getInstance().addHeader("Accept", "*/*"); |
| 952 | HttpClient.getInstance().post(HttpUrl.signature, params, new AsyncHttpResponseHandler() { | 952 | HttpClient.getInstance().post(HttpUrl.signature, params, new AsyncHttpResponseHandler() { |
| 953 | @Override | 953 | @Override |
| 954 | public void onSuccess(int i, Header[] headers, byte[] bytes) { | 954 | public void onSuccess(int i, Header[] headers, byte[] bytes) { |
| 955 | try { | 955 | try { |
| 956 | JSONObject jsonObject = new JSONObject(new String(bytes)); | 956 | JSONObject jsonObject = new JSONObject(new String(bytes)); |
| 957 | String status = jsonObject.optString("status"); | 957 | String status = jsonObject.optString("status"); |
| 958 | if (status.equals("1")) { | 958 | if (status.equals("1")) { |
| 959 | Toast.makeText(mContext, "个性签名修改成功", Toast.LENGTH_LONG).show(); | 959 | Toast.makeText(mContext, "个性签名修改成功", Toast.LENGTH_LONG).show(); |
| 960 | } else { | 960 | } else { |
| 961 | AlertUtils.showToast(mContext, "你好,服务器异常,请稍后重试"); | 961 | AlertUtils.showToast(mContext, "你好,服务器异常,请稍后重试"); |
| 962 | } | 962 | } |
| 963 | } catch (JSONException e) { | 963 | } catch (JSONException e) { |
| 964 | e.printStackTrace(); | 964 | e.printStackTrace(); |
| 965 | } | 965 | } |
| 966 | } | 966 | } |
| 967 | 967 | ||
| 968 | @Override | 968 | @Override |
| 969 | public void onFailure(int i, Header[] headers, byte[] bytes, Throwable throwable) { | 969 | public void onFailure(int i, Header[] headers, byte[] bytes, Throwable throwable) { |
| 970 | Log.e("test", "onFailure" + new String(bytes)); | 970 | Log.e("test", "onFailure" + new String(bytes)); |
| 971 | new CircleDialog.Builder((FragmentActivity) mContext) | 971 | new CircleDialog.Builder((FragmentActivity) mContext) |
| 972 | .setCanceledOnTouchOutside(false) | 972 | .setCanceledOnTouchOutside(false) |
| 973 | .setCancelable(false) | 973 | .setCancelable(false) |
| 974 | .setWidth(0.5f) | 974 | .setWidth(0.5f) |
| 975 | .configText(new ConfigText() { | 975 | .configText(new ConfigText() { |
| 976 | @Override | 976 | @Override |
| 977 | public void onConfig(TextParams params) { | 977 | public void onConfig(TextParams params) { |
| 978 | params.gravity = Gravity.CENTER; | 978 | params.gravity = Gravity.CENTER; |
| 979 | params.padding = new int[]{50, 50, 50, 50}; | 979 | params.padding = new int[]{50, 50, 50, 50}; |
| 980 | } | 980 | } |
| 981 | }) | 981 | }) |
| 982 | .setText("当前无网络,请检查网络设置") | 982 | .setText("当前无网络,请检查网络设置") |
| 983 | .setNegative("继续使用", null) | 983 | .setNegative("继续使用", null) |
| 984 | .setPositive("设置网络", new View.OnClickListener() { | 984 | .setPositive("设置网络", new View.OnClickListener() { |
| 985 | @Override | 985 | @Override |
| 986 | public void onClick(View v) { | 986 | public void onClick(View v) { |
| 987 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 | 987 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 |
| 988 | mContext.startActivity(intent); | 988 | mContext.startActivity(intent); |
| 989 | } | 989 | } |
| 990 | }) | 990 | }) |
| 991 | .show(); | 991 | .show(); |
| 992 | } | 992 | } |
| 993 | }); | 993 | }); |
| 994 | } | 994 | } |
| 995 | 995 | ||
| 996 | /** | 996 | /** |
| 997 | * 获取个性签名 | 997 | * 获取个性签名 |
| 998 | * | 998 | * |
| 999 | * @param mContext | 999 | * @param mContext |
| 1000 | * @param userId | 1000 | * @param userId |
| 1001 | * @param handler | 1001 | * @param handler |
| 1002 | */ | 1002 | */ |
| 1003 | public void getsignatures(final Context mContext, long userId, int type, final Handler handler) { | 1003 | public void getsignatures(final Context mContext, long userId, int type, final Handler handler) { |
| 1004 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); | 1004 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); |
| 1005 | HttpClient.getInstance().get(HttpUrl.getsignature + "?userId=" + userId + "&type=" + type, new AsyncHttpResponseHandler() { | 1005 | HttpClient.getInstance().get(HttpUrl.getsignature + "?userId=" + userId + "&type=" + type, new AsyncHttpResponseHandler() { |
| 1006 | @Override | 1006 | @Override |
| 1007 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { | 1007 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { |
| 1008 | Log.e("test", "个性签名" + new String(arg2)); | 1008 | Log.e("test", "个性签名" + new String(arg2)); |
| 1009 | try { | 1009 | try { |
| 1010 | JSONObject jsonObject = new JSONObject(new String(arg2)); | 1010 | JSONObject jsonObject = new JSONObject(new String(arg2)); |
| 1011 | int status = jsonObject.optInt("status"); | 1011 | int status = jsonObject.optInt("status"); |
| 1012 | if (status == 1) { | 1012 | if (status == 1) { |
| 1013 | SignInfo signInfo = GsonTool.getPerson(new String(arg2), SignInfo.class);//解析json数据 | 1013 | SignInfo signInfo = GsonTool.getPerson(new String(arg2), SignInfo.class);//解析json数据 |
| 1014 | SignInfo.DataBean signInfoBeanList = signInfo.getData(); | 1014 | SignInfo.DataBean signInfoBeanList = signInfo.getData(); |
| 1015 | Message message = Message.obtain(); | 1015 | Message message = Message.obtain(); |
| 1016 | message.what = HttpCode.SIGN; | 1016 | message.what = HttpCode.SIGN; |
| 1017 | message.obj = signInfoBeanList; | 1017 | message.obj = signInfoBeanList; |
| 1018 | handler.sendMessage(message); | 1018 | handler.sendMessage(message); |
| 1019 | 1019 | ||
| 1020 | 1020 | ||
| 1021 | } else if (status == 1000) { | 1021 | } else if (status == 1000) { |
| 1022 | AlertUtils.showToast(mContext, "您还没有签名哦"); | 1022 | AlertUtils.showToast(mContext, "您还没有签名哦"); |
| 1023 | 1023 | ||
| 1024 | } else { | 1024 | } else { |
| 1025 | AlertUtils.showToast(mContext, "你好,服务器异常,请稍后重试!"); | 1025 | AlertUtils.showToast(mContext, "你好,服务器异常,请稍后重试!"); |
| 1026 | } | 1026 | } |
| 1027 | } catch (JSONException e) { | 1027 | } catch (JSONException e) { |
| 1028 | e.printStackTrace(); | 1028 | e.printStackTrace(); |
| 1029 | } | 1029 | } |
| 1030 | 1030 | ||
| 1031 | 1031 | ||
| 1032 | } | 1032 | } |
| 1033 | 1033 | ||
| 1034 | @Override | 1034 | @Override |
| 1035 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { | 1035 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { |
| 1036 | Log.e("test", "失败原因" + arg3); | 1036 | Log.e("test", "失败原因" + arg3); |
| 1037 | AlertUtils.showToast(mContext, "你好,服务器异常,请稍后重试!"); | 1037 | AlertUtils.showToast(mContext, "你好,服务器异常,请稍后重试!"); |
| 1038 | } | 1038 | } |
| 1039 | }); | 1039 | }); |
| 1040 | } | 1040 | } |
| 1041 | 1041 | ||
| 1042 | /** | 1042 | /** |
| 1043 | * 用户反馈 | 1043 | * 用户反馈 |
| 1044 | * | 1044 | * |
| 1045 | * @param mContext | 1045 | * @param mContext |
| 1046 | * @param userId | 1046 | * @param userId |
| 1047 | * @param content | 1047 | * @param content |
| 1048 | * @param contact | 1048 | * @param contact |
| 1049 | * @param imgs | 1049 | * @param imgs |
| 1050 | * @param feedtype | 1050 | * @param feedtype |
| 1051 | * @throws UnsupportedEncodingException | 1051 | * @throws UnsupportedEncodingException |
| 1052 | */ | 1052 | */ |
| 1053 | public void feedback(final Context mContext, String userId, String content, | 1053 | public void feedback(final Context mContext, String userId, String content, |
| 1054 | String contact, String imgs, String feedtype) throws UnsupportedEncodingException { | 1054 | String contact, String imgs, String feedtype) throws UnsupportedEncodingException { |
| 1055 | mProgress = DialogPermission.showProgress(mContext, null, "正在提交反馈内容...", | 1055 | mProgress = DialogPermission.showProgress(mContext, null, "正在提交反馈内容...", |
| 1056 | false, true, null); | 1056 | false, true, null); |
| 1057 | File file = new File(imgs); | 1057 | File file = new File(imgs); |
| 1058 | if (file.exists() && file.length() > 0) { | 1058 | if (file.exists() && file.length() > 0) { |
| 1059 | RequestParams params = new RequestParams(); | 1059 | RequestParams params = new RequestParams(); |
| 1060 | try { | 1060 | try { |
| 1061 | params.put("userId", userId); | 1061 | params.put("userId", userId); |
| 1062 | params.put("content", content); | 1062 | params.put("content", content); |
| 1063 | params.put("contact", contact); | 1063 | params.put("contact", contact); |
| 1064 | params.put("imgs", file); | 1064 | params.put("imgs", file); |
| 1065 | params.put("feedtype", feedtype); | 1065 | params.put("feedtype", feedtype); |
| 1066 | } catch (FileNotFoundException e) { | 1066 | } catch (FileNotFoundException e) { |
| 1067 | e.printStackTrace(); | 1067 | e.printStackTrace(); |
| 1068 | } | 1068 | } |
| 1069 | Log.e("test", "onSuccess" + params); | 1069 | Log.e("test", "onSuccess" + params); |
| 1070 | HttpClient.getInstance().post(HttpUrl.feedbackURL, params, new AsyncHttpResponseHandler() { | 1070 | HttpClient.getInstance().post(HttpUrl.feedbackURL, params, new AsyncHttpResponseHandler() { |
| 1071 | @Override | 1071 | @Override |
| 1072 | public void onSuccess(int i, Header[] headers, byte[] bytes) { | 1072 | public void onSuccess(int i, Header[] headers, byte[] bytes) { |
| 1073 | closeProgress(); | 1073 | closeProgress(); |
| 1074 | Log.e("test", "onSuccess" + new String(bytes)); | 1074 | Log.e("test", "onSuccess" + new String(bytes)); |
| 1075 | try { | 1075 | try { |
| 1076 | JSONObject jsonObject = new JSONObject(new String(bytes)); | 1076 | JSONObject jsonObject = new JSONObject(new String(bytes)); |
| 1077 | String status = jsonObject.optString("status"); | 1077 | String status = jsonObject.optString("status"); |
| 1078 | if (status.equals("1")) { | 1078 | if (status.equals("1")) { |
| 1079 | Toast.makeText(mContext, "您的宝贵意见已经提交成功。", Toast.LENGTH_LONG).show(); | 1079 | Toast.makeText(mContext, "您的宝贵意见已经提交成功。", Toast.LENGTH_LONG).show(); |
| 1080 | ((Activity) mContext).finish(); | 1080 | ((Activity) mContext).finish(); |
| 1081 | } else { | 1081 | } else { |
| 1082 | AlertUtils.showToast(mContext, "你好,服务器异常,请稍后重试"); | 1082 | AlertUtils.showToast(mContext, "你好,服务器异常,请稍后重试"); |
| 1083 | } | 1083 | } |
| 1084 | } catch (JSONException e) { | 1084 | } catch (JSONException e) { |
| 1085 | e.printStackTrace(); | 1085 | e.printStackTrace(); |
| 1086 | } | 1086 | } |
| 1087 | } | 1087 | } |
| 1088 | 1088 | ||
| 1089 | @Override | 1089 | @Override |
| 1090 | public void onFailure(int i, Header[] headers, byte[] bytes, Throwable throwable) { | 1090 | public void onFailure(int i, Header[] headers, byte[] bytes, Throwable throwable) { |
| 1091 | closeProgress(); | 1091 | closeProgress(); |
| 1092 | Log.e("test", "错误信息" + new String(bytes)); | 1092 | Log.e("test", "错误信息" + new String(bytes)); |
| 1093 | new CircleDialog.Builder((FragmentActivity) mContext) | 1093 | new CircleDialog.Builder((FragmentActivity) mContext) |
| 1094 | .setCanceledOnTouchOutside(false) | 1094 | .setCanceledOnTouchOutside(false) |
| 1095 | .setCancelable(false) | 1095 | .setCancelable(false) |
| 1096 | .setWidth(0.5f) | 1096 | .setWidth(0.5f) |
| 1097 | .configText(new ConfigText() { | 1097 | .configText(new ConfigText() { |
| 1098 | @Override | 1098 | @Override |
| 1099 | public void onConfig(TextParams params) { | 1099 | public void onConfig(TextParams params) { |
| 1100 | params.gravity = Gravity.CENTER; | 1100 | params.gravity = Gravity.CENTER; |
| 1101 | params.padding = new int[]{50, 50, 50, 50}; | 1101 | params.padding = new int[]{50, 50, 50, 50}; |
| 1102 | } | 1102 | } |
| 1103 | }) | 1103 | }) |
| 1104 | .setText("当前无网络,请检查网络设置") | 1104 | .setText("当前无网络,请检查网络设置") |
| 1105 | .setNegative("继续使用", null) | 1105 | .setNegative("继续使用", null) |
| 1106 | .setPositive("设置网络", new View.OnClickListener() { | 1106 | .setPositive("设置网络", new View.OnClickListener() { |
| 1107 | @Override | 1107 | @Override |
| 1108 | public void onClick(View v) { | 1108 | public void onClick(View v) { |
| 1109 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 | 1109 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 |
| 1110 | mContext.startActivity(intent); | 1110 | mContext.startActivity(intent); |
| 1111 | } | 1111 | } |
| 1112 | }) | 1112 | }) |
| 1113 | .show(); | 1113 | .show(); |
| 1114 | 1114 | ||
| 1115 | } | 1115 | } |
| 1116 | }); | 1116 | }); |
| 1117 | } else { | 1117 | } else { |
| 1118 | Toast.makeText(mContext, "文件不存在", Toast.LENGTH_LONG).show(); | 1118 | Toast.makeText(mContext, "文件不存在", Toast.LENGTH_LONG).show(); |
| 1119 | } | 1119 | } |
| 1120 | } | 1120 | } |
| 1121 | 1121 | ||
| 1122 | /** | 1122 | /** |
| 1123 | * 查询子账户信息 | 1123 | * 查询子账户信息 |
| 1124 | * | 1124 | * |
| 1125 | * @param mContext | 1125 | * @param mContext |
| 1126 | * @param userId | 1126 | * @param userId |
| 1127 | * @param handler | 1127 | * @param handler |
| 1128 | */ | 1128 | */ |
| 1129 | public void getchildAccountinfo(final Context mContext, long userId, String deviceNumber, final Handler handler) { | 1129 | public void getchildAccountinfo(final Context mContext, long userId, String deviceNumber, final Handler handler) { |
| 1130 | mProgress = DialogPermission.showProgress(mContext, null, "正在获取信息...", | 1130 | mProgress = DialogPermission.showProgress(mContext, null, "正在获取信息...", |
| 1131 | false, true, null); | 1131 | false, true, null); |
| 1132 | 1132 | ||
| 1133 | Log.e("test", "ID" + userId + "deviceNumber" + deviceNumber); | 1133 | Log.e("test", "ID" + userId + "deviceNumber" + deviceNumber); |
| 1134 | HttpClient.getInstance().setTimeout(5 * 1000); | 1134 | HttpClient.getInstance().setTimeout(5 * 1000); |
| 1135 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); | 1135 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); |
| 1136 | HttpClient.getInstance().get(HttpUrl.childUserURL + "?userId=" + userId + "&deviceNumber=" + deviceNumber, new AsyncHttpResponseHandler() { | 1136 | HttpClient.getInstance().get(HttpUrl.childUserURL + "?userId=" + userId + "&deviceNumber=" + deviceNumber, new AsyncHttpResponseHandler() { |
| 1137 | @Override | 1137 | @Override |
| 1138 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { | 1138 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { |
| 1139 | closeProgress(); | 1139 | closeProgress(); |
| 1140 | Log.e("test", "子账户信息" + new String(arg2)); | 1140 | Log.e("test", "子账户信息" + new String(arg2)); |
| 1141 | try { | 1141 | try { |
| 1142 | JSONObject jsonObject = new JSONObject(new String(arg2)); | 1142 | JSONObject jsonObject = new JSONObject(new String(arg2)); |
| 1143 | int status = jsonObject.optInt("status"); | 1143 | int status = jsonObject.optInt("status"); |
| 1144 | if (status == 0) { | 1144 | if (status == 1) { |
| 1145 | AlertUtils.showToast(mContext, "你好,服务器异常,请稍后再试!"); | ||
| 1146 | } else if(status == 1000){ | ||
| 1147 | AlertUtils.showToast(mContext, "您还没有子账户哦"); | ||
| 1148 | }else { | ||
| 1149 | ChildsInfo childsInfo = GsonTool.getPerson(new String(arg2), ChildsInfo.class);//解析json数据 | 1145 | ChildsInfo childsInfo = GsonTool.getPerson(new String(arg2), ChildsInfo.class);//解析json数据 |
| 1150 | Log.e("test", "子账户信息" + childsInfo); | 1146 | Log.e("test", "子账户信息" + childsInfo); |
| 1151 | List<ChildsInfo.DataBean> schoolInfoBeanList = childsInfo.getData(); | 1147 | List<ChildsInfo.DataBean> schoolInfoBeanList = childsInfo.getData(); |
| 1152 | Log.e("test", "子账户信息" + schoolInfoBeanList); | 1148 | Log.e("test", "子账户信息" + schoolInfoBeanList); |
| 1153 | Message msg = Message.obtain(); | 1149 | Message msg = Message.obtain(); |
| 1154 | msg.what = HttpCode.CHILDS_SUCESS; | 1150 | msg.what = HttpCode.CHILDS_SUCESS; |
| 1155 | msg.obj = schoolInfoBeanList; | 1151 | msg.obj = schoolInfoBeanList; |
| 1156 | handler.sendMessage(msg); | 1152 | handler.sendMessage(msg); |
| 1157 | 1153 | ||
| 1154 | }else { | ||
| 1155 | AlertUtils.showToast(mContext, "你好,服务器异常,请稍后再试!"); | ||
| 1156 | |||
| 1158 | } | 1157 | } |
| 1159 | } catch (JSONException e) { | 1158 | } catch (JSONException e) { |
| 1160 | e.printStackTrace(); | 1159 | e.printStackTrace(); |
| 1161 | 1160 | ||
| 1162 | } | 1161 | } |
| 1163 | 1162 | ||
| 1164 | } | 1163 | } |
| 1165 | 1164 | ||
| 1166 | @Override | 1165 | @Override |
| 1167 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { | 1166 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { |
| 1168 | closeProgress(); | 1167 | closeProgress(); |
| 1169 | Log.e("test", "错误信息" + new String(arg2)); | 1168 | Log.e("test", "错误信息" + new String(arg2)); |
| 1170 | new CircleDialog.Builder((FragmentActivity) mContext) | 1169 | new CircleDialog.Builder((FragmentActivity) mContext) |
| 1171 | .setCanceledOnTouchOutside(false) | 1170 | .setCanceledOnTouchOutside(false) |
| 1172 | .setCancelable(false) | 1171 | .setCancelable(false) |
| 1173 | .setWidth(0.5f) | 1172 | .setWidth(0.5f) |
| 1174 | .configText(new ConfigText() { | 1173 | .configText(new ConfigText() { |
| 1175 | @Override | 1174 | @Override |
| 1176 | public void onConfig(TextParams params) { | 1175 | public void onConfig(TextParams params) { |
| 1177 | params.gravity = Gravity.CENTER; | 1176 | params.gravity = Gravity.CENTER; |
| 1178 | params.padding = new int[]{50, 50, 50, 50}; | 1177 | params.padding = new int[]{50, 50, 50, 50}; |
| 1179 | } | 1178 | } |
| 1180 | }) | 1179 | }) |
| 1181 | .setText("当前无网络,请检查网络设置") | 1180 | .setText("当前无网络,请检查网络设置") |
| 1182 | .setNegative("继续使用", null) | 1181 | .setNegative("继续使用", null) |
| 1183 | .setPositive("设置网络", new View.OnClickListener() { | 1182 | .setPositive("设置网络", new View.OnClickListener() { |
| 1184 | @Override | 1183 | @Override |
| 1185 | public void onClick(View v) { | 1184 | public void onClick(View v) { |
| 1186 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 | 1185 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 |
| 1187 | mContext.startActivity(intent); | 1186 | mContext.startActivity(intent); |
| 1188 | } | 1187 | } |
| 1189 | }) | 1188 | }) |
| 1190 | .show(); | 1189 | .show(); |
| 1191 | } | 1190 | } |
| 1192 | }); | 1191 | }); |
| 1193 | 1192 | ||
| 1194 | } | 1193 | } |
| 1195 | 1194 | ||
| 1196 | /** | 1195 | /** |
| 1197 | * 删除子账户信息 | 1196 | * 删除子账户信息 |
| 1198 | * | 1197 | * |
| 1199 | * @param mContext | 1198 | * @param mContext |
| 1200 | * @param subAccountId | 1199 | * @param subAccountId |
| 1201 | */ | 1200 | */ |
| 1202 | public void deletechildAccountinfo(final Context mContext, String subAccountId) { | 1201 | public void deletechildAccountinfo(final Context mContext, String subAccountId) { |
| 1203 | mProgress = DialogPermission.showProgress(mContext, null, "正在删除子账户...", | 1202 | mProgress = DialogPermission.showProgress(mContext, null, "正在删除子账户...", |
| 1204 | false, true, null); | 1203 | false, true, null); |
| 1205 | HttpClient.getInstance().setTimeout(5 * 1000); | 1204 | HttpClient.getInstance().setTimeout(5 * 1000); |
| 1206 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); | 1205 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); |
| 1207 | HttpClient.getInstance().get(HttpUrl.deletechildUserURL + "?subAccountId=" + subAccountId, new AsyncHttpResponseHandler() { | 1206 | HttpClient.getInstance().get(HttpUrl.deletechildUserURL + "?subAccountId=" + subAccountId, new AsyncHttpResponseHandler() { |
| 1208 | @Override | 1207 | @Override |
| 1209 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { | 1208 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { |
| 1210 | closeProgress(); | 1209 | closeProgress(); |
| 1211 | Log.e("test", "子账户信息" + new String(arg2)); | 1210 | Log.e("test", "子账户信息" + new String(arg2)); |
| 1212 | try { | 1211 | try { |
| 1213 | JSONObject jsonObject = new JSONObject(new String(arg2)); | 1212 | JSONObject jsonObject = new JSONObject(new String(arg2)); |
| 1214 | int status = jsonObject.optInt("status"); | 1213 | int status = jsonObject.optInt("status"); |
| 1215 | if (status == 1) { | 1214 | if (status == 1) { |
| 1216 | AlertUtils.showToast(mContext, "子账号删除成功!"); | 1215 | AlertUtils.showToast(mContext, "子账号删除成功!"); |
| 1217 | ((Activity) mContext).finish(); | 1216 | ((Activity) mContext).finish(); |
| 1218 | } else { | 1217 | } else { |
| 1219 | AlertUtils.showToast(mContext, "你好,子账号删除失败!"); | 1218 | AlertUtils.showToast(mContext, "你好,子账号删除失败!"); |
| 1220 | 1219 | ||
| 1221 | } | 1220 | } |
| 1222 | } catch (JSONException e) { | 1221 | } catch (JSONException e) { |
| 1223 | e.printStackTrace(); | 1222 | e.printStackTrace(); |
| 1224 | } | 1223 | } |
| 1225 | 1224 | ||
| 1226 | } | 1225 | } |
| 1227 | 1226 | ||
| 1228 | @Override | 1227 | @Override |
| 1229 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { | 1228 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { |
| 1230 | closeProgress(); | 1229 | closeProgress(); |
| 1231 | Log.e("test", "错误信息" + new String(arg2)); | 1230 | Log.e("test", "错误信息" + new String(arg2)); |
| 1232 | new CircleDialog.Builder((FragmentActivity) mContext) | 1231 | new CircleDialog.Builder((FragmentActivity) mContext) |
| 1233 | .setCanceledOnTouchOutside(false) | 1232 | .setCanceledOnTouchOutside(false) |
| 1234 | .setCancelable(false) | 1233 | .setCancelable(false) |
| 1235 | .setWidth(0.5f) | 1234 | .setWidth(0.5f) |
| 1236 | .configText(new ConfigText() { | 1235 | .configText(new ConfigText() { |
| 1237 | @Override | 1236 | @Override |
| 1238 | public void onConfig(TextParams params) { | 1237 | public void onConfig(TextParams params) { |
| 1239 | params.gravity = Gravity.CENTER; | 1238 | params.gravity = Gravity.CENTER; |
| 1240 | params.padding = new int[]{50, 50, 50, 50}; | 1239 | params.padding = new int[]{50, 50, 50, 50}; |
| 1241 | } | 1240 | } |
| 1242 | }) | 1241 | }) |
| 1243 | .setText("当前无网络,请检查网络设置") | 1242 | .setText("当前无网络,请检查网络设置") |
| 1244 | .setNegative("继续使用", null) | 1243 | .setNegative("继续使用", null) |
| 1245 | .setPositive("设置网络", new View.OnClickListener() { | 1244 | .setPositive("设置网络", new View.OnClickListener() { |
| 1246 | @Override | 1245 | @Override |
| 1247 | public void onClick(View v) { | 1246 | public void onClick(View v) { |
| 1248 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 | 1247 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 |
| 1249 | mContext.startActivity(intent); | 1248 | mContext.startActivity(intent); |
| 1250 | } | 1249 | } |
| 1251 | }) | 1250 | }) |
| 1252 | .show(); | 1251 | .show(); |
| 1253 | } | 1252 | } |
| 1254 | }); | 1253 | }); |
| 1255 | 1254 | ||
| 1256 | } | 1255 | } |
| 1257 | 1256 | ||
| 1258 | /** | 1257 | /** |
| 1259 | * 添加子账户信息 | 1258 | * 添加子账户信息 |
| 1260 | */ | 1259 | */ |
| 1261 | public void addchildAccountinfo(final Context mContext, long parentId, String image, | 1260 | public void addchildAccountinfo(final Context mContext, long parentId, String image, |
| 1262 | String name, Long grade, Object school, Long region | 1261 | String name, Long grade, Object school, Long region |
| 1263 | , String deviceNumber, String regionName) { | 1262 | , String deviceNumber, String regionName) { |
| 1264 | mProgress = DialogPermission.showProgress(mContext, null, "正在添加子账户...", | 1263 | mProgress = DialogPermission.showProgress(mContext, null, "正在添加子账户...", |
| 1265 | false, true, null); | 1264 | false, true, null); |
| 1266 | RequestParams params = new RequestParams(); | 1265 | RequestParams params = new RequestParams(); |
| 1267 | 1266 | ||
| 1268 | params.put(HttpKey.PARENTID, parentId); | 1267 | params.put(HttpKey.PARENTID, parentId); |
| 1269 | params.put(HttpKey.IMAGE, image); | 1268 | params.put(HttpKey.IMAGE, image); |
| 1270 | params.put(HttpKey.NAME, name); | 1269 | params.put(HttpKey.NAME, name); |
| 1271 | params.put(HttpKey.GRADE, grade); | 1270 | params.put(HttpKey.GRADE, grade); |
| 1272 | params.put(HttpKey.SCHOOL, school); | 1271 | params.put(HttpKey.SCHOOL, school); |
| 1273 | params.put(HttpKey.REGION, region); | 1272 | params.put(HttpKey.REGION, region); |
| 1274 | params.put(HttpKey.DEVINUMBER, deviceNumber); | 1273 | params.put(HttpKey.DEVINUMBER, deviceNumber); |
| 1275 | params.put(HttpKey.REGIONNAME, regionName); | 1274 | params.put(HttpKey.REGIONNAME, regionName); |
| 1276 | 1275 | ||
| 1277 | Log.e("test", "子账户信息" + params); | 1276 | Log.e("test", "子账户信息" + params); |
| 1278 | HttpClient.getInstance().addHeader("Accept", "*/*"); | 1277 | HttpClient.getInstance().addHeader("Accept", "*/*"); |
| 1279 | HttpClient.getInstance().setTimeout(5 * 1000); | 1278 | HttpClient.getInstance().setTimeout(5 * 1000); |
| 1280 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); | 1279 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); |
| 1281 | HttpClient.getInstance().post(HttpUrl.addchildUserURL, params, new AsyncHttpResponseHandler() { | 1280 | HttpClient.getInstance().post(HttpUrl.addchildUserURL, params, new AsyncHttpResponseHandler() { |
| 1282 | @Override | 1281 | @Override |
| 1283 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { | 1282 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { |
| 1284 | closeProgress(); | 1283 | closeProgress(); |
| 1285 | 1284 | ||
| 1286 | Log.e("test", "子账户信息" + new String(arg2)); | 1285 | Log.e("test", "子账户信息" + new String(arg2)); |
| 1287 | try { | 1286 | try { |
| 1288 | JSONObject jsonObject = new JSONObject(new String(arg2)); | 1287 | JSONObject jsonObject = new JSONObject(new String(arg2)); |
| 1289 | int status = jsonObject.optInt("status"); | 1288 | int status = jsonObject.optInt("status"); |
| 1290 | if (status == 1) { | 1289 | if (status == 1) { |
| 1291 | AlertUtils.showToast(mContext, "子账号添加成功!"); | 1290 | AlertUtils.showToast(mContext, "子账号添加成功!"); |
| 1292 | ((Activity) mContext).finish(); | 1291 | ((Activity) mContext).finish(); |
| 1293 | } else { | 1292 | } else { |
| 1294 | AlertUtils.showToast(mContext, "你好,子账号添加失败!"); | 1293 | AlertUtils.showToast(mContext, "你好,子账号添加失败!"); |
| 1295 | 1294 | ||
| 1296 | } | 1295 | } |
| 1297 | } catch (JSONException e) { | 1296 | } catch (JSONException e) { |
| 1298 | e.printStackTrace(); | 1297 | e.printStackTrace(); |
| 1299 | } | 1298 | } |
| 1300 | 1299 | ||
| 1301 | } | 1300 | } |
| 1302 | 1301 | ||
| 1303 | @Override | 1302 | @Override |
| 1304 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { | 1303 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { |
| 1305 | closeProgress(); | 1304 | closeProgress(); |
| 1306 | Log.e("test", "错误信息" + new String(arg2)); | 1305 | Log.e("test", "错误信息" + new String(arg2)); |
| 1307 | new CircleDialog.Builder((FragmentActivity) mContext) | 1306 | new CircleDialog.Builder((FragmentActivity) mContext) |
| 1308 | .setCanceledOnTouchOutside(false) | 1307 | .setCanceledOnTouchOutside(false) |
| 1309 | .setCancelable(false) | 1308 | .setCancelable(false) |
| 1310 | .setWidth(0.5f) | 1309 | .setWidth(0.5f) |
| 1311 | .configText(new ConfigText() { | 1310 | .configText(new ConfigText() { |
| 1312 | @Override | 1311 | @Override |
| 1313 | public void onConfig(TextParams params) { | 1312 | public void onConfig(TextParams params) { |
| 1314 | params.gravity = Gravity.CENTER; | 1313 | params.gravity = Gravity.CENTER; |
| 1315 | params.padding = new int[]{50, 50, 50, 50}; | 1314 | params.padding = new int[]{50, 50, 50, 50}; |
| 1316 | } | 1315 | } |
| 1317 | }) | 1316 | }) |
| 1318 | .setText("当前无网络,请检查网络设置") | 1317 | .setText("当前无网络,请检查网络设置") |
| 1319 | .setNegative("继续使用", null) | 1318 | .setNegative("继续使用", null) |
| 1320 | .setPositive("设置网络", new View.OnClickListener() { | 1319 | .setPositive("设置网络", new View.OnClickListener() { |
| 1321 | @Override | 1320 | @Override |
| 1322 | public void onClick(View v) { | 1321 | public void onClick(View v) { |
| 1323 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 | 1322 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 |
| 1324 | mContext.startActivity(intent); | 1323 | mContext.startActivity(intent); |
| 1325 | } | 1324 | } |
| 1326 | }) | 1325 | }) |
| 1327 | .show(); | 1326 | .show(); |
| 1328 | } | 1327 | } |
| 1329 | }); | 1328 | }); |
| 1330 | 1329 | ||
| 1331 | } | 1330 | } |
| 1332 | 1331 | ||
| 1333 | /** | 1332 | /** |
| 1334 | * 切换子账户信息 | 1333 | * 切换子账户信息 |
| 1335 | * | 1334 | * |
| 1336 | * @param mContext | 1335 | * @param mContext |
| 1337 | * @param subAccountId | 1336 | * @param subAccountId |
| 1338 | */ | 1337 | */ |
| 1339 | public void changechildAccountinfo(final Context mContext, String subAccountId, long userId | 1338 | public void changechildAccountinfo(final Context mContext, String subAccountId, long userId |
| 1340 | , String deviceNumber, int type) { | 1339 | , String deviceNumber, int type) { |
| 1341 | mProgress = DialogPermission.showProgress(mContext, null, "正在切换子账户...", | 1340 | mProgress = DialogPermission.showProgress(mContext, null, "正在切换子账户...", |
| 1342 | false, true, null); | 1341 | false, true, null); |
| 1343 | HttpClient.getInstance().setTimeout(5 * 1000); | 1342 | HttpClient.getInstance().setTimeout(5 * 1000); |
| 1344 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); | 1343 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); |
| 1345 | HttpClient.getInstance().get(HttpUrl.changechildUserURL + "?subAccountId=" + subAccountId + "&userId=" + userId | 1344 | HttpClient.getInstance().get(HttpUrl.changechildUserURL + "?subAccountId=" + subAccountId + "&userId=" + userId |
| 1346 | + "&deviceNumber=" + deviceNumber + "&type=" + type, new AsyncHttpResponseHandler() { | 1345 | + "&deviceNumber=" + deviceNumber + "&type=" + type, new AsyncHttpResponseHandler() { |
| 1347 | @Override | 1346 | @Override |
| 1348 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { | 1347 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { |
| 1349 | closeProgress(); | 1348 | closeProgress(); |
| 1350 | Log.e("test", "子账户信息" + new String(arg2)); | 1349 | Log.e("test", "子账户信息" + new String(arg2)); |
| 1351 | try { | 1350 | try { |
| 1352 | JSONObject jsonObject = new JSONObject(new String(arg2)); | 1351 | JSONObject jsonObject = new JSONObject(new String(arg2)); |
| 1353 | int status = jsonObject.optInt("status"); | 1352 | int status = jsonObject.optInt("status"); |
| 1354 | if (status == 1) { | 1353 | if (status == 1) { |
| 1355 | AlertUtils.showToast(mContext, "子账号切换成功!"); | 1354 | AlertUtils.showToast(mContext, "子账号切换成功!"); |
| 1356 | ((Activity) mContext).finish(); | 1355 | ((Activity) mContext).finish(); |
| 1357 | 1356 | ||
| 1358 | } else { | 1357 | } else { |
| 1359 | AlertUtils.showToast(mContext, "你好,子账号切换失败!"); | 1358 | AlertUtils.showToast(mContext, "你好,子账号切换失败!"); |
| 1360 | 1359 | ||
| 1361 | } | 1360 | } |
| 1362 | } catch (JSONException e) { | 1361 | } catch (JSONException e) { |
| 1363 | e.printStackTrace(); | 1362 | e.printStackTrace(); |
| 1364 | } | 1363 | } |
| 1365 | 1364 | ||
| 1366 | } | 1365 | } |
| 1367 | 1366 | ||
| 1368 | @Override | 1367 | @Override |
| 1369 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { | 1368 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { |
| 1370 | closeProgress(); | 1369 | closeProgress(); |
| 1371 | Log.e("test", "错误信息" + new String(arg2)); | 1370 | Log.e("test", "错误信息" + new String(arg2)); |
| 1372 | new CircleDialog.Builder((FragmentActivity) mContext) | 1371 | new CircleDialog.Builder((FragmentActivity) mContext) |
| 1373 | .setCanceledOnTouchOutside(false) | 1372 | .setCanceledOnTouchOutside(false) |
| 1374 | .setCancelable(false) | 1373 | .setCancelable(false) |
| 1375 | .setWidth(0.5f) | 1374 | .setWidth(0.5f) |
| 1376 | .configText(new ConfigText() { | 1375 | .configText(new ConfigText() { |
| 1377 | @Override | 1376 | @Override |
| 1378 | public void onConfig(TextParams params) { | 1377 | public void onConfig(TextParams params) { |
| 1379 | params.gravity = Gravity.CENTER; | 1378 | params.gravity = Gravity.CENTER; |
| 1380 | params.padding = new int[]{50, 50, 50, 50}; | 1379 | params.padding = new int[]{50, 50, 50, 50}; |
| 1381 | } | 1380 | } |
| 1382 | }) | 1381 | }) |
| 1383 | .setText("当前无网络,请检查网络设置") | 1382 | .setText("当前无网络,请检查网络设置") |
| 1384 | .setNegative("继续使用", null) | 1383 | .setNegative("继续使用", null) |
| 1385 | .setPositive("设置网络", new View.OnClickListener() { | 1384 | .setPositive("设置网络", new View.OnClickListener() { |
| 1386 | @Override | 1385 | @Override |
| 1387 | public void onClick(View v) { | 1386 | public void onClick(View v) { |
| 1388 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 | 1387 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 |
| 1389 | mContext.startActivity(intent); | 1388 | mContext.startActivity(intent); |
| 1390 | } | 1389 | } |
| 1391 | }) | 1390 | }) |
| 1392 | .show(); | 1391 | .show(); |
| 1393 | } | 1392 | } |
| 1394 | }); | 1393 | }); |
| 1395 | 1394 | ||
| 1396 | } | 1395 | } |
| 1397 | 1396 | ||
| 1398 | /** | 1397 | /** |
| 1399 | * 切换主账户信息 | 1398 | * 切换主账户信息 |
| 1400 | * | 1399 | * |
| 1401 | * @param mContext | 1400 | * @param mContext |
| 1402 | * @param type | 1401 | * @param type |
| 1403 | */ | 1402 | */ |
| 1404 | public void Accountinfo(final Context mContext, long userId | 1403 | public void Accountinfo(final Context mContext, long userId |
| 1405 | , String deviceNumber, int type) { | 1404 | , String deviceNumber, int type) { |
| 1406 | mProgress = DialogPermission.showProgress(mContext, null, "正在切换主账户...", | 1405 | mProgress = DialogPermission.showProgress(mContext, null, "正在切换主账户...", |
| 1407 | false, true, null); | 1406 | false, true, null); |
| 1408 | HttpClient.getInstance().setTimeout(5 * 1000); | 1407 | HttpClient.getInstance().setTimeout(5 * 1000); |
| 1409 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); | 1408 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); |
| 1410 | HttpClient.getInstance().get(HttpUrl.changechildUserURL + "?userId=" + userId + "&deviceNumber=" + deviceNumber | 1409 | HttpClient.getInstance().get(HttpUrl.changechildUserURL + "?userId=" + userId + "&deviceNumber=" + deviceNumber |
| 1411 | + "&type=" + type, new AsyncHttpResponseHandler() { | 1410 | + "&type=" + type, new AsyncHttpResponseHandler() { |
| 1412 | @Override | 1411 | @Override |
| 1413 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { | 1412 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { |
| 1414 | closeProgress(); | 1413 | closeProgress(); |
| 1415 | Log.e("test", "子账户信息" + new String(arg2)); | 1414 | Log.e("test", "子账户信息" + new String(arg2)); |
| 1416 | try { | 1415 | try { |
| 1417 | JSONObject jsonObject = new JSONObject(new String(arg2)); | 1416 | JSONObject jsonObject = new JSONObject(new String(arg2)); |
| 1418 | int status = jsonObject.optInt("status"); | 1417 | int status = jsonObject.optInt("status"); |
| 1419 | if (status == 1) { | 1418 | if (status == 1) { |
| 1420 | AlertUtils.showToast(mContext, "主账号切换成功!"); | 1419 | AlertUtils.showToast(mContext, "主账号切换成功!"); |
| 1421 | ((Activity) mContext).finish(); | 1420 | ((Activity) mContext).finish(); |
| 1422 | 1421 | ||
| 1423 | } else { | 1422 | } else { |
| 1424 | AlertUtils.showToast(mContext, "你好,主账号切换失败!"); | 1423 | AlertUtils.showToast(mContext, "你好,主账号切换失败!"); |
| 1425 | 1424 | ||
| 1426 | } | 1425 | } |
| 1427 | } catch (JSONException e) { | 1426 | } catch (JSONException e) { |
| 1428 | e.printStackTrace(); | 1427 | e.printStackTrace(); |
| 1429 | } | 1428 | } |
| 1430 | 1429 | ||
| 1431 | } | 1430 | } |
| 1432 | 1431 | ||
| 1433 | @Override | 1432 | @Override |
| 1434 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { | 1433 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { |
| 1435 | closeProgress(); | 1434 | closeProgress(); |
| 1436 | Log.e("test", "错误信息" + new String(arg2)); | 1435 | Log.e("test", "错误信息" + new String(arg2)); |
| 1437 | new CircleDialog.Builder((FragmentActivity) mContext) | 1436 | new CircleDialog.Builder((FragmentActivity) mContext) |
| 1438 | .setCanceledOnTouchOutside(false) | 1437 | .setCanceledOnTouchOutside(false) |
| 1439 | .setCancelable(false) | 1438 | .setCancelable(false) |
| 1440 | .setWidth(0.5f) | 1439 | .setWidth(0.5f) |
| 1441 | .configText(new ConfigText() { | 1440 | .configText(new ConfigText() { |
| 1442 | @Override | 1441 | @Override |
| 1443 | public void onConfig(TextParams params) { | 1442 | public void onConfig(TextParams params) { |
| 1444 | params.gravity = Gravity.CENTER; | 1443 | params.gravity = Gravity.CENTER; |
| 1445 | params.padding = new int[]{50, 50, 50, 50}; | 1444 | params.padding = new int[]{50, 50, 50, 50}; |
| 1446 | } | 1445 | } |
| 1447 | }) | 1446 | }) |
| 1448 | .setText("当前无网络,请检查网络设置") | 1447 | .setText("当前无网络,请检查网络设置") |
| 1449 | .setNegative("继续使用", null) | 1448 | .setNegative("继续使用", null) |
| 1450 | .setPositive("设置网络", new View.OnClickListener() { | 1449 | .setPositive("设置网络", new View.OnClickListener() { |
| 1451 | @Override | 1450 | @Override |
| 1452 | public void onClick(View v) { | 1451 | public void onClick(View v) { |
| 1453 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 | 1452 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 |
| 1454 | mContext.startActivity(intent); | 1453 | mContext.startActivity(intent); |
| 1455 | } | 1454 | } |
| 1456 | }) | 1455 | }) |
| 1457 | .show(); | 1456 | .show(); |
| 1458 | } | 1457 | } |
| 1459 | }); | 1458 | }); |
| 1460 | 1459 | ||
| 1461 | } | 1460 | } |
| 1462 | 1461 | ||
| 1463 | /** | 1462 | /** |
| 1464 | * 头像 | 1463 | * 头像拍张 |
| 1465 | * | 1464 | * |
| 1466 | * @param mContext | 1465 | * @param mContext |
| 1467 | * @param userId | 1466 | * @param userId |
| 1468 | * @param img | 1467 | * @param img |
| 1469 | * @throws UnsupportedEncodingException | 1468 | * @throws UnsupportedEncodingException |
| 1470 | */ | 1469 | */ |
| 1471 | public void header(final Context mContext, String userId, String type, String img) throws UnsupportedEncodingException { | 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 | File file = new File(img); | 1471 | File file = new File(img); |
| 1475 | if (file.exists() && file.length() > 0) { | 1472 | if (file.exists() && file.length() > 0) { |
| 1476 | RequestParams params = new RequestParams(); | 1473 | RequestParams params = new RequestParams(); |
| 1477 | try { | 1474 | try { |
| 1478 | params.put("userId", userId); | 1475 | params.put("userId", userId); |
| 1479 | params.put("type", type); | 1476 | params.put("type", type); |
| 1480 | params.put("img", file); | 1477 | params.put("img", file); |
| 1481 | } catch (FileNotFoundException e) { | 1478 | } catch (FileNotFoundException e) { |
| 1482 | e.printStackTrace(); | 1479 | e.printStackTrace(); |
| 1483 | } | 1480 | } |
| 1484 | Log.e("test", "onSuccess" + params); | 1481 | Log.e("test", "params" + params); |
| 1482 | HttpClient.getInstance().setTimeout(5 * 1000); | ||
| 1485 | HttpClient.getInstance().post(HttpUrl.headerURL, params, new AsyncHttpResponseHandler() { | 1483 | HttpClient.getInstance().post(HttpUrl.headerURL, params, new AsyncHttpResponseHandler() { |
| 1486 | @Override | 1484 | @Override |
| 1487 | public void onSuccess(int i, Header[] headers, byte[] bytes) { | 1485 | public void onSuccess(int i, Header[] headers, byte[] bytes) { |
| 1488 | closeProgress(); | ||
| 1489 | Log.e("test", "onSuccess" + new String(bytes)); | 1486 | Log.e("test", "onSuccess" + new String(bytes)); |
| 1490 | try { | 1487 | try { |
| 1491 | JSONObject jsonObject = new JSONObject(new String(bytes)); | 1488 | JSONObject jsonObject = new JSONObject(new String(bytes)); |
| 1492 | String status = jsonObject.optString("status"); | 1489 | String status = jsonObject.optString("status"); |
| 1493 | JSONObject jsonObject1 =jsonObject.getJSONObject("data"); | 1490 | JSONObject jsonObject1 =jsonObject.getJSONObject("data"); |
| 1494 | String imagUrl = jsonObject1.optString("imgUrl"); | 1491 | String imagUrl = jsonObject1.optString("imgUrl"); |
| 1495 | SaveParam.getInstance().saveLoginParam(mContext,SaveParam.HEADURL,imagUrl); | 1492 | SaveParam.getInstance().saveLoginParam(mContext,SaveParam.HEADURL,imagUrl); |
| 1496 | if (status.equals("1")) { | 1493 | if (status.equals("1")) { |
| 1497 | Toast.makeText(mContext, "头像上传成功。", Toast.LENGTH_LONG).show(); | 1494 | Toast.makeText(mContext, "头像上传成功。", Toast.LENGTH_LONG).show(); |
| 1498 | } else { | 1495 | } else { |
| 1499 | AlertUtils.showToast(mContext, "你好,服务器异常,请稍后重试"); | 1496 | AlertUtils.showToast(mContext, "你好,服务器异常,请稍后重试"); |
| 1500 | } | 1497 | } |
| 1501 | } catch (JSONException e) { | 1498 | } catch (JSONException e) { |
| 1502 | e.printStackTrace(); | 1499 | e.printStackTrace(); |
| 1503 | } | 1500 | } |
| 1504 | } | 1501 | } |
| 1505 | 1502 | ||
| 1506 | @Override | 1503 | @Override |
| 1507 | public void onFailure(int i, Header[] headers, byte[] bytes, Throwable throwable) { | 1504 | public void onFailure(int i, Header[] headers, byte[] bytes, Throwable throwable) { |
| 1508 | closeProgress(); | 1505 | closeProgress(); |
| 1509 | Log.e("test", "错误信息" + new String(bytes)); | 1506 | Log.e("test", "错误信息" + new String(bytes)); |
| 1510 | new CircleDialog.Builder((FragmentActivity) mContext) | 1507 | new CircleDialog.Builder((FragmentActivity) mContext) |
| 1511 | .setCanceledOnTouchOutside(false) | 1508 | .setCanceledOnTouchOutside(false) |
| 1512 | .setCancelable(false) | 1509 | .setCancelable(false) |
| 1513 | .setWidth(0.5f) | 1510 | .setWidth(0.5f) |
| 1514 | .configText(new ConfigText() { | 1511 | .configText(new ConfigText() { |
| 1515 | @Override | 1512 | @Override |
| 1516 | public void onConfig(TextParams params) { | 1513 | public void onConfig(TextParams params) { |
| 1517 | params.gravity = Gravity.CENTER; | 1514 | params.gravity = Gravity.CENTER; |
| 1518 | params.padding = new int[]{50, 50, 50, 50}; | 1515 | params.padding = new int[]{50, 50, 50, 50}; |
| 1519 | } | 1516 | } |
| 1520 | }) | 1517 | }) |
| 1521 | .setText("当前无网络,请检查网络设置") | 1518 | .setText("当前无网络,请检查网络设置") |
| 1522 | .setNegative("继续使用", null) | 1519 | .setNegative("继续使用", null) |
| 1523 | .setPositive("设置网络", new View.OnClickListener() { | 1520 | .setPositive("设置网络", new View.OnClickListener() { |
| 1524 | @Override | 1521 | @Override |
| 1525 | public void onClick(View v) { | 1522 | public void onClick(View v) { |
| 1526 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 | 1523 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 |
| 1527 | mContext.startActivity(intent); | 1524 | mContext.startActivity(intent); |
| 1528 | } | 1525 | } |
| 1529 | }) | 1526 | }) |
| 1530 | .show(); | 1527 | .show(); |
| 1531 | 1528 | ||
| 1532 | } | 1529 | } |
| 1533 | }); | 1530 | }); |
| 1534 | } else { | 1531 | } else { |
| 1535 | Toast.makeText(mContext, "文件不存在", Toast.LENGTH_LONG).show(); | 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 | /** |
| 1541 | * 系统升级 | 1602 | * 系统升级 |
| 1542 | * | 1603 | * |
| 1543 | * @param mContext | 1604 | * @param mContext |
| 1544 | * @param pid appName | 1605 | * @param pid appName |
| 1545 | */ | 1606 | */ |
| 1546 | public void updateAPP(final Context mContext, String pid, String appName, final Handler handler) { | 1607 | public void updateAPP(final Context mContext, String pid, String appName, final Handler handler) { |
| 1547 | mProgress = DialogPermission.showProgress(mContext, null, "正在切换子账户...", | 1608 | mProgress = DialogPermission.showProgress(mContext, null, "正在切换子账户...", |
| 1548 | false, true, null); | 1609 | false, true, null); |
| 1549 | HttpClient.getInstance().setTimeout(5 * 1000); | 1610 | HttpClient.getInstance().setTimeout(5 * 1000); |
| 1550 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); | 1611 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); |
| 1551 | HttpClient.getInstance().get(HttpUrl.updateappURL + "?pid=" + pid + "&appName=" + appName, new AsyncHttpResponseHandler() { | 1612 | HttpClient.getInstance().get(HttpUrl.updateappURL + "?pid=" + pid + "&appName=" + appName, new AsyncHttpResponseHandler() { |
| 1552 | @Override | 1613 | @Override |
| 1553 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { | 1614 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { |
| 1554 | closeProgress(); | 1615 | closeProgress(); |
| 1555 | Log.e("test", "版本升级信息" + new String(arg2)); | 1616 | Log.e("test", "版本升级信息" + new String(arg2)); |
| 1556 | AppVersion appVersion = GsonTool.getPerson(new String(arg2), AppVersion.class);//解析json数据 | 1617 | AppVersion appVersion = GsonTool.getPerson(new String(arg2), AppVersion.class);//解析json数据 |
| 1557 | Message msg = Message.obtain(); | 1618 | Message msg = Message.obtain(); |
| 1558 | msg.what = HttpCode.APPUPDATE_SUCESS; | 1619 | msg.what = HttpCode.APPUPDATE_SUCESS; |
| 1559 | msg.obj = appVersion; | 1620 | msg.obj = appVersion; |
| 1560 | handler.sendMessage(msg); | 1621 | handler.sendMessage(msg); |
| 1561 | 1622 | ||
| 1562 | 1623 | ||
| 1563 | } | 1624 | } |
| 1564 | 1625 | ||
| 1565 | @Override | 1626 | @Override |
| 1566 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { | 1627 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { |
| 1567 | closeProgress(); | 1628 | closeProgress(); |
| 1568 | Log.e("test", "错误信息" + new String(arg2)); | 1629 | Log.e("test", "错误信息" + new String(arg2)); |
| 1569 | new CircleDialog.Builder((FragmentActivity) mContext) | 1630 | new CircleDialog.Builder((FragmentActivity) mContext) |
| 1570 | .setCanceledOnTouchOutside(false) | 1631 | .setCanceledOnTouchOutside(false) |
| 1571 | .setCancelable(false) | 1632 | .setCancelable(false) |
| 1572 | .setWidth(0.5f) | 1633 | .setWidth(0.5f) |
| 1573 | .configText(new ConfigText() { | 1634 | .configText(new ConfigText() { |
| 1574 | @Override | 1635 | @Override |
| 1575 | public void onConfig(TextParams params) { | 1636 | public void onConfig(TextParams params) { |
| 1576 | params.gravity = Gravity.CENTER; | 1637 | params.gravity = Gravity.CENTER; |
| 1577 | params.padding = new int[]{50, 50, 50, 50}; | 1638 | params.padding = new int[]{50, 50, 50, 50}; |
| 1578 | } | 1639 | } |
| 1579 | }) | 1640 | }) |
| 1580 | .setText("当前无网络,请检查网络设置") | 1641 | .setText("当前无网络,请检查网络设置") |
| 1581 | .setNegative("继续使用", null) | 1642 | .setNegative("继续使用", null) |
| 1582 | .setPositive("设置网络", new View.OnClickListener() { | 1643 | .setPositive("设置网络", new View.OnClickListener() { |
| 1583 | @Override | 1644 | @Override |
| 1584 | public void onClick(View v) { | 1645 | public void onClick(View v) { |
| 1585 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 | 1646 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 |
| 1586 | mContext.startActivity(intent); | 1647 | mContext.startActivity(intent); |
| 1587 | } | 1648 | } |
| 1588 | }) | 1649 | }) |
| 1589 | .show(); | 1650 | .show(); |
| 1590 | } | 1651 | } |
| 1591 | }); | 1652 | }); |
| 1592 | 1653 | ||
| 1593 | } | 1654 | } |
| 1594 | 1655 | ||
| 1595 | 1656 | ||
| 1596 | ///省级接口 | 1657 | ///省级接口 |
| 1597 | public void provices(final Context mContext, final Handler handler) { | 1658 | public void provices(final Context mContext, final Handler handler) { |
| 1598 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); | 1659 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); |
| 1599 | HttpClient.getInstance().get(HttpUrl.provinceUrl, new AsyncHttpResponseHandler() { | 1660 | HttpClient.getInstance().get(HttpUrl.provinceUrl, new AsyncHttpResponseHandler() { |
| 1600 | @Override | 1661 | @Override |
| 1601 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { | 1662 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { |
| 1602 | Log.e("test", "省" + new String(arg2)); | 1663 | Log.e("test", "省" + new String(arg2)); |
| 1603 | try { | 1664 | try { |
| 1604 | JSONObject jsonObject = new JSONObject(new String(arg2)); | 1665 | JSONObject jsonObject = new JSONObject(new String(arg2)); |
| 1605 | int status = jsonObject.optInt("status"); | 1666 | int status = jsonObject.optInt("status"); |
| 1606 | if (status == 100) { | 1667 | if (status == 100) { |
| 1607 | ProvinceInfo provinceInfo = GsonTool.getPerson(new String(arg2), ProvinceInfo.class);//解析json数据 | 1668 | ProvinceInfo provinceInfo = GsonTool.getPerson(new String(arg2), ProvinceInfo.class);//解析json数据 |
| 1608 | Log.e("test", "状态码" + provinceInfo.getStatus()); | 1669 | Log.e("test", "状态码" + provinceInfo.getStatus()); |
| 1609 | List<ProvinceInfo.ProvincesBean> provincesBeanList = provinceInfo.getProvinces(); | 1670 | List<ProvinceInfo.ProvincesBean> provincesBeanList = provinceInfo.getProvinces(); |
| 1610 | Message message = Message.obtain(); | 1671 | Message message = Message.obtain(); |
| 1611 | message.what = HttpCode.PROVICES; | 1672 | message.what = HttpCode.PROVICES; |
| 1612 | message.obj = provincesBeanList; | 1673 | message.obj = provincesBeanList; |
| 1613 | handler.sendMessage(message); | 1674 | handler.sendMessage(message); |
| 1614 | 1675 | ||
| 1615 | 1676 | ||
| 1616 | } else { | 1677 | } else { |
| 1617 | AlertUtils.showToast(mContext, "你好,服务器异常,请稍后重试!"); | 1678 | AlertUtils.showToast(mContext, "你好,服务器异常,请稍后重试!"); |
| 1618 | 1679 | ||
| 1619 | } | 1680 | } |
| 1620 | } catch (JSONException e) { | 1681 | } catch (JSONException e) { |
| 1621 | e.printStackTrace(); | 1682 | e.printStackTrace(); |
| 1622 | } | 1683 | } |
| 1623 | 1684 | ||
| 1624 | 1685 | ||
| 1625 | } | 1686 | } |
| 1626 | 1687 | ||
| 1627 | @Override | 1688 | @Override |
| 1628 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { | 1689 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { |
| 1629 | new CircleDialog.Builder((FragmentActivity) mContext) | 1690 | new CircleDialog.Builder((FragmentActivity) mContext) |
| 1630 | .setCanceledOnTouchOutside(false) | 1691 | .setCanceledOnTouchOutside(false) |
| 1631 | .setCancelable(false) | 1692 | .setCancelable(false) |
| 1632 | .setWidth(0.5f) | 1693 | .setWidth(0.5f) |
| 1633 | .configText(new ConfigText() { | 1694 | .configText(new ConfigText() { |
| 1634 | @Override | 1695 | @Override |
| 1635 | public void onConfig(TextParams params) { | 1696 | public void onConfig(TextParams params) { |
| 1636 | params.gravity = Gravity.CENTER; | 1697 | params.gravity = Gravity.CENTER; |
| 1637 | params.padding = new int[]{50, 50, 50, 50}; | 1698 | params.padding = new int[]{50, 50, 50, 50}; |
| 1638 | } | 1699 | } |
| 1639 | }) | 1700 | }) |
| 1640 | .setText("当前无网络,请检查网络设置") | 1701 | .setText("当前无网络,请检查网络设置") |
| 1641 | .setNegative("继续使用", null) | 1702 | .setNegative("继续使用", null) |
| 1642 | .setPositive("设置网络", new View.OnClickListener() { | 1703 | .setPositive("设置网络", new View.OnClickListener() { |
| 1643 | @Override | 1704 | @Override |
| 1644 | public void onClick(View v) { | 1705 | public void onClick(View v) { |
| 1645 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 | 1706 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 |
| 1646 | mContext.startActivity(intent); | 1707 | mContext.startActivity(intent); |
| 1647 | } | 1708 | } |
| 1648 | }) | 1709 | }) |
| 1649 | .show(); | 1710 | .show(); |
| 1650 | } | 1711 | } |
| 1651 | }); | 1712 | }); |
| 1652 | } | 1713 | } |
| 1653 | 1714 | ||
| 1654 | //市级接口 | 1715 | //市级接口 |
| 1655 | public void cityinfo(final Context mContext, long regionId, final Handler handler) { | 1716 | public void cityinfo(final Context mContext, long regionId, final Handler handler) { |
| 1656 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); | 1717 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); |
| 1657 | HttpClient.getInstance().get(HttpUrl.cityUrl + "?regionId=" + regionId, new AsyncHttpResponseHandler() { | 1718 | HttpClient.getInstance().get(HttpUrl.cityUrl + "?regionId=" + regionId, new AsyncHttpResponseHandler() { |
| 1658 | @Override | 1719 | @Override |
| 1659 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { | 1720 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { |
| 1660 | Log.e("test", "市" + new String(arg2)); | 1721 | Log.e("test", "市" + new String(arg2)); |
| 1661 | try { | 1722 | try { |
| 1662 | JSONObject jsonObject = new JSONObject(new String(arg2)); | 1723 | JSONObject jsonObject = new JSONObject(new String(arg2)); |
| 1663 | int status = jsonObject.optInt("status"); | 1724 | int status = jsonObject.optInt("status"); |
| 1664 | if (status == 100) { | 1725 | if (status == 100) { |
| 1665 | Gson gson = new Gson(); | 1726 | Gson gson = new Gson(); |
| 1666 | CityInfo cityInfo = gson.fromJson(new String(arg2), CityInfo.class); | 1727 | CityInfo cityInfo = gson.fromJson(new String(arg2), CityInfo.class); |
| 1667 | List<CityInfo.CitiesBean> cityInfoBeanList = cityInfo.getCities(); | 1728 | List<CityInfo.CitiesBean> cityInfoBeanList = cityInfo.getCities(); |
| 1668 | Message message = Message.obtain(); | 1729 | Message message = Message.obtain(); |
| 1669 | message.what = HttpCode.CITYS; | 1730 | message.what = HttpCode.CITYS; |
| 1670 | message.obj = cityInfoBeanList; | 1731 | message.obj = cityInfoBeanList; |
| 1671 | handler.sendMessage(message); | 1732 | handler.sendMessage(message); |
| 1672 | 1733 | ||
| 1673 | } else { | 1734 | } else { |
| 1674 | AlertUtils.showToast(mContext, "你好,服务器异常,请稍后重试!"); | 1735 | AlertUtils.showToast(mContext, "你好,服务器异常,请稍后重试!"); |
| 1675 | 1736 | ||
| 1676 | } | 1737 | } |
| 1677 | } catch (JSONException e) { | 1738 | } catch (JSONException e) { |
| 1678 | e.printStackTrace(); | 1739 | e.printStackTrace(); |
| 1679 | } | 1740 | } |
| 1680 | 1741 | ||
| 1681 | 1742 | ||
| 1682 | } | 1743 | } |
| 1683 | 1744 | ||
| 1684 | @Override | 1745 | @Override |
| 1685 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { | 1746 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { |
| 1686 | new CircleDialog.Builder((FragmentActivity) mContext) | 1747 | new CircleDialog.Builder((FragmentActivity) mContext) |
| 1687 | .setCanceledOnTouchOutside(false) | 1748 | .setCanceledOnTouchOutside(false) |
| 1688 | .setCancelable(false) | 1749 | .setCancelable(false) |
| 1689 | .setWidth(0.5f) | 1750 | .setWidth(0.5f) |
| 1690 | .configText(new ConfigText() { | 1751 | .configText(new ConfigText() { |
| 1691 | @Override | 1752 | @Override |
| 1692 | public void onConfig(TextParams params) { | 1753 | public void onConfig(TextParams params) { |
| 1693 | params.gravity = Gravity.CENTER; | 1754 | params.gravity = Gravity.CENTER; |
| 1694 | params.padding = new int[]{50, 50, 50, 50}; | 1755 | params.padding = new int[]{50, 50, 50, 50}; |
| 1695 | } | 1756 | } |
| 1696 | }) | 1757 | }) |
| 1697 | .setText("当前无网络,请检查网络设置") | 1758 | .setText("当前无网络,请检查网络设置") |
| 1698 | .setNegative("继续使用", null) | 1759 | .setNegative("继续使用", null) |
| 1699 | .setPositive("设置网络", new View.OnClickListener() { | 1760 | .setPositive("设置网络", new View.OnClickListener() { |
| 1700 | @Override | 1761 | @Override |
| 1701 | public void onClick(View v) { | 1762 | public void onClick(View v) { |
| 1702 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 | 1763 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 |
| 1703 | mContext.startActivity(intent); | 1764 | mContext.startActivity(intent); |
| 1704 | } | 1765 | } |
| 1705 | }) | 1766 | }) |
| 1706 | .show(); | 1767 | .show(); |
| 1707 | } | 1768 | } |
| 1708 | }); | 1769 | }); |
| 1709 | } | 1770 | } |
| 1710 | 1771 | ||
| 1711 | //区县级接口 | 1772 | //区县级接口 |
| 1712 | public void countyinfo(final Context mContext, int parentId, final Handler handler) { | 1773 | public void countyinfo(final Context mContext, int parentId, final Handler handler) { |
| 1713 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); | 1774 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); |
| 1714 | HttpClient.getInstance().get(HttpUrl.countyUrl + "?regionId=" + parentId, new AsyncHttpResponseHandler() { | 1775 | HttpClient.getInstance().get(HttpUrl.countyUrl + "?regionId=" + parentId, new AsyncHttpResponseHandler() { |
| 1715 | @Override | 1776 | @Override |
| 1716 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { | 1777 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { |
| 1717 | Log.e("test", "区" + new String(arg2)); | 1778 | Log.e("test", "区" + new String(arg2)); |
| 1718 | try { | 1779 | try { |
| 1719 | JSONObject jsonObject = new JSONObject(new String(arg2)); | 1780 | JSONObject jsonObject = new JSONObject(new String(arg2)); |
| 1720 | int status = jsonObject.optInt("status"); | 1781 | int status = jsonObject.optInt("status"); |
| 1721 | if (status == 100) { | 1782 | if (status == 100) { |
| 1722 | Gson gson = new Gson(); | 1783 | Gson gson = new Gson(); |
| 1723 | CountyInfo countyInfo = gson.fromJson(new String(arg2), CountyInfo.class); | 1784 | CountyInfo countyInfo = gson.fromJson(new String(arg2), CountyInfo.class); |
| 1724 | List<CountyInfo.CountiesBean> countyInfoInfoBeanList = countyInfo.getCounties(); | 1785 | List<CountyInfo.CountiesBean> countyInfoInfoBeanList = countyInfo.getCounties(); |
| 1725 | Message message = Message.obtain(); | 1786 | Message message = Message.obtain(); |
| 1726 | message.what = HttpCode.COUNTRY; | 1787 | message.what = HttpCode.COUNTRY; |
| 1727 | message.obj = countyInfoInfoBeanList; | 1788 | message.obj = countyInfoInfoBeanList; |
| 1728 | handler.sendMessage(message); | 1789 | handler.sendMessage(message); |
| 1729 | } else { | 1790 | } else { |
| 1730 | AlertUtils.showToast(mContext, "你好,服务器异常,请稍后重试!"); | 1791 | AlertUtils.showToast(mContext, "你好,服务器异常,请稍后重试!"); |
| 1731 | 1792 | ||
| 1732 | } | 1793 | } |
| 1733 | } catch (JSONException e) { | 1794 | } catch (JSONException e) { |
| 1734 | e.printStackTrace(); | 1795 | e.printStackTrace(); |
| 1735 | } | 1796 | } |
| 1736 | 1797 | ||
| 1737 | 1798 | ||
| 1738 | } | 1799 | } |
| 1739 | 1800 | ||
| 1740 | @Override | 1801 | @Override |
| 1741 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { | 1802 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { |
| 1742 | new CircleDialog.Builder((FragmentActivity) mContext) | 1803 | new CircleDialog.Builder((FragmentActivity) mContext) |
| 1743 | .setCanceledOnTouchOutside(false) | 1804 | .setCanceledOnTouchOutside(false) |
| 1744 | .setCancelable(false) | 1805 | .setCancelable(false) |
| 1745 | .setWidth(0.5f) | 1806 | .setWidth(0.5f) |
| 1746 | .configText(new ConfigText() { | 1807 | .configText(new ConfigText() { |
| 1747 | @Override | 1808 | @Override |
| 1748 | public void onConfig(TextParams params) { | 1809 | public void onConfig(TextParams params) { |
| 1749 | params.gravity = Gravity.CENTER; | 1810 | params.gravity = Gravity.CENTER; |
| 1750 | params.padding = new int[]{50, 50, 50, 50}; | 1811 | params.padding = new int[]{50, 50, 50, 50}; |
| 1751 | } | 1812 | } |
| 1752 | }) | 1813 | }) |
| 1753 | .setText("当前无网络,请检查网络设置") | 1814 | .setText("当前无网络,请检查网络设置") |
| 1754 | .setNegative("继续使用", null) | 1815 | .setNegative("继续使用", null) |
| 1755 | .setPositive("设置网络", new View.OnClickListener() { | 1816 | .setPositive("设置网络", new View.OnClickListener() { |
| 1756 | @Override | 1817 | @Override |
| 1757 | public void onClick(View v) { | 1818 | public void onClick(View v) { |
| 1758 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 | 1819 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 |
| 1759 | mContext.startActivity(intent); | 1820 | mContext.startActivity(intent); |
| 1760 | } | 1821 | } |
| 1761 | }) | 1822 | }) |
| 1762 | .show(); | 1823 | .show(); |
| 1763 | } | 1824 | } |
| 1764 | }); | 1825 | }); |
| 1765 | } | 1826 | } |
| 1766 | 1827 | ||
| 1767 | 1828 | ||
| 1768 | private void closeProgress() { | 1829 | private void closeProgress() { |
| 1769 | try { | 1830 | try { |
| 1770 | if (mProgress != null) { | 1831 | if (mProgress != null) { |
| 1771 | mProgress.dismiss(); | 1832 | mProgress.dismiss(); |
| 1772 | mProgress = null; | 1833 | mProgress = null; |
| 1773 | } | 1834 | } |
PersonalCenter/app/src/main/java/com/hjx/personalcenter/http/HttpUrl.java
| 1 | package com.hjx.personalcenter.http; | 1 | package com.hjx.personalcenter.http; |
| 2 | 2 | ||
| 3 | /** | 3 | /** |
| 4 | * Created by h on 2017/8/15. | 4 | * Created by h on 2017/8/15. |
| 5 | */ | 5 | */ |
| 6 | 6 | ||
| 7 | public class HttpUrl { | 7 | public class HttpUrl { |
| 8 | private final static String Enviroment = "DEVELOPMENT"; | 8 | private final static String Enviroment = "DEVELOPMENT"; |
| 9 | 9 | ||
| 10 | public static String GetDomain(){ | 10 | public static String GetDomain(){ |
| 11 | return Enviroment.equals("DEVELOPMENT") ? "http://boss.test.hjx.com" : "http://boss.hjx.com"; | 11 | return Enviroment.equals("DEVELOPMENT") ? "http://boss.test.hjx.com" : "http://boss.hjx.com"; |
| 12 | } | 12 | } |
| 13 | 13 | ||
| 14 | public static String loginUrl = GetDomain()+"/user/access_token";//登录 | 14 | public static String loginUrl = GetDomain()+"/user/access_token";//登录 |
| 15 | public static String schoolUrl = GetDomain()+"/school/get";//学校 | 15 | public static String schoolUrl = GetDomain()+"/school/get";//学校 |
| 16 | public static String gradesUrl = GetDomain()+"/grades";//年级 | 16 | public static String gradesUrl = GetDomain()+"/grades";//年级 |
| 17 | public static String provinceUrl = GetDomain()+"/ozing/provinces";//省 | 17 | public static String provinceUrl = GetDomain()+"/ozing/provinces";//省 |
| 18 | public static String cityUrl = GetDomain()+"/ozing/cities";//市 | 18 | public static String cityUrl = GetDomain()+"/ozing/cities";//市 |
| 19 | public static String countyUrl = GetDomain()+"/ozing/counties";//区县 | 19 | public static String countyUrl = GetDomain()+"/ozing/counties";//区县 |
| 20 | public static String forgetpassword=GetDomain()+"/ozing/timer/user/newpassword";//忘记密码/ | 20 | public static String forgetpassword=GetDomain()+"/ozing/timer/user/newpassword";//忘记密码/ |
| 21 | public static String registeredUrl=GetDomain()+"/ozing/timer/anking/user";//注册 | 21 | public static String registeredUrl=GetDomain()+"/ozing/timer/anking/user";//注册 |
| 22 | public static String authCodedUrl=GetDomain()+"/ozing/timer/user/fetchAuthCode";//验证码 | 22 | public static String authCodedUrl=GetDomain()+"/ozing/timer/user/fetchAuthCode";//验证码 |
| 23 | public static String isRegiterUrl=GetDomain()+"/ozing/timer/user/registered";//手机号是否注册 | 23 | public static String isRegiterUrl=GetDomain()+"/ozing/timer/user/registered";//手机号是否注册 |
| 24 | public static String changepassword=GetDomain()+"/ozing/timer/user/changepassword";//修改密码 | 24 | public static String changepassword=GetDomain()+"/ozing/timer/user/changepassword";//修改密码 |
| 25 | public static String subcardinfo=GetDomain()+"/electronicCard/addCustomer";//提交保卡信息 | 25 | public static String subcardinfo=GetDomain()+"/electronicCard/addCustomer";//提交保卡信息 |
| 26 | public static String getcardinfo=GetDomain()+"/electronicCard/info";//得到保卡信息 | 26 | public static String getcardinfo=GetDomain()+"/electronicCard/info";//得到保卡信息 |
| 27 | public static String changecardinfo=GetDomain()+"/electronicCard/updateByUserId";//修改保卡信息 | 27 | public static String changecardinfo=GetDomain()+"/electronicCard/updateByUserId";//修改保卡信息 |
| 28 | public static String cardcheck=GetDomain()+"/electronicCard/check";//检查保卡是否填写 | 28 | public static String cardcheck=GetDomain()+"/electronicCard/check";//检查保卡是否填写 |
| 29 | public static String changepresonalinfo=GetDomain()+"/personal/update";//修改个人信息 | 29 | public static String changepresonalinfo=GetDomain()+"/personal/update";//修改个人信息 |
| 30 | public static String getpresonalinfo=GetDomain()+"/personal/get";//获取个人信息 | 30 | public static String getpresonalinfo=GetDomain()+"/personal/get";//获取个人信息 |
| 31 | public static String signature=GetDomain()+"/signature/addOrUpdateSignature";//修改个性签名 | 31 | public static String signature=GetDomain()+"/signature/addOrUpdateSignature";//修改个性签名 |
| 32 | public static String getsignature=GetDomain()+"/signature/info";//获取个性签名 | 32 | public static String getsignature=GetDomain()+"/signature/info";//获取个性签名 |
| 33 | public static String feedbackURL=GetDomain()+"/feedback/add";//用户反馈 | 33 | public static String feedbackURL=GetDomain()+"/feedback/add";//用户反馈 |
| 34 | public static String childUserURL=GetDomain()+"/childUser/info";//获取子账户信息 | 34 | public static String childUserURL=GetDomain()+"/childUser/info";//获取子账户信息 |
| 35 | public static String deletechildUserURL=GetDomain()+"/childUser/delete";//删除子账户 | 35 | public static String deletechildUserURL=GetDomain()+"/childUser/delete";//删除子账户 |
| 36 | public static String addchildUserURL=GetDomain()+"/childUser/addChildUser";//添加子账户 | 36 | public static String addchildUserURL=GetDomain()+"/childUser/addChildUser";//添加子账户 |
| 37 | public static String changechildUserURL=GetDomain()+"/childUser/update";//切换子账户 | 37 | public static String changechildUserURL=GetDomain()+"/childUser/update";//切换子账户 |
| 38 | public static String updateappURL=GetDomain()+"/general/release/version";//系统升级 | 38 | public static String updateappURL=GetDomain()+"/general/release/version";//系统升级 |
| 39 | public static String headerURL=GetDomain()+"/profile/picture/update";//头像上传 | 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 | ||
| 43 | 45 | ||
| 44 | 46 | ||
| 45 | } | 47 | } |
| 46 | 48 |
PersonalCenter/app/src/main/java/com/hjx/personalcenter/util/GetDevicesUtil.java
| 1 | package com.hjx.personalcenter.util; | 1 | package com.hjx.personalcenter.util; |
| 2 | 2 | ||
| 3 | import android.content.Context; | 3 | import android.content.Context; |
| 4 | import android.net.wifi.WifiInfo; | 4 | import android.net.wifi.WifiInfo; |
| 5 | import android.net.wifi.WifiManager; | 5 | import android.net.wifi.WifiManager; |
| 6 | import android.provider.Settings; | ||
| 7 | import android.telephony.TelephonyManager; | ||
| 6 | import android.util.Log; | 8 | import android.util.Log; |
| 7 | 9 | ||
| 8 | import com.hjx.personalcenter.model.DeviceInfo; | 10 | import com.hjx.personalcenter.model.DeviceInfo; |
| 9 | 11 | ||
| 10 | 12 | ||
| 11 | public class GetDevicesUtil { | 13 | public class GetDevicesUtil { |
| 12 | private final static String LOG_TAG = "GetDevicesUtil"; | 14 | private final static String LOG_TAG = "GetDevicesUtil"; |
| 13 | 15 | ||
| 14 | public static DeviceInfo getDevicesInfo(Context context){ | 16 | public static DeviceInfo getDevicesInfo(Context context){ |
| 15 | DeviceInfo mDeviceInfo = new DeviceInfo(); | 17 | DeviceInfo mDeviceInfo = new DeviceInfo(); |
| 16 | initDevicesInfo(mDeviceInfo,context); | 18 | initDevicesInfo(mDeviceInfo,context); |
| 17 | 19 | ||
| 18 | return mDeviceInfo; | 20 | return mDeviceInfo; |
| 19 | } | 21 | } |
| 20 | 22 | ||
| 21 | public static void initDevicesInfo(DeviceInfo mDeviceInfo,Context context){ | 23 | public static void initDevicesInfo(DeviceInfo mDeviceInfo,Context context){ |
| 22 | mDeviceInfo.setDeviceModel(android.os.Build.MODEL); | 24 | mDeviceInfo.setDeviceModel(android.os.Build.MODEL); |
| 23 | Log.e(LOG_TAG,"" + mDeviceInfo.getDeviceModel()); | 25 | Log.e(LOG_TAG,"" + mDeviceInfo.getDeviceModel()); |
| 24 | mDeviceInfo.setMac(getMacAddress(context)); | 26 | mDeviceInfo.setMac(getMacAddress(context)); |
| 25 | Log.e(LOG_TAG,"" + mDeviceInfo.getMac()); | 27 | Log.e(LOG_TAG,"" + mDeviceInfo.getMac()); |
| 26 | 28 | ||
| 27 | mDeviceInfo.setDeviceNumber(getCPUSerial(context)); | 29 | mDeviceInfo.setDeviceNumber(getCPUSerial(context)); |
| 28 | Log.e(LOG_TAG,"" + mDeviceInfo.getDeviceNumber()); | 30 | Log.e(LOG_TAG,"" + mDeviceInfo.getDeviceNumber()); |
| 29 | } | 31 | } |
| 30 | 32 | ||
| 31 | private static String getCPUSerial(Context context) { | 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 | private static String getMacAddress(Context mContext){ | 45 | private static String getMacAddress(Context mContext){ |
| 36 | 46 | ||
| 37 | String ret = null; | 47 | String ret = null; |
| 38 | try { | 48 | try { |
| 39 | WifiManager manager = (WifiManager)mContext.getSystemService(Context.WIFI_SERVICE); | 49 | WifiManager manager = (WifiManager)mContext.getSystemService(Context.WIFI_SERVICE); |
| 40 | WifiInfo info = manager.getConnectionInfo(); | 50 | WifiInfo info = manager.getConnectionInfo(); |
| 41 | ret = info.getMacAddress(); | 51 | ret = info.getMacAddress(); |
| 42 | } catch (Exception e) { | 52 | } catch (Exception e) { |
| 43 | Log.e(LOG_TAG, "get wifi address wrong", e); | 53 | Log.e(LOG_TAG, "get wifi address wrong", e); |
| 44 | } | 54 | } |
| 45 | Log.i(LOG_TAG, "wifi address is" + ret); | 55 | Log.i(LOG_TAG, "wifi address is" + ret); |
| 46 | return ret; | 56 | return ret; |
| 47 | } | 57 | } |
| 48 | } | 58 | } |
| 49 | 59 |