Commit a5bcfdbccfb3179d669fcce5cbc70f4c07f20908
1 parent
d40389f8d6
Exists in
master
版本信息处理
Showing
15 changed files
with
266 additions
and
101 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.util.Log; | ||
| 8 | import android.view.View; | 9 | import android.view.View; |
| 10 | import android.widget.AdapterView; | ||
| 9 | import android.widget.Button; | 11 | import android.widget.Button; |
| 10 | import android.widget.GridView; | 12 | import android.widget.GridView; |
| 11 | import android.widget.ImageView; | 13 | import android.widget.ImageView; |
| 12 | import android.widget.SimpleAdapter; | ||
| 13 | 14 | ||
| 14 | import com.hjx.personalcenter.R; | 15 | import com.hjx.personalcenter.R; |
| 16 | import com.hjx.personalcenter.adapter.GridAdapter; | ||
| 15 | import com.hjx.personalcenter.customdialog.ElectronicCardDialog; | 17 | import com.hjx.personalcenter.customdialog.ElectronicCardDialog; |
| 18 | import com.hjx.personalcenter.customdialog.VerSionDialog; | ||
| 16 | import com.hjx.personalcenter.db.SaveParam; | 19 | import com.hjx.personalcenter.db.SaveParam; |
| 17 | import com.hjx.personalcenter.http.HttpCode; | 20 | import com.hjx.personalcenter.http.HttpCode; |
| 18 | import com.hjx.personalcenter.http.HttpManager; | 21 | import com.hjx.personalcenter.http.HttpManager; |
| 22 | import com.hjx.personalcenter.interfaces.DialogCallBack; | ||
| 23 | import com.hjx.personalcenter.model.DefautPublishInfo; | ||
| 24 | import com.hjx.personalcenter.model.VersionInfo; | ||
| 19 | import com.hjx.personalcenter.util.AlertUtils; | 25 | import com.hjx.personalcenter.util.AlertUtils; |
| 20 | 26 | ||
| 21 | import org.json.JSONException; | 27 | import org.json.JSONException; |
| 22 | import org.json.JSONObject; | 28 | import org.json.JSONObject; |
| 23 | 29 | ||
| 24 | import java.util.ArrayList; | 30 | import java.util.ArrayList; |
| 25 | import java.util.HashMap; | ||
| 26 | import java.util.List; | 31 | import java.util.List; |
| 27 | import java.util.Map; | ||
| 28 | 32 | ||
| 29 | /** | 33 | /** |
| 30 | * 选择教材 | 34 | * 选择教材 |
| 31 | * Created by h on 2017/8/10. | 35 | * Created by h on 2017/8/10. |
| 32 | */ | 36 | */ |
| 33 | 37 | ||
| 34 | public class ChoiseTextBookActivity extends AppCompatActivity implements View.OnClickListener { | 38 | public class ChoiseTextBookActivity extends AppCompatActivity implements View.OnClickListener, AdapterView.OnItemClickListener, DialogCallBack.VersionCallBack { |
| 35 | private GridView gridView; | 39 | private GridView gridView; |
| 36 | private Button btn_ok; | 40 | private Button btn_ok; |
| 37 | private ImageView cancel; | 41 | private ImageView cancel; |
| 38 | private List<Map<String, Object>> data_list; | 42 | private ArrayList<DefautPublishInfo.DataBean> defautPublishInfos = new ArrayList<>(); |
| 39 | private SimpleAdapter sim_adapter; | 43 | private GridAdapter sim_adapter; |
| 40 | // 图片封装为一个数组 | 44 | |
| 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, | ||
| 43 | R.mipmap.ic_launcher, R.mipmap.ic_launcher, R.mipmap.ic_launcher, | ||
| 44 | R.mipmap.ic_launcher}; | ||
| 45 | private String[] subject = {"语文", "数学", "英语", "物理", "化学", "生物", "政治", | ||
| 46 | "历史", "地理"}; | ||
| 47 | private String[] publish = {"人民教育出版社", "人民教育出版社", "人民教育出版社", | ||
| 48 | "人民教育出版社", "人民教育出版社", "人民教育出版社", "人民教育出版社", | ||
| 49 | "人民教育出版社", "人民教育出版社"}; | ||
| 50 | 45 | ||
| 51 | 46 | ||
| 52 | Handler handler = new Handler() { | 47 | Handler handler = new Handler() { |
| 53 | @Override | 48 | @Override |
| 54 | public void handleMessage(Message msg) { | 49 | public void handleMessage(Message msg) { |
| 55 | super.handleMessage(msg); | 50 | super.handleMessage(msg); |
| 56 | JSONObject jsonObject; | 51 | JSONObject jsonObject; |
| 57 | String status; | 52 | String status; |
| 58 | switch (msg.what) { | 53 | switch (msg.what) { |
| 59 | case HttpCode.CHECKCARD: | 54 | case HttpCode.CHECKCARD: |
| 60 | try { | 55 | try { |
| 61 | jsonObject = new JSONObject((String) msg.obj); | 56 | jsonObject = new JSONObject((String) msg.obj); |
| 62 | status = jsonObject.optString("status"); | 57 | status = jsonObject.optString("status"); |
| 63 | if (status.equals("1")) { | 58 | if (status.equals("1")) { |
| 64 | AlertUtils.showToast(ChoiseTextBookActivity.this, "您已经填写了保卡信息,请到主界面确认您的保卡信息是否正确!"); | 59 | AlertUtils.showToast(ChoiseTextBookActivity.this, "您已经填写了保卡信息,请到主界面确认您的保卡信息是否正确!"); |
| 65 | Intent intent = new Intent(); | 60 | Intent intent = new Intent(); |
| 66 | intent.setClass(ChoiseTextBookActivity.this, TheStartPageActivity.class); | 61 | intent.setClass(ChoiseTextBookActivity.this, TheStartPageActivity.class); |
| 67 | ChoiseTextBookActivity.this.startActivity(intent); | 62 | ChoiseTextBookActivity.this.startActivity(intent); |
| 68 | overridePendingTransition(R.anim.rightin, R.anim.rightout); | 63 | overridePendingTransition(R.anim.rightin, R.anim.rightout); |
| 69 | } else if (status.equals("2001")) { | 64 | } else if (status.equals("2001")) { |
| 70 | ElectronicCardDialog.getInstance().show(getSupportFragmentManager(), "ElectronicCardDialog"); | 65 | ElectronicCardDialog.getInstance().show(getSupportFragmentManager(), "ElectronicCardDialog"); |
| 71 | } | 66 | } |
| 72 | 67 | ||
| 73 | } catch (JSONException e) { | 68 | } catch (JSONException e) { |
| 74 | e.printStackTrace(); | 69 | e.printStackTrace(); |
| 75 | } | 70 | } |
| 76 | 71 | ||
| 77 | break; | 72 | break; |
| 73 | case HttpCode.PUBLISH_SUCESS: | ||
| 74 | defautPublishInfos.clear(); | ||
| 75 | defautPublishInfos.addAll( (List<DefautPublishInfo.DataBean>)msg.obj); | ||
| 76 | sim_adapter.notifyDataSetChanged(); | ||
| 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 | String userID = SaveParam.getInstance().getLoginParam(this,"userId"); | ||
| 88 | String graderid = SaveParam.getInstance().getLoginParam(this,SaveParam.GRADENS); | ||
| 89 | try { | ||
| 90 | long auserID = Long.parseLong(userID); | ||
| 91 | int graderID = Integer.parseInt(graderid); | ||
| 92 | //获取个人信息 | ||
| 93 | HttpManager.getInstance().getpublishinfo(this,auserID,graderID,handler); | ||
| 94 | |||
| 95 | } catch (NumberFormatException e) { | ||
| 96 | e.printStackTrace(); | ||
| 97 | } | ||
| 87 | setContentView(R.layout.activity_choisetextbook); | 98 | setContentView(R.layout.activity_choisetextbook); |
| 88 | initView(); | 99 | initView(); |
| 89 | initData(); | 100 | initData(); |
| 90 | initLister(); | 101 | initLister(); |
| 91 | } | 102 | } |
| 92 | 103 | ||
| 93 | private void initView() { | 104 | private void initView() { |
| 94 | gridView = (GridView) findViewById(R.id.grideview); | 105 | gridView = (GridView) findViewById(R.id.grideview); |
| 95 | cancel = (ImageView) findViewById(R.id.cancel); | 106 | cancel = (ImageView) findViewById(R.id.cancel); |
| 96 | btn_ok = (Button) findViewById(R.id.btn_ok); | 107 | btn_ok = (Button) findViewById(R.id.btn_ok); |
| 97 | } | 108 | } |
| 98 | 109 | ||
| 99 | private void initData() { | 110 | private void initData() { |
| 100 | data_list = new ArrayList<Map<String, Object>>(); | 111 | sim_adapter = new GridAdapter(defautPublishInfos,this); |
| 101 | getData(); | ||
| 102 | String[] from = {"image", "text", "text1"}; | ||
| 103 | int[] to = {R.id.image, R.id.text}; | ||
| 104 | sim_adapter = new SimpleAdapter(this, data_list, R.layout.activity_choisetextbook_items, from, to); | ||
| 105 | //配置适配器 | 112 | //配置适配器 |
| 106 | gridView.setAdapter(sim_adapter); | 113 | gridView.setAdapter(sim_adapter); |
| 107 | 114 | ||
| 108 | } | 115 | } |
| 109 | 116 | ||
| 110 | private void initLister() { | 117 | private void initLister() { |
| 111 | btn_ok.setOnClickListener(this); | 118 | btn_ok.setOnClickListener(this); |
| 112 | cancel.setOnClickListener(this); | 119 | cancel.setOnClickListener(this); |
| 120 | gridView.setOnItemClickListener(this); | ||
| 113 | 121 | ||
| 114 | } | 122 | } |
| 115 | 123 | ||
| 116 | public List<Map<String, Object>> getData() { | ||
| 117 | //cion和iconName的长度是相同的,这里任选其一都可以 | ||
| 118 | for (int i = 0; i < icon.length; i++) { | ||
| 119 | Map<String, Object> map = new HashMap<String, Object>(); | ||
| 120 | map.put("image", icon[i]); | ||
| 121 | map.put("text", subject[i]); | ||
| 122 | map.put("text1", publish[i]); | ||
| 123 | data_list.add(map); | ||
| 124 | } | ||
| 125 | |||
| 126 | return data_list; | ||
| 127 | } | ||
| 128 | |||
| 129 | @Override | 124 | @Override |
| 130 | public void onClick(View v) { | 125 | public void onClick(View v) { |
| 131 | switch (v.getId()) { | 126 | switch (v.getId()) { |
| 132 | case R.id.btn_ok: | 127 | case R.id.btn_ok: |
| 133 | String userID = SaveParam.getInstance().getLoginParam(this, "userId"); | 128 | String userID = SaveParam.getInstance().getLoginParam(this, "userId"); |
| 134 | try { | 129 | try { |
| 135 | if (userID == null) { | 130 | if (userID == null) { |
| 136 | AlertUtils.showToast(ChoiseTextBookActivity.this, "连接超时请重新登录!"); | 131 | AlertUtils.showToast(ChoiseTextBookActivity.this, "连接超时请重新登录!"); |
| 137 | 132 | ||
| 138 | } else { | 133 | } else { |
| 139 | long auserID = Long.parseLong(userID); | 134 | long auserID = Long.parseLong(userID); |
| 135 | //验证保卡信息 | ||
| 136 | HttpManager.getInstance().cardinfocheck(this, auserID, handler); | ||
| 137 | //提交注册信息 | ||
| 140 | HttpManager.getInstance().cardinfocheck(this, auserID, handler); | 138 | HttpManager.getInstance().cardinfocheck(this, auserID, handler); |
| 141 | } | 139 | } |
| 142 | 140 |
PersonalCenter/app/src/main/java/com/hjx/personalcenter/activity/MyApplication.java
| 1 | package com.hjx.personalcenter.activity; | 1 | package com.hjx.personalcenter.activity; |
| 2 | 2 | ||
| 3 | import android.app.Application; | 3 | import android.app.Application; |
| 4 | import android.content.Context; | 4 | import android.content.Context; |
| 5 | import android.graphics.drawable.Drawable; | 5 | import android.graphics.drawable.Drawable; |
| 6 | import android.os.Looper; | 6 | import android.os.Looper; |
| 7 | import android.view.Gravity; | 7 | import android.view.Gravity; |
| 8 | import android.widget.TextView; | 8 | import android.widget.TextView; |
| 9 | import android.widget.Toast; | 9 | import android.widget.Toast; |
| 10 | 10 | ||
| 11 | import com.facebook.drawee.backends.pipeline.Fresco; | 11 | import com.facebook.drawee.backends.pipeline.Fresco; |
| 12 | import com.hjx.personalcenter.R; | 12 | import com.hjx.personalcenter.R; |
| 13 | import com.hjx.personalcenter.crash.CrashHandler; | 13 | import com.hjx.personalcenter.crash.CrashHandler; |
| 14 | import com.hjx.personalcenter.util.ImageCache; | 14 | import com.hjx.personalcenter.util.ImageCache; |
| 15 | import com.squareup.leakcanary.LeakCanary; | 15 | import com.squareup.leakcanary.LeakCanary; |
| 16 | import com.tencent.bugly.crashreport.CrashReport; | 16 | import com.tencent.bugly.crashreport.CrashReport; |
| 17 | 17 | ||
| 18 | /** | 18 | /** |
| 19 | * Created by ${yf} on 2017/2/16. | 19 | * Created by ${yf} on 2017/2/16. |
| 20 | */ | 20 | */ |
| 21 | 21 | ||
| 22 | public class MyApplication extends Application { | 22 | public class MyApplication extends Application { |
| 23 | 23 | ||
| 24 | private ImageCache mImageCache; | 24 | private ImageCache mImageCache; |
| 25 | private static Context context; | 25 | private static Context context; |
| 26 | private static MyApplication instance; | 26 | private static MyApplication instance; |
| 27 | @Override | 27 | @Override |
| 28 | public void onCreate() { | 28 | public void onCreate() { |
| 29 | context = getApplicationContext(); | 29 | context = getApplicationContext(); |
| 30 | //c初始化内存检测 | 30 | //c初始化内存检测 |
| 31 | LeakCanary.install(this); | 31 | LeakCanary.install(this); |
| 32 | //初始化Fresco | 32 | //初始化Fresco |
| 33 | Fresco.initialize(this); | 33 | Fresco.initialize(this); |
| 34 | mImageCache = new ImageCache(); | 34 | mImageCache = new ImageCache(); |
| 35 | instance = this; | 35 | instance = this; |
| 36 | CrashReport.initCrashReport(getApplicationContext(), "c2170557a0", false); | 36 | CrashReport.initCrashReport(getApplicationContext(), "c2170557a0", false); |
| 37 | CrashHandler crashHandler = CrashHandler.getInstance(); | 37 | CrashHandler crashHandler = CrashHandler.getInstance(); |
| 38 | //生成错误日志,测试的时候得放开 | 38 | //生成错误日志,测试的时候得放开 |
| 39 | crashHandler.init(getApplicationContext()); | 39 | //crashHandler.init(getApplicationContext()); |
| 40 | crashHandler.registerHandler(new CrashHandler.ExceptionHandler() { | 40 | crashHandler.registerHandler(new CrashHandler.ExceptionHandler() { |
| 41 | 41 | ||
| 42 | @Override | 42 | @Override |
| 43 | public boolean handleCrash(final Context context, final Throwable ex) { | 43 | public boolean handleCrash(final Context context, final Throwable ex) { |
| 44 | new Thread(new Runnable() { | 44 | new Thread(new Runnable() { |
| 45 | 45 | ||
| 46 | @Override | 46 | @Override |
| 47 | public void run() { | 47 | public void run() { |
| 48 | Looper.prepare(); | 48 | Looper.prepare(); |
| 49 | System.out.println("bcz = " + ex.toString()); | 49 | System.out.println("bcz = " + ex.toString()); |
| 50 | Toast toast = new Toast(context); | 50 | Toast toast = new Toast(context); |
| 51 | TextView tv = new TextView(context); | 51 | TextView tv = new TextView(context); |
| 52 | tv.setText(" 很抱歉,"+context.getString(R.string.app_name)+"崩溃了,我们会尽快修复."); | 52 | tv.setText(" 很抱歉,"+context.getString(R.string.app_name)+"崩溃了,我们会尽快修复."); |
| 53 | tv.setPadding(10, 10, 10, 10); | 53 | tv.setPadding(10, 10, 10, 10); |
| 54 | tv.setTextSize(20); | 54 | tv.setTextSize(20); |
| 55 | tv.setBackgroundResource(R.drawable.black_btn_default); | 55 | tv.setBackgroundResource(R.drawable.black_btn_default); |
| 56 | tv.setTextColor(context.getResources().getColor(android.R.color.white)); | 56 | tv.setTextColor(context.getResources().getColor(android.R.color.white)); |
| 57 | Drawable drawable= context.getResources().getDrawable(R.drawable.sorry); | 57 | Drawable drawable= context.getResources().getDrawable(R.drawable.sorry); |
| 58 | drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight()); | 58 | drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight()); |
| 59 | tv.setCompoundDrawables(drawable,null,null,null); | 59 | tv.setCompoundDrawables(drawable,null,null,null); |
| 60 | toast.setView(tv); | 60 | toast.setView(tv); |
| 61 | toast.setGravity(Gravity.CENTER, 0, 0); | 61 | toast.setGravity(Gravity.CENTER, 0, 0); |
| 62 | toast.setDuration(Toast.LENGTH_LONG); | 62 | toast.setDuration(Toast.LENGTH_LONG); |
| 63 | toast.show(); | 63 | toast.show(); |
| 64 | Looper.loop(); | 64 | Looper.loop(); |
| 65 | } | 65 | } |
| 66 | }).start(); | 66 | }).start(); |
| 67 | try { | 67 | try { |
| 68 | Thread.sleep(1000); | 68 | Thread.sleep(1000); |
| 69 | } catch (InterruptedException e) { | 69 | } catch (InterruptedException e) { |
| 70 | // TODO Auto-generated catch block | 70 | // TODO Auto-generated catch block |
| 71 | e.printStackTrace(); | 71 | e.printStackTrace(); |
| 72 | } | 72 | } |
| 73 | return false; | 73 | return false; |
| 74 | } | 74 | } |
| 75 | }); | 75 | }); |
| 76 | super.onCreate(); | 76 | super.onCreate(); |
| 77 | } | 77 | } |
| 78 | public ImageCache getImageCache() { | 78 | public ImageCache getImageCache() { |
| 79 | return mImageCache; | 79 | return mImageCache; |
| 80 | } | 80 | } |
| 81 | 81 | ||
| 82 | public static Context getContext() { | 82 | public static Context getContext() { |
| 83 | return context; | 83 | return context; |
| 84 | } | 84 | } |
| 85 | public static MyApplication getInstance() { | 85 | public static MyApplication getInstance() { |
| 86 | return instance; | 86 | return instance; |
| 87 | } | 87 | } |
| 88 | 88 | ||
| 89 | } | 89 | } |
| 90 | 90 |
PersonalCenter/app/src/main/java/com/hjx/personalcenter/activity/RegisterInfoActivity.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.support.v7.app.AppCompatActivity; | 5 | import android.support.v7.app.AppCompatActivity; |
| 6 | import android.text.TextUtils; | 6 | import android.text.TextUtils; |
| 7 | import android.view.KeyEvent; | 7 | import android.view.KeyEvent; |
| 8 | import android.view.View; | 8 | import android.view.View; |
| 9 | import android.widget.Button; | 9 | import android.widget.Button; |
| 10 | import android.widget.EditText; | 10 | import android.widget.EditText; |
| 11 | import android.widget.TextView; | 11 | import android.widget.TextView; |
| 12 | 12 | ||
| 13 | import com.hjx.personalcenter.R; | 13 | import com.hjx.personalcenter.R; |
| 14 | import com.hjx.personalcenter.customdialog.CitysListDialog; | 14 | import com.hjx.personalcenter.customdialog.CitysListDialog; |
| 15 | import com.hjx.personalcenter.customdialog.CountryDialog; | 15 | import com.hjx.personalcenter.customdialog.CountryDialog; |
| 16 | import com.hjx.personalcenter.customdialog.GradeListDialog; | 16 | import com.hjx.personalcenter.customdialog.GradeListDialog; |
| 17 | import com.hjx.personalcenter.customdialog.ProvinceListDialog; | 17 | import com.hjx.personalcenter.customdialog.ProvinceListDialog; |
| 18 | import com.hjx.personalcenter.customdialog.SchoolListDialog; | 18 | import com.hjx.personalcenter.customdialog.SchoolListDialog; |
| 19 | import com.hjx.personalcenter.db.Content; | 19 | import com.hjx.personalcenter.db.Content; |
| 20 | import com.hjx.personalcenter.db.SaveParam; | 20 | import com.hjx.personalcenter.db.SaveParam; |
| 21 | import com.hjx.personalcenter.http.HttpManager; | 21 | import com.hjx.personalcenter.http.HttpManager; |
| 22 | import com.hjx.personalcenter.interfaces.DialogCallBack; | 22 | import com.hjx.personalcenter.interfaces.DialogCallBack; |
| 23 | import com.hjx.personalcenter.model.CityInfo; | 23 | import com.hjx.personalcenter.model.CityInfo; |
| 24 | import com.hjx.personalcenter.model.CountyInfo; | 24 | import com.hjx.personalcenter.model.CountyInfo; |
| 25 | import com.hjx.personalcenter.model.GradeInfo; | 25 | import com.hjx.personalcenter.model.GradeInfo; |
| 26 | import com.hjx.personalcenter.model.ProvinceInfo; | 26 | import com.hjx.personalcenter.model.ProvinceInfo; |
| 27 | import com.hjx.personalcenter.model.SchoolInfo; | 27 | import com.hjx.personalcenter.model.SchoolInfo; |
| 28 | import com.hjx.personalcenter.util.AlertUtils; | 28 | import com.hjx.personalcenter.util.AlertUtils; |
| 29 | import com.hjx.personalcenter.util.GetDevicesUtil; | 29 | import com.hjx.personalcenter.util.GetDevicesUtil; |
| 30 | 30 | ||
| 31 | import java.util.ArrayList; | 31 | import java.util.ArrayList; |
| 32 | 32 | ||
| 33 | /** | 33 | /** |
| 34 | * 填写注册信息 熊巍 | 34 | * 填写注册信息 熊巍 |
| 35 | * Created by h on 2017/8/9. | 35 | * Created by h on 2017/8/9. |
| 36 | */ | 36 | */ |
| 37 | 37 | ||
| 38 | public class RegisterInfoActivity extends AppCompatActivity implements View.OnClickListener, DialogCallBack.GradeCallBack, DialogCallBack.ProvincesCallBack | 38 | public class RegisterInfoActivity extends AppCompatActivity implements View.OnClickListener, DialogCallBack.GradeCallBack, DialogCallBack.ProvincesCallBack |
| 39 | , DialogCallBack.CitysCallBack, DialogCallBack.CountryCallBack, DialogCallBack.SchoolCallBack { | 39 | , DialogCallBack.CitysCallBack, DialogCallBack.CountryCallBack, DialogCallBack.SchoolCallBack { |
| 40 | private EditText et_username; | 40 | private EditText et_username; |
| 41 | private TextView et_region, et_grade, et_school; | 41 | private TextView et_region, et_grade, et_school; |
| 42 | private Button btn_ok; | 42 | private Button btn_ok; |
| 43 | 43 | ||
| 44 | @Override | 44 | @Override |
| 45 | protected void onCreate(Bundle savedInstanceState) { | 45 | protected void onCreate(Bundle savedInstanceState) { |
| 46 | super.onCreate(savedInstanceState); | 46 | super.onCreate(savedInstanceState); |
| 47 | setContentView(R.layout.activity_registerinfo); | 47 | setContentView(R.layout.activity_registerinfo); |
| 48 | initView(); | 48 | initView(); |
| 49 | initData(); | 49 | initData(); |
| 50 | initLister(); | 50 | initLister(); |
| 51 | } | 51 | } |
| 52 | 52 | ||
| 53 | private void initView() { | 53 | private void initView() { |
| 54 | et_username = (EditText) findViewById(R.id.et_username); | 54 | et_username = (EditText) findViewById(R.id.et_username); |
| 55 | et_region = (TextView) findViewById(R.id.et_region); | 55 | et_region = (TextView) findViewById(R.id.et_region); |
| 56 | et_grade = (TextView) findViewById(R.id.et_grade); | 56 | et_grade = (TextView) findViewById(R.id.et_grade); |
| 57 | et_school = (TextView) findViewById(R.id.et_school); | 57 | et_school = (TextView) findViewById(R.id.et_school); |
| 58 | btn_ok = (Button) findViewById(R.id.btn_ok); | 58 | btn_ok = (Button) findViewById(R.id.btn_ok); |
| 59 | 59 | ||
| 60 | 60 | ||
| 61 | } | 61 | } |
| 62 | 62 | ||
| 63 | private void initData() { | 63 | private void initData() { |
| 64 | if (Content.accountflag == 2) { | 64 | if (Content.accountflag == 2) { |
| 65 | btn_ok.setText("提交"); | 65 | btn_ok.setText("提交"); |
| 66 | 66 | ||
| 67 | } | 67 | } |
| 68 | 68 | ||
| 69 | } | 69 | } |
| 70 | 70 | ||
| 71 | private void initLister() { | 71 | private void initLister() { |
| 72 | et_region.setOnClickListener(this); | 72 | et_region.setOnClickListener(this); |
| 73 | et_grade.setOnClickListener(this); | 73 | et_grade.setOnClickListener(this); |
| 74 | et_school.setOnClickListener(this); | 74 | et_school.setOnClickListener(this); |
| 75 | btn_ok.setOnClickListener(this); | 75 | btn_ok.setOnClickListener(this); |
| 76 | 76 | ||
| 77 | 77 | ||
| 78 | } | 78 | } |
| 79 | 79 | ||
| 80 | @Override | 80 | @Override |
| 81 | public void onClick(View v) { | 81 | public void onClick(View v) { |
| 82 | String register1 = et_username.getText().toString().trim(); | 82 | String register1 = et_username.getText().toString().trim(); |
| 83 | String register2 = et_region.getText().toString().trim(); | 83 | String register2 = et_region.getText().toString().trim(); |
| 84 | String register3 = et_grade.getText().toString().trim(); | 84 | String register3 = et_grade.getText().toString().trim(); |
| 85 | String register4 = et_school.getText().toString().trim(); | 85 | String register4 = et_school.getText().toString().trim(); |
| 86 | switch (v.getId()) { | 86 | switch (v.getId()) { |
| 87 | case R.id.et_region: | 87 | case R.id.et_region: |
| 88 | choiseregion(); | 88 | choiseregion(); |
| 89 | break; | 89 | break; |
| 90 | case R.id.et_grade: | 90 | case R.id.et_grade: |
| 91 | choisegrade(); | 91 | choisegrade(); |
| 92 | break; | 92 | break; |
| 93 | case R.id.et_school: | 93 | case R.id.et_school: |
| 94 | if (TextUtils.isEmpty(register2) || TextUtils.isEmpty(register3)) { | 94 | if (TextUtils.isEmpty(register2) || TextUtils.isEmpty(register3)) { |
| 95 | AlertUtils.showToast(RegisterInfoActivity.this, "请选择年级和地址"); | 95 | AlertUtils.showToast(RegisterInfoActivity.this, "请选择年级和地址"); |
| 96 | return; | 96 | return; |
| 97 | } else { | 97 | } else { |
| 98 | choiseschool(); | 98 | choiseschool(); |
| 99 | } | 99 | } |
| 100 | 100 | ||
| 101 | break; | 101 | break; |
| 102 | case R.id.btn_ok: | 102 | case R.id.btn_ok: |
| 103 | if (TextUtils.isEmpty(register1) || | 103 | if (TextUtils.isEmpty(register1) || |
| 104 | TextUtils.isEmpty(register2) || TextUtils.isEmpty(register3)) { | 104 | TextUtils.isEmpty(register2) || TextUtils.isEmpty(register3)) { |
| 105 | AlertUtils.showToast(RegisterInfoActivity.this, "请将必填项填写完整"); | 105 | AlertUtils.showToast(RegisterInfoActivity.this, "请将必填项填写完整"); |
| 106 | return; | 106 | return; |
| 107 | } else { | 107 | } else { |
| 108 | String register5 = et_username.getText().toString().trim(); | 108 | String register5 = et_username.getText().toString().trim(); |
| 109 | String register6 = et_region.getText().toString().trim(); | 109 | String register6 = et_region.getText().toString().trim(); |
| 110 | String register7 = et_grade.getText().toString().trim(); | 110 | String register7 = et_grade.getText().toString().trim(); |
| 111 | String register8 = et_school.getText().toString().trim(); | 111 | String register8 = et_school.getText().toString().trim(); |
| 112 | if (Content.accountflag == 2) { | 112 | if (Content.accountflag == 2) { |
| 113 | String userID = SaveParam.getInstance().getLoginParam(this, "userId"); | 113 | String userID = SaveParam.getInstance().getLoginParam(this, "userId"); |
| 114 | String grade = SaveParam.getInstance().getLoginParam(this, SaveParam.GRADENS); | 114 | String grade = SaveParam.getInstance().getLoginParam(this, SaveParam.GRADENS); |
| 115 | String School = SaveParam.getInstance().getLoginParam(this, SaveParam.SCHOOOlID); | 115 | String School = SaveParam.getInstance().getLoginParam(this, SaveParam.SCHOOOlID); |
| 116 | String regionId = SaveParam.getInstance().getLoginParam(this, SaveParam.COUNTRY); | 116 | String regionId = SaveParam.getInstance().getLoginParam(this, SaveParam.COUNTRY); |
| 117 | String regionId1 = SaveParam.getInstance().getLoginParam(this, SaveParam.CITYS); | 117 | String regionId1 = SaveParam.getInstance().getLoginParam(this, SaveParam.CITYS); |
| 118 | String devicenumber = GetDevicesUtil.getDevicesInfo(this).getDeviceNumber(); | 118 | String devicenumber = GetDevicesUtil.getDevicesInfo(this).getDeviceNumber(); |
| 119 | if (regionId == null) { | 119 | if (regionId == null) { |
| 120 | regionId = regionId1; | 120 | regionId = regionId1; |
| 121 | } | 121 | } |
| 122 | 122 | ||
| 123 | try { | 123 | try { |
| 124 | Object schoolss; | 124 | Object schoolss; |
| 125 | long auserID = Long.parseLong(userID); | 125 | long auserID = Long.parseLong(userID); |
| 126 | long grades = Long.parseLong(grade); | 126 | long grades = Long.parseLong(grade); |
| 127 | if (TextUtils.isEmpty(register8)) { | 127 | if (TextUtils.isEmpty(register8)) { |
| 128 | schoolss = null; | 128 | schoolss = null; |
| 129 | } else { | 129 | } else { |
| 130 | schoolss = Long.parseLong(School); | 130 | schoolss = Long.parseLong(School); |
| 131 | } | 131 | } |
| 132 | long regionIds = Long.parseLong(regionId); | 132 | long regionIds = Long.parseLong(regionId); |
| 133 | HttpManager.getInstance().addchildAccountinfo(RegisterInfoActivity.this, auserID, "http://hjxprodbucket.oss.aliyuncs.com/static/upload/boss_api/announcement/2017-08-29/a00de899-2f6d-43fb-9e30-71883842540e.png", | 133 | HttpManager.getInstance().addchildAccountinfo(RegisterInfoActivity.this, auserID, "http://hjxprodbucket.oss.aliyuncs.com/static/upload/boss_api/announcement/2017-08-29/a00de899-2f6d-43fb-9e30-71883842540e.png", |
| 134 | register5, grades, schoolss, regionIds, devicenumber, register6); | 134 | register5, grades, schoolss, regionIds, devicenumber, register6); |
| 135 | 135 | ||
| 136 | } catch (NumberFormatException e) { | 136 | } catch (NumberFormatException e) { |
| 137 | e.printStackTrace(); | 137 | e.printStackTrace(); |
| 138 | } | 138 | } |
| 139 | 139 | ||
| 140 | } else { | 140 | } else { |
| 141 | saveinfo(); | ||
| 142 | Intent intent = new Intent(); | 141 | Intent intent = new Intent(); |
| 143 | intent.setClass(RegisterInfoActivity.this, ChoiseTextBookActivity.class); | 142 | intent.setClass(RegisterInfoActivity.this, ChoiseTextBookActivity.class); |
| 144 | startActivity(intent); | 143 | startActivity(intent); |
| 145 | overridePendingTransition(R.anim.rightin, R.anim.rightout); | 144 | overridePendingTransition(R.anim.rightin, R.anim.rightout); |
| 146 | } | 145 | } |
| 147 | 146 | ||
| 148 | } | 147 | } |
| 149 | 148 | ||
| 150 | break; | 149 | break; |
| 151 | } | 150 | } |
| 152 | 151 | ||
| 153 | } | 152 | } |
| 154 | 153 | ||
| 155 | @Override | 154 | @Override |
| 156 | protected void onResume() { | 155 | protected void onResume() { |
| 157 | super.onResume(); | 156 | super.onResume(); |
| 158 | } | 157 | } |
| 159 | 158 | ||
| 160 | //保存个人信息 | ||
| 161 | private void saveinfo() { | ||
| 162 | String register1 = et_username.getText().toString().trim(); | ||
| 163 | String register2 = et_region.getText().toString().trim(); | ||
| 164 | String register3 = et_grade.getText().toString().trim(); | ||
| 165 | String register4 = et_school.getText().toString().trim(); | ||
| 166 | SaveParam.getInstance().saveLoginParam(this, SaveParam.USERNAME, register1); | ||
| 167 | SaveParam.getInstance().saveLoginParam(this, SaveParam.ADRESS, register2); | ||
| 168 | SaveParam.getInstance().saveLoginParam(this, SaveParam.GRADES, register3); | ||
| 169 | SaveParam.getInstance().saveLoginParam(this, SaveParam.SCHOOL, register4); | ||
| 170 | |||
| 171 | } | ||
| 172 | 159 | ||
| 173 | //选择地区 | 160 | //选择地区 |
| 174 | private void choiseregion() { | 161 | private void choiseregion() { |
| 175 | ProvinceListDialog.getInstance((DialogCallBack.ProvincesCallBack) RegisterInfoActivity.this).show(getSupportFragmentManager(), "ProvinceListDialog"); | 162 | ProvinceListDialog.getInstance((DialogCallBack.ProvincesCallBack) RegisterInfoActivity.this).show(getSupportFragmentManager(), "ProvinceListDialog"); |
| 176 | 163 | ||
| 177 | } | 164 | } |
| 178 | 165 | ||
| 179 | //选择年级 | 166 | //选择年级 |
| 180 | private void choisegrade() { | 167 | private void choisegrade() { |
| 181 | GradeListDialog.getInstance((DialogCallBack.GradeCallBack) this).show(getSupportFragmentManager(), "GradeListDialog"); | 168 | GradeListDialog.getInstance((DialogCallBack.GradeCallBack) this).show(getSupportFragmentManager(), "GradeListDialog"); |
| 182 | 169 | ||
| 183 | } | 170 | } |
| 184 | 171 | ||
| 185 | //选择学校 | 172 | //选择学校 |
| 186 | private void choiseschool() { | 173 | private void choiseschool() { |
| 187 | SchoolListDialog.getInstance((DialogCallBack.SchoolCallBack) this).show(getSupportFragmentManager(), "SchoolListDialog"); | 174 | SchoolListDialog.getInstance((DialogCallBack.SchoolCallBack) this).show(getSupportFragmentManager(), "SchoolListDialog"); |
| 188 | 175 | ||
| 189 | } | 176 | } |
| 190 | 177 | ||
| 191 | 178 | ||
| 192 | @Override | 179 | @Override |
| 193 | public void provinceOnItemClick(ArrayList<ProvinceInfo.ProvincesBean> data, int position, int type) { | 180 | public void provinceOnItemClick(ArrayList<ProvinceInfo.ProvincesBean> data, int position, int type) { |
| 194 | String regionName = data.get(position).getRegionName(); | 181 | String regionName = data.get(position).getRegionName(); |
| 195 | SaveParam.getInstance().saveLoginParam(this, "sheng", regionName); | 182 | SaveParam.getInstance().saveLoginParam(this, "sheng", regionName); |
| 196 | CitysListDialog.getInstance((DialogCallBack.CitysCallBack) this).show(getSupportFragmentManager(), "CitysListDialog"); | 183 | CitysListDialog.getInstance((DialogCallBack.CitysCallBack) this).show(getSupportFragmentManager(), "CitysListDialog"); |
| 197 | et_region.setText(""); | 184 | et_region.setText(""); |
| 198 | et_region.setText(regionName); | 185 | et_region.setText(regionName); |
| 199 | 186 | ||
| 200 | } | 187 | } |
| 201 | 188 | ||
| 202 | @Override | 189 | @Override |
| 203 | public boolean onKeyUp(int keyCode, KeyEvent event) { | 190 | public boolean onKeyUp(int keyCode, KeyEvent event) { |
| 204 | if (keyCode == KeyEvent.KEYCODE_BACK) { | 191 | if (keyCode == KeyEvent.KEYCODE_BACK) { |
| 205 | finish(); | 192 | finish(); |
| 206 | 193 | ||
| 207 | } | 194 | } |
| 208 | return super.onKeyUp(keyCode, event); | 195 | return super.onKeyUp(keyCode, event); |
| 209 | } | 196 | } |
| 210 | 197 | ||
| 211 | @Override | 198 | @Override |
| 212 | public void province3OnItemClick(ArrayList<GradeInfo.DataBean.ChildrenBean> data, int position, int type) { | 199 | public void province3OnItemClick(ArrayList<GradeInfo.DataBean.ChildrenBean> data, int position, int type) { |
| 213 | String regionName = data.get(position).getName(); | 200 | String regionName = data.get(position).getName(); |
| 214 | et_grade.setText(regionName); | 201 | et_grade.setText(regionName); |
| 215 | 202 | ||
| 216 | } | 203 | } |
| 217 | 204 | ||
| 218 | @Override | 205 | @Override |
| 219 | public void province1OnItemClick(ArrayList<CityInfo.CitiesBean> data, int position, int type) { | 206 | public void province1OnItemClick(ArrayList<CityInfo.CitiesBean> data, int position, int type) { |
| 220 | String regionName = data.get(position).getRegionName(); | 207 | String regionName = data.get(position).getRegionName(); |
| 221 | String provice = SaveParam.getInstance().getLoginParam(this, "sheng"); | 208 | String provice = SaveParam.getInstance().getLoginParam(this, "sheng"); |
| 222 | SaveParam.getInstance().saveLoginParam(this, "shi", regionName); | 209 | SaveParam.getInstance().saveLoginParam(this, "shi", regionName); |
| 223 | CountryDialog.getInstance((DialogCallBack.CountryCallBack) this).show(getSupportFragmentManager(), "CountryDialog"); | 210 | CountryDialog.getInstance((DialogCallBack.CountryCallBack) this).show(getSupportFragmentManager(), "CountryDialog"); |
| 224 | et_region.setText(""); | 211 | et_region.setText(""); |
| 225 | et_region.setText(provice + regionName); | 212 | et_region.setText(provice + regionName); |
| 226 | 213 | ||
| 227 | } | 214 | } |
| 228 | 215 | ||
| 229 | @Override | 216 | @Override |
| 230 | public void province2OnItemClick(ArrayList<CountyInfo.CountiesBean> data, int position, int type) { | 217 | public void province2OnItemClick(ArrayList<CountyInfo.CountiesBean> data, int position, int type) { |
| 231 | String regionName = data.get(position).getRegionName(); | 218 | String regionName = data.get(position).getRegionName(); |
| 232 | String provices = SaveParam.getInstance().getLoginParam(this, "sheng"); | 219 | String provices = SaveParam.getInstance().getLoginParam(this, "sheng"); |
| 233 | String citys = SaveParam.getInstance().getLoginParam(this, "shi"); | 220 | String citys = SaveParam.getInstance().getLoginParam(this, "shi"); |
| 234 | et_region.setText(""); | 221 | et_region.setText(""); |
| 235 | et_region.setText(provices + citys + regionName); | 222 | et_region.setText(provices + citys + regionName); |
| 236 | 223 | ||
| 237 | } | 224 | } |
| 238 | 225 | ||
| 239 | @Override | 226 | @Override |
| 240 | public void provinceO4nItemClick(ArrayList<SchoolInfo.DataBean> data, int position, int type) { | 227 | public void provinceO4nItemClick(ArrayList<SchoolInfo.DataBean> data, int position, int type) { |
| 241 | String regionName = data.get(position).getSchoolName(); | 228 | String regionName = data.get(position).getSchoolName(); |
| 242 | et_school.setText(regionName); | 229 | et_school.setText(regionName); |
| 243 | 230 | ||
| 244 | } | 231 | } |
| 245 | } | 232 | } |
| 246 | 233 |
PersonalCenter/app/src/main/java/com/hjx/personalcenter/activity/TheStartPageActivity.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.support.v7.app.AppCompatActivity; | 5 | import android.support.v7.app.AppCompatActivity; |
| 6 | import android.view.View; | 6 | import android.view.View; |
| 7 | import android.widget.Button; | 7 | import android.widget.Button; |
| 8 | 8 | ||
| 9 | import com.hjx.personalcenter.R; | 9 | import com.hjx.personalcenter.R; |
| 10 | import com.hjx.personalcenter.db.SaveParam; | ||
| 10 | 11 | ||
| 11 | /** | 12 | /** |
| 12 | * Created by h on 2017/8/10. | 13 | * Created by h on 2017/8/10. |
| 13 | */ | 14 | */ |
| 14 | 15 | ||
| 15 | public class TheStartPageActivity extends AppCompatActivity implements View.OnClickListener { | 16 | public class TheStartPageActivity extends AppCompatActivity implements View.OnClickListener { |
| 16 | private Button btn_start; | 17 | private Button btn_start; |
| 17 | @Override | 18 | @Override |
| 18 | protected void onCreate(Bundle savedInstanceState) { | 19 | protected void onCreate(Bundle savedInstanceState) { |
| 19 | super.onCreate(savedInstanceState); | 20 | super.onCreate(savedInstanceState); |
| 20 | setContentView(R.layout.activity_start_page); | 21 | setContentView(R.layout.activity_start_page); |
| 21 | initView(); | 22 | initView(); |
| 22 | initData(); | 23 | initData(); |
| 23 | initLister(); | 24 | initLister(); |
| 24 | } | 25 | } |
| 25 | private void initView() { | 26 | private void initView() { |
| 26 | btn_start = (Button) findViewById(R.id.btn_start); | 27 | btn_start = (Button) findViewById(R.id.btn_start); |
| 27 | } | 28 | } |
| 28 | 29 | ||
| 29 | private void initData() { | 30 | private void initData() { |
| 30 | 31 | ||
| 31 | } | 32 | } |
| 32 | 33 | ||
| 33 | private void initLister() { | 34 | private void initLister() { |
| 34 | btn_start.setOnClickListener(this); | 35 | btn_start.setOnClickListener(this); |
| 35 | } | 36 | } |
| 36 | 37 | ||
| 37 | @Override | 38 | @Override |
| 38 | public void onClick(View v) { | 39 | public void onClick(View v) { |
| 39 | switch (v.getId()){ | 40 | switch (v.getId()){ |
| 40 | case R.id.btn_start: | 41 | case R.id.btn_start: |
| 42 | SaveParam.getInstance().saveLoginParam(this, "login", "true"); | ||
| 41 | Intent intent = new Intent(); | 43 | Intent intent = new Intent(); |
| 42 | intent.setClass(TheStartPageActivity.this,MainActivity.class); | 44 | intent.setClass(TheStartPageActivity.this,MainActivity.class); |
| 43 | startActivity(intent); | 45 | startActivity(intent); |
| 44 | overridePendingTransition(R.anim.rightin, R.anim.rightout); | 46 | overridePendingTransition(R.anim.rightin, R.anim.rightout); |
| 45 | finish(); | 47 | finish(); |
| 46 | break; | 48 | break; |
| 47 | } | 49 | } |
| 48 | } | 50 | } |
| 49 | } | 51 | } |
| 50 | 52 |
PersonalCenter/app/src/main/java/com/hjx/personalcenter/adapter/GridAdapter.java
| 1 | package com.hjx.personalcenter.adapter; | 1 | package com.hjx.personalcenter.adapter; |
| 2 | 2 | ||
| 3 | import android.content.Context; | 3 | import android.content.Context; |
| 4 | import android.view.View; | 4 | import android.view.View; |
| 5 | import android.view.ViewGroup; | 5 | import android.view.ViewGroup; |
| 6 | import android.widget.BaseAdapter; | 6 | import android.widget.BaseAdapter; |
| 7 | import android.widget.TextView; | 7 | import android.widget.TextView; |
| 8 | 8 | ||
| 9 | import com.facebook.drawee.view.SimpleDraweeView; | 9 | import com.facebook.drawee.view.SimpleDraweeView; |
| 10 | import com.hjx.personalcenter.R; | 10 | import com.hjx.personalcenter.R; |
| 11 | import com.hjx.personalcenter.model.DefautPublishInfo; | 11 | import com.hjx.personalcenter.model.DefautPublishInfo; |
| 12 | 12 | ||
| 13 | import java.util.ArrayList; | 13 | import java.util.ArrayList; |
| 14 | 14 | ||
| 15 | /** | 15 | /** |
| 16 | * Created by h on 2017/9/12. | 16 | * Created by h on 2017/9/12. |
| 17 | */ | 17 | */ |
| 18 | 18 | ||
| 19 | public class GridAdapter extends BaseAdapter { | 19 | public class GridAdapter extends BaseAdapter { |
| 20 | private ArrayList<DefautPublishInfo> defautPublishInfo; | 20 | private ArrayList<DefautPublishInfo.DataBean> defautPublishInfo; |
| 21 | private Context context; | 21 | private Context context; |
| 22 | 22 | ||
| 23 | public GridAdapter(ArrayList<DefautPublishInfo> defautPublishInfo, Context context) { | 23 | public GridAdapter(ArrayList<DefautPublishInfo.DataBean> defautPublishInfo, Context context) { |
| 24 | this.defautPublishInfo = defautPublishInfo; | 24 | this.defautPublishInfo = defautPublishInfo; |
| 25 | this.context = context; | 25 | this.context = context; |
| 26 | } | 26 | } |
| 27 | 27 | ||
| 28 | @Override | 28 | @Override |
| 29 | public int getCount() { | 29 | public int getCount() { |
| 30 | return defautPublishInfo.size(); | 30 | return defautPublishInfo.size(); |
| 31 | } | 31 | } |
| 32 | 32 | ||
| 33 | @Override | 33 | @Override |
| 34 | public Object getItem(int position) { | 34 | public Object getItem(int position) { |
| 35 | return position; | 35 | return position; |
| 36 | } | 36 | } |
| 37 | 37 | ||
| 38 | @Override | 38 | @Override |
| 39 | public long getItemId(int position) { | 39 | public long getItemId(int position) { |
| 40 | return position; | 40 | return position; |
| 41 | } | 41 | } |
| 42 | 42 | ||
| 43 | @Override | 43 | @Override |
| 44 | public View getView(int position, View convertView, ViewGroup parent) { | 44 | public View getView(int position, View convertView, ViewGroup parent) { |
| 45 | ViewHolder viewHolder = new ViewHolder(); | 45 | ViewHolder viewHolder = new ViewHolder(); |
| 46 | if (convertView == null) { | 46 | if (convertView == null) { |
| 47 | convertView = View.inflate(context, R.layout.fragment_changge_version_info_itmes, null); | 47 | convertView = View.inflate(context, R.layout.fragment_changge_version_info_itmes, null); |
| 48 | viewHolder.simpleDraweeView = (SimpleDraweeView) convertView.findViewById(R.id.image_publish); | 48 | viewHolder.simpleDraweeView = (SimpleDraweeView) convertView.findViewById(R.id.image_publish); |
| 49 | viewHolder.subject = (TextView) convertView.findViewById(R.id.subject); | 49 | viewHolder.subject = (TextView) convertView.findViewById(R.id.subject); |
| 50 | viewHolder.publish = (TextView) convertView.findViewById(R.id.tv_publish); | 50 | viewHolder.publish = (TextView) convertView.findViewById(R.id.tv_publish); |
| 51 | convertView.setTag(viewHolder); | 51 | convertView.setTag(viewHolder); |
| 52 | } else { | 52 | } else { |
| 53 | viewHolder = (ViewHolder) convertView.getTag(); | 53 | viewHolder = (ViewHolder) convertView.getTag(); |
| 54 | } | 54 | } |
| 55 | viewHolder.simpleDraweeView.setImageURI(defautPublishInfo.get(position).getImagurl()); | 55 | viewHolder.simpleDraweeView.setImageURI(defautPublishInfo.get(position).getCover()); |
| 56 | viewHolder.subject.setText(defautPublishInfo.get(position).getSubjuct()); | 56 | viewHolder.subject.setText(defautPublishInfo.get(position).getSubject()); |
| 57 | viewHolder.publish.setText(defautPublishInfo.get(position).getPublish()); | 57 | viewHolder.publish.setText(defautPublishInfo.get(position).getPress()); |
| 58 | return convertView; | 58 | return convertView; |
| 59 | } | 59 | } |
| 60 | 60 | ||
| 61 | static class ViewHolder { | 61 | static class ViewHolder { |
| 62 | SimpleDraweeView simpleDraweeView; | 62 | SimpleDraweeView simpleDraweeView; |
| 63 | TextView subject; | 63 | TextView subject; |
| 64 | TextView publish; | 64 | TextView publish; |
| 65 | } | 65 | } |
| 66 | } | 66 | } |
| 67 | 67 |
PersonalCenter/app/src/main/java/com/hjx/personalcenter/customdialog/VerSionDialog.java
| 1 | package com.hjx.personalcenter.customdialog; | 1 | package com.hjx.personalcenter.customdialog; |
| 2 | 2 | ||
| 3 | import android.annotation.SuppressLint; | 3 | import android.annotation.SuppressLint; |
| 4 | import android.content.Context; | 4 | import android.content.Context; |
| 5 | import android.graphics.Color; | 5 | import android.graphics.Color; |
| 6 | import android.os.Bundle; | 6 | import android.os.Bundle; |
| 7 | import android.os.Handler; | 7 | import android.os.Handler; |
| 8 | import android.os.Message; | 8 | import android.os.Message; |
| 9 | import android.util.Log; | 9 | import android.util.Log; |
| 10 | import android.view.Gravity; | 10 | import android.view.Gravity; |
| 11 | import android.view.LayoutInflater; | 11 | import android.view.LayoutInflater; |
| 12 | import android.view.View; | 12 | import android.view.View; |
| 13 | import android.view.ViewGroup; | 13 | import android.view.ViewGroup; |
| 14 | import android.widget.AdapterView; | 14 | import android.widget.AdapterView; |
| 15 | import android.widget.ImageView; | 15 | import android.widget.ImageView; |
| 16 | import android.widget.ListView; | 16 | import android.widget.ListView; |
| 17 | 17 | ||
| 18 | import com.hjx.personalcenter.R; | 18 | import com.hjx.personalcenter.R; |
| 19 | import com.hjx.personalcenter.adapter.VersionAdapter; | 19 | import com.hjx.personalcenter.adapter.VersionAdapter; |
| 20 | import com.hjx.personalcenter.db.SaveParam; | 20 | import com.hjx.personalcenter.db.SaveParam; |
| 21 | import com.hjx.personalcenter.http.HttpCode; | 21 | import com.hjx.personalcenter.http.HttpCode; |
| 22 | import com.hjx.personalcenter.http.HttpManager; | 22 | import com.hjx.personalcenter.http.HttpManager; |
| 23 | import com.hjx.personalcenter.interfaces.DialogCallBack; | 23 | import com.hjx.personalcenter.interfaces.DialogCallBack; |
| 24 | import com.hjx.personalcenter.model.VersionInfo; | 24 | import com.hjx.personalcenter.model.VersionInfo; |
| 25 | import com.mylhyl.circledialog.BaseCircleDialog; | 25 | import com.mylhyl.circledialog.BaseCircleDialog; |
| 26 | import com.mylhyl.circledialog.res.values.CircleDimen; | 26 | import com.mylhyl.circledialog.res.values.CircleDimen; |
| 27 | 27 | ||
| 28 | import java.util.ArrayList; | 28 | import java.util.ArrayList; |
| 29 | import java.util.List; | 29 | import java.util.List; |
| 30 | 30 | ||
| 31 | /** | 31 | /** |
| 32 | * 自定义版本信息列表对话框 | 32 | * 自定义版本信息列表对话框 |
| 33 | * Created by h on 2017/8/10. | 33 | * Created by h on 2017/8/10. |
| 34 | */ | 34 | */ |
| 35 | @SuppressLint("ValidFragment") | 35 | @SuppressLint("ValidFragment") |
| 36 | public class VerSionDialog extends BaseCircleDialog implements AdapterView.OnItemClickListener { | 36 | public class VerSionDialog extends BaseCircleDialog implements AdapterView.OnItemClickListener { |
| 37 | private VersionAdapter listadapter; | 37 | private VersionAdapter listadapter; |
| 38 | private ImageView cance; | 38 | private ImageView cance; |
| 39 | private ListView listView; | 39 | private ListView listView; |
| 40 | private ArrayList<VersionInfo.DataBean> data = new ArrayList<>(); | 40 | private ArrayList<VersionInfo.DataBean> data = new ArrayList<>(); |
| 41 | 41 | ||
| 42 | private DialogCallBack.VersionCallBack mCallBack; | 42 | private DialogCallBack.VersionCallBack mCallBack; |
| 43 | 43 | ||
| 44 | Handler handler = new Handler(){ | 44 | Handler handler = new Handler(){ |
| 45 | @Override | 45 | @Override |
| 46 | public void handleMessage(Message msg) { | 46 | public void handleMessage(Message msg) { |
| 47 | super.handleMessage(msg); | 47 | super.handleMessage(msg); |
| 48 | switch (msg.what){ | 48 | switch (msg.what){ |
| 49 | case HttpCode.VERSION_SUCESS: | 49 | case HttpCode.VERSION_SUCESS: |
| 50 | data.clear(); | 50 | data.clear(); |
| 51 | data.addAll( (List<VersionInfo.DataBean>)msg.obj); | 51 | data.addAll( (List<VersionInfo.DataBean>)msg.obj); |
| 52 | listadapter.notifyDataSetChanged(); | 52 | listadapter.notifyDataSetChanged(); |
| 53 | 53 | ||
| 54 | break; | 54 | break; |
| 55 | } | 55 | } |
| 56 | } | 56 | } |
| 57 | }; | 57 | }; |
| 58 | public VerSionDialog(DialogCallBack.VersionCallBack callBack) { | 58 | public VerSionDialog(DialogCallBack.VersionCallBack callBack) { |
| 59 | this.mCallBack = callBack; | 59 | this.mCallBack = callBack; |
| 60 | } | 60 | } |
| 61 | 61 | ||
| 62 | public static VerSionDialog getInstance(DialogCallBack.VersionCallBack callBack) { | 62 | public static VerSionDialog getInstance(DialogCallBack.VersionCallBack callBack) { |
| 63 | VerSionDialog dialogFragment = new VerSionDialog(callBack); | 63 | VerSionDialog dialogFragment = new VerSionDialog(callBack); |
| 64 | dialogFragment.setCanceledBack(true); | 64 | dialogFragment.setCanceledBack(true); |
| 65 | dialogFragment.setCanceledOnTouchOutside(true); | 65 | dialogFragment.setCanceledOnTouchOutside(true); |
| 66 | dialogFragment.setRadius(CircleDimen.RADIUS); | 66 | dialogFragment.setRadius(CircleDimen.RADIUS); |
| 67 | dialogFragment.setWidth(0.5f); | 67 | dialogFragment.setWidth(0.5f); |
| 68 | dialogFragment.setGravity(Gravity.CENTER); | 68 | dialogFragment.setGravity(Gravity.CENTER); |
| 69 | dialogFragment.setBackgroundColor(Color.WHITE); | 69 | dialogFragment.setBackgroundColor(Color.WHITE); |
| 70 | return dialogFragment; | 70 | return dialogFragment; |
| 71 | } | 71 | } |
| 72 | 72 | ||
| 73 | @Override | 73 | @Override |
| 74 | public View createView(Context context, LayoutInflater inflater, ViewGroup container) { | 74 | public View createView(Context context, LayoutInflater inflater, ViewGroup container) { |
| 75 | return inflater.inflate(R.layout.custom_adilog_provicelist, container, false); | 75 | return inflater.inflate(R.layout.custom_adilog_publishlist, container, false); |
| 76 | } | 76 | } |
| 77 | 77 | ||
| 78 | @Override | 78 | @Override |
| 79 | public void onActivityCreated(Bundle savedInstanceState) { | 79 | public void onActivityCreated(Bundle savedInstanceState) { |
| 80 | super.onActivityCreated(savedInstanceState); | 80 | super.onActivityCreated(savedInstanceState); |
| 81 | listView = (ListView) getView().findViewById(R.id.listadapter); | 81 | listView = (ListView) getView().findViewById(R.id.listadapter); |
| 82 | cance = (ImageView) getView().findViewById(R.id.cancel); | 82 | cance = (ImageView) getView().findViewById(R.id.cancel); |
| 83 | listadapter = new VersionAdapter(data,getActivity()); | 83 | listadapter = new VersionAdapter(data,getActivity()); |
| 84 | listView.setAdapter(listadapter); | 84 | listView.setAdapter(listadapter); |
| 85 | listView.setOnItemClickListener(this); | 85 | listView.setOnItemClickListener(this); |
| 86 | cance.setOnClickListener(new View.OnClickListener() { | 86 | cance.setOnClickListener(new View.OnClickListener() { |
| 87 | @Override | 87 | @Override |
| 88 | public void onClick(View v) { | 88 | public void onClick(View v) { |
| 89 | dismiss(); | 89 | dismiss(); |
| 90 | } | 90 | } |
| 91 | }); | 91 | }); |
| 92 | String subjectName = SaveParam.getInstance().getLoginParam(getActivity(),SaveParam.VERSION); | 92 | String subjectName = SaveParam.getInstance().getLoginParam(getActivity(),SaveParam.VERSION); |
| 93 | Log.e("test","选择的科目"+subjectName); | 93 | Log.e("test","选择的科目"+subjectName); |
| 94 | HttpManager.getInstance().versioninfo(getActivity(),subjectName,handler); | 94 | HttpManager.getInstance().versioninfo(getActivity(),subjectName,handler); |
| 95 | 95 | ||
| 96 | } | 96 | } |
| 97 | 97 | ||
| 98 | @Override | 98 | @Override |
| 99 | public void onItemClick(AdapterView<?> parent, View view, int position, long id) { | 99 | public void onItemClick(AdapterView<?> parent, View view, int position, long id) { |
| 100 | //Toast.makeText(getActivity(), "你点击了第" + position + "个", Toast.LENGTH_LONG).show(); | 100 | mCallBack.versionOnItemClick(data,position,1100); |
| 101 | //SaveParam.getInstance().saveLoginParam(getActivity(), SaveParam.PROVINCES, ""+data.get(position).getRegionId()); | ||
| 102 | mCallBack.versionOnItemClick(data,position,1); | ||
| 103 | dismiss(); | 101 | dismiss(); |
| 104 | 102 | ||
| 105 | } | 103 | } |
| 106 | } | 104 | } |
| 107 | 105 |
PersonalCenter/app/src/main/java/com/hjx/personalcenter/fragment/LoginFragment.java
| 1 | package com.hjx.personalcenter.fragment; | 1 | package com.hjx.personalcenter.fragment; |
| 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.annotation.Nullable; | 7 | import android.support.annotation.Nullable; |
| 8 | import android.support.v4.app.Fragment; | 8 | import android.support.v4.app.Fragment; |
| 9 | import android.text.TextUtils; | 9 | import android.text.TextUtils; |
| 10 | import android.view.LayoutInflater; | 10 | import android.view.LayoutInflater; |
| 11 | import android.view.View; | 11 | import android.view.View; |
| 12 | import android.view.ViewGroup; | 12 | import android.view.ViewGroup; |
| 13 | import android.widget.Button; | 13 | import android.widget.Button; |
| 14 | import android.widget.EditText; | 14 | import android.widget.EditText; |
| 15 | import android.widget.TextView; | 15 | import android.widget.TextView; |
| 16 | import android.widget.Toast; | 16 | import android.widget.Toast; |
| 17 | 17 | ||
| 18 | import com.hjx.personalcenter.R; | 18 | import com.hjx.personalcenter.R; |
| 19 | import com.hjx.personalcenter.activity.ForgotPasswordActivity; | 19 | import com.hjx.personalcenter.activity.ForgotPasswordActivity; |
| 20 | import com.hjx.personalcenter.activity.MainActivity; | 20 | import com.hjx.personalcenter.activity.MainActivity; |
| 21 | import com.hjx.personalcenter.activity.RegisterInfoActivity; | 21 | import com.hjx.personalcenter.activity.RegisterInfoActivity; |
| 22 | import com.hjx.personalcenter.customdialog.ElectronicCardDialog; | 22 | import com.hjx.personalcenter.customdialog.ElectronicCardDialog; |
| 23 | import com.hjx.personalcenter.db.SaveParam; | 23 | import com.hjx.personalcenter.db.SaveParam; |
| 24 | import com.hjx.personalcenter.http.HttpCode; | 24 | import com.hjx.personalcenter.http.HttpCode; |
| 25 | import com.hjx.personalcenter.http.HttpManager; | 25 | import com.hjx.personalcenter.http.HttpManager; |
| 26 | import com.hjx.personalcenter.util.AlertUtils; | 26 | import com.hjx.personalcenter.util.AlertUtils; |
| 27 | import com.hjx.personalcenter.util.PhoneNumCheckUtils; | 27 | import com.hjx.personalcenter.util.PhoneNumCheckUtils; |
| 28 | 28 | ||
| 29 | import org.json.JSONException; | 29 | import org.json.JSONException; |
| 30 | import org.json.JSONObject; | 30 | import org.json.JSONObject; |
| 31 | 31 | ||
| 32 | /** | 32 | /** |
| 33 | * 登录 | 33 | * 登录 |
| 34 | * Created by h on 2017/8/8. | 34 | * Created by h on 2017/8/8. |
| 35 | */ | 35 | */ |
| 36 | 36 | ||
| 37 | public class LoginFragment extends Fragment implements View.OnClickListener { | 37 | public class LoginFragment extends Fragment implements View.OnClickListener { |
| 38 | private View mView; | 38 | private View mView; |
| 39 | private int type; | 39 | private int type; |
| 40 | private TextView tv_forget_pwd; | 40 | private TextView tv_forget_pwd; |
| 41 | private Button btn_login; | 41 | private Button btn_login; |
| 42 | private EditText phonenumber,login_pwwd; | 42 | private EditText phonenumber,login_pwwd; |
| 43 | public static String TABLAYOUT_FRAGMENT = "tab_fragment"; | 43 | public static String TABLAYOUT_FRAGMENT = "tab_fragment"; |
| 44 | Intent intent = new Intent(); | 44 | Intent intent = new Intent(); |
| 45 | public static LoginFragment newInstance(int type) { | 45 | public static LoginFragment newInstance(int type) { |
| 46 | LoginFragment fragment = new LoginFragment(); | 46 | LoginFragment fragment = new LoginFragment(); |
| 47 | Bundle bundle = new Bundle(); | 47 | Bundle bundle = new Bundle(); |
| 48 | bundle.putSerializable(TABLAYOUT_FRAGMENT, type); | 48 | bundle.putSerializable(TABLAYOUT_FRAGMENT, type); |
| 49 | fragment.setArguments(bundle); | 49 | fragment.setArguments(bundle); |
| 50 | return fragment; | 50 | return fragment; |
| 51 | 51 | ||
| 52 | } | 52 | } |
| 53 | Handler handler = new Handler(){ | 53 | Handler handler = new Handler(){ |
| 54 | @Override | 54 | @Override |
| 55 | public void handleMessage(Message msg) { | 55 | public void handleMessage(Message msg) { |
| 56 | super.handleMessage(msg); | 56 | super.handleMessage(msg); |
| 57 | 57 | ||
| 58 | switch (msg.what){ | 58 | switch (msg.what){ |
| 59 | case HttpCode.LOGIN_SUCESS: | 59 | case HttpCode.LOGIN_SUCESS: |
| 60 | JSONObject jsonObject; | 60 | JSONObject jsonObject; |
| 61 | String status; | 61 | String status; |
| 62 | try { | 62 | try { |
| 63 | jsonObject = new JSONObject((String) msg.obj); | 63 | jsonObject = new JSONObject((String) msg.obj); |
| 64 | status = jsonObject.getString("status"); | 64 | status = jsonObject.getString("status"); |
| 65 | if (status.equals("100")) { | 65 | if (status.equals("100")) { |
| 66 | String access_token = jsonObject.getString("access_token"); | 66 | String access_token = jsonObject.getString("access_token"); |
| 67 | String userId = jsonObject.getString("userId"); | 67 | String userId = jsonObject.getString("userId"); |
| 68 | final String name = phonenumber.getText().toString().trim(); | 68 | final String name = phonenumber.getText().toString().trim(); |
| 69 | final String pwd = login_pwwd.getText().toString().trim(); | 69 | final String pwd = login_pwwd.getText().toString().trim(); |
| 70 | // | 70 | // |
| 71 | try { | 71 | try { |
| 72 | long auserID = Long.parseLong(userId); | 72 | long auserID = Long.parseLong(userId); |
| 73 | //登录成功,保存登录数据并且获取个人信息 | ||
| 74 | HttpManager.getInstance().saveLoginInfo(getActivity(), name, pwd, access_token, "true", userId); | ||
| 75 | //检测注册信息是否完整 | 73 | //检测注册信息是否完整 |
| 76 | HttpManager.getInstance().registerinfocheck(getActivity(),auserID,handler); | 74 | HttpManager.getInstance().registerinfocheck(getActivity(),auserID,handler); |
| 75 | //登录成功,保存登录数据并且获取个人信息 | ||
| 76 | HttpManager.getInstance().saveLoginInfo(getActivity(), name, pwd, access_token, userId); | ||
| 77 | 77 | ||
| 78 | 78 | ||
| 79 | 79 | ||
| 80 | } catch (NumberFormatException e) { | 80 | } catch (NumberFormatException e) { |
| 81 | e.printStackTrace(); | 81 | e.printStackTrace(); |
| 82 | } | 82 | } |
| 83 | 83 | ||
| 84 | 84 | ||
| 85 | } else if (status.equals("200")) { | 85 | } else if (status.equals("200")) { |
| 86 | Toast.makeText(getActivity(), "用户名不存在!", Toast.LENGTH_LONG).show(); | 86 | Toast.makeText(getActivity(), "用户名不存在!", Toast.LENGTH_LONG).show(); |
| 87 | return; | 87 | return; |
| 88 | } else if (status.equals("204")) { | 88 | } else if (status.equals("204")) { |
| 89 | Toast.makeText(getActivity(), "密码错误!", Toast.LENGTH_LONG).show(); | 89 | Toast.makeText(getActivity(), "密码错误!", Toast.LENGTH_LONG).show(); |
| 90 | } else { | 90 | } else { |
| 91 | Toast.makeText(getActivity(), "登录失败!请检查网络", Toast.LENGTH_LONG).show(); | 91 | Toast.makeText(getActivity(), "登录失败!请检查网络", Toast.LENGTH_LONG).show(); |
| 92 | 92 | ||
| 93 | 93 | ||
| 94 | } | 94 | } |
| 95 | } catch (JSONException e) { | 95 | } catch (JSONException e) { |
| 96 | e.printStackTrace(); | 96 | e.printStackTrace(); |
| 97 | } | 97 | } |
| 98 | break; | 98 | break; |
| 99 | case HttpCode.REGISTER_SUCESS: | 99 | case HttpCode.REGISTER_SUCESS: |
| 100 | try { | 100 | try { |
| 101 | jsonObject = new JSONObject( (String) msg.obj); | 101 | jsonObject = new JSONObject( (String) msg.obj); |
| 102 | status = jsonObject.optString("status"); | 102 | status = jsonObject.optString("status"); |
| 103 | JSONObject isregisterinfo = (JSONObject) jsonObject.opt("data"); | 103 | JSONObject isregisterinfo = (JSONObject) jsonObject.opt("data"); |
| 104 | boolean isRegisterInfoComplete =isregisterinfo.optBoolean("isRegisterInfoComplete"); | 104 | boolean isRegisterInfoComplete =isregisterinfo.optBoolean("isRegisterInfoComplete"); |
| 105 | if (status.equals("1")){ | 105 | if (status.equals("1")){ |
| 106 | if (!isRegisterInfoComplete){ | 106 | if (!isRegisterInfoComplete){ |
| 107 | Intent intent = new Intent(); | 107 | Intent intent = new Intent(); |
| 108 | intent.setClass(getActivity(), RegisterInfoActivity.class); | 108 | intent.setClass(getActivity(), RegisterInfoActivity.class); |
| 109 | getActivity().startActivity(intent); | 109 | getActivity().startActivity(intent); |
| 110 | getActivity().overridePendingTransition(R.anim.rightin, R.anim.rightout); | 110 | getActivity().overridePendingTransition(R.anim.rightin, R.anim.rightout); |
| 111 | }else { | 111 | }else { |
| 112 | String userID = SaveParam.getInstance().getLoginParam(getActivity(),"userId"); | 112 | String userID = SaveParam.getInstance().getLoginParam(getActivity(),"userId"); |
| 113 | try { | 113 | try { |
| 114 | long auserID = Long.parseLong(userID); | 114 | long auserID = Long.parseLong(userID); |
| 115 | //是否填写保卡 | 115 | //是否填写保卡 |
| 116 | HttpManager.getInstance().cardinfocheck(getActivity(),auserID,handler); | 116 | HttpManager.getInstance().cardinfocheck(getActivity(),auserID,handler); |
| 117 | } catch (NumberFormatException e) { | 117 | } catch (NumberFormatException e) { |
| 118 | e.printStackTrace(); | 118 | e.printStackTrace(); |
| 119 | } | 119 | } |
| 120 | 120 | ||
| 121 | 121 | ||
| 122 | } | 122 | } |
| 123 | 123 | ||
| 124 | }else{ | 124 | }else{ |
| 125 | Toast.makeText(getActivity(), "请检查网络", Toast.LENGTH_LONG).show(); | 125 | Toast.makeText(getActivity(), "请检查网络", Toast.LENGTH_LONG).show(); |
| 126 | } | 126 | } |
| 127 | 127 | ||
| 128 | } catch (JSONException e) { | 128 | } catch (JSONException e) { |
| 129 | e.printStackTrace(); | 129 | e.printStackTrace(); |
| 130 | } | 130 | } |
| 131 | 131 | ||
| 132 | break; | 132 | break; |
| 133 | case HttpCode.CHECKCARD: | 133 | case HttpCode.CHECKCARD: |
| 134 | try { | 134 | try { |
| 135 | jsonObject = new JSONObject( (String) msg.obj); | 135 | jsonObject = new JSONObject( (String) msg.obj); |
| 136 | status = jsonObject.optString("status"); | 136 | status = jsonObject.optString("status"); |
| 137 | if (status.equals("1")){ | 137 | if (status.equals("1")){ |
| 138 | SaveParam.getInstance().saveLoginParam(getActivity(), "login", "true"); | ||
| 138 | Intent intent = new Intent(); | 139 | Intent intent = new Intent(); |
| 139 | intent.setClass(getActivity(), MainActivity.class); | 140 | intent.setClass(getActivity(), MainActivity.class); |
| 140 | getActivity().startActivity(intent); | 141 | getActivity().startActivity(intent); |
| 141 | getActivity().overridePendingTransition(R.anim.rightin, R.anim.rightout); | 142 | getActivity().overridePendingTransition(R.anim.rightin, R.anim.rightout); |
| 143 | |||
| 142 | }else if(status.equals("2001")){ | 144 | }else if(status.equals("2001")){ |
| 143 | ElectronicCardDialog.getInstance().show(getChildFragmentManager(), "ElectronicCardDialog"); | 145 | ElectronicCardDialog.getInstance().show(getChildFragmentManager(), "ElectronicCardDialog"); |
| 144 | }else{ | 146 | }else{ |
| 145 | Toast.makeText(getActivity(), "请检查网络", Toast.LENGTH_LONG).show(); | 147 | Toast.makeText(getActivity(), "请检查网络", Toast.LENGTH_LONG).show(); |
| 146 | } | 148 | } |
| 147 | 149 | ||
| 148 | } catch (JSONException e) { | 150 | } catch (JSONException e) { |
| 149 | e.printStackTrace(); | 151 | e.printStackTrace(); |
| 150 | } | 152 | } |
| 151 | 153 | ||
| 152 | break; | 154 | break; |
| 153 | } | 155 | } |
| 154 | } | 156 | } |
| 155 | }; | 157 | }; |
| 156 | 158 | ||
| 157 | @Override | 159 | @Override |
| 158 | public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { | 160 | public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { |
| 159 | if (mView == null) { | 161 | if (mView == null) { |
| 160 | mView = inflater.inflate(R.layout.fragment_loginandregister_login, container, false); | 162 | mView = inflater.inflate(R.layout.fragment_loginandregister_login, container, false); |
| 161 | initView(mView); | 163 | initView(mView); |
| 162 | initData(); | 164 | initData(); |
| 163 | setLister(); | 165 | setLister(); |
| 164 | 166 | ||
| 165 | 167 | ||
| 166 | } | 168 | } |
| 167 | return mView; | 169 | return mView; |
| 168 | } | 170 | } |
| 169 | //初始化 | 171 | //初始化 |
| 170 | private void initView(View mView) { | 172 | private void initView(View mView) { |
| 171 | tv_forget_pwd = (TextView) mView.findViewById(R.id.tv_forget_pwd); | 173 | tv_forget_pwd = (TextView) mView.findViewById(R.id.tv_forget_pwd); |
| 172 | phonenumber = (EditText) mView.findViewById(R.id.et_phonenumber); | 174 | phonenumber = (EditText) mView.findViewById(R.id.et_phonenumber); |
| 173 | login_pwwd = (EditText) mView.findViewById(R.id.et_password); | 175 | login_pwwd = (EditText) mView.findViewById(R.id.et_password); |
| 174 | btn_login = (Button) mView.findViewById(R.id.btn_login); | 176 | btn_login = (Button) mView.findViewById(R.id.btn_login); |
| 175 | 177 | ||
| 176 | } | 178 | } |
| 177 | private void initData() { | 179 | private void initData() { |
| 178 | } | 180 | } |
| 179 | private void setLister() { | 181 | private void setLister() { |
| 180 | tv_forget_pwd.setOnClickListener(this); | 182 | tv_forget_pwd.setOnClickListener(this); |
| 181 | btn_login.setOnClickListener(this); | 183 | btn_login.setOnClickListener(this); |
| 182 | } | 184 | } |
| 183 | 185 | ||
| 184 | 186 | ||
| 185 | @Override | 187 | @Override |
| 186 | public void onClick(View v) { | 188 | public void onClick(View v) { |
| 187 | switch (v.getId()){ | 189 | switch (v.getId()){ |
| 188 | case R.id.tv_forget_pwd: | 190 | case R.id.tv_forget_pwd: |
| 189 | intent.setClass(getActivity(),ForgotPasswordActivity.class); | 191 | intent.setClass(getActivity(),ForgotPasswordActivity.class); |
| 190 | startActivity(intent); | 192 | startActivity(intent); |
| 191 | getActivity().overridePendingTransition(R.anim.rightin, R.anim.rightout); | 193 | getActivity().overridePendingTransition(R.anim.rightin, R.anim.rightout); |
| 192 | break; | 194 | break; |
| 193 | case R.id.btn_login: | 195 | case R.id.btn_login: |
| 194 | login(); | 196 | login(); |
| 195 | break; | 197 | break; |
| 196 | } | 198 | } |
| 197 | 199 | ||
| 198 | } | 200 | } |
| 199 | 201 | ||
| 200 | private void login() { | 202 | private void login() { |
| 201 | final String name = phonenumber.getText().toString().trim(); | 203 | final String name = phonenumber.getText().toString().trim(); |
| 202 | final String pwd = login_pwwd.getText().toString().trim(); | 204 | final String pwd = login_pwwd.getText().toString().trim(); |
| 203 | if (TextUtils.isEmpty(name) || TextUtils.isEmpty(pwd)) { | 205 | if (TextUtils.isEmpty(name) || TextUtils.isEmpty(pwd)) { |
| 204 | AlertUtils.showToast(getActivity(), "请输入手机号和密码"); | 206 | AlertUtils.showToast(getActivity(), "请输入手机号和密码"); |
| 205 | return; | 207 | return; |
| 206 | }else if (!PhoneNumCheckUtils.isPhone(name)){ | 208 | }else if (!PhoneNumCheckUtils.isPhone(name)){ |
| 207 | AlertUtils.showToast(getActivity(), "请输入正确的手机号"); | 209 | AlertUtils.showToast(getActivity(), "请输入正确的手机号"); |
| 208 | }else { | 210 | }else { |
| 209 | //登录接口 | 211 | //登录接口 |
| 210 | HttpManager.getInstance().login(name,pwd, getActivity(),handler); | 212 | HttpManager.getInstance().login(name,pwd, getActivity(),handler); |
| 211 | } | 213 | } |
| 212 | 214 | ||
| 213 | 215 | ||
| 214 | } | 216 | } |
PersonalCenter/app/src/main/java/com/hjx/personalcenter/fragment/RegisterFragment.java
| 1 | package com.hjx.personalcenter.fragment; | 1 | package com.hjx.personalcenter.fragment; |
| 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.annotation.Nullable; | 7 | import android.support.annotation.Nullable; |
| 8 | import android.support.v4.app.Fragment; | 8 | import android.support.v4.app.Fragment; |
| 9 | import android.text.TextUtils; | 9 | import android.text.TextUtils; |
| 10 | import android.text.method.HideReturnsTransformationMethod; | 10 | import android.text.method.HideReturnsTransformationMethod; |
| 11 | import android.text.method.PasswordTransformationMethod; | 11 | import android.text.method.PasswordTransformationMethod; |
| 12 | import android.view.LayoutInflater; | 12 | import android.view.LayoutInflater; |
| 13 | import android.view.View; | 13 | import android.view.View; |
| 14 | import android.view.ViewGroup; | 14 | import android.view.ViewGroup; |
| 15 | import android.widget.Button; | 15 | import android.widget.Button; |
| 16 | import android.widget.EditText; | 16 | import android.widget.EditText; |
| 17 | import android.widget.ImageView; | 17 | import android.widget.ImageView; |
| 18 | 18 | ||
| 19 | import com.hjx.personalcenter.R; | 19 | import com.hjx.personalcenter.R; |
| 20 | import com.hjx.personalcenter.activity.RegisterInfoActivity; | 20 | import com.hjx.personalcenter.activity.RegisterInfoActivity; |
| 21 | import com.hjx.personalcenter.db.Content; | 21 | import com.hjx.personalcenter.db.Content; |
| 22 | import com.hjx.personalcenter.http.HttpCode; | 22 | import com.hjx.personalcenter.http.HttpCode; |
| 23 | import com.hjx.personalcenter.http.HttpManager; | 23 | import com.hjx.personalcenter.http.HttpManager; |
| 24 | import com.hjx.personalcenter.util.AlertUtils; | 24 | import com.hjx.personalcenter.util.AlertUtils; |
| 25 | import com.hjx.personalcenter.util.PasswordCheckUtils; | 25 | import com.hjx.personalcenter.util.PasswordCheckUtils; |
| 26 | import com.hjx.personalcenter.util.PhoneNumCheckUtils; | 26 | import com.hjx.personalcenter.util.PhoneNumCheckUtils; |
| 27 | 27 | ||
| 28 | import org.json.JSONException; | 28 | import org.json.JSONException; |
| 29 | import org.json.JSONObject; | 29 | import org.json.JSONObject; |
| 30 | 30 | ||
| 31 | import java.util.TimerTask; | 31 | import java.util.TimerTask; |
| 32 | 32 | ||
| 33 | /** | 33 | /** |
| 34 | * 注册 | 34 | * 注册 |
| 35 | * Created by Administrator on 2016/11/7. | 35 | * Created by Administrator on 2016/11/7. |
| 36 | */ | 36 | */ |
| 37 | 37 | ||
| 38 | public class RegisterFragment extends Fragment implements View.OnClickListener { | 38 | public class RegisterFragment extends Fragment implements View.OnClickListener { |
| 39 | private View mView; | 39 | private View mView; |
| 40 | 40 | ||
| 41 | private Button btn_register,get_authcode; | 41 | private Button btn_register,get_authcode; |
| 42 | private EditText phonenumber,password,anth_6num;//;//密码 | 42 | private EditText phonenumber,password,anth_6num;//;//密码 |
| 43 | private ImageView openeyes; | 43 | private ImageView openeyes; |
| 44 | private String sourceStr ="android"; | 44 | private String sourceStr ="android"; |
| 45 | private String typeStr = "register"; | 45 | private String typeStr = "register"; |
| 46 | private int delayTime=60; | 46 | private int delayTime=60; |
| 47 | private java.util.Timer Delaytimer; | 47 | private java.util.Timer Delaytimer; |
| 48 | private int type; | 48 | private int type; |
| 49 | public static Boolean showPassword = false; | 49 | public static Boolean showPassword = false; |
| 50 | public static String TABLAYOUT_FRAGMENT = "tab_fragment"; | 50 | public static String TABLAYOUT_FRAGMENT = "tab_fragment"; |
| 51 | 51 | ||
| 52 | public static RegisterFragment newInstance(int type) { | 52 | public static RegisterFragment newInstance(int type) { |
| 53 | RegisterFragment fragment = new RegisterFragment(); | 53 | RegisterFragment fragment = new RegisterFragment(); |
| 54 | Bundle bundle = new Bundle(); | 54 | Bundle bundle = new Bundle(); |
| 55 | bundle.putSerializable(TABLAYOUT_FRAGMENT, type); | 55 | bundle.putSerializable(TABLAYOUT_FRAGMENT, type); |
| 56 | fragment.setArguments(bundle); | 56 | fragment.setArguments(bundle); |
| 57 | return fragment; | 57 | return fragment; |
| 58 | 58 | ||
| 59 | } | 59 | } |
| 60 | Handler handler = new Handler() { | 60 | Handler handler = new Handler() { |
| 61 | @Override | 61 | @Override |
| 62 | public void handleMessage(Message msg) { | 62 | public void handleMessage(Message msg) { |
| 63 | super.handleMessage(msg); | 63 | super.handleMessage(msg); |
| 64 | try { | 64 | try { |
| 65 | JSONObject jsonObject; | 65 | JSONObject jsonObject; |
| 66 | String status; | 66 | String status; |
| 67 | switch (msg.what) { | 67 | switch (msg.what) { |
| 68 | case HttpCode.REGISTERED_SUCESS: | 68 | case HttpCode.REGISTERED_SUCESS: |
| 69 | jsonObject = (JSONObject) msg.obj; | 69 | jsonObject = (JSONObject) msg.obj; |
| 70 | status = jsonObject.getString("status"); | 70 | status = jsonObject.getString("status"); |
| 71 | //AlertUtils.showToast(RegisterActivity.this, jsonObject.optString("message")); | 71 | //AlertUtils.showToast(RegisterActivity.this, jsonObject.optString("message")); |
| 72 | String access_token = jsonObject.getString("access_token"); | 72 | String access_token = jsonObject.getString("access_token"); |
| 73 | String userId = jsonObject.getString("userId"); | 73 | String userId = jsonObject.getString("userId"); |
| 74 | if (status.equals("100")) { | 74 | if (status.equals("100")) { |
| 75 | String usernameStr = phonenumber.getText().toString().trim(); | 75 | String usernameStr = phonenumber.getText().toString().trim(); |
| 76 | String passwordStr = password.getText().toString().trim(); | 76 | String passwordStr = password.getText().toString().trim(); |
| 77 | HttpManager.getInstance().saveLoginInfo(getActivity(),usernameStr,passwordStr,access_token,"true",userId); | 77 | HttpManager.getInstance().saveLoginInfo(getActivity(),usernameStr,passwordStr,access_token,userId); |
| 78 | AlertUtils.showToast(getActivity(), "注册成功!"); | 78 | AlertUtils.showToast(getActivity(), "注册成功!"); |
| 79 | Content.accountflag =1; | 79 | Content.accountflag =1; |
| 80 | Intent intent = new Intent(); | 80 | Intent intent = new Intent(); |
| 81 | intent.setClass(getActivity(),RegisterInfoActivity.class); | 81 | intent.setClass(getActivity(),RegisterInfoActivity.class); |
| 82 | startActivity(intent); | 82 | startActivity(intent); |
| 83 | getActivity().overridePendingTransition(R.anim.rightin, R.anim.rightout); | 83 | getActivity().overridePendingTransition(R.anim.rightin, R.anim.rightout); |
| 84 | getActivity().finish(); | 84 | getActivity().finish(); |
| 85 | } | 85 | } |
| 86 | break; | 86 | break; |
| 87 | case HttpCode.REGISTERED_FAIL: | 87 | case HttpCode.REGISTERED_FAIL: |
| 88 | AlertUtils.showToast(getActivity(), "注册失败"); | 88 | AlertUtils.showToast(getActivity(), "注册失败"); |
| 89 | break; | 89 | break; |
| 90 | case HttpCode.AUTHCODE_SUCESS: | 90 | case HttpCode.AUTHCODE_SUCESS: |
| 91 | jsonObject = (JSONObject) msg.obj; | 91 | jsonObject = (JSONObject) msg.obj; |
| 92 | status = jsonObject.optString("status"); | 92 | status = jsonObject.optString("status"); |
| 93 | if (status.equals("100")) { | 93 | if (status.equals("100")) { |
| 94 | AlertUtils.showToast(getActivity(), "验证码发送成功"); | 94 | AlertUtils.showToast(getActivity(), "验证码发送成功"); |
| 95 | } | 95 | } |
| 96 | 96 | ||
| 97 | break; | 97 | break; |
| 98 | case HttpCode.AUTHCODE_FAIL: | 98 | case HttpCode.AUTHCODE_FAIL: |
| 99 | jsonObject = (JSONObject) msg.obj; | 99 | jsonObject = (JSONObject) msg.obj; |
| 100 | AlertUtils.showToast(getActivity(), "验证码发送失败"); | 100 | AlertUtils.showToast(getActivity(), "验证码发送失败"); |
| 101 | break; | 101 | break; |
| 102 | case HttpCode.IS_REFISTER: | 102 | case HttpCode.IS_REFISTER: |
| 103 | jsonObject = (JSONObject) msg.obj; | 103 | jsonObject = (JSONObject) msg.obj; |
| 104 | status = jsonObject.getString("status"); | 104 | status = jsonObject.getString("status"); |
| 105 | if (!status.equals("true")) { | 105 | if (!status.equals("true")) { |
| 106 | getauthcode(); | 106 | getauthcode(); |
| 107 | 107 | ||
| 108 | }else { | 108 | }else { |
| 109 | AlertUtils.showToast(getActivity(), "该手机号已经注册过了"); | 109 | AlertUtils.showToast(getActivity(), "该手机号已经注册过了"); |
| 110 | } | 110 | } |
| 111 | break; | 111 | break; |
| 112 | case 21: | 112 | case 21: |
| 113 | if(delayTime<=0){ | 113 | if(delayTime<=0){ |
| 114 | if(Delaytimer!=null){ | 114 | if(Delaytimer!=null){ |
| 115 | Delaytimer.cancel(); | 115 | Delaytimer.cancel(); |
| 116 | } | 116 | } |
| 117 | get_authcode.setEnabled(true); | 117 | get_authcode.setEnabled(true); |
| 118 | get_authcode.setClickable(true); | 118 | get_authcode.setClickable(true); |
| 119 | get_authcode.setText("获取验证码"); | 119 | get_authcode.setText("获取验证码"); |
| 120 | delayTime=60; | 120 | delayTime=60; |
| 121 | }else{ | 121 | }else{ |
| 122 | get_authcode.setEnabled(false); | 122 | get_authcode.setEnabled(false); |
| 123 | get_authcode.setClickable(false); | 123 | get_authcode.setClickable(false); |
| 124 | get_authcode.setText(delayTime + " s"); | 124 | get_authcode.setText(delayTime + " s"); |
| 125 | } | 125 | } |
| 126 | break; | 126 | break; |
| 127 | } | 127 | } |
| 128 | } catch (JSONException e) { | 128 | } catch (JSONException e) { |
| 129 | e.printStackTrace(); | 129 | e.printStackTrace(); |
| 130 | } | 130 | } |
| 131 | } | 131 | } |
| 132 | }; | 132 | }; |
| 133 | @Override | 133 | @Override |
| 134 | public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { | 134 | public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { |
| 135 | if (mView == null) { | 135 | if (mView == null) { |
| 136 | mView = inflater.inflate(R.layout.fragment_loginandregister_register, container, false); | 136 | mView = inflater.inflate(R.layout.fragment_loginandregister_register, container, false); |
| 137 | initView(mView); | 137 | initView(mView); |
| 138 | initData(); | 138 | initData(); |
| 139 | setLister(); | 139 | setLister(); |
| 140 | 140 | ||
| 141 | 141 | ||
| 142 | } | 142 | } |
| 143 | return mView; | 143 | return mView; |
| 144 | } | 144 | } |
| 145 | 145 | ||
| 146 | private void initView(View mView) { | 146 | private void initView(View mView) { |
| 147 | get_authcode = (Button) mView.findViewById(R.id.btn_authcode); | 147 | get_authcode = (Button) mView.findViewById(R.id.btn_authcode); |
| 148 | anth_6num = (EditText) mView.findViewById(R.id.et_authcode); | 148 | anth_6num = (EditText) mView.findViewById(R.id.et_authcode); |
| 149 | phonenumber = (EditText) mView.findViewById(R.id.et_phonenumber); | 149 | phonenumber = (EditText) mView.findViewById(R.id.et_phonenumber); |
| 150 | password = (EditText) mView.findViewById(R.id.et_password); | 150 | password = (EditText) mView.findViewById(R.id.et_password); |
| 151 | openeyes= (ImageView) mView.findViewById(R.id.iv_pwd_change); | 151 | openeyes= (ImageView) mView.findViewById(R.id.iv_pwd_change); |
| 152 | btn_register = (Button) mView.findViewById(R.id.btn_register); | 152 | btn_register = (Button) mView.findViewById(R.id.btn_register); |
| 153 | 153 | ||
| 154 | } | 154 | } |
| 155 | private void initData() { | 155 | private void initData() { |
| 156 | } | 156 | } |
| 157 | private void setLister() { | 157 | private void setLister() { |
| 158 | get_authcode.setOnClickListener(this); | 158 | get_authcode.setOnClickListener(this); |
| 159 | openeyes.setOnClickListener(this); | 159 | openeyes.setOnClickListener(this); |
| 160 | btn_register.setOnClickListener(this); | 160 | btn_register.setOnClickListener(this); |
| 161 | } | 161 | } |
| 162 | 162 | ||
| 163 | 163 | ||
| 164 | @Override | 164 | @Override |
| 165 | public void onClick(View v) { | 165 | public void onClick(View v) { |
| 166 | switch (v.getId()){ | 166 | switch (v.getId()){ |
| 167 | case R.id.btn_register: | 167 | case R.id.btn_register: |
| 168 | //测试 | 168 | //测试 |
| 169 | // | 169 | // |
| 170 | 170 | ||
| 171 | String usernameStr = phonenumber.getText().toString().trim(); | 171 | String usernameStr = phonenumber.getText().toString().trim(); |
| 172 | String authcodeStr = anth_6num.getText().toString().trim(); | 172 | String authcodeStr = anth_6num.getText().toString().trim(); |
| 173 | String passwordStr = password.getText().toString().trim(); | 173 | String passwordStr = password.getText().toString().trim(); |
| 174 | if (TextUtils.isEmpty(usernameStr) || TextUtils.isEmpty(authcodeStr)||TextUtils.isEmpty(passwordStr)) { | 174 | if (TextUtils.isEmpty(usernameStr) || TextUtils.isEmpty(authcodeStr)||TextUtils.isEmpty(passwordStr)) { |
| 175 | AlertUtils.showToast(getActivity(), "手机号,密码和验证码不能为空"); | 175 | AlertUtils.showToast(getActivity(), "手机号,密码和验证码不能为空"); |
| 176 | return; | 176 | return; |
| 177 | } else if(passwordStr.length()<8){ | 177 | } else if(passwordStr.length()<8){ |
| 178 | AlertUtils.showToast(getActivity(), "密码不能少于8位"); | 178 | AlertUtils.showToast(getActivity(), "密码不能少于8位"); |
| 179 | }else if (!PhoneNumCheckUtils.isPhone(usernameStr)){ | 179 | }else if (!PhoneNumCheckUtils.isPhone(usernameStr)){ |
| 180 | AlertUtils.showToast(getActivity(), "手机号码输入错误"); | 180 | AlertUtils.showToast(getActivity(), "手机号码输入错误"); |
| 181 | 181 | ||
| 182 | }else if(!passwordStr.matches(PasswordCheckUtils.PASSWORD_CHAR_AND_NUMBER)){ | 182 | }else if(!passwordStr.matches(PasswordCheckUtils.PASSWORD_CHAR_AND_NUMBER)){ |
| 183 | AlertUtils.showToast(getActivity(), "密码由英文和数字组成"); | 183 | AlertUtils.showToast(getActivity(), "密码由英文和数字组成"); |
| 184 | }else { | 184 | }else { |
| 185 | register(); | 185 | register(); |
| 186 | } | 186 | } |
| 187 | 187 | ||
| 188 | break; | 188 | break; |
| 189 | case R.id.iv_pwd_change: | 189 | case R.id.iv_pwd_change: |
| 190 | if(showPassword){//显示密码 | 190 | if(showPassword){//显示密码 |
| 191 | showPassword = !showPassword; | 191 | showPassword = !showPassword; |
| 192 | openeyes.setImageResource(R.mipmap.pwd_open); | 192 | openeyes.setImageResource(R.mipmap.pwd_open); |
| 193 | password.setTransformationMethod(HideReturnsTransformationMethod.getInstance()); | 193 | password.setTransformationMethod(HideReturnsTransformationMethod.getInstance()); |
| 194 | password.setSelection(password.getText().toString().length()); | 194 | password.setSelection(password.getText().toString().length()); |
| 195 | }else{//隐藏密码 | 195 | }else{//隐藏密码 |
| 196 | showPassword = !showPassword; | 196 | showPassword = !showPassword; |
| 197 | openeyes.setImageResource(R.mipmap.pwd_hide); | 197 | openeyes.setImageResource(R.mipmap.pwd_hide); |
| 198 | password.setTransformationMethod(PasswordTransformationMethod.getInstance()); | 198 | password.setTransformationMethod(PasswordTransformationMethod.getInstance()); |
| 199 | password.setSelection(password.getText().toString().length()); | 199 | password.setSelection(password.getText().toString().length()); |
| 200 | } | 200 | } |
| 201 | break; | 201 | break; |
| 202 | case R.id.btn_authcode: | 202 | case R.id.btn_authcode: |
| 203 | usernameStr = phonenumber.getText().toString().trim(); | 203 | usernameStr = phonenumber.getText().toString().trim(); |
| 204 | if (!PhoneNumCheckUtils.isPhone(usernameStr)){ | 204 | if (!PhoneNumCheckUtils.isPhone(usernameStr)){ |
| 205 | AlertUtils.showToast(getActivity(), "请输入正确的手机号"); | 205 | AlertUtils.showToast(getActivity(), "请输入正确的手机号"); |
| 206 | }else { | 206 | }else { |
| 207 | anth_6num.requestFocus(); | 207 | anth_6num.requestFocus(); |
| 208 | ifregister(); | 208 | ifregister(); |
| 209 | } | 209 | } |
| 210 | 210 | ||
| 211 | break; | 211 | break; |
| 212 | } | 212 | } |
| 213 | 213 | ||
| 214 | } | 214 | } |
| 215 | //获取验证码 | 215 | //获取验证码 |
| 216 | private void getauthcode() { | 216 | private void getauthcode() { |
| 217 | String usernameStr = phonenumber.getText().toString().trim(); | 217 | String usernameStr = phonenumber.getText().toString().trim(); |
| 218 | HttpManager.getInstance().authCode(typeStr, usernameStr, handler, getActivity()); | 218 | HttpManager.getInstance().authCode(typeStr, usernameStr, handler, getActivity()); |
| 219 | valiDelay(); | 219 | valiDelay(); |
| 220 | } | 220 | } |
| 221 | 221 | ||
| 222 | private void ifregister() { | 222 | private void ifregister() { |
| 223 | String usernameStr = phonenumber.getText().toString().trim(); | 223 | String usernameStr = phonenumber.getText().toString().trim(); |
| 224 | HttpManager.getInstance().isregistered(usernameStr, handler, getActivity()); | 224 | HttpManager.getInstance().isregistered(usernameStr, handler, getActivity()); |
| 225 | } | 225 | } |
| 226 | 226 | ||
| 227 | private void register() { | 227 | private void register() { |
| 228 | String usernameStr = phonenumber.getText().toString().trim(); | 228 | String usernameStr = phonenumber.getText().toString().trim(); |
| 229 | String authcodeStr = anth_6num.getText().toString().trim(); | 229 | String authcodeStr = anth_6num.getText().toString().trim(); |
| 230 | String passwordStr = password.getText().toString().trim(); | 230 | String passwordStr = password.getText().toString().trim(); |
| 231 | HttpManager.getInstance().register(getActivity(), usernameStr, passwordStr, authcodeStr, sourceStr,handler); | 231 | HttpManager.getInstance().register(getActivity(), usernameStr, passwordStr, authcodeStr, sourceStr,handler); |
| 232 | } | 232 | } |
| 233 | // 线程类 定时器 | 233 | // 线程类 定时器 |
| 234 | public void valiDelay() { | 234 | public void valiDelay() { |
| 235 | 235 | ||
| 236 | Delaytimer = new java.util.Timer(true); | 236 | Delaytimer = new java.util.Timer(true); |
| 237 | 237 | ||
| 238 | 238 | ||
| 239 | TimerTask task = new TimerTask() { | 239 | TimerTask task = new TimerTask() { |
| 240 | public void run() { | 240 | public void run() { |
| 241 | //每次需要执行的代码放到这里面。 | 241 | //每次需要执行的代码放到这里面。 |
| 242 | delayTime--; | 242 | delayTime--; |
| 243 | handler.sendEmptyMessage(21); | 243 | handler.sendEmptyMessage(21); |
| 244 | } | 244 | } |
| 245 | }; | 245 | }; |
| 246 | Delaytimer.schedule(task, 1000,1000); | 246 | Delaytimer.schedule(task, 1000,1000); |
| 247 | } | 247 | } |
| 248 | } | 248 | } |
| 249 | 249 |
PersonalCenter/app/src/main/java/com/hjx/personalcenter/fragment/VersionsInfoFragment.java
| 1 | package com.hjx.personalcenter.fragment; | 1 | package com.hjx.personalcenter.fragment; |
| 2 | 2 | ||
| 3 | import android.os.Bundle; | 3 | import android.os.Bundle; |
| 4 | import android.os.Handler; | ||
| 5 | import android.os.Message; | ||
| 4 | import android.support.annotation.Nullable; | 6 | import android.support.annotation.Nullable; |
| 5 | import android.support.v4.app.Fragment; | 7 | import android.support.v4.app.Fragment; |
| 6 | import android.view.LayoutInflater; | 8 | import android.view.LayoutInflater; |
| 7 | import android.view.View; | 9 | import android.view.View; |
| 8 | import android.view.ViewGroup; | 10 | import android.view.ViewGroup; |
| 9 | import android.widget.AdapterView; | 11 | import android.widget.AdapterView; |
| 10 | import android.widget.GridView; | 12 | import android.widget.GridView; |
| 11 | 13 | ||
| 12 | import com.hjx.personalcenter.R; | 14 | import com.hjx.personalcenter.R; |
| 13 | import com.hjx.personalcenter.adapter.GridAdapter; | 15 | import com.hjx.personalcenter.adapter.GridAdapter; |
| 14 | import com.hjx.personalcenter.customdialog.VerSionDialog; | 16 | import com.hjx.personalcenter.customdialog.VerSionDialog; |
| 15 | import com.hjx.personalcenter.db.SaveParam; | 17 | import com.hjx.personalcenter.db.SaveParam; |
| 18 | import com.hjx.personalcenter.http.HttpCode; | ||
| 19 | import com.hjx.personalcenter.http.HttpManager; | ||
| 16 | import com.hjx.personalcenter.interfaces.DialogCallBack; | 20 | import com.hjx.personalcenter.interfaces.DialogCallBack; |
| 17 | import com.hjx.personalcenter.model.DefautPublishInfo; | 21 | import com.hjx.personalcenter.model.DefautPublishInfo; |
| 18 | 22 | ||
| 19 | import java.util.ArrayList; | 23 | import java.util.ArrayList; |
| 24 | import java.util.List; | ||
| 20 | 25 | ||
| 21 | /** | 26 | /** |
| 22 | * Created by h on 2017/8/12. | 27 | * Created by h on 2017/8/12. |
| 23 | */ | 28 | */ |
| 24 | 29 | ||
| 25 | public class VersionsInfoFragment extends Fragment implements AdapterView.OnItemClickListener{ | 30 | public class VersionsInfoFragment extends Fragment implements AdapterView.OnItemClickListener{ |
| 26 | private GridView gridView; | 31 | private GridView gridView; |
| 27 | private ArrayList<DefautPublishInfo> defautPublishInfos = new ArrayList<>(); | 32 | private ArrayList<DefautPublishInfo.DataBean> defautPublishInfos = new ArrayList<>(); |
| 28 | private GridAdapter sim_adapter; | 33 | private GridAdapter sim_adapter; |
| 29 | private View mView; | 34 | private View mView; |
| 30 | private int type; | 35 | private int type; |
| 31 | public static String TABLAYOUT_FRAGMENT = "tab_fragment"; | 36 | public static String TABLAYOUT_FRAGMENT = "tab_fragment"; |
| 32 | 37 | ||
| 33 | public static VersionsInfoFragment newInstance(int type) { | 38 | public static VersionsInfoFragment newInstance(int type) { |
| 34 | VersionsInfoFragment fragment = new VersionsInfoFragment(); | 39 | VersionsInfoFragment fragment = new VersionsInfoFragment(); |
| 35 | Bundle bundle = new Bundle(); | 40 | Bundle bundle = new Bundle(); |
| 36 | bundle.putSerializable(TABLAYOUT_FRAGMENT, type); | 41 | bundle.putSerializable(TABLAYOUT_FRAGMENT, type); |
| 37 | fragment.setArguments(bundle); | 42 | fragment.setArguments(bundle); |
| 38 | return fragment; | 43 | return fragment; |
| 39 | 44 | ||
| 40 | } | 45 | } |
| 46 | Handler handler = new Handler(){ | ||
| 47 | @Override | ||
| 48 | public void handleMessage(Message msg) { | ||
| 49 | super.handleMessage(msg); | ||
| 50 | switch (msg.what){ | ||
| 51 | case HttpCode.PUBLISH_SUCESS: | ||
| 52 | defautPublishInfos.clear(); | ||
| 53 | defautPublishInfos.addAll( (List<DefautPublishInfo.DataBean>)msg.obj); | ||
| 54 | sim_adapter.notifyDataSetChanged(); | ||
| 55 | break; | ||
| 56 | } | ||
| 57 | } | ||
| 58 | }; | ||
| 41 | @Override | 59 | @Override |
| 42 | public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { | 60 | public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { |
| 43 | if (mView == null) { | 61 | if (mView == null) { |
| 44 | mView = inflater.inflate(R.layout.fragment_changge_version_info, container, false); | 62 | mView = inflater.inflate(R.layout.fragment_changge_version_info, container, false); |
| 63 | String userID = SaveParam.getInstance().getLoginParam(getActivity(),"userId"); | ||
| 64 | String graderid = SaveParam.getInstance().getLoginParam(getActivity(),SaveParam.GRADENS); | ||
| 65 | |||
| 66 | try { | ||
| 67 | long auserID = Long.parseLong(userID); | ||
| 68 | int graderID = Integer.parseInt(graderid); | ||
| 69 | //获取版本信息 | ||
| 70 | HttpManager.getInstance().getpublishinfo(getActivity(),auserID,graderID,handler); | ||
| 71 | |||
| 72 | } catch (NumberFormatException e) { | ||
| 73 | e.printStackTrace(); | ||
| 74 | } | ||
| 75 | |||
| 45 | initView(mView); | 76 | initView(mView); |
| 46 | initData(); | 77 | initData(); |
| 47 | setLister(); | 78 | setLister(); |
| 48 | 79 | ||
| 49 | 80 | ||
| 50 | } | 81 | } |
| 51 | return mView; | 82 | return mView; |
| 52 | } | 83 | } |
| 53 | //初始化 | 84 | //初始化 |
| 54 | private void initView(View mView) { | 85 | private void initView(View mView) { |
| 55 | gridView =(GridView) mView.findViewById(R.id.grideview); | 86 | gridView =(GridView) mView.findViewById(R.id.grideview); |
| 56 | 87 | ||
| 57 | } | 88 | } |
| 58 | private void initData() { | 89 | private void initData() { |
| 59 | DefautPublishInfo defautPublishInfo = new DefautPublishInfo(); | ||
| 60 | defautPublishInfo.setImagurl("http://hjxprodbucket.oss.aliyuncs.com/static/upload/boss_api/announcement/2017-08-29/8480ff7b-42f1-4d64-b848-c8f4f3afd385.png"); | ||
| 61 | defautPublishInfo.setSubjuct("语文"); | ||
| 62 | defautPublishInfo.setPublish("人民教育出版社"); | ||
| 63 | DefautPublishInfo defautPublishInfo1 = new DefautPublishInfo(); | ||
| 64 | defautPublishInfo1.setImagurl("http://hjxprodbucket.oss.aliyuncs.com/static/upload/boss_api/announcement/2017-08-29/8480ff7b-42f1-4d64-b848-c8f4f3afd385.png"); | ||
| 65 | defautPublishInfo1.setSubjuct("数学"); | ||
| 66 | defautPublishInfo1.setPublish("人民教育出版社"); | ||
| 67 | DefautPublishInfo defautPublishInfo2 = new DefautPublishInfo(); | ||
| 68 | defautPublishInfo2.setImagurl("http://hjxprodbucket.oss.aliyuncs.com/static/upload/boss_api/announcement/2017-08-29/8480ff7b-42f1-4d64-b848-c8f4f3afd385.png"); | ||
| 69 | defautPublishInfo2.setSubjuct("英语"); | ||
| 70 | defautPublishInfo2.setPublish("人民教育出版社"); | ||
| 71 | defautPublishInfos.add(defautPublishInfo); | ||
| 72 | defautPublishInfos.add(defautPublishInfo1); | ||
| 73 | defautPublishInfos.add(defautPublishInfo2); | ||
| 74 | sim_adapter = new GridAdapter(defautPublishInfos,getActivity()); | 90 | sim_adapter = new GridAdapter(defautPublishInfos,getActivity()); |
| 75 | //配置适配器 | 91 | //配置适配器 |
| 76 | gridView.setAdapter(sim_adapter); | 92 | gridView.setAdapter(sim_adapter); |
| 77 | } | 93 | } |
| 78 | 94 | ||
| 79 | private void setLister() { | 95 | private void setLister() { |
| 80 | gridView.setOnItemClickListener(this); | 96 | gridView.setOnItemClickListener(this); |
| 81 | } | 97 | } |
| 82 | 98 | ||
| 83 | @Override | 99 | @Override |
| 84 | public void onItemClick(AdapterView<?> parent, View view, int position, long id) { | 100 | public void onItemClick(AdapterView<?> parent, View view, int position, long id) { |
| 85 | switch (position){ | 101 | switch (position){ |
| 86 | 102 | ||
| 87 | case 0: | 103 | case 0: |
| 88 | SaveParam.getInstance().saveLoginParam(getActivity(),SaveParam.VERSION,"语文"); | 104 | SaveParam.getInstance().saveLoginParam(getActivity(),SaveParam.VERSION,"语文"); |
| 89 | break; | 105 | break; |
| 90 | case 1: | 106 | case 1: |
| 91 | SaveParam.getInstance().saveLoginParam(getActivity(),SaveParam.VERSION,"数学"); | 107 | SaveParam.getInstance().saveLoginParam(getActivity(),SaveParam.VERSION,"数学"); |
| 92 | break; | 108 | break; |
| 93 | case 2: | 109 | case 2: |
| 94 | SaveParam.getInstance().saveLoginParam(getActivity(),SaveParam.VERSION,"英语"); | 110 | SaveParam.getInstance().saveLoginParam(getActivity(),SaveParam.VERSION,"英语"); |
| 95 | break; | 111 | break; |
| 96 | case 3: | 112 | case 3: |
| 97 | SaveParam.getInstance().saveLoginParam(getActivity(),SaveParam.VERSION,"物理"); | 113 | SaveParam.getInstance().saveLoginParam(getActivity(),SaveParam.VERSION,"物理"); |
| 98 | break; | 114 | break; |
| 99 | case 4: | 115 | case 4: |
| 100 | SaveParam.getInstance().saveLoginParam(getActivity(),SaveParam.VERSION,"化学"); | 116 | SaveParam.getInstance().saveLoginParam(getActivity(),SaveParam.VERSION,"化学"); |
| 101 | break; | 117 | break; |
| 102 | case 5: | 118 | case 5: |
| 103 | SaveParam.getInstance().saveLoginParam(getActivity(),SaveParam.VERSION,"生物"); | 119 | SaveParam.getInstance().saveLoginParam(getActivity(),SaveParam.VERSION,"生物"); |
| 104 | break; | 120 | break; |
| 105 | case 6: | 121 | case 6: |
| 106 | SaveParam.getInstance().saveLoginParam(getActivity(),SaveParam.VERSION,"政治"); | 122 | SaveParam.getInstance().saveLoginParam(getActivity(),SaveParam.VERSION,"政治"); |
| 107 | break; | 123 | break; |
| 108 | case 7: | 124 | case 7: |
| 109 | SaveParam.getInstance().saveLoginParam(getActivity(),SaveParam.VERSION,"历史"); | 125 | SaveParam.getInstance().saveLoginParam(getActivity(),SaveParam.VERSION,"历史"); |
| 110 | break; | 126 | break; |
| 111 | case 8: | 127 | case 8: |
| 112 | SaveParam.getInstance().saveLoginParam(getActivity(),SaveParam.VERSION,"地理"); | 128 | SaveParam.getInstance().saveLoginParam(getActivity(),SaveParam.VERSION,"地理"); |
| 113 | break; | 129 | break; |
PersonalCenter/app/src/main/java/com/hjx/personalcenter/http/HttpCode.java
| 1 | package com.hjx.personalcenter.http; | 1 | package com.hjx.personalcenter.http; |
| 2 | 2 | ||
| 3 | /** | 3 | /** |
| 4 | * Created by wei on 2017/6/21. | 4 | * Created by wei on 2017/6/21. |
| 5 | */ | 5 | */ |
| 6 | 6 | ||
| 7 | public class HttpCode { | 7 | public class HttpCode { |
| 8 | //查询保卡信息 | 8 | //查询保卡信息 |
| 9 | public static final int SUCHCARDINFO = 0; | 9 | public static final int SUCHCARDINFO = 0; |
| 10 | //是否填写保卡信息 | 10 | //是否填写保卡信息 |
| 11 | public static final int CHECKCARD = 1; | 11 | public static final int CHECKCARD = 1; |
| 12 | //注册 | 12 | //注册 |
| 13 | public static final int REGISTERED_SUCESS = 2; | 13 | public static final int REGISTERED_SUCESS = 2; |
| 14 | public static final int REGISTERED_FAIL = 3; | 14 | public static final int REGISTERED_FAIL = 3; |
| 15 | //注册验证码 | 15 | //注册验证码 |
| 16 | public static final int AUTHCODE_SUCESS = 4; | 16 | public static final int AUTHCODE_SUCESS = 4; |
| 17 | public static final int AUTHCODE_FAIL = 5; | 17 | public static final int AUTHCODE_FAIL = 5; |
| 18 | //忘记密码验证码 | 18 | //忘记密码验证码 |
| 19 | public static final int AUTHCODE_SUCESS1 = 6; | 19 | public static final int AUTHCODE_SUCESS1 = 6; |
| 20 | public static final int AUTHCODE_FAIL1 = 7; | 20 | public static final int AUTHCODE_FAIL1 = 7; |
| 21 | //是否已经注册 | 21 | //是否已经注册 |
| 22 | public static final int IS_REFISTER = 8; | 22 | public static final int IS_REFISTER = 8; |
| 23 | //忘记密码 | 23 | //忘记密码 |
| 24 | public static final int PASSWORD_SUCESS = 9; | 24 | public static final int PASSWORD_SUCESS = 9; |
| 25 | public static final int PASSWORD_FAIL = 10; | 25 | public static final int PASSWORD_FAIL = 10; |
| 26 | //s省 | 26 | //s省 |
| 27 | public static final int PROVICES = 11; | 27 | public static final int PROVICES = 11; |
| 28 | //市 | 28 | //市 |
| 29 | public static final int CITYS = 12; | 29 | public static final int CITYS = 12; |
| 30 | //区 | 30 | //区 |
| 31 | public static final int COUNTRY = 13; | 31 | public static final int COUNTRY = 13; |
| 32 | //学校 | 32 | //学校 |
| 33 | public static final int SCHOOL = 14; | 33 | public static final int SCHOOL = 14; |
| 34 | //年级 | 34 | //年级 |
| 35 | public static final int GRADER = 15; | 35 | public static final int GRADER = 15; |
| 36 | //获取个人信息 | 36 | //获取个人信息 |
| 37 | public static final int GETINFO = 16; | 37 | public static final int GETINFO = 16; |
| 38 | //获取个性签名 | 38 | //获取个性签名 |
| 39 | public static final int SIGN = 17; | 39 | public static final int SIGN = 17; |
| 40 | //登录 | 40 | //登录 |
| 41 | public static final int LOGIN_SUCESS = 18; | 41 | public static final int LOGIN_SUCESS = 18; |
| 42 | //获取子账户信息 | 42 | //获取子账户信息 |
| 43 | public static final int CHILDS_SUCESS = 19; | 43 | public static final int CHILDS_SUCESS = 19; |
| 44 | //版本升级 | 44 | //版本升级 |
| 45 | public static final int APPUPDATE_SUCESS = 20; | 45 | public static final int APPUPDATE_SUCESS = 20; |
| 46 | //获取版本信息 | 46 | //获取出版社 |
| 47 | public static final int VERSION_SUCESS = 22; | 47 | public static final int VERSION_SUCESS = 22; |
| 48 | //注册信息是否完整 | 48 | //注册信息是否完整 |
| 49 | public static final int REGISTER_SUCESS = 23; | 49 | public static final int REGISTER_SUCESS = 23; |
| 50 | //获取默认版本信息 | ||
| 51 | public static final int PUBLISH_SUCESS = 24; | ||
| 50 | 52 | ||
| 51 | 53 | ||
| 52 | 54 | ||
| 53 | 55 | ||
| 54 | } | 56 | } |
| 55 | 57 |
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.util.Log; | 9 | import android.util.Log; |
| 10 | import android.widget.Toast; | 10 | import android.widget.Toast; |
| 11 | 11 | ||
| 12 | import com.google.gson.Gson; | 12 | import com.google.gson.Gson; |
| 13 | import com.hjx.personalcenter.R; | 13 | import com.hjx.personalcenter.R; |
| 14 | import com.hjx.personalcenter.activity.LoginAndRegisterActivity; | 14 | import com.hjx.personalcenter.activity.LoginAndRegisterActivity; |
| 15 | import com.hjx.personalcenter.activity.TheStartPageActivity; | 15 | import com.hjx.personalcenter.activity.TheStartPageActivity; |
| 16 | import com.hjx.personalcenter.db.Content; | 16 | import com.hjx.personalcenter.db.Content; |
| 17 | import com.hjx.personalcenter.db.SaveParam; | 17 | import com.hjx.personalcenter.db.SaveParam; |
| 18 | import com.hjx.personalcenter.gson.GsonTool; | 18 | import com.hjx.personalcenter.gson.GsonTool; |
| 19 | import com.hjx.personalcenter.model.AppVersion; | 19 | import com.hjx.personalcenter.model.AppVersion; |
| 20 | import com.hjx.personalcenter.model.CardInfo; | 20 | import com.hjx.personalcenter.model.CardInfo; |
| 21 | import com.hjx.personalcenter.model.ChildsInfo; | 21 | import com.hjx.personalcenter.model.ChildsInfo; |
| 22 | import com.hjx.personalcenter.model.CityInfo; | 22 | import com.hjx.personalcenter.model.CityInfo; |
| 23 | import com.hjx.personalcenter.model.CountyInfo; | 23 | import com.hjx.personalcenter.model.CountyInfo; |
| 24 | import com.hjx.personalcenter.model.DefautPublishInfo; | ||
| 24 | import com.hjx.personalcenter.model.GradeInfo; | 25 | import com.hjx.personalcenter.model.GradeInfo; |
| 25 | import com.hjx.personalcenter.model.PesonalInfo; | 26 | import com.hjx.personalcenter.model.PesonalInfo; |
| 26 | import com.hjx.personalcenter.model.ProvinceInfo; | 27 | import com.hjx.personalcenter.model.ProvinceInfo; |
| 27 | import com.hjx.personalcenter.model.SchoolInfo; | 28 | import com.hjx.personalcenter.model.SchoolInfo; |
| 28 | import com.hjx.personalcenter.model.SignInfo; | 29 | import com.hjx.personalcenter.model.SignInfo; |
| 29 | import com.hjx.personalcenter.model.VersionInfo; | 30 | import com.hjx.personalcenter.model.VersionInfo; |
| 30 | import com.hjx.personalcenter.util.AlertUtils; | 31 | import com.hjx.personalcenter.util.AlertUtils; |
| 31 | import com.hjx.personalcenter.util.DialogPermission; | 32 | import com.hjx.personalcenter.util.DialogPermission; |
| 32 | import com.loopj.android.http.AsyncHttpResponseHandler; | 33 | import com.loopj.android.http.AsyncHttpResponseHandler; |
| 33 | import com.loopj.android.http.JsonHttpResponseHandler; | 34 | import com.loopj.android.http.JsonHttpResponseHandler; |
| 34 | import com.loopj.android.http.RequestParams; | 35 | import com.loopj.android.http.RequestParams; |
| 35 | 36 | ||
| 36 | import org.apache.http.Header; | 37 | import org.apache.http.Header; |
| 37 | import org.apache.http.entity.ByteArrayEntity; | 38 | import org.apache.http.entity.ByteArrayEntity; |
| 38 | import org.apache.http.message.BasicHeader; | 39 | import org.apache.http.message.BasicHeader; |
| 39 | import org.apache.http.protocol.HTTP; | 40 | import org.apache.http.protocol.HTTP; |
| 40 | import org.json.JSONException; | 41 | import org.json.JSONException; |
| 41 | import org.json.JSONObject; | 42 | import org.json.JSONObject; |
| 42 | 43 | ||
| 43 | import java.io.File; | 44 | import java.io.File; |
| 44 | import java.io.FileNotFoundException; | 45 | import java.io.FileNotFoundException; |
| 45 | import java.io.UnsupportedEncodingException; | 46 | import java.io.UnsupportedEncodingException; |
| 46 | import java.util.ArrayList; | 47 | import java.util.ArrayList; |
| 47 | import java.util.List; | 48 | import java.util.List; |
| 48 | 49 | ||
| 49 | public class HttpManager { | 50 | public class HttpManager { |
| 50 | private static HttpManager instance; | 51 | private static HttpManager instance; |
| 51 | private ProgressDialog mProgress = null; | 52 | private ProgressDialog mProgress = null; |
| 52 | 53 | ||
| 53 | public static HttpManager getInstance() { | 54 | public static HttpManager getInstance() { |
| 54 | if (instance == null) { | 55 | if (instance == null) { |
| 55 | instance = new HttpManager(); | 56 | instance = new HttpManager(); |
| 56 | } | 57 | } |
| 57 | return instance; | 58 | return instance; |
| 58 | } | 59 | } |
| 59 | 60 | ||
| 60 | 61 | ||
| 61 | //登录接口 | 62 | //登录接口 |
| 62 | 63 | ||
| 63 | public void login(final String username, final String password, final Context mContext, final Handler handler) { | 64 | public void login(final String username, final String password, final Context mContext, final Handler handler) { |
| 64 | mProgress = DialogPermission.showProgress(mContext, null, "正在登录...", | 65 | mProgress = DialogPermission.showProgress(mContext, null, "正在登录...", |
| 65 | false, true, null); | 66 | false, true, null); |
| 66 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); | 67 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); |
| 67 | HttpClient.getInstance().get(HttpUrl.loginUrl + "?username=" + username + "&password=" + password, new AsyncHttpResponseHandler() { | 68 | HttpClient.getInstance().get(HttpUrl.loginUrl + "?username=" + username + "&password=" + password, new AsyncHttpResponseHandler() { |
| 68 | @Override | 69 | @Override |
| 69 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { | 70 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { |
| 70 | closeProgress(); | 71 | closeProgress(); |
| 71 | Message msg = Message.obtain(); | 72 | Message msg = Message.obtain(); |
| 72 | msg.what = HttpCode.LOGIN_SUCESS; | 73 | msg.what = HttpCode.LOGIN_SUCESS; |
| 73 | msg.obj = new String(arg2); | 74 | msg.obj = new String(arg2); |
| 74 | handler.sendMessage(msg); | 75 | handler.sendMessage(msg); |
| 75 | 76 | ||
| 76 | 77 | ||
| 77 | } | 78 | } |
| 78 | 79 | ||
| 79 | @Override | 80 | @Override |
| 80 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { | 81 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { |
| 81 | closeProgress(); | 82 | closeProgress(); |
| 82 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); | 83 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); |
| 83 | } | 84 | } |
| 84 | }); | 85 | }); |
| 85 | } | 86 | } |
| 86 | 87 | ||
| 87 | //注册接口 | 88 | //注册接口 |
| 88 | public void register(final Context context, String username, String password, String smscode, String source, final Handler handler) { | 89 | public void register(final Context context, String username, String password, String smscode, String source, final Handler handler) { |
| 89 | mProgress = DialogPermission.showProgress(context, null, "正在注册...", | 90 | mProgress = DialogPermission.showProgress(context, null, "正在注册...", |
| 90 | false, true, null); | 91 | false, true, null); |
| 91 | JSONObject jsonObject = new JSONObject(); | 92 | JSONObject jsonObject = new JSONObject(); |
| 92 | ByteArrayEntity entity = null; | 93 | ByteArrayEntity entity = null; |
| 93 | try { | 94 | try { |
| 94 | jsonObject.put(HttpKey.USERNAME, username); | 95 | jsonObject.put(HttpKey.USERNAME, username); |
| 95 | jsonObject.put(HttpKey.PASSWORD, password); | 96 | jsonObject.put(HttpKey.PASSWORD, password); |
| 96 | jsonObject.put(HttpKey.SMSCODE, smscode); | 97 | jsonObject.put(HttpKey.SMSCODE, smscode); |
| 97 | jsonObject.put(HttpKey.SOURCE, source); | 98 | jsonObject.put(HttpKey.SOURCE, source); |
| 98 | Log.e("test", "jsonObject" + jsonObject); | 99 | Log.e("test", "jsonObject" + jsonObject); |
| 99 | entity = new ByteArrayEntity(jsonObject.toString().getBytes("UTF-8")); | 100 | entity = new ByteArrayEntity(jsonObject.toString().getBytes("UTF-8")); |
| 100 | entity.setContentType(new BasicHeader(HTTP.CONTENT_TYPE, "application/json")); | 101 | entity.setContentType(new BasicHeader(HTTP.CONTENT_TYPE, "application/json")); |
| 101 | } catch (JSONException e) { | 102 | } catch (JSONException e) { |
| 102 | e.printStackTrace(); | 103 | e.printStackTrace(); |
| 103 | } catch (UnsupportedEncodingException e) { | 104 | } catch (UnsupportedEncodingException e) { |
| 104 | e.printStackTrace(); | 105 | e.printStackTrace(); |
| 105 | } | 106 | } |
| 106 | HttpClient.getInstance().addHeader("Accept", "*/*"); | 107 | HttpClient.getInstance().addHeader("Accept", "*/*"); |
| 107 | HttpClient.getInstance().post(context, HttpUrl.registeredUrl, entity, "application/json", new JsonHttpResponseHandler() { | 108 | HttpClient.getInstance().post(context, HttpUrl.registeredUrl, entity, "application/json", new JsonHttpResponseHandler() { |
| 108 | @Override | 109 | @Override |
| 109 | public void onSuccess(int statusCode, Header[] headers, JSONObject response) { | 110 | public void onSuccess(int statusCode, Header[] headers, JSONObject response) { |
| 110 | super.onSuccess(statusCode, headers, response); | 111 | super.onSuccess(statusCode, headers, response); |
| 111 | closeProgress(); | 112 | closeProgress(); |
| 112 | Log.e("test", "onSuccess" + response); | 113 | Log.e("test", "onSuccess" + response); |
| 113 | Message msg = Message.obtain(); | 114 | Message msg = Message.obtain(); |
| 114 | msg.what = HttpCode.REGISTERED_SUCESS; | 115 | msg.what = HttpCode.REGISTERED_SUCESS; |
| 115 | msg.obj = response; | 116 | msg.obj = response; |
| 116 | handler.sendMessage(msg); | 117 | handler.sendMessage(msg); |
| 117 | 118 | ||
| 118 | } | 119 | } |
| 119 | 120 | ||
| 120 | @Override | 121 | @Override |
| 121 | public void onFailure(int statusCode, Header[] headers, Throwable throwable, JSONObject errorResponse) { | 122 | public void onFailure(int statusCode, Header[] headers, Throwable throwable, JSONObject errorResponse) { |
| 122 | super.onFailure(statusCode, headers, throwable, errorResponse); | 123 | super.onFailure(statusCode, headers, throwable, errorResponse); |
| 123 | closeProgress(); | 124 | closeProgress(); |
| 124 | Log.e("test", "onFailure" + errorResponse); | 125 | Log.e("test", "onFailure" + errorResponse); |
| 125 | AlertUtils.showToast(context, "无法链接到服务器,请检查您的网络或稍后重试!"); | 126 | AlertUtils.showToast(context, "无法链接到服务器,请检查您的网络或稍后重试!"); |
| 126 | } | 127 | } |
| 127 | 128 | ||
| 128 | }); | 129 | }); |
| 129 | } | 130 | } |
| 130 | 131 | ||
| 131 | //注册验证码 | 132 | //注册验证码 |
| 132 | public void authCode(final String type, final String mobile, final Handler handler, final Context mContext) { | 133 | public void authCode(final String type, final String mobile, final Handler handler, final Context mContext) { |
| 133 | RequestParams params = new RequestParams(); | 134 | RequestParams params = new RequestParams(); |
| 134 | params.put(HttpKey.TYPE, type); | 135 | params.put(HttpKey.TYPE, type); |
| 135 | params.put(HttpKey.MOBIL, mobile); | 136 | params.put(HttpKey.MOBIL, mobile); |
| 136 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); | 137 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); |
| 137 | HttpClient.getInstance().post(HttpUrl.authCodedUrl, params, new JsonHttpResponseHandler() { | 138 | HttpClient.getInstance().post(HttpUrl.authCodedUrl, params, new JsonHttpResponseHandler() { |
| 138 | 139 | ||
| 139 | @Override | 140 | @Override |
| 140 | public void onSuccess(int statusCode, Header[] headers, JSONObject response) { | 141 | public void onSuccess(int statusCode, Header[] headers, JSONObject response) { |
| 141 | Log.e("test", "onSuccess-----" + response); | 142 | Log.e("test", "onSuccess-----" + response); |
| 142 | Message msg = Message.obtain(); | 143 | Message msg = Message.obtain(); |
| 143 | msg.what = HttpCode.AUTHCODE_SUCESS; | 144 | msg.what = HttpCode.AUTHCODE_SUCESS; |
| 144 | msg.obj = response; | 145 | msg.obj = response; |
| 145 | handler.sendMessage(msg); | 146 | handler.sendMessage(msg); |
| 146 | } | 147 | } |
| 147 | 148 | ||
| 148 | @Override | 149 | @Override |
| 149 | public void onFailure(int statusCode, Header[] headers, Throwable throwable, JSONObject errorResponse) { | 150 | public void onFailure(int statusCode, Header[] headers, Throwable throwable, JSONObject errorResponse) { |
| 150 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); | 151 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); |
| 151 | } | 152 | } |
| 152 | }); | 153 | }); |
| 153 | } | 154 | } |
| 154 | 155 | ||
| 155 | 156 | ||
| 156 | //手机号是否注册 | 157 | //手机号是否注册 |
| 157 | public void isregistered(final String mobile, final Handler handler, final Context mContext) { | 158 | public void isregistered(final String mobile, final Handler handler, final Context mContext) { |
| 158 | RequestParams params = new RequestParams(); | 159 | RequestParams params = new RequestParams(); |
| 159 | params.put(HttpKey.USERNAME, mobile); | 160 | params.put(HttpKey.USERNAME, mobile); |
| 160 | HttpClient.getInstance().get(HttpUrl.isRegiterUrl + "?mobile=" + mobile, new JsonHttpResponseHandler() { | 161 | HttpClient.getInstance().get(HttpUrl.isRegiterUrl + "?mobile=" + mobile, new JsonHttpResponseHandler() { |
| 161 | @Override | 162 | @Override |
| 162 | public void onSuccess(int statusCode, Header[] headers, JSONObject response) { | 163 | public void onSuccess(int statusCode, Header[] headers, JSONObject response) { |
| 163 | Log.e("test", "isregistered" + response.toString()); | 164 | Log.e("test", "isregistered" + response.toString()); |
| 164 | Message msg = Message.obtain(); | 165 | Message msg = Message.obtain(); |
| 165 | msg.what = HttpCode.IS_REFISTER; | 166 | msg.what = HttpCode.IS_REFISTER; |
| 166 | msg.obj = response; | 167 | msg.obj = response; |
| 167 | handler.sendMessage(msg); | 168 | handler.sendMessage(msg); |
| 168 | 169 | ||
| 169 | } | 170 | } |
| 170 | 171 | ||
| 171 | @Override | 172 | @Override |
| 172 | public void onFailure(int statusCode, Header[] headers, Throwable throwable, JSONObject errorResponse) { | 173 | public void onFailure(int statusCode, Header[] headers, Throwable throwable, JSONObject errorResponse) { |
| 173 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); | 174 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); |
| 174 | 175 | ||
| 175 | } | 176 | } |
| 176 | }); | 177 | }); |
| 177 | } | 178 | } |
| 178 | 179 | ||
| 179 | //修改密码 | 180 | //修改密码 |
| 180 | public void changepwd(final Context context, String username, String old_pwd1, String newpassword3) { | 181 | public void changepwd(final Context context, String username, String old_pwd1, String newpassword3) { |
| 181 | RequestParams params = new RequestParams(); | 182 | RequestParams params = new RequestParams(); |
| 182 | params.put(HttpKey.USERNAME, username); | 183 | params.put(HttpKey.USERNAME, username); |
| 183 | params.put(HttpKey.OLDPASS, old_pwd1); | 184 | params.put(HttpKey.OLDPASS, old_pwd1); |
| 184 | params.put(HttpKey.NEWPASS, newpassword3); | 185 | params.put(HttpKey.NEWPASS, newpassword3); |
| 185 | HttpClient.getInstance().addHeader("Accept", "*/*"); | 186 | HttpClient.getInstance().addHeader("Accept", "*/*"); |
| 186 | HttpClient.getInstance().setTimeout(10 * 1000); | 187 | HttpClient.getInstance().setTimeout(10 * 1000); |
| 187 | HttpClient.getInstance().post(HttpUrl.changepassword, params, new AsyncHttpResponseHandler() { | 188 | HttpClient.getInstance().post(HttpUrl.changepassword, params, new AsyncHttpResponseHandler() { |
| 188 | @Override | 189 | @Override |
| 189 | public void onSuccess(int i, Header[] headers, byte[] bytes) { | 190 | public void onSuccess(int i, Header[] headers, byte[] bytes) { |
| 190 | try { | 191 | try { |
| 191 | JSONObject jsonObject = new JSONObject(new String(bytes)); | 192 | JSONObject jsonObject = new JSONObject(new String(bytes)); |
| 192 | String status = jsonObject.optString("status"); | 193 | String status = jsonObject.optString("status"); |
| 193 | if (status.equals("100")) { | 194 | if (status.equals("100")) { |
| 194 | Log.e("test", "onSuccess" + new String(bytes)); | 195 | Log.e("test", "onSuccess" + new String(bytes)); |
| 195 | Toast.makeText(context, "密码修改成功!", Toast.LENGTH_LONG).show(); | 196 | Toast.makeText(context, "密码修改成功!", Toast.LENGTH_LONG).show(); |
| 196 | SaveParam.getInstance().clearData((Activity) context); | 197 | SaveParam.getInstance().clearData((Activity) context); |
| 197 | Intent intent = new Intent(); | 198 | Intent intent = new Intent(); |
| 198 | intent.setClass(context, LoginAndRegisterActivity.class); | 199 | intent.setClass(context, LoginAndRegisterActivity.class); |
| 199 | ((Activity) context).startActivity(intent); | 200 | ((Activity) context).startActivity(intent); |
| 200 | ((Activity) context).finish(); | 201 | ((Activity) context).finish(); |
| 201 | } else { | 202 | } else { |
| 202 | Toast.makeText(context, "密码修改失败!", Toast.LENGTH_LONG).show(); | 203 | Toast.makeText(context, "密码修改失败!", Toast.LENGTH_LONG).show(); |
| 203 | } | 204 | } |
| 204 | } catch (JSONException e) { | 205 | } catch (JSONException e) { |
| 205 | e.printStackTrace(); | 206 | e.printStackTrace(); |
| 206 | } | 207 | } |
| 207 | } | 208 | } |
| 208 | 209 | ||
| 209 | @Override | 210 | @Override |
| 210 | public void onFailure(int i, Header[] headers, byte[] bytes, Throwable throwable) { | 211 | public void onFailure(int i, Header[] headers, byte[] bytes, Throwable throwable) { |
| 211 | Log.e("test", "onFailure" + new String(bytes)); | 212 | Log.e("test", "onFailure" + new String(bytes)); |
| 212 | AlertUtils.showToast(context, "无法链接到服务器,请检查您的网络或稍后重试!"); | 213 | AlertUtils.showToast(context, "无法链接到服务器,请检查您的网络或稍后重试!"); |
| 213 | } | 214 | } |
| 214 | }); | 215 | }); |
| 215 | 216 | ||
| 216 | } | 217 | } |
| 217 | 218 | ||
| 218 | //忘记密码 | 219 | //忘记密码 |
| 219 | public void forgetpassword(final Context context, String forot_pwd_phone1, String forot_pwd_pwd3, String forot_pwd_anthcode1, Handler handler) { | 220 | public void forgetpassword(final Context context, String forot_pwd_phone1, String forot_pwd_pwd3, String forot_pwd_anthcode1, Handler handler) { |
| 220 | RequestParams params = new RequestParams(); | 221 | RequestParams params = new RequestParams(); |
| 221 | params.put(HttpKey.USERNAME, forot_pwd_phone1); | 222 | params.put(HttpKey.USERNAME, forot_pwd_phone1); |
| 222 | params.put(HttpKey.PASSWORD, forot_pwd_pwd3); | 223 | params.put(HttpKey.PASSWORD, forot_pwd_pwd3); |
| 223 | params.put(HttpKey.AUTHCODE, forot_pwd_anthcode1); | 224 | params.put(HttpKey.AUTHCODE, forot_pwd_anthcode1); |
| 224 | HttpClient.getInstance().addHeader("Accept", "*/*"); | 225 | HttpClient.getInstance().addHeader("Accept", "*/*"); |
| 225 | HttpClient.getInstance().post(HttpUrl.forgetpassword, params, new AsyncHttpResponseHandler() { | 226 | HttpClient.getInstance().post(HttpUrl.forgetpassword, params, new AsyncHttpResponseHandler() { |
| 226 | @Override | 227 | @Override |
| 227 | public void onSuccess(int i, Header[] headers, byte[] bytes) { | 228 | public void onSuccess(int i, Header[] headers, byte[] bytes) { |
| 228 | try { | 229 | try { |
| 229 | JSONObject jsonObject = new JSONObject(new String(bytes)); | 230 | JSONObject jsonObject = new JSONObject(new String(bytes)); |
| 230 | String status = jsonObject.optString("status"); | 231 | String status = jsonObject.optString("status"); |
| 231 | if (status.equals("100")) { | 232 | if (status.equals("100")) { |
| 232 | Log.e("test", "onSuccess" + new String(bytes)); | 233 | Log.e("test", "onSuccess" + new String(bytes)); |
| 233 | Toast.makeText(context, "密码修改成功!", Toast.LENGTH_LONG).show(); | 234 | Toast.makeText(context, "密码修改成功!", Toast.LENGTH_LONG).show(); |
| 234 | ((Activity) context).finish(); | 235 | ((Activity) context).finish(); |
| 235 | } else { | 236 | } else { |
| 236 | Toast.makeText(context, "密码修改失败!", Toast.LENGTH_LONG).show(); | 237 | Toast.makeText(context, "密码修改失败!", Toast.LENGTH_LONG).show(); |
| 237 | } | 238 | } |
| 238 | } catch (JSONException e) { | 239 | } catch (JSONException e) { |
| 239 | e.printStackTrace(); | 240 | e.printStackTrace(); |
| 240 | } | 241 | } |
| 241 | } | 242 | } |
| 242 | 243 | ||
| 243 | @Override | 244 | @Override |
| 244 | public void onFailure(int i, Header[] headers, byte[] bytes, Throwable throwable) { | 245 | public void onFailure(int i, Header[] headers, byte[] bytes, Throwable throwable) { |
| 245 | Log.e("test", "onFailure" + new String(bytes)); | 246 | Log.e("test", "onFailure" + new String(bytes)); |
| 246 | AlertUtils.showToast(context, "无法链接到服务器,请检查您的网络或稍后重试!"); | 247 | AlertUtils.showToast(context, "无法链接到服务器,请检查您的网络或稍后重试!"); |
| 247 | } | 248 | } |
| 248 | }); | 249 | }); |
| 249 | 250 | ||
| 250 | } | 251 | } |
| 251 | 252 | ||
| 252 | //保存用户登录信息 | 253 | //保存用户登录信息 |
| 253 | public void saveLoginInfo(Context context, String username, String password, String access_token, String loginStatus, String userId) { | 254 | public void saveLoginInfo(Context context, String username, String password, String access_token, String userId) { |
| 254 | SaveParam.getInstance().saveLoginParam(context, "username", username); | 255 | SaveParam.getInstance().saveLoginParam(context, "username", username); |
| 255 | SaveParam.getInstance().saveLoginParam(context, "password", password); | 256 | SaveParam.getInstance().saveLoginParam(context, "password", password); |
| 256 | SaveParam.getInstance().saveLoginParam(context, "access_token", access_token); | 257 | SaveParam.getInstance().saveLoginParam(context, "access_token", access_token); |
| 257 | SaveParam.getInstance().saveLoginParam(context, "login", loginStatus); | ||
| 258 | SaveParam.getInstance().saveLoginParam(context, "userId", userId); | 258 | SaveParam.getInstance().saveLoginParam(context, "userId", userId); |
| 259 | 259 | ||
| 260 | 260 | ||
| 261 | } | 261 | } |
| 262 | 262 | ||
| 263 | //提交保卡信息 | 263 | //提交保卡信息 |
| 264 | public void subcardinfo(final Context context, long userId, String customerName, String customerAddress, | 264 | public void subcardinfo(final Context context, long userId, String customerName, String customerAddress, |
| 265 | String buyAddress, String buyTime, String alterSaleCall, | 265 | String buyAddress, String buyTime, String alterSaleCall, |
| 266 | String productModel, String deviceNumber, String macAddress, | 266 | String productModel, String deviceNumber, String macAddress, |
| 267 | String mobilePhone) { | 267 | String mobilePhone) { |
| 268 | mProgress = DialogPermission.showProgress(context, null, "正在绑定保卡...", | 268 | mProgress = DialogPermission.showProgress(context, null, "正在绑定保卡...", |
| 269 | false, true, null); | 269 | false, true, null); |
| 270 | RequestParams params = new RequestParams(); | 270 | RequestParams params = new RequestParams(); |
| 271 | 271 | ||
| 272 | params.put(HttpKey.USEID, userId); | 272 | params.put(HttpKey.USEID, userId); |
| 273 | params.put(HttpKey.CUSTOMENAME, customerName); | 273 | params.put(HttpKey.CUSTOMENAME, customerName); |
| 274 | params.put(HttpKey.CUSTOMADRESS, customerAddress); | 274 | params.put(HttpKey.CUSTOMADRESS, customerAddress); |
| 275 | params.put(HttpKey.BUYADREES, buyAddress); | 275 | params.put(HttpKey.BUYADREES, buyAddress); |
| 276 | params.put(HttpKey.BUYTIME, buyTime); | 276 | params.put(HttpKey.BUYTIME, buyTime); |
| 277 | params.put(HttpKey.ALTERSALECALL, alterSaleCall); | 277 | params.put(HttpKey.ALTERSALECALL, alterSaleCall); |
| 278 | params.put(HttpKey.PRODUCTMODEL, productModel); | 278 | params.put(HttpKey.PRODUCTMODEL, productModel); |
| 279 | params.put(HttpKey.DEVICENUMBER, deviceNumber); | 279 | params.put(HttpKey.DEVICENUMBER, deviceNumber); |
| 280 | params.put(HttpKey.MACADRESS, macAddress); | 280 | params.put(HttpKey.MACADRESS, macAddress); |
| 281 | params.put(HttpKey.MOBILPHONE, mobilePhone); | 281 | params.put(HttpKey.MOBILPHONE, mobilePhone); |
| 282 | 282 | ||
| 283 | HttpClient.getInstance().addHeader("Accept", "*/*"); | 283 | HttpClient.getInstance().addHeader("Accept", "*/*"); |
| 284 | 284 | ||
| 285 | Log.e("test", "params" + params); | 285 | Log.e("test", "params" + params); |
| 286 | HttpClient.getInstance().setTimeout(5 * 1000); | 286 | HttpClient.getInstance().setTimeout(5 * 1000); |
| 287 | HttpClient.getInstance().post(context, HttpUrl.subcardinfo, params, new AsyncHttpResponseHandler() { | 287 | HttpClient.getInstance().post(context, HttpUrl.subcardinfo, params, new AsyncHttpResponseHandler() { |
| 288 | @Override | 288 | @Override |
| 289 | public void onSuccess(int i, Header[] headers, byte[] bytes) { | 289 | public void onSuccess(int i, Header[] headers, byte[] bytes) { |
| 290 | JSONObject jsonObject = null; | 290 | JSONObject jsonObject = null; |
| 291 | closeProgress(); | 291 | closeProgress(); |
| 292 | try { | 292 | try { |
| 293 | jsonObject = new JSONObject(new String(bytes)); | 293 | jsonObject = new JSONObject(new String(bytes)); |
| 294 | String status = jsonObject.optString("status"); | 294 | String status = jsonObject.optString("status"); |
| 295 | if (status.equals("1")) { | 295 | if (status.equals("1")) { |
| 296 | Log.e("test", "onSuccess" + jsonObject); | 296 | Log.e("test", "onSuccess" + jsonObject); |
| 297 | Toast.makeText(context, "保卡绑定成功!", Toast.LENGTH_LONG).show(); | 297 | Toast.makeText(context, "保卡绑定成功!", Toast.LENGTH_LONG).show(); |
| 298 | Intent intent = new Intent(); | 298 | Intent intent = new Intent(); |
| 299 | intent.setClass((Activity) context, TheStartPageActivity.class); | 299 | intent.setClass((Activity) context, TheStartPageActivity.class); |
| 300 | ((Activity) context).startActivity(intent); | 300 | ((Activity) context).startActivity(intent); |
| 301 | ((Activity) context).overridePendingTransition(R.anim.rightin, R.anim.rightout); | 301 | ((Activity) context).overridePendingTransition(R.anim.rightin, R.anim.rightout); |
| 302 | ((Activity) context).finish(); | 302 | ((Activity) context).finish(); |
| 303 | } else { | 303 | } else { |
| 304 | Toast.makeText(context, "保卡绑定失败!", Toast.LENGTH_LONG).show(); | 304 | Toast.makeText(context, "保卡绑定失败!", Toast.LENGTH_LONG).show(); |
| 305 | } | 305 | } |
| 306 | } catch (JSONException e) { | 306 | } catch (JSONException e) { |
| 307 | e.printStackTrace(); | 307 | e.printStackTrace(); |
| 308 | } | 308 | } |
| 309 | 309 | ||
| 310 | 310 | ||
| 311 | } | 311 | } |
| 312 | 312 | ||
| 313 | @Override | 313 | @Override |
| 314 | public void onFailure(int i, Header[] headers, byte[] bytes, Throwable throwable) { | 314 | public void onFailure(int i, Header[] headers, byte[] bytes, Throwable throwable) { |
| 315 | Log.e("test", "onFailure" + (throwable)); | 315 | Log.e("test", "onFailure" + (throwable)); |
| 316 | closeProgress(); | 316 | closeProgress(); |
| 317 | AlertUtils.showToast(context, "无法链接到服务器,请检查您的网络或稍后重试!"); | 317 | AlertUtils.showToast(context, "无法链接到服务器,请检查您的网络或稍后重试!"); |
| 318 | 318 | ||
| 319 | } | 319 | } |
| 320 | }); | 320 | }); |
| 321 | 321 | ||
| 322 | } | 322 | } |
| 323 | 323 | ||
| 324 | //获取保卡信息 | 324 | //获取保卡信息 |
| 325 | public void getcardinfo(final Context mContext, long userId, final Handler handler) { | 325 | public void getcardinfo(final Context mContext, long userId, final Handler handler) { |
| 326 | mProgress = DialogPermission.showProgress(mContext, null, "正在获取保卡信息...", | 326 | mProgress = DialogPermission.showProgress(mContext, null, "正在获取保卡信息...", |
| 327 | false, true, null); | 327 | false, true, null); |
| 328 | HttpClient.getInstance().setTimeout(5 * 1000); | 328 | HttpClient.getInstance().setTimeout(5 * 1000); |
| 329 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); | 329 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); |
| 330 | HttpClient.getInstance().get(HttpUrl.getcardinfo + "?userId=" + userId, new AsyncHttpResponseHandler() { | 330 | HttpClient.getInstance().get(HttpUrl.getcardinfo + "?userId=" + userId, new AsyncHttpResponseHandler() { |
| 331 | @Override | 331 | @Override |
| 332 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { | 332 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { |
| 333 | closeProgress(); | 333 | closeProgress(); |
| 334 | Log.e("test", "保卡信息" + new String(arg2)); | 334 | Log.e("test", "保卡信息" + new String(arg2)); |
| 335 | try { | 335 | try { |
| 336 | JSONObject jsonObject = new JSONObject(new String(arg2)); | 336 | JSONObject jsonObject = new JSONObject(new String(arg2)); |
| 337 | int status = jsonObject.optInt("status"); | 337 | int status = jsonObject.optInt("status"); |
| 338 | if (status == 1) { | 338 | if (status == 1) { |
| 339 | CardInfo cardInfo = GsonTool.getPerson(new String(arg2), CardInfo.class);//解析json数据 | 339 | CardInfo cardInfo = GsonTool.getPerson(new String(arg2), CardInfo.class);//解析json数据 |
| 340 | CardInfo.DataBean schoolInfoBeanList = cardInfo.getData(); | 340 | CardInfo.DataBean schoolInfoBeanList = cardInfo.getData(); |
| 341 | Message msg = Message.obtain(); | 341 | Message msg = Message.obtain(); |
| 342 | msg.what = HttpCode.SUCHCARDINFO; | 342 | msg.what = HttpCode.SUCHCARDINFO; |
| 343 | msg.obj = schoolInfoBeanList; | 343 | msg.obj = schoolInfoBeanList; |
| 344 | handler.sendMessage(msg); | 344 | handler.sendMessage(msg); |
| 345 | 345 | ||
| 346 | 346 | ||
| 347 | } else { | 347 | } else { |
| 348 | AlertUtils.showToast(mContext, "你好,服务器异常,请稍后重试!"); | 348 | AlertUtils.showToast(mContext, "你好,服务器异常,请稍后重试!"); |
| 349 | 349 | ||
| 350 | } | 350 | } |
| 351 | } catch (JSONException e) { | 351 | } catch (JSONException e) { |
| 352 | e.printStackTrace(); | 352 | e.printStackTrace(); |
| 353 | } | 353 | } |
| 354 | 354 | ||
| 355 | } | 355 | } |
| 356 | 356 | ||
| 357 | @Override | 357 | @Override |
| 358 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { | 358 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { |
| 359 | closeProgress(); | 359 | closeProgress(); |
| 360 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); | 360 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); |
| 361 | } | 361 | } |
| 362 | }); | 362 | }); |
| 363 | } | 363 | } |
| 364 | 364 | ||
| 365 | //修改保卡信息电话 | 365 | //修改保卡信息电话 |
| 366 | public void changecardinfophone(final Context mContext, long userId, final String customerPhone, String authCode) { | 366 | public void changecardinfophone(final Context mContext, long userId, final String customerPhone, String authCode) { |
| 367 | RequestParams params = new RequestParams(); | 367 | RequestParams params = new RequestParams(); |
| 368 | params.put("userId", userId); | 368 | params.put("userId", userId); |
| 369 | params.put("customerPhone", customerPhone); | 369 | params.put("customerPhone", customerPhone); |
| 370 | params.put("authCode", authCode); | 370 | params.put("authCode", authCode); |
| 371 | HttpClient.getInstance().addHeader("Accept", "*/*"); | 371 | HttpClient.getInstance().addHeader("Accept", "*/*"); |
| 372 | HttpClient.getInstance().post(HttpUrl.changecardinfo, params, new AsyncHttpResponseHandler() { | 372 | HttpClient.getInstance().post(HttpUrl.changecardinfo, params, new AsyncHttpResponseHandler() { |
| 373 | @Override | 373 | @Override |
| 374 | public void onSuccess(int i, Header[] headers, byte[] bytes) { | 374 | public void onSuccess(int i, Header[] headers, byte[] bytes) { |
| 375 | try { | 375 | try { |
| 376 | JSONObject jsonObject = new JSONObject(new String(bytes)); | 376 | JSONObject jsonObject = new JSONObject(new String(bytes)); |
| 377 | String status = jsonObject.optString("status"); | 377 | String status = jsonObject.optString("status"); |
| 378 | if (status.equals("1")) { | 378 | if (status.equals("1")) { |
| 379 | Toast.makeText(mContext, "手机号修改成功", Toast.LENGTH_LONG).show(); | 379 | Toast.makeText(mContext, "手机号修改成功", Toast.LENGTH_LONG).show(); |
| 380 | if (Content.authcodeflag==2){ | 380 | if (Content.authcodeflag==2){ |
| 381 | SaveParam.getInstance().saveCustomizeParam(mContext, SaveParam.CARDPHONE, customerPhone); | 381 | SaveParam.getInstance().saveCustomizeParam(mContext, SaveParam.CARDPHONE, customerPhone); |
| 382 | }else if (Content.authcodeflag==1){ | 382 | }else if (Content.authcodeflag==1){ |
| 383 | SaveParam.getInstance().saveLoginParam(mContext, "username", customerPhone); | 383 | SaveParam.getInstance().saveLoginParam(mContext, "username", customerPhone); |
| 384 | }else { | 384 | }else { |
| 385 | AlertUtils.showToast(mContext, "修改未知的手机号"); | 385 | AlertUtils.showToast(mContext, "修改未知的手机号"); |
| 386 | } | 386 | } |
| 387 | ((Activity) mContext).finish(); | 387 | ((Activity) mContext).finish(); |
| 388 | } else if (status.equals("1001")) { | 388 | } else if (status.equals("1001")) { |
| 389 | Toast.makeText(mContext, "验证码输入错误", Toast.LENGTH_LONG).show(); | 389 | Toast.makeText(mContext, "验证码输入错误", Toast.LENGTH_LONG).show(); |
| 390 | } else { | 390 | } else { |
| 391 | AlertUtils.showToast(mContext, "您好,服务器异常,请稍后重试"); | 391 | AlertUtils.showToast(mContext, "您好,服务器异常,请稍后重试"); |
| 392 | } | 392 | } |
| 393 | } catch (JSONException e) { | 393 | } catch (JSONException e) { |
| 394 | e.printStackTrace(); | 394 | e.printStackTrace(); |
| 395 | } | 395 | } |
| 396 | } | 396 | } |
| 397 | 397 | ||
| 398 | @Override | 398 | @Override |
| 399 | public void onFailure(int i, Header[] headers, byte[] bytes, Throwable throwable) { | 399 | public void onFailure(int i, Header[] headers, byte[] bytes, Throwable throwable) { |
| 400 | Log.e("test", "onFailure" + new String(bytes)); | 400 | Log.e("test", "onFailure" + new String(bytes)); |
| 401 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); | 401 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); |
| 402 | } | 402 | } |
| 403 | }); | 403 | }); |
| 404 | } | 404 | } |
| 405 | 405 | ||
| 406 | //修改保卡信息地址 | 406 | //修改保卡信息地址 |
| 407 | public void changecardadressinfo(final Context mContext, long userId, final String customerPhone, String authCode, final String customerAddress) { | 407 | public void changecardadressinfo(final Context mContext, long userId, final String customerPhone, String authCode, final String customerAddress) { |
| 408 | RequestParams params = new RequestParams(); | 408 | RequestParams params = new RequestParams(); |
| 409 | params.put("userId", userId); | 409 | params.put("userId", userId); |
| 410 | params.put("customerPhone", customerPhone); | 410 | params.put("customerPhone", customerPhone); |
| 411 | params.put("authCode", authCode); | 411 | params.put("authCode", authCode); |
| 412 | params.put("customerAddress", customerAddress); | 412 | params.put("customerAddress", customerAddress); |
| 413 | HttpClient.getInstance().addHeader("Accept", "*/*"); | 413 | HttpClient.getInstance().addHeader("Accept", "*/*"); |
| 414 | HttpClient.getInstance().post(HttpUrl.changecardinfo, params, new AsyncHttpResponseHandler() { | 414 | HttpClient.getInstance().post(HttpUrl.changecardinfo, params, new AsyncHttpResponseHandler() { |
| 415 | @Override | 415 | @Override |
| 416 | public void onSuccess(int i, Header[] headers, byte[] bytes) { | 416 | public void onSuccess(int i, Header[] headers, byte[] bytes) { |
| 417 | try { | 417 | try { |
| 418 | JSONObject jsonObject = new JSONObject(new String(bytes)); | 418 | JSONObject 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 | Toast.makeText(mContext, "修改成功", Toast.LENGTH_LONG).show(); | 421 | Toast.makeText(mContext, "修改成功", Toast.LENGTH_LONG).show(); |
| 422 | SaveParam.getInstance().saveCustomizeParam(mContext, SaveParam.ADRESSCUNSTEM, customerAddress); | 422 | SaveParam.getInstance().saveCustomizeParam(mContext, SaveParam.ADRESSCUNSTEM, customerAddress); |
| 423 | ((Activity) mContext).finish(); | 423 | ((Activity) mContext).finish(); |
| 424 | } else { | 424 | } else { |
| 425 | AlertUtils.showToast(mContext, "您好,服务器异常,请稍后重试"); | 425 | AlertUtils.showToast(mContext, "您好,服务器异常,请稍后重试"); |
| 426 | } | 426 | } |
| 427 | } catch (JSONException e) { | 427 | } catch (JSONException e) { |
| 428 | e.printStackTrace(); | 428 | e.printStackTrace(); |
| 429 | } | 429 | } |
| 430 | } | 430 | } |
| 431 | 431 | ||
| 432 | @Override | 432 | @Override |
| 433 | public void onFailure(int i, Header[] headers, byte[] bytes, Throwable throwable) { | 433 | public void onFailure(int i, Header[] headers, byte[] bytes, Throwable throwable) { |
| 434 | Log.e("test", "onFailure" + new String(bytes)); | 434 | Log.e("test", "onFailure" + new String(bytes)); |
| 435 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); | 435 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); |
| 436 | } | 436 | } |
| 437 | }); | 437 | }); |
| 438 | } | 438 | } |
| 439 | 439 | ||
| 440 | //验证是否保卡信息 | 440 | //验证是否保卡信息 |
| 441 | public void cardinfocheck(final Context mContext, long userId, final Handler handler) { | 441 | public void cardinfocheck(final Context mContext, long userId, final Handler handler) { |
| 442 | mProgress = DialogPermission.showProgress(mContext, null, "正在验证保卡信息...", | 442 | mProgress = DialogPermission.showProgress(mContext, null, "正在验证保卡信息...", |
| 443 | false, true, null); | 443 | false, true, null); |
| 444 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); | 444 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); |
| 445 | HttpClient.getInstance().get(HttpUrl.cardcheck + "?userId=" + userId, new AsyncHttpResponseHandler() { | 445 | HttpClient.getInstance().get(HttpUrl.cardcheck + "?userId=" + userId, new AsyncHttpResponseHandler() { |
| 446 | @Override | 446 | @Override |
| 447 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { | 447 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { |
| 448 | Log.e("test", "---" + new String(arg2)); | 448 | Log.e("test", "---" + new String(arg2)); |
| 449 | closeProgress(); | 449 | closeProgress(); |
| 450 | Message msg = Message.obtain(); | 450 | Message msg = Message.obtain(); |
| 451 | msg.what = HttpCode.CHECKCARD; | 451 | msg.what = HttpCode.CHECKCARD; |
| 452 | msg.obj = new String(arg2); | 452 | msg.obj = new String(arg2); |
| 453 | handler.sendMessage(msg); | 453 | handler.sendMessage(msg); |
| 454 | 454 | ||
| 455 | 455 | ||
| 456 | } | 456 | } |
| 457 | 457 | ||
| 458 | @Override | 458 | @Override |
| 459 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { | 459 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { |
| 460 | closeProgress(); | 460 | closeProgress(); |
| 461 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); | 461 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); |
| 462 | //Toast.makeText(mContext, "请检查网络。。" + arg3, Toast.LENGTH_LONG).show(); | 462 | //Toast.makeText(mContext, "请检查网络。。" + arg3, Toast.LENGTH_LONG).show(); |
| 463 | } | 463 | } |
| 464 | }); | 464 | }); |
| 465 | } | 465 | } |
| 466 | 466 | ||
| 467 | ///获取年级 | 467 | ///获取年级 |
| 468 | public void getgrade(final Context mContext, final Handler handler) { | 468 | public void getgrade(final Context mContext, final Handler handler) { |
| 469 | HttpClient.getInstance().addHeader("Accept", "application/json"); | 469 | HttpClient.getInstance().addHeader("Accept", "application/json"); |
| 470 | HttpClient.getInstance().get(HttpUrl.gradesUrl, new AsyncHttpResponseHandler() { | 470 | HttpClient.getInstance().get(HttpUrl.gradesUrl, new AsyncHttpResponseHandler() { |
| 471 | @Override | 471 | @Override |
| 472 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { | 472 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { |
| 473 | Log.e("test", "年级" + new String(arg2)); | 473 | Log.e("test", "年级" + new String(arg2)); |
| 474 | GradeInfo gradeInfo = GsonTool.getPerson(new String(arg2), GradeInfo.class);//解析json数据 | 474 | GradeInfo gradeInfo = GsonTool.getPerson(new String(arg2), GradeInfo.class);//解析json数据 |
| 475 | List<GradeInfo.DataBean.ChildrenBean> gradeInfoLists = new ArrayList<GradeInfo.DataBean.ChildrenBean>(); | 475 | List<GradeInfo.DataBean.ChildrenBean> gradeInfoLists = new ArrayList<GradeInfo.DataBean.ChildrenBean>(); |
| 476 | for (int i = 0; i < gradeInfo.getData().size() - 2; i++) { | 476 | for (int i = 0; i < gradeInfo.getData().size() - 2; i++) { |
| 477 | String name = gradeInfo.getData().get(i).getName(); | 477 | String name = gradeInfo.getData().get(i).getName(); |
| 478 | int id = gradeInfo.getData().get(i).getId(); | 478 | int id = gradeInfo.getData().get(i).getId(); |
| 479 | List<GradeInfo.DataBean.ChildrenBean> gradeinfoList = gradeInfo.getData().get(i).getChildren(); | 479 | List<GradeInfo.DataBean.ChildrenBean> gradeinfoList = gradeInfo.getData().get(i).getChildren(); |
| 480 | for (int j = 0; j < gradeinfoList.size(); j++) { | 480 | for (int j = 0; j < gradeinfoList.size(); j++) { |
| 481 | String secondname = gradeinfoList.get(j).getName(); | 481 | String secondname = gradeinfoList.get(j).getName(); |
| 482 | int secondid = gradeinfoList.get(j).getId(); | 482 | int secondid = gradeinfoList.get(j).getId(); |
| 483 | GradeInfo.DataBean.ChildrenBean dataBean = new GradeInfo.DataBean.ChildrenBean(); | 483 | GradeInfo.DataBean.ChildrenBean dataBean = new GradeInfo.DataBean.ChildrenBean(); |
| 484 | dataBean.setName(secondname); | 484 | dataBean.setName(secondname); |
| 485 | dataBean.setId(secondid); | 485 | dataBean.setId(secondid); |
| 486 | gradeInfoLists.add(dataBean); | 486 | gradeInfoLists.add(dataBean); |
| 487 | } | 487 | } |
| 488 | 488 | ||
| 489 | } | 489 | } |
| 490 | 490 | ||
| 491 | Message message = Message.obtain(); | 491 | Message message = Message.obtain(); |
| 492 | message.what = HttpCode.GRADER; | 492 | message.what = HttpCode.GRADER; |
| 493 | message.obj = gradeInfoLists; | 493 | message.obj = gradeInfoLists; |
| 494 | handler.sendMessage(message); | 494 | handler.sendMessage(message); |
| 495 | 495 | ||
| 496 | 496 | ||
| 497 | } | 497 | } |
| 498 | 498 | ||
| 499 | @Override | 499 | @Override |
| 500 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { | 500 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { |
| 501 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); | 501 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); |
| 502 | } | 502 | } |
| 503 | }); | 503 | }); |
| 504 | } | 504 | } |
| 505 | 505 | ||
| 506 | /** | 506 | /** |
| 507 | * 获取学校 | 507 | * 获取学校 |
| 508 | * | 508 | * |
| 509 | * @param mContext | 509 | * @param mContext |
| 510 | * @param regionId | 510 | * @param regionId |
| 511 | * @param gradeId | 511 | * @param gradeId |
| 512 | * @param handler | 512 | * @param handler |
| 513 | */ | 513 | */ |
| 514 | public void getschool(final Context mContext, int regionId, int gradeId, final Handler handler) { | 514 | public void getschool(final Context mContext, int regionId, int gradeId, final Handler handler) { |
| 515 | HttpClient.getInstance().addHeader("Accept", "application/json"); | 515 | HttpClient.getInstance().addHeader("Accept", "application/json"); |
| 516 | HttpClient.getInstance().get(HttpUrl.schoolUrl + "?regionId=" + regionId + "&gradeId=" + gradeId, new AsyncHttpResponseHandler() { | 516 | HttpClient.getInstance().get(HttpUrl.schoolUrl + "?regionId=" + regionId + "&gradeId=" + gradeId, new AsyncHttpResponseHandler() { |
| 517 | @Override | 517 | @Override |
| 518 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { | 518 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { |
| 519 | Log.e("test", "学校" + new String(arg2)); | 519 | Log.e("test", "学校" + new String(arg2)); |
| 520 | try { | 520 | try { |
| 521 | JSONObject jsonObject = new JSONObject(new String(arg2)); | 521 | JSONObject jsonObject = new JSONObject(new String(arg2)); |
| 522 | int status = jsonObject.optInt("status"); | 522 | int status = jsonObject.optInt("status"); |
| 523 | if (status == 1) { | 523 | if (status == 1) { |
| 524 | SchoolInfo schoolInfo = GsonTool.getPerson(new String(arg2), SchoolInfo.class);//解析json数据 | 524 | SchoolInfo schoolInfo = GsonTool.getPerson(new String(arg2), SchoolInfo.class);//解析json数据 |
| 525 | List<SchoolInfo.DataBean> schoolInfoBeanList = schoolInfo.getData(); | 525 | List<SchoolInfo.DataBean> schoolInfoBeanList = schoolInfo.getData(); |
| 526 | Message message = Message.obtain(); | 526 | Message message = Message.obtain(); |
| 527 | message.what = HttpCode.SCHOOL; | 527 | message.what = HttpCode.SCHOOL; |
| 528 | message.obj = schoolInfoBeanList; | 528 | message.obj = schoolInfoBeanList; |
| 529 | handler.sendMessage(message); | 529 | handler.sendMessage(message); |
| 530 | 530 | ||
| 531 | 531 | ||
| 532 | } else { | 532 | } else { |
| 533 | AlertUtils.showToast(mContext, "你好,服务器异常,请稍后重试!"); | 533 | AlertUtils.showToast(mContext, "你好,服务器异常,请稍后重试!"); |
| 534 | 534 | ||
| 535 | } | 535 | } |
| 536 | } catch (JSONException e) { | 536 | } catch (JSONException e) { |
| 537 | e.printStackTrace(); | 537 | e.printStackTrace(); |
| 538 | } | 538 | } |
| 539 | 539 | ||
| 540 | } | 540 | } |
| 541 | 541 | ||
| 542 | @Override | 542 | @Override |
| 543 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { | 543 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { |
| 544 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); | 544 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); |
| 545 | } | 545 | } |
| 546 | }); | 546 | }); |
| 547 | } | 547 | } |
| 548 | 548 | ||
| 549 | 549 | ||
| 550 | /** | 550 | /** |
| 551 | * 获取个人信息 | 551 | * 获取个人信息 |
| 552 | * | 552 | * |
| 553 | * @param mContext | 553 | * @param mContext |
| 554 | * @param userId | 554 | * @param userId |
| 555 | * @param handler | 555 | * @param handler |
| 556 | */ | 556 | */ |
| 557 | public void getpresonalinfo(final Context mContext, long userId, int type, final Handler handler) { | 557 | public void getpresonalinfo(final Context mContext, long userId, int type, final Handler handler) { |
| 558 | mProgress = DialogPermission.showProgress(mContext, null, "正在获取个人信息...", | 558 | mProgress = DialogPermission.showProgress(mContext, null, "正在获取个人信息...", |
| 559 | false, true, null); | 559 | false, true, null); |
| 560 | HttpClient.getInstance().addHeader("Accept", "application/json"); | 560 | HttpClient.getInstance().addHeader("Accept", "application/json"); |
| 561 | HttpClient.getInstance().setConnectTimeout(5 * 1000); | 561 | HttpClient.getInstance().setConnectTimeout(5 * 1000); |
| 562 | HttpClient.getInstance().get(HttpUrl.getpresonalinfo + "?userId=" + userId + "&type=" + type, new AsyncHttpResponseHandler() { | 562 | HttpClient.getInstance().get(HttpUrl.getpresonalinfo + "?userId=" + userId + "&type=" + type, new AsyncHttpResponseHandler() { |
| 563 | @Override | 563 | @Override |
| 564 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { | 564 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { |
| 565 | closeProgress(); | 565 | closeProgress(); |
| 566 | Log.e("test", "个人信息" + new String(arg2)); | 566 | Log.e("test", "个人信息" + new String(arg2)); |
| 567 | try { | 567 | try { |
| 568 | JSONObject jsonObject = new JSONObject(new String(arg2)); | 568 | JSONObject jsonObject = new JSONObject(new String(arg2)); |
| 569 | int status = jsonObject.optInt("status"); | 569 | int status = jsonObject.optInt("status"); |
| 570 | if (status == 1) { | 570 | if (status == 1) { |
| 571 | PesonalInfo pesonalInfo = GsonTool.getPerson(new String(arg2), PesonalInfo.class);//解析json数据 | 571 | PesonalInfo pesonalInfo = GsonTool.getPerson(new String(arg2), PesonalInfo.class);//解析json数据 |
| 572 | PesonalInfo.DataBean pesonalInfoBeanList = pesonalInfo.getData(); | 572 | PesonalInfo.DataBean pesonalInfoBeanList = pesonalInfo.getData(); |
| 573 | Message message = Message.obtain(); | 573 | Message message = Message.obtain(); |
| 574 | message.what = HttpCode.GETINFO; | 574 | message.what = HttpCode.GETINFO; |
| 575 | message.obj = pesonalInfoBeanList; | 575 | message.obj = pesonalInfoBeanList; |
| 576 | handler.sendMessage(message); | 576 | handler.sendMessage(message); |
| 577 | 577 | ||
| 578 | 578 | ||
| 579 | } else { | 579 | } else { |
| 580 | AlertUtils.showToast(mContext, "你好,服务器异常,请稍后重试!"); | 580 | AlertUtils.showToast(mContext, "你好,服务器异常,请稍后重试!"); |
| 581 | 581 | ||
| 582 | } | 582 | } |
| 583 | } catch (JSONException e) { | 583 | } catch (JSONException e) { |
| 584 | e.printStackTrace(); | 584 | e.printStackTrace(); |
| 585 | } | 585 | } |
| 586 | 586 | ||
| 587 | 587 | ||
| 588 | } | 588 | } |
| 589 | 589 | ||
| 590 | @Override | 590 | @Override |
| 591 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { | 591 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { |
| 592 | closeProgress(); | 592 | closeProgress(); |
| 593 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); | 593 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); |
| 594 | } | 594 | } |
| 595 | }); | 595 | }); |
| 596 | } | 596 | } |
| 597 | 597 | ||
| 598 | //修改个人信息 | 598 | //修改个人信息 |
| 599 | public void changepresonalinfo(final Context mContext, Long id, int type | 599 | public void changepresonalinfo(final Context mContext, Long id, int type |
| 600 | , String name, String birthday, int gradeId, long regionId, | 600 | , String name, String birthday, int gradeId, long regionId, |
| 601 | Object schoolId, String qq, String gender | 601 | Object schoolId, String qq, String gender |
| 602 | , String regionName, String devicenumber) throws UnsupportedEncodingException { | 602 | , String regionName, String devicenumber) throws UnsupportedEncodingException { |
| 603 | mProgress = DialogPermission.showProgress(mContext, null, "正在保存个人信息...", | 603 | mProgress = DialogPermission.showProgress(mContext, null, "正在保存个人信息...", |
| 604 | false, true, null); | 604 | false, true, null); |
| 605 | RequestParams params = new RequestParams(); | 605 | RequestParams params = new RequestParams(); |
| 606 | 606 | ||
| 607 | params.put(HttpKey.USEID, id); | 607 | params.put(HttpKey.USEID, id); |
| 608 | params.put(HttpKey.TYPE, type); | 608 | params.put(HttpKey.TYPE, type); |
| 609 | params.put(HttpKey.NAME, name); | 609 | params.put(HttpKey.NAME, name); |
| 610 | params.put(HttpKey.BIRDays, birthday); | 610 | params.put(HttpKey.BIRDays, birthday); |
| 611 | params.put(HttpKey.GRADE, gradeId); | 611 | params.put(HttpKey.GRADE, gradeId); |
| 612 | params.put(HttpKey.REGION, regionId); | 612 | params.put(HttpKey.REGION, regionId); |
| 613 | params.put(HttpKey.SCHOOL, schoolId); | 613 | params.put(HttpKey.SCHOOL, schoolId); |
| 614 | params.put(HttpKey.QQ, qq); | 614 | params.put(HttpKey.QQ, qq); |
| 615 | params.put(HttpKey.GENDER, gender); | 615 | params.put(HttpKey.GENDER, gender); |
| 616 | params.put(HttpKey.REGIONNAME, regionName); | 616 | params.put(HttpKey.REGIONNAME, regionName); |
| 617 | params.put(HttpKey.DEVINUMBER, devicenumber); | 617 | params.put(HttpKey.DEVINUMBER, devicenumber); |
| 618 | Log.e("test", "个人信息" + params); | 618 | Log.e("test", "个人信息" + params); |
| 619 | HttpClient.getInstance().addHeader("Accept", "*/*"); | 619 | HttpClient.getInstance().addHeader("Accept", "*/*"); |
| 620 | HttpClient.getInstance().post(mContext, HttpUrl.changepresonalinfo, params, new JsonHttpResponseHandler() { | 620 | HttpClient.getInstance().post(mContext, HttpUrl.changepresonalinfo, params, new JsonHttpResponseHandler() { |
| 621 | @Override | 621 | @Override |
| 622 | public void onSuccess(int statusCode, Header[] headers, JSONObject response) { | 622 | public void onSuccess(int statusCode, Header[] headers, JSONObject response) { |
| 623 | super.onSuccess(statusCode, headers, response); | 623 | super.onSuccess(statusCode, headers, response); |
| 624 | closeProgress(); | 624 | closeProgress(); |
| 625 | String status = response.optString("status"); | 625 | String status = response.optString("status"); |
| 626 | if (status.equals("1")) { | 626 | if (status.equals("1")) { |
| 627 | Toast.makeText(mContext, "个人信息保存成功", Toast.LENGTH_LONG).show(); | 627 | Toast.makeText(mContext, "个人信息保存成功", Toast.LENGTH_LONG).show(); |
| 628 | ((Activity) mContext).finish(); | 628 | ((Activity) mContext).finish(); |
| 629 | } else { | 629 | } else { |
| 630 | AlertUtils.showToast(mContext, "您好,服务器异常,请稍后重试"); | 630 | AlertUtils.showToast(mContext, "您好,服务器异常,请稍后重试"); |
| 631 | } | 631 | } |
| 632 | 632 | ||
| 633 | } | 633 | } |
| 634 | 634 | ||
| 635 | @Override | 635 | @Override |
| 636 | public void onFailure(int statusCode, Header[] headers, Throwable throwable, JSONObject errorResponse) { | 636 | public void onFailure(int statusCode, Header[] headers, Throwable throwable, JSONObject errorResponse) { |
| 637 | super.onFailure(statusCode, headers, throwable, errorResponse); | 637 | super.onFailure(statusCode, headers, throwable, errorResponse); |
| 638 | closeProgress(); | 638 | closeProgress(); |
| 639 | Log.e("test", "onFailure" + errorResponse); | 639 | Log.e("test", "onFailure" + errorResponse); |
| 640 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); | 640 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); |
| 641 | } | 641 | } |
| 642 | 642 | ||
| 643 | }); | 643 | }); |
| 644 | } | 644 | } |
| 645 | 645 | ||
| 646 | //修改个性签名 | 646 | //修改个性签名 |
| 647 | public void changsignature(final Context mContext, long userId, int type, final String signature) { | 647 | public void changsignature(final Context mContext, long userId, int type, final String signature) { |
| 648 | RequestParams params = new RequestParams(); | 648 | RequestParams params = new RequestParams(); |
| 649 | params.put("userId", userId); | 649 | params.put("userId", userId); |
| 650 | params.put("type", type); | 650 | params.put("type", type); |
| 651 | params.put("signature", signature); | 651 | params.put("signature", signature); |
| 652 | HttpClient.getInstance().addHeader("Accept", "*/*"); | 652 | HttpClient.getInstance().addHeader("Accept", "*/*"); |
| 653 | HttpClient.getInstance().post(HttpUrl.signature, params, new AsyncHttpResponseHandler() { | 653 | HttpClient.getInstance().post(HttpUrl.signature, params, new AsyncHttpResponseHandler() { |
| 654 | @Override | 654 | @Override |
| 655 | public void onSuccess(int i, Header[] headers, byte[] bytes) { | 655 | public void onSuccess(int i, Header[] headers, byte[] bytes) { |
| 656 | try { | 656 | try { |
| 657 | JSONObject jsonObject = new JSONObject(new String(bytes)); | 657 | JSONObject jsonObject = new JSONObject(new String(bytes)); |
| 658 | String status = jsonObject.optString("status"); | 658 | String status = jsonObject.optString("status"); |
| 659 | if (status.equals("1")) { | 659 | if (status.equals("1")) { |
| 660 | Toast.makeText(mContext, "个性签名修改成功", Toast.LENGTH_LONG).show(); | 660 | Toast.makeText(mContext, "个性签名修改成功", Toast.LENGTH_LONG).show(); |
| 661 | } else { | 661 | } else { |
| 662 | AlertUtils.showToast(mContext, "你好,服务器异常,请稍后重试"); | 662 | AlertUtils.showToast(mContext, "你好,服务器异常,请稍后重试"); |
| 663 | } | 663 | } |
| 664 | } catch (JSONException e) { | 664 | } catch (JSONException e) { |
| 665 | e.printStackTrace(); | 665 | e.printStackTrace(); |
| 666 | } | 666 | } |
| 667 | } | 667 | } |
| 668 | 668 | ||
| 669 | @Override | 669 | @Override |
| 670 | public void onFailure(int i, Header[] headers, byte[] bytes, Throwable throwable) { | 670 | public void onFailure(int i, Header[] headers, byte[] bytes, Throwable throwable) { |
| 671 | Log.e("test", "onFailure" + new String(bytes)); | 671 | Log.e("test", "onFailure" + new String(bytes)); |
| 672 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); | 672 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); |
| 673 | } | 673 | } |
| 674 | }); | 674 | }); |
| 675 | } | 675 | } |
| 676 | 676 | ||
| 677 | /** | 677 | /** |
| 678 | * 获取个性签名 | 678 | * 获取个性签名 |
| 679 | * | 679 | * |
| 680 | * @param mContext | 680 | * @param mContext |
| 681 | * @param userId | 681 | * @param userId |
| 682 | * @param handler | 682 | * @param handler |
| 683 | */ | 683 | */ |
| 684 | public void getsignatures(final Context mContext, long userId, int type, final Handler handler) { | 684 | public void getsignatures(final Context mContext, long userId, int type, final Handler handler) { |
| 685 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); | 685 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); |
| 686 | HttpClient.getInstance().get(HttpUrl.getsignature + "?userId=" + userId + "&type=" + type, new AsyncHttpResponseHandler() { | 686 | HttpClient.getInstance().get(HttpUrl.getsignature + "?userId=" + userId + "&type=" + type, new AsyncHttpResponseHandler() { |
| 687 | @Override | 687 | @Override |
| 688 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { | 688 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { |
| 689 | Log.e("test", "个性签名" + new String(arg2)); | 689 | Log.e("test", "个性签名" + new String(arg2)); |
| 690 | try { | 690 | try { |
| 691 | JSONObject jsonObject = new JSONObject(new String(arg2)); | 691 | JSONObject jsonObject = new JSONObject(new String(arg2)); |
| 692 | int status = jsonObject.optInt("status"); | 692 | int status = jsonObject.optInt("status"); |
| 693 | if (status == 1) { | 693 | if (status == 1) { |
| 694 | SignInfo signInfo = GsonTool.getPerson(new String(arg2), SignInfo.class);//解析json数据 | 694 | SignInfo signInfo = GsonTool.getPerson(new String(arg2), SignInfo.class);//解析json数据 |
| 695 | SignInfo.DataBean signInfoBeanList = signInfo.getData(); | 695 | SignInfo.DataBean signInfoBeanList = signInfo.getData(); |
| 696 | Message message = Message.obtain(); | 696 | Message message = Message.obtain(); |
| 697 | message.what = HttpCode.SIGN; | 697 | message.what = HttpCode.SIGN; |
| 698 | message.obj = signInfoBeanList; | 698 | message.obj = signInfoBeanList; |
| 699 | handler.sendMessage(message); | 699 | handler.sendMessage(message); |
| 700 | 700 | ||
| 701 | 701 | ||
| 702 | } else if (status == 1000) { | 702 | } else if (status == 1000) { |
| 703 | AlertUtils.showToast(mContext, "您还没有签名哦"); | 703 | AlertUtils.showToast(mContext, "您还没有签名哦"); |
| 704 | 704 | ||
| 705 | } else { | 705 | } else { |
| 706 | AlertUtils.showToast(mContext, "你好,服务器异常,请稍后重试!"); | 706 | AlertUtils.showToast(mContext, "你好,服务器异常,请稍后重试!"); |
| 707 | } | 707 | } |
| 708 | } catch (JSONException e) { | 708 | } catch (JSONException e) { |
| 709 | e.printStackTrace(); | 709 | e.printStackTrace(); |
| 710 | } | 710 | } |
| 711 | 711 | ||
| 712 | 712 | ||
| 713 | } | 713 | } |
| 714 | 714 | ||
| 715 | @Override | 715 | @Override |
| 716 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { | 716 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { |
| 717 | Log.e("test", "失败原因" + arg3); | 717 | Log.e("test", "失败原因" + arg3); |
| 718 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); | 718 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); |
| 719 | } | 719 | } |
| 720 | }); | 720 | }); |
| 721 | } | 721 | } |
| 722 | 722 | ||
| 723 | /** | 723 | /** |
| 724 | * 用户反馈 | 724 | * 用户反馈 |
| 725 | * | 725 | * |
| 726 | * @param mContext | 726 | * @param mContext |
| 727 | * @param userId | 727 | * @param userId |
| 728 | * @param content | 728 | * @param content |
| 729 | * @param contact | 729 | * @param contact |
| 730 | * @param imgs | 730 | * @param imgs |
| 731 | * @param feedtype | 731 | * @param feedtype |
| 732 | * @throws UnsupportedEncodingException | 732 | * @throws UnsupportedEncodingException |
| 733 | */ | 733 | */ |
| 734 | public void feedback(final Context mContext, String userId, String content, | 734 | public void feedback(final Context mContext, String userId, String content, |
| 735 | String contact, String imgs, String feedtype) throws UnsupportedEncodingException { | 735 | String contact, String imgs, String feedtype) throws UnsupportedEncodingException { |
| 736 | mProgress = DialogPermission.showProgress(mContext, null, "正在提交反馈内容...", | 736 | mProgress = DialogPermission.showProgress(mContext, null, "正在提交反馈内容...", |
| 737 | false, true, null); | 737 | false, true, null); |
| 738 | File file = new File(imgs); | 738 | File file = new File(imgs); |
| 739 | if (file.exists() && file.length() > 0) { | 739 | if (file.exists() && file.length() > 0) { |
| 740 | RequestParams params = new RequestParams(); | 740 | RequestParams params = new RequestParams(); |
| 741 | try { | 741 | try { |
| 742 | params.put("userId", userId); | 742 | params.put("userId", userId); |
| 743 | params.put("content", content); | 743 | params.put("content", content); |
| 744 | params.put("contact", contact); | 744 | params.put("contact", contact); |
| 745 | params.put("imgs", file); | 745 | params.put("imgs", file); |
| 746 | params.put("feedtype", feedtype); | 746 | params.put("feedtype", feedtype); |
| 747 | } catch (FileNotFoundException e) { | 747 | } catch (FileNotFoundException e) { |
| 748 | e.printStackTrace(); | 748 | e.printStackTrace(); |
| 749 | } | 749 | } |
| 750 | Log.e("test", "onSuccess" + params); | 750 | Log.e("test", "onSuccess" + params); |
| 751 | HttpClient.getInstance().post(HttpUrl.feedbackURL, params, new AsyncHttpResponseHandler() { | 751 | HttpClient.getInstance().post(HttpUrl.feedbackURL, params, new AsyncHttpResponseHandler() { |
| 752 | @Override | 752 | @Override |
| 753 | public void onSuccess(int i, Header[] headers, byte[] bytes) { | 753 | public void onSuccess(int i, Header[] headers, byte[] bytes) { |
| 754 | closeProgress(); | 754 | closeProgress(); |
| 755 | Log.e("test", "onSuccess" + new String(bytes)); | 755 | Log.e("test", "onSuccess" + new String(bytes)); |
| 756 | try { | 756 | try { |
| 757 | JSONObject jsonObject = new JSONObject(new String(bytes)); | 757 | JSONObject jsonObject = new JSONObject(new String(bytes)); |
| 758 | String status = jsonObject.optString("status"); | 758 | String status = jsonObject.optString("status"); |
| 759 | if (status.equals("1")) { | 759 | if (status.equals("1")) { |
| 760 | Toast.makeText(mContext, "您的宝贵意见已经提交成功。", Toast.LENGTH_LONG).show(); | 760 | Toast.makeText(mContext, "您的宝贵意见已经提交成功。", Toast.LENGTH_LONG).show(); |
| 761 | ((Activity) mContext).finish(); | 761 | ((Activity) mContext).finish(); |
| 762 | } else { | 762 | } else { |
| 763 | AlertUtils.showToast(mContext, "你好,服务器异常,请稍后重试"); | 763 | AlertUtils.showToast(mContext, "你好,服务器异常,请稍后重试"); |
| 764 | } | 764 | } |
| 765 | } catch (JSONException e) { | 765 | } catch (JSONException e) { |
| 766 | e.printStackTrace(); | 766 | e.printStackTrace(); |
| 767 | } | 767 | } |
| 768 | } | 768 | } |
| 769 | 769 | ||
| 770 | @Override | 770 | @Override |
| 771 | public void onFailure(int i, Header[] headers, byte[] bytes, Throwable throwable) { | 771 | public void onFailure(int i, Header[] headers, byte[] bytes, Throwable throwable) { |
| 772 | closeProgress(); | 772 | closeProgress(); |
| 773 | Log.e("test", "错误信息" + new String(bytes)); | 773 | Log.e("test", "错误信息" + new String(bytes)); |
| 774 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); | 774 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); |
| 775 | 775 | ||
| 776 | } | 776 | } |
| 777 | }); | 777 | }); |
| 778 | } else { | 778 | } else { |
| 779 | Toast.makeText(mContext, "文件不存在", Toast.LENGTH_LONG).show(); | 779 | Toast.makeText(mContext, "文件不存在", Toast.LENGTH_LONG).show(); |
| 780 | } | 780 | } |
| 781 | } | 781 | } |
| 782 | 782 | ||
| 783 | /** | 783 | /** |
| 784 | * 查询子账户信息 | 784 | * 查询子账户信息 |
| 785 | * | 785 | * |
| 786 | * @param mContext | 786 | * @param mContext |
| 787 | * @param userId | 787 | * @param userId |
| 788 | * @param handler | 788 | * @param handler |
| 789 | */ | 789 | */ |
| 790 | public void getchildAccountinfo(final Context mContext, long userId, String deviceNumber, final Handler handler) { | 790 | public void getchildAccountinfo(final Context mContext, long userId, String deviceNumber, final Handler handler) { |
| 791 | mProgress = DialogPermission.showProgress(mContext, null, "正在获取信息...", | 791 | mProgress = DialogPermission.showProgress(mContext, null, "正在获取信息...", |
| 792 | false, true, null); | 792 | false, true, null); |
| 793 | 793 | ||
| 794 | Log.e("test", "ID" + userId + "deviceNumber" + deviceNumber); | 794 | Log.e("test", "ID" + userId + "deviceNumber" + deviceNumber); |
| 795 | HttpClient.getInstance().setTimeout(5 * 1000); | 795 | HttpClient.getInstance().setTimeout(5 * 1000); |
| 796 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); | 796 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); |
| 797 | HttpClient.getInstance().get(HttpUrl.childUserURL + "?userId=" + userId + "&deviceNumber=" + deviceNumber, new AsyncHttpResponseHandler() { | 797 | HttpClient.getInstance().get(HttpUrl.childUserURL + "?userId=" + userId + "&deviceNumber=" + deviceNumber, new AsyncHttpResponseHandler() { |
| 798 | @Override | 798 | @Override |
| 799 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { | 799 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { |
| 800 | closeProgress(); | 800 | closeProgress(); |
| 801 | Log.e("test", "子账户信息" + new String(arg2)); | 801 | Log.e("test", "子账户信息" + new String(arg2)); |
| 802 | try { | 802 | try { |
| 803 | JSONObject jsonObject = new JSONObject(new String(arg2)); | 803 | JSONObject jsonObject = new JSONObject(new String(arg2)); |
| 804 | int status = jsonObject.optInt("status"); | 804 | int status = jsonObject.optInt("status"); |
| 805 | if (status == 1) { | 805 | if (status == 1) { |
| 806 | ChildsInfo childsInfo = GsonTool.getPerson(new String(arg2), ChildsInfo.class);//解析json数据 | 806 | ChildsInfo childsInfo = GsonTool.getPerson(new String(arg2), ChildsInfo.class);//解析json数据 |
| 807 | Log.e("test", "子账户信息" + childsInfo); | 807 | Log.e("test", "子账户信息" + childsInfo); |
| 808 | List<ChildsInfo.DataBean> schoolInfoBeanList = childsInfo.getData(); | 808 | List<ChildsInfo.DataBean> schoolInfoBeanList = childsInfo.getData(); |
| 809 | Log.e("test", "子账户信息" + schoolInfoBeanList); | 809 | Log.e("test", "子账户信息" + schoolInfoBeanList); |
| 810 | Message msg = Message.obtain(); | 810 | Message msg = Message.obtain(); |
| 811 | msg.what = HttpCode.CHILDS_SUCESS; | 811 | msg.what = HttpCode.CHILDS_SUCESS; |
| 812 | msg.obj = schoolInfoBeanList; | 812 | msg.obj = schoolInfoBeanList; |
| 813 | handler.sendMessage(msg); | 813 | handler.sendMessage(msg); |
| 814 | 814 | ||
| 815 | }else { | 815 | }else { |
| 816 | AlertUtils.showToast(mContext, "你好,服务器异常,请稍后再试!"); | 816 | AlertUtils.showToast(mContext, "你好,服务器异常,请稍后再试!"); |
| 817 | 817 | ||
| 818 | } | 818 | } |
| 819 | } catch (JSONException e) { | 819 | } catch (JSONException e) { |
| 820 | e.printStackTrace(); | 820 | e.printStackTrace(); |
| 821 | 821 | ||
| 822 | } | 822 | } |
| 823 | 823 | ||
| 824 | } | 824 | } |
| 825 | 825 | ||
| 826 | @Override | 826 | @Override |
| 827 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { | 827 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { |
| 828 | closeProgress(); | 828 | closeProgress(); |
| 829 | // Log.e("test", "错误信息" + new String(arg2)); | 829 | // Log.e("test", "错误信息" + new String(arg2)); |
| 830 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); | 830 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); |
| 831 | } | 831 | } |
| 832 | }); | 832 | }); |
| 833 | 833 | ||
| 834 | } | 834 | } |
| 835 | 835 | ||
| 836 | /** | 836 | /** |
| 837 | * 删除子账户信息 | 837 | * 删除子账户信息 |
| 838 | * | 838 | * |
| 839 | * @param mContext | 839 | * @param mContext |
| 840 | * @param subAccountId | 840 | * @param subAccountId |
| 841 | */ | 841 | */ |
| 842 | public void deletechildAccountinfo(final Context mContext, String subAccountId) { | 842 | public void deletechildAccountinfo(final Context mContext, String subAccountId) { |
| 843 | mProgress = DialogPermission.showProgress(mContext, null, "正在删除子账户...", | 843 | mProgress = DialogPermission.showProgress(mContext, null, "正在删除子账户...", |
| 844 | false, true, null); | 844 | false, true, null); |
| 845 | HttpClient.getInstance().setTimeout(5 * 1000); | 845 | HttpClient.getInstance().setTimeout(5 * 1000); |
| 846 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); | 846 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); |
| 847 | HttpClient.getInstance().get(HttpUrl.deletechildUserURL + "?subAccountId=" + subAccountId, new AsyncHttpResponseHandler() { | 847 | HttpClient.getInstance().get(HttpUrl.deletechildUserURL + "?subAccountId=" + subAccountId, new AsyncHttpResponseHandler() { |
| 848 | @Override | 848 | @Override |
| 849 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { | 849 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { |
| 850 | closeProgress(); | 850 | closeProgress(); |
| 851 | Log.e("test", "子账户信息" + new String(arg2)); | 851 | Log.e("test", "子账户信息" + new String(arg2)); |
| 852 | try { | 852 | try { |
| 853 | JSONObject jsonObject = new JSONObject(new String(arg2)); | 853 | JSONObject jsonObject = new JSONObject(new String(arg2)); |
| 854 | int status = jsonObject.optInt("status"); | 854 | int status = jsonObject.optInt("status"); |
| 855 | if (status == 1) { | 855 | if (status == 1) { |
| 856 | AlertUtils.showToast(mContext, "子账号删除成功!"); | 856 | AlertUtils.showToast(mContext, "子账号删除成功!"); |
| 857 | ((Activity) mContext).finish(); | 857 | ((Activity) mContext).finish(); |
| 858 | } else { | 858 | } else { |
| 859 | AlertUtils.showToast(mContext, "你好,子账号删除失败!"); | 859 | AlertUtils.showToast(mContext, "你好,子账号删除失败!"); |
| 860 | 860 | ||
| 861 | } | 861 | } |
| 862 | } catch (JSONException e) { | 862 | } catch (JSONException e) { |
| 863 | e.printStackTrace(); | 863 | e.printStackTrace(); |
| 864 | } | 864 | } |
| 865 | 865 | ||
| 866 | } | 866 | } |
| 867 | 867 | ||
| 868 | @Override | 868 | @Override |
| 869 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { | 869 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { |
| 870 | closeProgress(); | 870 | closeProgress(); |
| 871 | Log.e("test", "错误信息" + new String(arg2)); | 871 | Log.e("test", "错误信息" + new String(arg2)); |
| 872 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); | 872 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); |
| 873 | } | 873 | } |
| 874 | }); | 874 | }); |
| 875 | 875 | ||
| 876 | } | 876 | } |
| 877 | 877 | ||
| 878 | /** | 878 | /** |
| 879 | * 添加子账户信息 | 879 | * 添加子账户信息 |
| 880 | */ | 880 | */ |
| 881 | public void addchildAccountinfo(final Context mContext, long parentId, String image, | 881 | public void addchildAccountinfo(final Context mContext, long parentId, String image, |
| 882 | String name, Long grade, Object school, Long region | 882 | String name, Long grade, Object school, Long region |
| 883 | , String deviceNumber, String regionName) { | 883 | , String deviceNumber, String regionName) { |
| 884 | mProgress = DialogPermission.showProgress(mContext, null, "正在添加子账户...", | 884 | mProgress = DialogPermission.showProgress(mContext, null, "正在添加子账户...", |
| 885 | false, true, null); | 885 | false, true, null); |
| 886 | RequestParams params = new RequestParams(); | 886 | RequestParams params = new RequestParams(); |
| 887 | 887 | ||
| 888 | params.put(HttpKey.PARENTID, parentId); | 888 | params.put(HttpKey.PARENTID, parentId); |
| 889 | params.put(HttpKey.IMAGE, image); | 889 | params.put(HttpKey.IMAGE, image); |
| 890 | params.put(HttpKey.NAME, name); | 890 | params.put(HttpKey.NAME, name); |
| 891 | params.put(HttpKey.GRADE, grade); | 891 | params.put(HttpKey.GRADE, grade); |
| 892 | params.put(HttpKey.SCHOOL, school); | 892 | params.put(HttpKey.SCHOOL, school); |
| 893 | params.put(HttpKey.REGION, region); | 893 | params.put(HttpKey.REGION, region); |
| 894 | params.put(HttpKey.DEVINUMBER, deviceNumber); | 894 | params.put(HttpKey.DEVINUMBER, deviceNumber); |
| 895 | params.put(HttpKey.REGIONNAME, regionName); | 895 | params.put(HttpKey.REGIONNAME, regionName); |
| 896 | 896 | ||
| 897 | Log.e("test", "子账户信息" + params); | 897 | Log.e("test", "子账户信息" + params); |
| 898 | HttpClient.getInstance().addHeader("Accept", "*/*"); | 898 | HttpClient.getInstance().addHeader("Accept", "*/*"); |
| 899 | HttpClient.getInstance().setTimeout(5 * 1000); | 899 | HttpClient.getInstance().setTimeout(5 * 1000); |
| 900 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); | 900 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); |
| 901 | HttpClient.getInstance().post(HttpUrl.addchildUserURL, params, new AsyncHttpResponseHandler() { | 901 | HttpClient.getInstance().post(HttpUrl.addchildUserURL, params, new AsyncHttpResponseHandler() { |
| 902 | @Override | 902 | @Override |
| 903 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { | 903 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { |
| 904 | closeProgress(); | 904 | closeProgress(); |
| 905 | 905 | ||
| 906 | Log.e("test", "子账户信息" + new String(arg2)); | 906 | Log.e("test", "子账户信息" + new String(arg2)); |
| 907 | try { | 907 | try { |
| 908 | JSONObject jsonObject = new JSONObject(new String(arg2)); | 908 | JSONObject jsonObject = new JSONObject(new String(arg2)); |
| 909 | int status = jsonObject.optInt("status"); | 909 | int status = jsonObject.optInt("status"); |
| 910 | if (status == 1) { | 910 | if (status == 1) { |
| 911 | AlertUtils.showToast(mContext, "子账号添加成功!"); | 911 | AlertUtils.showToast(mContext, "子账号添加成功!"); |
| 912 | ((Activity) mContext).finish(); | 912 | ((Activity) mContext).finish(); |
| 913 | } else { | 913 | } else { |
| 914 | AlertUtils.showToast(mContext, "你好,子账号添加失败!"); | 914 | AlertUtils.showToast(mContext, "你好,子账号添加失败!"); |
| 915 | 915 | ||
| 916 | } | 916 | } |
| 917 | } catch (JSONException e) { | 917 | } catch (JSONException e) { |
| 918 | e.printStackTrace(); | 918 | e.printStackTrace(); |
| 919 | } | 919 | } |
| 920 | 920 | ||
| 921 | } | 921 | } |
| 922 | 922 | ||
| 923 | @Override | 923 | @Override |
| 924 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { | 924 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { |
| 925 | closeProgress(); | 925 | closeProgress(); |
| 926 | Log.e("test", "错误信息" + new String(arg2)); | 926 | Log.e("test", "错误信息" + new String(arg2)); |
| 927 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); | 927 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); |
| 928 | } | 928 | } |
| 929 | }); | 929 | }); |
| 930 | 930 | ||
| 931 | } | 931 | } |
| 932 | 932 | ||
| 933 | /** | 933 | /** |
| 934 | * 切换子账户信息 | 934 | * 切换子账户信息 |
| 935 | * | 935 | * |
| 936 | * @param mContext | 936 | * @param mContext |
| 937 | * @param subAccountId | 937 | * @param subAccountId |
| 938 | */ | 938 | */ |
| 939 | public void changechildAccountinfo(final Context mContext, String subAccountId, long userId | 939 | public void changechildAccountinfo(final Context mContext, String subAccountId, long userId |
| 940 | , String deviceNumber, int type) { | 940 | , String deviceNumber, int type) { |
| 941 | mProgress = DialogPermission.showProgress(mContext, null, "正在切换子账户...", | 941 | mProgress = DialogPermission.showProgress(mContext, null, "正在切换子账户...", |
| 942 | false, true, null); | 942 | false, true, null); |
| 943 | HttpClient.getInstance().setTimeout(5 * 1000); | 943 | HttpClient.getInstance().setTimeout(5 * 1000); |
| 944 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); | 944 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); |
| 945 | HttpClient.getInstance().get(HttpUrl.changechildUserURL + "?subAccountId=" + subAccountId + "&userId=" + userId | 945 | HttpClient.getInstance().get(HttpUrl.changechildUserURL + "?subAccountId=" + subAccountId + "&userId=" + userId |
| 946 | + "&deviceNumber=" + deviceNumber + "&type=" + type, new AsyncHttpResponseHandler() { | 946 | + "&deviceNumber=" + deviceNumber + "&type=" + type, new AsyncHttpResponseHandler() { |
| 947 | @Override | 947 | @Override |
| 948 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { | 948 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { |
| 949 | closeProgress(); | 949 | closeProgress(); |
| 950 | Log.e("test", "子账户信息" + new String(arg2)); | 950 | Log.e("test", "子账户信息" + new String(arg2)); |
| 951 | try { | 951 | try { |
| 952 | JSONObject jsonObject = new JSONObject(new String(arg2)); | 952 | JSONObject jsonObject = new JSONObject(new String(arg2)); |
| 953 | int status = jsonObject.optInt("status"); | 953 | int status = jsonObject.optInt("status"); |
| 954 | if (status == 1) { | 954 | if (status == 1) { |
| 955 | AlertUtils.showToast(mContext, "子账号切换成功!"); | 955 | AlertUtils.showToast(mContext, "子账号切换成功!"); |
| 956 | ((Activity) mContext).finish(); | 956 | ((Activity) mContext).finish(); |
| 957 | 957 | ||
| 958 | } else { | 958 | } else { |
| 959 | AlertUtils.showToast(mContext, "你好,子账号切换失败!"); | 959 | AlertUtils.showToast(mContext, "你好,子账号切换失败!"); |
| 960 | 960 | ||
| 961 | } | 961 | } |
| 962 | } catch (JSONException e) { | 962 | } catch (JSONException e) { |
| 963 | e.printStackTrace(); | 963 | e.printStackTrace(); |
| 964 | } | 964 | } |
| 965 | 965 | ||
| 966 | } | 966 | } |
| 967 | 967 | ||
| 968 | @Override | 968 | @Override |
| 969 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { | 969 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { |
| 970 | closeProgress(); | 970 | closeProgress(); |
| 971 | Log.e("test", "错误信息" + new String(arg2)); | 971 | Log.e("test", "错误信息" + new String(arg2)); |
| 972 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); | 972 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); |
| 973 | } | 973 | } |
| 974 | }); | 974 | }); |
| 975 | 975 | ||
| 976 | } | 976 | } |
| 977 | 977 | ||
| 978 | /** | 978 | /** |
| 979 | * 切换主账户信息 | 979 | * 切换主账户信息 |
| 980 | * | 980 | * |
| 981 | * @param mContext | 981 | * @param mContext |
| 982 | * @param type | 982 | * @param type |
| 983 | */ | 983 | */ |
| 984 | public void Accountinfo(final Context mContext, long userId | 984 | public void Accountinfo(final Context mContext, long userId |
| 985 | , String deviceNumber, int type) { | 985 | , String deviceNumber, int type) { |
| 986 | mProgress = DialogPermission.showProgress(mContext, null, "正在切换主账户...", | 986 | mProgress = DialogPermission.showProgress(mContext, null, "正在切换主账户...", |
| 987 | false, true, null); | 987 | false, true, null); |
| 988 | HttpClient.getInstance().setTimeout(5 * 1000); | 988 | HttpClient.getInstance().setTimeout(5 * 1000); |
| 989 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); | 989 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); |
| 990 | HttpClient.getInstance().get(HttpUrl.changechildUserURL + "?userId=" + userId + "&deviceNumber=" + deviceNumber | 990 | HttpClient.getInstance().get(HttpUrl.changechildUserURL + "?userId=" + userId + "&deviceNumber=" + deviceNumber |
| 991 | + "&type=" + type, new AsyncHttpResponseHandler() { | 991 | + "&type=" + type, new AsyncHttpResponseHandler() { |
| 992 | @Override | 992 | @Override |
| 993 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { | 993 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { |
| 994 | closeProgress(); | 994 | closeProgress(); |
| 995 | Log.e("test", "子账户信息" + new String(arg2)); | 995 | Log.e("test", "子账户信息" + new String(arg2)); |
| 996 | try { | 996 | try { |
| 997 | JSONObject jsonObject = new JSONObject(new String(arg2)); | 997 | JSONObject jsonObject = new JSONObject(new String(arg2)); |
| 998 | int status = jsonObject.optInt("status"); | 998 | int status = jsonObject.optInt("status"); |
| 999 | if (status == 1) { | 999 | if (status == 1) { |
| 1000 | AlertUtils.showToast(mContext, "主账号切换成功!"); | 1000 | AlertUtils.showToast(mContext, "主账号切换成功!"); |
| 1001 | ((Activity) mContext).finish(); | 1001 | ((Activity) mContext).finish(); |
| 1002 | 1002 | ||
| 1003 | } else { | 1003 | } else { |
| 1004 | AlertUtils.showToast(mContext, "你好,主账号切换失败!"); | 1004 | AlertUtils.showToast(mContext, "你好,主账号切换失败!"); |
| 1005 | 1005 | ||
| 1006 | } | 1006 | } |
| 1007 | } catch (JSONException e) { | 1007 | } catch (JSONException e) { |
| 1008 | e.printStackTrace(); | 1008 | e.printStackTrace(); |
| 1009 | } | 1009 | } |
| 1010 | 1010 | ||
| 1011 | } | 1011 | } |
| 1012 | 1012 | ||
| 1013 | @Override | 1013 | @Override |
| 1014 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { | 1014 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { |
| 1015 | closeProgress(); | 1015 | closeProgress(); |
| 1016 | Log.e("test", "错误信息" + new String(arg2)); | 1016 | Log.e("test", "错误信息" + new String(arg2)); |
| 1017 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); | 1017 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); |
| 1018 | } | 1018 | } |
| 1019 | }); | 1019 | }); |
| 1020 | 1020 | ||
| 1021 | } | 1021 | } |
| 1022 | 1022 | ||
| 1023 | /** | 1023 | /** |
| 1024 | * 头像拍张 | 1024 | * 头像拍张 |
| 1025 | * | 1025 | * |
| 1026 | * @param mContext | 1026 | * @param mContext |
| 1027 | * @param userId | 1027 | * @param userId |
| 1028 | * @param img | 1028 | * @param img |
| 1029 | * @throws UnsupportedEncodingException | 1029 | * @throws UnsupportedEncodingException |
| 1030 | */ | 1030 | */ |
| 1031 | public void header(final Context mContext, String userId, String type, String img) throws UnsupportedEncodingException { | 1031 | public void header(final Context mContext, String userId, String type, String img) throws UnsupportedEncodingException { |
| 1032 | File file = new File(img); | 1032 | File file = new File(img); |
| 1033 | if (file.exists() && file.length() > 0) { | 1033 | if (file.exists() && file.length() > 0) { |
| 1034 | RequestParams params = new RequestParams(); | 1034 | RequestParams params = new RequestParams(); |
| 1035 | try { | 1035 | try { |
| 1036 | params.put("userId", userId); | 1036 | params.put("userId", userId); |
| 1037 | params.put("type", type); | 1037 | params.put("type", type); |
| 1038 | params.put("img", file); | 1038 | params.put("img", file); |
| 1039 | } catch (FileNotFoundException e) { | 1039 | } catch (FileNotFoundException e) { |
| 1040 | e.printStackTrace(); | 1040 | e.printStackTrace(); |
| 1041 | } | 1041 | } |
| 1042 | Log.e("test", "params" + params); | 1042 | Log.e("test", "params" + params); |
| 1043 | HttpClient.getInstance().setTimeout(5 * 1000); | 1043 | HttpClient.getInstance().setTimeout(5 * 1000); |
| 1044 | HttpClient.getInstance().post(HttpUrl.headerURL, params, new AsyncHttpResponseHandler() { | 1044 | HttpClient.getInstance().post(HttpUrl.headerURL, params, new AsyncHttpResponseHandler() { |
| 1045 | @Override | 1045 | @Override |
| 1046 | public void onSuccess(int i, Header[] headers, byte[] bytes) { | 1046 | public void onSuccess(int i, Header[] headers, byte[] bytes) { |
| 1047 | Log.e("test", "onSuccess" + new String(bytes)); | 1047 | Log.e("test", "onSuccess" + new String(bytes)); |
| 1048 | try { | 1048 | try { |
| 1049 | JSONObject jsonObject = new JSONObject(new String(bytes)); | 1049 | JSONObject jsonObject = new JSONObject(new String(bytes)); |
| 1050 | String status = jsonObject.optString("status"); | 1050 | String status = jsonObject.optString("status"); |
| 1051 | JSONObject jsonObject1 =jsonObject.getJSONObject("data"); | 1051 | JSONObject jsonObject1 =jsonObject.getJSONObject("data"); |
| 1052 | String imagUrl = jsonObject1.optString("imgUrl"); | 1052 | String imagUrl = jsonObject1.optString("imgUrl"); |
| 1053 | SaveParam.getInstance().saveLoginParam(mContext,SaveParam.HEADURL,imagUrl); | 1053 | SaveParam.getInstance().saveLoginParam(mContext,SaveParam.HEADURL,imagUrl); |
| 1054 | if (status.equals("1")) { | 1054 | if (status.equals("1")) { |
| 1055 | Toast.makeText(mContext, "头像上传成功。", Toast.LENGTH_LONG).show(); | 1055 | Toast.makeText(mContext, "头像上传成功。", Toast.LENGTH_LONG).show(); |
| 1056 | } else { | 1056 | } else { |
| 1057 | AlertUtils.showToast(mContext, "你好,服务器异常,请稍后重试"); | 1057 | AlertUtils.showToast(mContext, "你好,服务器异常,请稍后重试"); |
| 1058 | } | 1058 | } |
| 1059 | } catch (JSONException e) { | 1059 | } catch (JSONException e) { |
| 1060 | e.printStackTrace(); | 1060 | e.printStackTrace(); |
| 1061 | } | 1061 | } |
| 1062 | } | 1062 | } |
| 1063 | 1063 | ||
| 1064 | @Override | 1064 | @Override |
| 1065 | public void onFailure(int i, Header[] headers, byte[] bytes, Throwable throwable) { | 1065 | public void onFailure(int i, Header[] headers, byte[] bytes, Throwable throwable) { |
| 1066 | closeProgress(); | 1066 | closeProgress(); |
| 1067 | Log.e("test", "错误信息" + new String(bytes)); | 1067 | Log.e("test", "错误信息" + new String(bytes)); |
| 1068 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); | 1068 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); |
| 1069 | 1069 | ||
| 1070 | } | 1070 | } |
| 1071 | }); | 1071 | }); |
| 1072 | } else { | 1072 | } else { |
| 1073 | Toast.makeText(mContext, "文件不存在", Toast.LENGTH_LONG).show(); | 1073 | Toast.makeText(mContext, "文件不存在", Toast.LENGTH_LONG).show(); |
| 1074 | } | 1074 | } |
| 1075 | } | 1075 | } |
| 1076 | /** | 1076 | /** |
| 1077 | * 头像默认 | 1077 | * 头像默认 |
| 1078 | * | 1078 | * |
| 1079 | * @param mContext | 1079 | * @param mContext |
| 1080 | * @param userId | 1080 | * @param userId |
| 1081 | * @param | 1081 | * @param |
| 1082 | * @throws UnsupportedEncodingException | 1082 | * @throws UnsupportedEncodingException |
| 1083 | */ | 1083 | */ |
| 1084 | public void headerdeft(final Context mContext, String userId, String type,String defaultImg) throws UnsupportedEncodingException { | 1084 | public void headerdeft(final Context mContext, String userId, String type,String defaultImg) throws UnsupportedEncodingException { |
| 1085 | RequestParams params = new RequestParams(); | 1085 | RequestParams params = new RequestParams(); |
| 1086 | params.put("userId", userId); | 1086 | params.put("userId", userId); |
| 1087 | params.put("type", type); | 1087 | params.put("type", type); |
| 1088 | params.put("defaultImg", defaultImg); | 1088 | params.put("defaultImg", defaultImg); |
| 1089 | Log.e("test", "params" + params); | 1089 | Log.e("test", "params" + params); |
| 1090 | HttpClient.getInstance().setTimeout(5 * 1000); | 1090 | HttpClient.getInstance().setTimeout(5 * 1000); |
| 1091 | HttpClient.getInstance().post(HttpUrl.headerdefaultURL, params, new AsyncHttpResponseHandler() { | 1091 | HttpClient.getInstance().post(HttpUrl.headerdefaultURL, params, new AsyncHttpResponseHandler() { |
| 1092 | @Override | 1092 | @Override |
| 1093 | public void onSuccess(int i, Header[] headers, byte[] bytes) { | 1093 | public void onSuccess(int i, Header[] headers, byte[] bytes) { |
| 1094 | Log.e("test", "onSuccess" + new String(bytes)); | 1094 | Log.e("test", "onSuccess" + new String(bytes)); |
| 1095 | try { | 1095 | try { |
| 1096 | JSONObject jsonObject = new JSONObject(new String(bytes)); | 1096 | JSONObject jsonObject = new JSONObject(new String(bytes)); |
| 1097 | String status = jsonObject.optString("status"); | 1097 | String status = jsonObject.optString("status"); |
| 1098 | JSONObject jsonObject1 =jsonObject.getJSONObject("data"); | 1098 | JSONObject jsonObject1 =jsonObject.getJSONObject("data"); |
| 1099 | String imagUrl = jsonObject1.optString("imgUrl"); | 1099 | String imagUrl = jsonObject1.optString("imgUrl"); |
| 1100 | SaveParam.getInstance().saveLoginParam(mContext,SaveParam.HEADURL,imagUrl); | 1100 | SaveParam.getInstance().saveLoginParam(mContext,SaveParam.HEADURL,imagUrl); |
| 1101 | if (status.equals("1")) { | 1101 | if (status.equals("1")) { |
| 1102 | Toast.makeText(mContext, "头像上传成功。", Toast.LENGTH_LONG).show(); | 1102 | Toast.makeText(mContext, "头像上传成功。", Toast.LENGTH_LONG).show(); |
| 1103 | } else { | 1103 | } else { |
| 1104 | AlertUtils.showToast(mContext, "你好,服务器异常,请稍后重试"); | 1104 | AlertUtils.showToast(mContext, "你好,服务器异常,请稍后重试"); |
| 1105 | } | 1105 | } |
| 1106 | } catch (JSONException e) { | 1106 | } catch (JSONException e) { |
| 1107 | e.printStackTrace(); | 1107 | e.printStackTrace(); |
| 1108 | } | 1108 | } |
| 1109 | } | 1109 | } |
| 1110 | 1110 | ||
| 1111 | @Override | 1111 | @Override |
| 1112 | public void onFailure(int i, Header[] headers, byte[] bytes, Throwable throwable) { | 1112 | public void onFailure(int i, Header[] headers, byte[] bytes, Throwable throwable) { |
| 1113 | closeProgress(); | 1113 | closeProgress(); |
| 1114 | Log.e("test", "错误信息" + new String(bytes)); | 1114 | Log.e("test", "错误信息" + new String(bytes)); |
| 1115 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); | 1115 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); |
| 1116 | 1116 | ||
| 1117 | } | 1117 | } |
| 1118 | }); | 1118 | }); |
| 1119 | } | 1119 | } |
| 1120 | 1120 | ||
| 1121 | /** | 1121 | /** |
| 1122 | * 检查注册信息是否完整 | 1122 | * 检查注册信息是否完整 |
| 1123 | * @param mContext | 1123 | * @param mContext |
| 1124 | * @param userId | 1124 | * @param userId |
| 1125 | */ | 1125 | */ |
| 1126 | public void registerinfocheck(final Context mContext, long userId, final Handler handler) { | 1126 | public void registerinfocheck(final Context mContext, long userId, final Handler handler) { |
| 1127 | mProgress = DialogPermission.showProgress(mContext, null, "正在检查注册信息是否完整...", | 1127 | mProgress = DialogPermission.showProgress(mContext, null, "正在检查注册信息是否完整...", |
| 1128 | false, true, null); | 1128 | false, true, null); |
| 1129 | HttpClient.getInstance().setTimeout(5 * 1000); | 1129 | HttpClient.getInstance().setTimeout(5 * 1000); |
| 1130 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); | 1130 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); |
| 1131 | HttpClient.getInstance().get(HttpUrl.isRegisterInfoCompleteURL + "?userId=" + userId , new AsyncHttpResponseHandler() { | 1131 | HttpClient.getInstance().get(HttpUrl.isRegisterInfoCompleteURL + "?userId=" + userId , new AsyncHttpResponseHandler() { |
| 1132 | @Override | 1132 | @Override |
| 1133 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { | 1133 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { |
| 1134 | closeProgress(); | 1134 | closeProgress(); |
| 1135 | Log.e("test", "注册信息" + new String(arg2)); | 1135 | Log.e("test", "注册信息" + new String(arg2)); |
| 1136 | Message msg = Message.obtain(); | 1136 | Message msg = Message.obtain(); |
| 1137 | msg.what = HttpCode.REGISTER_SUCESS; | 1137 | msg.what = HttpCode.REGISTER_SUCESS; |
| 1138 | msg.obj = new String(arg2); | 1138 | msg.obj = new String(arg2); |
| 1139 | handler.sendMessage(msg); | 1139 | handler.sendMessage(msg); |
| 1140 | 1140 | ||
| 1141 | } | 1141 | } |
| 1142 | 1142 | ||
| 1143 | @Override | 1143 | @Override |
| 1144 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { | 1144 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { |
| 1145 | closeProgress(); | 1145 | closeProgress(); |
| 1146 | Log.e("test", "错误信息" + new String(arg2)); | 1146 | // Log.e("test", "错误信息" + new String(arg2)); |
| 1147 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); | 1147 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); |
| 1148 | 1148 | ||
| 1149 | } | 1149 | } |
| 1150 | }); | 1150 | }); |
| 1151 | 1151 | ||
| 1152 | } | 1152 | } |
| 1153 | 1153 | ||
| 1154 | /** | 1154 | /** |
| 1155 | * 系统升级 | 1155 | * 系统升级 |
| 1156 | * | 1156 | * |
| 1157 | * @param mContext | 1157 | * @param mContext |
| 1158 | * @param pid appName | 1158 | * @param pid appName |
| 1159 | */ | 1159 | */ |
| 1160 | public void updateAPP(final Context mContext, String pid, String appName, final Handler handler) { | 1160 | public void updateAPP(final Context mContext, String pid, String appName, final Handler handler) { |
| 1161 | mProgress = DialogPermission.showProgress(mContext, null, "正在检测是否版本信息...", | 1161 | mProgress = DialogPermission.showProgress(mContext, null, "正在检测是否升级版本...", |
| 1162 | false, true, null); | 1162 | false, true, null); |
| 1163 | HttpClient.getInstance().setTimeout(5 * 1000); | 1163 | HttpClient.getInstance().setTimeout(5 * 1000); |
| 1164 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); | 1164 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); |
| 1165 | HttpClient.getInstance().get(HttpUrl.updateappURL + "?pid=" + pid + "&appName=" + appName, new AsyncHttpResponseHandler() { | 1165 | HttpClient.getInstance().get(HttpUrl.updateappURL + "?pid=" + pid + "&appName=" + appName, new AsyncHttpResponseHandler() { |
| 1166 | @Override | 1166 | @Override |
| 1167 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { | 1167 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { |
| 1168 | closeProgress(); | 1168 | closeProgress(); |
| 1169 | Log.e("test", "版本升级信息" + new String(arg2)); | 1169 | Log.e("test", "版本升级信息" + new String(arg2)); |
| 1170 | AppVersion appVersion = GsonTool.getPerson(new String(arg2), AppVersion.class);//解析json数据 | 1170 | AppVersion appVersion = GsonTool.getPerson(new String(arg2), AppVersion.class);//解析json数据 |
| 1171 | Message msg = Message.obtain(); | 1171 | Message msg = Message.obtain(); |
| 1172 | msg.what = HttpCode.APPUPDATE_SUCESS; | 1172 | msg.what = HttpCode.APPUPDATE_SUCESS; |
| 1173 | msg.obj = appVersion; | 1173 | msg.obj = appVersion; |
| 1174 | handler.sendMessage(msg); | 1174 | handler.sendMessage(msg); |
| 1175 | 1175 | ||
| 1176 | 1176 | ||
| 1177 | } | 1177 | } |
| 1178 | 1178 | ||
| 1179 | @Override | 1179 | @Override |
| 1180 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { | 1180 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { |
| 1181 | closeProgress(); | 1181 | closeProgress(); |
| 1182 | Log.e("test", "错误信息" + new String(arg2)); | 1182 | Log.e("test", "错误信息" + new String(arg2)); |
| 1183 | } | 1183 | } |
| 1184 | }); | 1184 | }); |
| 1185 | 1185 | ||
| 1186 | } | 1186 | } |
| 1187 | //版本信息 | 1187 | //版本信息 |
| 1188 | public void versioninfo(final Context mContext,String subjectName, final Handler handler) { | 1188 | public void versioninfo(final Context mContext,String subjectName, final Handler handler) { |
| 1189 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); | 1189 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); |
| 1190 | HttpClient.getInstance().get(HttpUrl.getversionURL+"?subjectName="+subjectName, new AsyncHttpResponseHandler() { | 1190 | HttpClient.getInstance().get(HttpUrl.getversionURL+"?subjectName="+subjectName, new AsyncHttpResponseHandler() { |
| 1191 | @Override | 1191 | @Override |
| 1192 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { | 1192 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { |
| 1193 | Log.e("test", "版本信息" + new String(arg2)); | 1193 | Log.e("test", "版本信息" + new String(arg2)); |
| 1194 | try { | 1194 | try { |
| 1195 | JSONObject jsonObject = new JSONObject(new String(arg2)); | 1195 | JSONObject jsonObject = new JSONObject(new String(arg2)); |
| 1196 | int status = jsonObject.optInt("status"); | 1196 | int status = jsonObject.optInt("status"); |
| 1197 | if (status == 1) { | 1197 | if (status == 1) { |
| 1198 | VersionInfo versionInfo = GsonTool.getPerson(new String(arg2), VersionInfo.class);//解析json数据 | 1198 | VersionInfo versionInfo = GsonTool.getPerson(new String(arg2), VersionInfo.class);//解析json数据 |
| 1199 | List<VersionInfo.DataBean> versionInfoList = versionInfo.getData(); | 1199 | List<VersionInfo.DataBean> versionInfoList = versionInfo.getData(); |
| 1200 | Message message = Message.obtain(); | 1200 | Message message = Message.obtain(); |
| 1201 | message.what = HttpCode.VERSION_SUCESS; | 1201 | message.what = HttpCode.VERSION_SUCESS; |
| 1202 | message.obj = versionInfoList; | 1202 | message.obj = versionInfoList; |
| 1203 | handler.sendMessage(message); | 1203 | handler.sendMessage(message); |
| 1204 | 1204 | ||
| 1205 | } else if(status == 1000){ | 1205 | } else if(status == 1000){ |
| 1206 | AlertUtils.showToast(mContext, "你好,该科目没有版本信息"); | 1206 | AlertUtils.showToast(mContext, "你好,该科目没有版本信息"); |
| 1207 | 1207 | ||
| 1208 | }else { | 1208 | }else { |
| 1209 | AlertUtils.showToast(mContext, "你好,服务器异常,请稍后重试!"); | 1209 | AlertUtils.showToast(mContext, "你好,服务器异常,请稍后重试!"); |
| 1210 | } | 1210 | } |
| 1211 | } catch (JSONException e) { | 1211 | } catch (JSONException e) { |
| 1212 | e.printStackTrace(); | 1212 | e.printStackTrace(); |
| 1213 | } | 1213 | } |
| 1214 | 1214 | ||
| 1215 | 1215 | ||
| 1216 | } | 1216 | } |
| 1217 | 1217 | ||
| 1218 | @Override | 1218 | @Override |
| 1219 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { | 1219 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { |
| 1220 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); | 1220 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); |
| 1221 | } | 1221 | } |
| 1222 | }); | 1222 | }); |
| 1223 | } | 1223 | } |
| 1224 | 1224 | ||
| 1225 | 1225 | ||
| 1226 | |||
| 1227 | |||
| 1228 | |||
| 1229 | |||
| 1226 | ///省级接口 | 1230 | ///省级接口 |
| 1227 | public void provices(final Context mContext, final Handler handler) { | 1231 | public void provices(final Context mContext, final Handler handler) { |
| 1228 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); | 1232 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); |
| 1229 | HttpClient.getInstance().get(HttpUrl.provinceUrl, new AsyncHttpResponseHandler() { | 1233 | HttpClient.getInstance().get(HttpUrl.provinceUrl, new AsyncHttpResponseHandler() { |
| 1230 | @Override | 1234 | @Override |
| 1231 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { | 1235 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { |
| 1232 | Log.e("test", "省" + new String(arg2)); | 1236 | Log.e("test", "省" + new String(arg2)); |
| 1233 | try { | 1237 | try { |
| 1234 | JSONObject jsonObject = new JSONObject(new String(arg2)); | 1238 | JSONObject jsonObject = new JSONObject(new String(arg2)); |
| 1235 | int status = jsonObject.optInt("status"); | 1239 | int status = jsonObject.optInt("status"); |
| 1236 | if (status == 100) { | 1240 | if (status == 100) { |
| 1237 | ProvinceInfo provinceInfo = GsonTool.getPerson(new String(arg2), ProvinceInfo.class);//解析json数据 | 1241 | ProvinceInfo provinceInfo = GsonTool.getPerson(new String(arg2), ProvinceInfo.class);//解析json数据 |
| 1238 | Log.e("test", "状态码" + provinceInfo.getStatus()); | 1242 | Log.e("test", "状态码" + provinceInfo.getStatus()); |
| 1239 | List<ProvinceInfo.ProvincesBean> provincesBeanList = provinceInfo.getProvinces(); | 1243 | List<ProvinceInfo.ProvincesBean> provincesBeanList = provinceInfo.getProvinces(); |
| 1240 | Message message = Message.obtain(); | 1244 | Message message = Message.obtain(); |
| 1241 | message.what = HttpCode.PROVICES; | 1245 | message.what = HttpCode.PROVICES; |
| 1242 | message.obj = provincesBeanList; | 1246 | message.obj = provincesBeanList; |
| 1243 | handler.sendMessage(message); | 1247 | handler.sendMessage(message); |
| 1244 | 1248 | ||
| 1245 | 1249 | ||
| 1246 | } else { | 1250 | } else { |
| 1247 | AlertUtils.showToast(mContext, "你好,服务器异常,请稍后重试!"); | 1251 | AlertUtils.showToast(mContext, "你好,服务器异常,请稍后重试!"); |
| 1248 | 1252 | ||
| 1249 | } | 1253 | } |
| 1250 | } catch (JSONException e) { | 1254 | } catch (JSONException e) { |
| 1251 | e.printStackTrace(); | 1255 | e.printStackTrace(); |
| 1252 | } | 1256 | } |
| 1253 | 1257 | ||
| 1254 | 1258 | ||
| 1255 | } | 1259 | } |
| 1256 | 1260 | ||
| 1257 | @Override | 1261 | @Override |
| 1258 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { | 1262 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { |
| 1259 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); | 1263 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); |
| 1260 | } | 1264 | } |
| 1261 | }); | 1265 | }); |
| 1262 | } | 1266 | } |
| 1267 | //获取版本信息接口 | ||
| 1268 | public void getpublishinfo(final Context mContext, long userId,int gradeId, final Handler handler) { | ||
| 1269 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); | ||
| 1270 | HttpClient.getInstance().get(HttpUrl.getpublishURL + "?userId=" + userId+ "&gradeId=" + gradeId, new AsyncHttpResponseHandler() { | ||
| 1271 | @Override | ||
| 1272 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { | ||
| 1273 | Log.e("test", "获取版本信息接口" + new String(arg2)); | ||
| 1274 | try { | ||
| 1275 | JSONObject jsonObject = new JSONObject(new String(arg2)); | ||
| 1276 | int status = jsonObject.optInt("status"); | ||
| 1277 | if (status == 1) { | ||
| 1278 | Gson gson = new Gson(); | ||
| 1279 | DefautPublishInfo defautPublishInfo = gson.fromJson(new String(arg2), DefautPublishInfo.class); | ||
| 1280 | List<DefautPublishInfo.DataBean> defautPublishInfoBeanList = defautPublishInfo.getData(); | ||
| 1281 | Message message = Message.obtain(); | ||
| 1282 | message.what = HttpCode.PUBLISH_SUCESS; | ||
| 1283 | message.obj = defautPublishInfoBeanList; | ||
| 1284 | handler.sendMessage(message); | ||
| 1285 | |||
| 1286 | } else { | ||
| 1287 | AlertUtils.showToast(mContext, "你好,服务器异常,请稍后重试!"); | ||
| 1288 | |||
| 1289 | } | ||
| 1290 | } catch (JSONException e) { | ||
| 1291 | e.printStackTrace(); | ||
| 1292 | } | ||
| 1293 | |||
| 1294 | |||
| 1295 | } | ||
| 1296 | |||
| 1297 | @Override | ||
| 1298 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { | ||
| 1299 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); | ||
| 1300 | } | ||
| 1301 | }); | ||
| 1302 | } | ||
| 1303 | |||
| 1263 | 1304 | ||
| 1264 | //市级接口 | 1305 | //市级接口 |
| 1265 | public void cityinfo(final Context mContext, long regionId, final Handler handler) { | 1306 | public void cityinfo(final Context mContext, long regionId, final Handler handler) { |
| 1266 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); | 1307 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); |
| 1267 | HttpClient.getInstance().get(HttpUrl.cityUrl + "?regionId=" + regionId, new AsyncHttpResponseHandler() { | 1308 | HttpClient.getInstance().get(HttpUrl.cityUrl + "?regionId=" + regionId, new AsyncHttpResponseHandler() { |
| 1268 | @Override | 1309 | @Override |
| 1269 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { | 1310 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { |
| 1270 | Log.e("test", "市" + new String(arg2)); | 1311 | Log.e("test", "市" + new String(arg2)); |
| 1271 | try { | 1312 | try { |
| 1272 | JSONObject jsonObject = new JSONObject(new String(arg2)); | 1313 | JSONObject jsonObject = new JSONObject(new String(arg2)); |
| 1273 | int status = jsonObject.optInt("status"); | 1314 | int status = jsonObject.optInt("status"); |
| 1274 | if (status == 100) { | 1315 | if (status == 100) { |
| 1275 | Gson gson = new Gson(); | 1316 | Gson gson = new Gson(); |
| 1276 | CityInfo cityInfo = gson.fromJson(new String(arg2), CityInfo.class); | 1317 | CityInfo cityInfo = gson.fromJson(new String(arg2), CityInfo.class); |
| 1277 | List<CityInfo.CitiesBean> cityInfoBeanList = cityInfo.getCities(); | 1318 | List<CityInfo.CitiesBean> cityInfoBeanList = cityInfo.getCities(); |
| 1278 | Message message = Message.obtain(); | 1319 | Message message = Message.obtain(); |
| 1279 | message.what = HttpCode.CITYS; | 1320 | message.what = HttpCode.CITYS; |
| 1280 | message.obj = cityInfoBeanList; | 1321 | message.obj = cityInfoBeanList; |
| 1281 | handler.sendMessage(message); | 1322 | handler.sendMessage(message); |
| 1282 | 1323 | ||
| 1283 | } else { | 1324 | } else { |
| 1284 | AlertUtils.showToast(mContext, "你好,服务器异常,请稍后重试!"); | 1325 | AlertUtils.showToast(mContext, "你好,服务器异常,请稍后重试!"); |
| 1285 | 1326 | ||
| 1286 | } | 1327 | } |
| 1287 | } catch (JSONException e) { | 1328 | } catch (JSONException e) { |
| 1288 | e.printStackTrace(); | 1329 | e.printStackTrace(); |
| 1289 | } | 1330 | } |
| 1290 | 1331 | ||
| 1291 | 1332 | ||
| 1292 | } | 1333 | } |
| 1293 | 1334 | ||
| 1294 | @Override | 1335 | @Override |
| 1295 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { | 1336 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { |
| 1296 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); | 1337 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); |
| 1297 | } | 1338 | } |
| 1298 | }); | 1339 | }); |
| 1299 | } | 1340 | } |
| 1300 | 1341 | ||
| 1301 | //区县级接口 | 1342 | //区县级接口 |
| 1302 | public void countyinfo(final Context mContext, int parentId, final Handler handler) { | 1343 | public void countyinfo(final Context mContext, int parentId, final Handler handler) { |
| 1303 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); | 1344 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); |
| 1304 | HttpClient.getInstance().get(HttpUrl.countyUrl + "?regionId=" + parentId, new AsyncHttpResponseHandler() { | 1345 | HttpClient.getInstance().get(HttpUrl.countyUrl + "?regionId=" + parentId, new AsyncHttpResponseHandler() { |
| 1305 | @Override | 1346 | @Override |
| 1306 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { | 1347 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { |
| 1307 | Log.e("test", "区" + new String(arg2)); | 1348 | Log.e("test", "区" + new String(arg2)); |
| 1308 | try { | 1349 | try { |
| 1309 | JSONObject jsonObject = new JSONObject(new String(arg2)); | 1350 | JSONObject jsonObject = new JSONObject(new String(arg2)); |
| 1310 | int status = jsonObject.optInt("status"); | 1351 | int status = jsonObject.optInt("status"); |
| 1311 | if (status == 100) { | 1352 | if (status == 100) { |
| 1312 | Gson gson = new Gson(); | 1353 | Gson gson = new Gson(); |
| 1313 | CountyInfo countyInfo = gson.fromJson(new String(arg2), CountyInfo.class); | 1354 | CountyInfo countyInfo = gson.fromJson(new String(arg2), CountyInfo.class); |
| 1314 | List<CountyInfo.CountiesBean> countyInfoInfoBeanList = countyInfo.getCounties(); | 1355 | List<CountyInfo.CountiesBean> countyInfoInfoBeanList = countyInfo.getCounties(); |
| 1315 | Message message = Message.obtain(); | 1356 | Message message = Message.obtain(); |
| 1316 | message.what = HttpCode.COUNTRY; | 1357 | message.what = HttpCode.COUNTRY; |
| 1317 | message.obj = countyInfoInfoBeanList; | 1358 | message.obj = countyInfoInfoBeanList; |
| 1318 | handler.sendMessage(message); | 1359 | handler.sendMessage(message); |
| 1319 | } else { | 1360 | } else { |
| 1320 | AlertUtils.showToast(mContext, "你好,服务器异常,请稍后重试!"); | 1361 | AlertUtils.showToast(mContext, "你好,服务器异常,请稍后重试!"); |
| 1321 | 1362 | ||
| 1322 | } | 1363 | } |
| 1323 | } catch (JSONException e) { | 1364 | } catch (JSONException e) { |
| 1324 | e.printStackTrace(); | 1365 | e.printStackTrace(); |
| 1325 | } | 1366 | } |
| 1326 | 1367 | ||
| 1327 | 1368 | ||
| 1328 | } | 1369 | } |
| 1329 | 1370 | ||
| 1330 | @Override | 1371 | @Override |
| 1331 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { | 1372 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { |
| 1332 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); | 1373 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); |
| 1333 | } | 1374 | } |
| 1334 | }); | 1375 | }); |
| 1335 | } | 1376 | } |
| 1336 | 1377 | ||
| 1337 | 1378 | ||
| 1338 | private void closeProgress() { | 1379 | private void closeProgress() { |
| 1339 | try { | 1380 | try { |
| 1340 | if (mProgress != null) { | 1381 | if (mProgress != null) { |
| 1341 | mProgress.dismiss(); | 1382 | mProgress.dismiss(); |
| 1342 | mProgress = null; | 1383 | mProgress = null; |
| 1343 | } | 1384 | } |
| 1344 | } catch (Exception e) { | 1385 | } catch (Exception e) { |
| 1345 | e.printStackTrace(); | 1386 | e.printStackTrace(); |
| 1346 | } | 1387 | } |
| 1347 | } | 1388 | } |
| 1348 | 1389 | ||
| 1349 | } | 1390 | } |
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";//默认头像上传 | 40 | public static String headerdefaultURL=GetDomain()+"/profile/picture/default";//默认头像上传 |
| 41 | public static String getversionURL=GetDomain()+"/press/list";//获取版本信息 | 41 | public static String getversionURL=GetDomain()+"/press/list";//获取版本信息 |
| 42 | public static String isRegisterInfoCompleteURL=GetDomain()+"/register/extrainfo/check";//注册信息是否完整 | 42 | public static String isRegisterInfoCompleteURL=GetDomain()+"/register/extrainfo/check";//注册信息是否完整 |
| 43 | public static String getpublishURL=GetDomain()+"/userPress/info";//获取版本信息 | ||
| 43 | 44 | ||
| 44 | 45 | ||
| 45 | 46 | ||
| 46 | 47 | ||
| 47 | 48 | ||
| 48 | 49 | ||
| 49 | } | 50 | } |
| 50 | 51 |
PersonalCenter/app/src/main/java/com/hjx/personalcenter/model/DefautPublishInfo.java
| 1 | package com.hjx.personalcenter.model; | 1 | package com.hjx.personalcenter.model; |
| 2 | 2 | ||
| 3 | import java.io.Serializable; | 3 | import java.io.Serializable; |
| 4 | import java.util.List; | ||
| 4 | 5 | ||
| 5 | /** | 6 | /** |
| 6 | * Created by h on 2017/9/12. | 7 | * Created by h on 2017/9/12. |
| 7 | */ | 8 | */ |
| 8 | 9 | ||
| 9 | public class DefautPublishInfo implements Serializable{ | 10 | public class DefautPublishInfo implements Serializable{ |
| 10 | private String imagurl; | ||
| 11 | 11 | ||
| 12 | public String getImagurl() { | 12 | /** |
| 13 | return imagurl; | 13 | * status : 1 |
| 14 | * pageSize : 0 | ||
| 15 | * data : [{"cover":"","press":"北京出版社_北京教育出版社","subject":"语文"},{"cover":"","press":"北京出版社_北京教育出版社","subject":"数学"},{"cover":"","press":"北京出版社_北京教育出版社","subject":"英语"},{"cover":"","press":"人民教育出版社","subject":"物理"},{"cover":"","press":"人民教育出版社","subject":"化学"},{"cover":"","press":"人民教育出版社","subject":"历史"},{"cover":"","press":"人民教育出版社","subject":"地理"},{"cover":"","press":"人民教育出版社","subject":"政治"},{"cover":"","press":"人民教育出版社","subject":"生物"},{"cover":"","press":"人民教育出版社","subject":"科学"}] | ||
| 16 | * msg : success | ||
| 17 | * pageNum : 0 | ||
| 18 | */ | ||
| 19 | |||
| 20 | private int status; | ||
| 21 | private int pageSize; | ||
| 22 | private String msg; | ||
| 23 | private int pageNum; | ||
| 24 | private List<DataBean> data; | ||
| 25 | |||
| 26 | public void setStatus(int status) { | ||
| 27 | this.status = status; | ||
| 28 | } | ||
| 29 | |||
| 30 | public void setPageSize(int pageSize) { | ||
| 31 | this.pageSize = pageSize; | ||
| 32 | } | ||
| 33 | |||
| 34 | public void setMsg(String msg) { | ||
| 35 | this.msg = msg; | ||
| 36 | } | ||
| 37 | |||
| 38 | public void setPageNum(int pageNum) { | ||
| 39 | this.pageNum = pageNum; | ||
| 40 | } | ||
| 41 | |||
| 42 | public void setData(List<DataBean> data) { | ||
| 43 | this.data = data; | ||
| 14 | } | 44 | } |
| 15 | 45 | ||
| 16 | public void setImagurl(String imagurl) { | 46 | public int getStatus() { |
| 17 | this.imagurl = imagurl; | 47 | return status; |
| 18 | } | 48 | } |
| 19 | 49 | ||
| 20 | public String getSubjuct() { | 50 | public int getPageSize() { |
| 21 | return subjuct; | 51 | return pageSize; |
| 22 | } | 52 | } |
| 23 | 53 | ||
| 24 | public void setSubjuct(String subjuct) { | 54 | public String getMsg() { |
| 25 | this.subjuct = subjuct; | 55 | return msg; |
| 26 | } | 56 | } |
| 27 | 57 | ||
| 28 | public String getPublish() { | 58 | public int getPageNum() { |
| 29 | return publish; | 59 | return pageNum; |
| 30 | } | 60 | } |
| 31 | 61 | ||
| 32 | public void setPublish(String publish) { | 62 | public List<DataBean> getData() { |
| 33 | this.publish = publish; | 63 | return data; |
| 34 | } | 64 | } |
| 35 | 65 | ||
| 36 | private String subjuct; | 66 | public static class DataBean { |
| 37 | private String publish; | 67 | /** |
| 68 | * cover : | ||
| 69 | * press : 北京出版社_北京教育出版社 | ||
| 70 | * subject : 语文 | ||
| 71 | */ | ||
| 72 | |||
| 73 | private String cover; | ||
| 74 | private String press; | ||
| 75 | private String subject; | ||
| 76 | |||
| 77 | public void setCover(String cover) { | ||
| 78 | this.cover = cover; | ||
| 79 | } | ||
| 80 | |||
| 81 | public void setPress(String press) { | ||
| 82 | this.press = press; | ||
| 83 | } | ||
| 84 | |||
| 85 | public void setSubject(String subject) { | ||
| 86 | this.subject = subject; | ||
| 87 | } | ||
| 88 | |||
| 89 | public String getCover() { | ||
| 90 | return cover; | ||
| 91 | } | ||
| 92 | |||
| 93 | public String getPress() { | ||
| 94 | return press; | ||
| 95 | } | ||
| 96 | |||
| 97 | public String getSubject() { | ||
| 98 | return subject; | ||
| 99 | } | ||
| 100 | } | ||
| 38 | } | 101 | } |
PersonalCenter/app/src/main/java/com/hjx/personalcenter/service/CenterService.java
| 1 | package com.hjx.personalcenter.service; | 1 | package com.hjx.personalcenter.service; |
| 2 | 2 | ||
| 3 | import android.content.Intent; | 3 | import android.content.Intent; |
| 4 | import android.os.IBinder; | 4 | import android.os.IBinder; |
| 5 | import android.os.RemoteException; | 5 | import android.os.RemoteException; |
| 6 | import android.util.Log; | 6 | import android.util.Log; |
| 7 | 7 | ||
| 8 | import com.google.gson.Gson; | 8 | import com.google.gson.Gson; |
| 9 | import com.hjx.personalcenter.activity.LoginAndRegisterActivity; | 9 | import com.hjx.personalcenter.activity.LoginAndRegisterActivity; |
| 10 | import com.hjx.personalcenter.db.SaveParam; | 10 | import com.hjx.personalcenter.db.SaveParam; |
| 11 | import com.hjx.personalcenter.model.CardInfo; | 11 | import com.hjx.personalcenter.model.CardInfo; |
| 12 | import com.hjx.personalcenter.model.LoginInfo; | 12 | import com.hjx.personalcenter.model.LoginInfo; |
| 13 | import com.hjx.personalcenter.util.GetDevicesUtil; | 13 | import com.hjx.personalcenter.util.GetDevicesUtil; |
| 14 | 14 | ||
| 15 | /** | 15 | /** |
| 16 | * Created by h on 2017/9/1. | 16 | * Created by h on 2017/9/1. |
| 17 | */ | 17 | */ |
| 18 | 18 | ||
| 19 | public class CenterService extends BaseService { | 19 | public class CenterService extends BaseService { |
| 20 | enum ACTIVITY_ACTION{ | 20 | enum ACTIVITY_ACTION{ |
| 21 | userinfo_activity | 21 | userinfo_activity |
| 22 | } | 22 | } |
| 23 | public CenterService(){ | 23 | public CenterService(){ |
| 24 | 24 | ||
| 25 | } | 25 | } |
| 26 | IPresonalInterface.Stub binder = new IPresonalInterface.Stub() { | 26 | IPresonalInterface.Stub binder = new IPresonalInterface.Stub() { |
| 27 | @Override | 27 | @Override |
| 28 | public String sayHello() throws RemoteException { | 28 | public String sayHello() throws RemoteException { |
| 29 | return "这是测试AIDL的方法"; | 29 | return "这是测试AIDL的方法"; |
| 30 | } | 30 | } |
| 31 | 31 | ||
| 32 | @Override | 32 | @Override |
| 33 | public String viewPage(String action) throws RemoteException { | 33 | public String viewPage(String action) throws RemoteException { |
| 34 | String result = null; | 34 | String result = null; |
| 35 | if(action.equals(ACTIVITY_ACTION.userinfo_activity.toString())){ | 35 | if(action.equals(ACTIVITY_ACTION.userinfo_activity.toString())){ |
| 36 | //登录界面 | 36 | //登录界面 |
| 37 | Intent intent = new Intent(); | 37 | Intent intent = new Intent(); |
| 38 | intent.setClass(CenterService.this, LoginAndRegisterActivity.class); | 38 | intent.setClass(CenterService.this, LoginAndRegisterActivity.class); |
| 39 | intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); | 39 | intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); |
| 40 | startActivity(intent); | 40 | startActivity(intent); |
| 41 | result= "跳转成功"; | 41 | result= "跳转成功"; |
| 42 | } | 42 | } |
| 43 | 43 | ||
| 44 | return result; | 44 | return result; |
| 45 | } | 45 | } |
| 46 | 46 | ||
| 47 | @Override | 47 | @Override |
| 48 | public String getSimpleUser() throws RemoteException { | 48 | public String getSimpleUser() throws RemoteException { |
| 49 | String logininfo = null; | 49 | String logininfo = null; |
| 50 | Gson gson = new Gson(); | 50 | Gson gson = new Gson(); |
| 51 | LoginInfo loginInfo = new LoginInfo(); | 51 | LoginInfo loginInfo = new LoginInfo(); |
| 52 | String islogin = SaveParam.getInstance().getLoginParam(getApplication(),"login"); | 52 | String islogin = SaveParam.getInstance().getLoginParam(getApplication(),"login"); |
| 53 | if ("true".equals(islogin)){ | 53 | if ("true".equals(islogin)){ |
| 54 | loginInfo.setUsername(SaveParam.getInstance().getLoginParam(getApplication(), "username")); | 54 | loginInfo.setUsername(SaveParam.getInstance().getLoginParam(getApplication(), "username")); |
| 55 | loginInfo.setPassword(SaveParam.getInstance().getLoginParam(getApplication(), "password")); | 55 | loginInfo.setPassword(SaveParam.getInstance().getLoginParam(getApplication(), "password")); |
| 56 | loginInfo.setAccess_token(SaveParam.getInstance().getLoginParam(getApplication(), "access_token")); | 56 | loginInfo.setAccess_token(SaveParam.getInstance().getLoginParam(getApplication(), "access_token")); |
| 57 | loginInfo.setLoginStatus(SaveParam.getInstance().getLoginParam(getApplication(), "login")); | 57 | loginInfo.setLoginStatus(SaveParam.getInstance().getLoginParam(getApplication(), "login")); |
| 58 | loginInfo.setUserId(SaveParam.getInstance().getLoginParam(getApplication(), "userId")); | 58 | loginInfo.setUserId(SaveParam.getInstance().getLoginParam(getApplication(), "userId")); |
| 59 | 59 | ||
| 60 | logininfo =gson.toJson(loginInfo); | 60 | logininfo =gson.toJson(loginInfo); |
| 61 | 61 | ||
| 62 | Log.e("test","登录信息"+logininfo); | 62 | Log.e("test","登录信息"+logininfo); |
| 63 | 63 | ||
| 64 | } | 64 | } |
| 65 | 65 | ||
| 66 | return logininfo; | 66 | return logininfo; |
| 67 | } | 67 | } |
| 68 | //保卡信息 | 68 | //保卡信息 |
| 69 | @Override | 69 | @Override |
| 70 | public String getcardUser() throws RemoteException { | 70 | public String getcardUser() throws RemoteException { |
| 71 | String results = null; | 71 | String results = null; |
| 72 | CardInfo cardInfo = new CardInfo(); | 72 | // CardInfo cardInfo = new CardInfo(); |
| 73 | CardInfo.DataBean dataBean = new CardInfo.DataBean(); | 73 | CardInfo.DataBean dataBean = new CardInfo.DataBean(); |
| 74 | Gson gson = new Gson(); | 74 | Gson gson = new Gson(); |
| 75 | 75 | ||
| 76 | //获取设备信息 | 76 | //获取设备信息 |
| 77 | dataBean.setProductModel(GetDevicesUtil.getDevicesInfo(getApplication()).getDeviceModel()); | 77 | dataBean.setProductModel(GetDevicesUtil.getDevicesInfo(getApplication()).getDeviceModel()); |
| 78 | dataBean.setDeviceNumber(GetDevicesUtil.getDevicesInfo(getApplication()).getDeviceNumber()); | 78 | dataBean.setDeviceNumber(GetDevicesUtil.getDevicesInfo(getApplication()).getDeviceNumber()); |
| 79 | dataBean.setMacAddress(GetDevicesUtil.getDevicesInfo(getApplication()).getMac()); | 79 | dataBean.setMacAddress(GetDevicesUtil.getDevicesInfo(getApplication()).getMac()); |
| 80 | //获取保卡信息 | 80 | //获取保卡信息 |
| 81 | dataBean.setCustomerName(SaveParam.getInstance().getCustomizeParam(getApplication(),SaveParam.CUNSTEMNAME)); | 81 | dataBean.setCustomerName(SaveParam.getInstance().getCustomizeParam(getApplication(),SaveParam.CUNSTEMNAME)); |
| 82 | dataBean.setCustomerAddress(SaveParam.getInstance().getCustomizeParam(getApplication(),SaveParam.ADRESSCUNSTEM)); | 82 | dataBean.setCustomerAddress(SaveParam.getInstance().getCustomizeParam(getApplication(),SaveParam.ADRESSCUNSTEM)); |
| 83 | dataBean.setBuyTime(SaveParam.getInstance().getCustomizeParam(getApplication(),SaveParam.SHOPTIME)); | 83 | dataBean.setBuyTime(SaveParam.getInstance().getCustomizeParam(getApplication(),SaveParam.SHOPTIME)); |
| 84 | dataBean.setBuyAddress(SaveParam.getInstance().getCustomizeParam(getApplication(),SaveParam.SHOPADRESS)); | 84 | dataBean.setBuyAddress(SaveParam.getInstance().getCustomizeParam(getApplication(),SaveParam.SHOPADRESS)); |
| 85 | dataBean.setAlterSaleCall(SaveParam.getInstance().getCustomizeParam(getApplication(),SaveParam.SHOPTLEPHONE)); | 85 | dataBean.setAlterSaleCall(SaveParam.getInstance().getCustomizeParam(getApplication(),SaveParam.SHOPTLEPHONE)); |
| 86 | dataBean.setMobilePhone(SaveParam.getInstance().getCustomizeParam(getApplication(),SaveParam.CARDPHONE)); | 86 | dataBean.setMobilePhone(SaveParam.getInstance().getCustomizeParam(getApplication(),SaveParam.CARDPHONE)); |
| 87 | cardInfo.setData(dataBean); | 87 | // cardInfo.setData(dataBean); |
| 88 | results =gson.toJson(cardInfo); | 88 | results =gson.toJson(dataBean); |
| 89 | 89 | Log.e("test","保卡信息"+results); | |
| 90 | return results; | 90 | return results; |
| 91 | |||
| 91 | } | 92 | } |
| 92 | 93 | ||
| 93 | @Override | 94 | @Override |
| 94 | public String getUserInfo() throws RemoteException { | 95 | public String getUserInfo() throws RemoteException { |
| 95 | return null; | 96 | return null; |
| 96 | } | 97 | } |
| 97 | 98 | ||
| 98 | @Override | 99 | @Override |
| 99 | public String logout() throws RemoteException { | 100 | public String logout() throws RemoteException { |
| 100 | return null; | 101 | return null; |
| 101 | } | 102 | } |
| 102 | 103 | ||
| 103 | @Override | 104 | @Override |
| 104 | public String validateToken() throws RemoteException { | 105 | public String validateToken() throws RemoteException { |
| 105 | return null; | 106 | return null; |
| 106 | } | 107 | } |
| 107 | 108 | ||
| 108 | @Override | 109 | @Override |
| 109 | public String getDeviceID() throws RemoteException { | 110 | public String getDeviceID() throws RemoteException { |
| 110 | return null; | 111 | return null; |
| 111 | } | 112 | } |
| 112 | 113 | ||
| 113 | @Override | 114 | @Override |
| 114 | public String getChildsInfo() throws RemoteException { | 115 | public String getChildsInfo() throws RemoteException { |
| 115 | return null; | 116 | return null; |
| 116 | } | 117 | } |
| 117 | }; | 118 | }; |
| 118 | 119 | ||
| 119 | @Override | 120 | @Override |
| 120 | public IBinder onBind(Intent intent) { | 121 | public IBinder onBind(Intent intent) { |
| 121 | return binder; | 122 | return binder; |
| 122 | } | 123 | } |
| 123 | } | 124 | } |
| 124 | 125 |
PersonalCenter/app/src/main/res/layout/custom_adilog_publishlist.xml
| File was created | 1 | <?xml version="1.0" encoding="utf-8"?> | |
| 2 | <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
| 3 | android:layout_width="match_parent" | ||
| 4 | android:layout_height="match_parent" | ||
| 5 | android:orientation="vertical"> | ||
| 6 | |||
| 7 | <RelativeLayout | ||
| 8 | android:id="@+id/title" | ||
| 9 | android:layout_width="match_parent" | ||
| 10 | android:layout_height="wrap_content" | ||
| 11 | android:minHeight="70dp" > | ||
| 12 | |||
| 13 | <ImageView | ||
| 14 | android:id="@+id/cancel" | ||
| 15 | android:layout_width="wrap_content" | ||
| 16 | android:layout_height="wrap_content" | ||
| 17 | android:layout_centerVertical="true" | ||
| 18 | android:layout_alignParentRight="true" | ||
| 19 | android:padding="20dp" | ||
| 20 | android:src="@mipmap/cancel_fork" /> | ||
| 21 | |||
| 22 | <TextView | ||
| 23 | android:id="@+id/menu_title" | ||
| 24 | android:layout_width="wrap_content" | ||
| 25 | android:layout_height="wrap_content" | ||
| 26 | android:layout_centerInParent="true" | ||
| 27 | android:padding="20dp" | ||
| 28 | android:text="请选择出版社" | ||
| 29 | android:textColor="@android:color/black" | ||
| 30 | android:textSize="22sp" /> | ||
| 31 | </RelativeLayout> | ||
| 32 | <ListView | ||
| 33 | android:id="@+id/listadapter" | ||
| 34 | android:layout_width="match_parent" | ||
| 35 | android:layout_height="400dp"> | ||
| 36 | |||
| 37 | </ListView> | ||
| 38 | </LinearLayout> | ||
| 39 |