Commit 78458fa9f2ddd16d9e43aaddaf2d927e5ab7f9fc
1 parent
0ff2ad496e
Exists in
master
数据模型的使用
Showing
11 changed files
with
304 additions
and
100 deletions
Show diff stats
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.AdapterView; | 9 | import android.widget.AdapterView; |
10 | import android.widget.Button; | 10 | import android.widget.Button; |
11 | import android.widget.EditText; | 11 | import android.widget.EditText; |
12 | import android.widget.TextView; | 12 | import android.widget.TextView; |
13 | 13 | ||
14 | import com.hjx.personalcenter.R; | 14 | import com.hjx.personalcenter.R; |
15 | import com.hjx.personalcenter.customdialog.CitysListDialog; | ||
16 | import com.hjx.personalcenter.customdialog.CountryDialog; | ||
15 | import com.hjx.personalcenter.customdialog.GradeListDialog; | 17 | import com.hjx.personalcenter.customdialog.GradeListDialog; |
16 | import com.hjx.personalcenter.customdialog.ProvinceListDialog; | 18 | import com.hjx.personalcenter.customdialog.ProvinceListDialog; |
17 | import com.hjx.personalcenter.customdialog.SchoolListDialog; | 19 | import com.hjx.personalcenter.customdialog.SchoolListDialog; |
20 | import com.hjx.personalcenter.db.SaveParam; | ||
18 | import com.hjx.personalcenter.http.HttpManager; | 21 | import com.hjx.personalcenter.http.HttpManager; |
19 | import com.hjx.personalcenter.interfaces.DialogCallBack; | 22 | import com.hjx.personalcenter.interfaces.DialogCallBack; |
20 | import com.hjx.personalcenter.util.AlertUtils; | 23 | import com.hjx.personalcenter.util.AlertUtils; |
21 | 24 | ||
22 | /**填写注册信息 熊巍 | 25 | /**填写注册信息 熊巍 |
23 | * Created by h on 2017/8/9. | 26 | * Created by h on 2017/8/9. |
24 | */ | 27 | */ |
25 | 28 | ||
26 | public class RegisterInfoActivity extends AppCompatActivity implements View.OnClickListener,DialogCallBack.CallBack { | 29 | public class RegisterInfoActivity extends AppCompatActivity implements View.OnClickListener,DialogCallBack.CallBack { |
27 | private EditText et_username; | 30 | private EditText et_username; |
28 | private TextView et_region,et_grade,et_school; | 31 | private TextView et_region,et_grade,et_school; |
29 | private Button btn_ok; | 32 | private Button btn_ok; |
30 | 33 | ||
31 | @Override | 34 | @Override |
32 | protected void onCreate(Bundle savedInstanceState) { | 35 | protected void onCreate(Bundle savedInstanceState) { |
33 | super.onCreate(savedInstanceState); | 36 | super.onCreate(savedInstanceState); |
34 | setContentView(R.layout.activity_registerinfo); | 37 | setContentView(R.layout.activity_registerinfo); |
35 | initView(); | 38 | initView(); |
36 | initData(); | 39 | initData(); |
37 | initLister(); | 40 | initLister(); |
38 | } | 41 | } |
39 | 42 | ||
40 | private void initView() { | 43 | private void initView() { |
41 | et_username = (EditText) findViewById(R.id.et_username); | 44 | et_username = (EditText) findViewById(R.id.et_username); |
42 | et_region = (TextView) findViewById(R.id.et_region); | 45 | et_region = (TextView) findViewById(R.id.et_region); |
43 | et_grade = (TextView) findViewById(R.id.et_grade); | 46 | et_grade = (TextView) findViewById(R.id.et_grade); |
44 | et_school = (TextView) findViewById(R.id.et_school); | 47 | et_school = (TextView) findViewById(R.id.et_school); |
45 | btn_ok = (Button) findViewById(R.id.btn_ok); | 48 | btn_ok = (Button) findViewById(R.id.btn_ok); |
46 | 49 | ||
47 | 50 | ||
48 | } | 51 | } |
49 | 52 | ||
50 | private void initData() { | 53 | private void initData() { |
51 | 54 | ||
52 | } | 55 | } |
53 | 56 | ||
54 | private void initLister() { | 57 | private void initLister() { |
55 | et_region.setOnClickListener(this); | 58 | et_region.setOnClickListener(this); |
56 | et_grade.setOnClickListener(this); | 59 | et_grade.setOnClickListener(this); |
57 | et_school.setOnClickListener(this); | 60 | et_school.setOnClickListener(this); |
58 | btn_ok.setOnClickListener(this); | 61 | btn_ok.setOnClickListener(this); |
59 | 62 | ||
60 | 63 | ||
61 | } | 64 | } |
62 | 65 | ||
63 | @Override | 66 | @Override |
64 | public void onClick(View v) { | 67 | public void onClick(View v) { |
65 | String register1 = et_username.getText().toString().trim(); | 68 | String register1 = et_username.getText().toString().trim(); |
66 | String register2 = et_region.getText().toString().trim(); | 69 | String register2 = et_region.getText().toString().trim(); |
67 | String register3 = et_grade.getText().toString().trim(); | 70 | String register3 = et_grade.getText().toString().trim(); |
68 | String register4 = et_school.getText().toString().trim(); | 71 | String register4 = et_school.getText().toString().trim(); |
69 | switch (v.getId()){ | 72 | switch (v.getId()){ |
70 | case R.id.et_region: | 73 | case R.id.et_region: |
71 | choiseregion(); | 74 | choiseregion(); |
72 | break; | 75 | break; |
73 | case R.id.et_grade: | 76 | case R.id.et_grade: |
74 | choisegrade(); | 77 | choisegrade(); |
75 | break; | 78 | break; |
76 | case R.id.et_school: | 79 | case R.id.et_school: |
77 | if (TextUtils.isEmpty(register2) || TextUtils.isEmpty(register3)){ | 80 | // if (TextUtils.isEmpty(register2) || TextUtils.isEmpty(register3)){ |
78 | AlertUtils.showToast(RegisterInfoActivity.this, "请选择年级和地址"); | 81 | // AlertUtils.showToast(RegisterInfoActivity.this, "请选择年级和地址"); |
79 | return; | 82 | // return; |
80 | }else { | 83 | // }else { |
81 | choiseschool(); | 84 | choiseschool(); |
82 | } | 85 | // } |
83 | 86 | ||
84 | break; | 87 | break; |
85 | case R.id.btn_ok: | 88 | case R.id.btn_ok: |
86 | if (TextUtils.isEmpty(register1)||TextUtils.isEmpty(register4) || | 89 | if (TextUtils.isEmpty(register1)||TextUtils.isEmpty(register4) || |
87 | TextUtils.isEmpty(register2) || TextUtils.isEmpty(register3)){ | 90 | TextUtils.isEmpty(register2) || TextUtils.isEmpty(register3)){ |
88 | AlertUtils.showToast(RegisterInfoActivity.this, "请将必填项填写完整"); | 91 | AlertUtils.showToast(RegisterInfoActivity.this, "请将必填项填写完整"); |
89 | return; | 92 | return; |
90 | }else{ | 93 | }else{ |
91 | Intent intent = new Intent(); | 94 | Intent intent = new Intent(); |
92 | intent.setClass(RegisterInfoActivity.this,ChoiseTextBookActivity.class); | 95 | intent.setClass(RegisterInfoActivity.this,ChoiseTextBookActivity.class); |
93 | startActivity(intent); | 96 | startActivity(intent); |
94 | overridePendingTransition(R.anim.rightin, R.anim.rightout); | 97 | overridePendingTransition(R.anim.rightin, R.anim.rightout); |
95 | } | 98 | } |
96 | 99 | ||
97 | break; | 100 | break; |
98 | } | 101 | } |
99 | 102 | ||
100 | } | 103 | } |
101 | 104 | ||
102 | //选择地区 | 105 | //选择地区 |
103 | private void choiseregion() { | 106 | private void choiseregion() { |
104 | HttpManager.getInstance().provices(RegisterInfoActivity.this); | 107 | |
105 | ProvinceListDialog.getInstance(this).show(getSupportFragmentManager(), "ProvinceListDialog"); | 108 | ProvinceListDialog.getInstance(this).show(getSupportFragmentManager(), "ProvinceListDialog"); |
106 | // HttpManager.getInstance().cityinfo(RegisterInfoActivity.this,111); | ||
107 | // CitysListDialog.getInstance(this).show(getSupportFragmentManager(), "CitysListDialog"); | ||
108 | 109 | ||
109 | } | 110 | } |
110 | //选择年级 | 111 | //选择年级 |
111 | private void choisegrade() { | 112 | private void choisegrade() { |
112 | HttpManager.getInstance().getgrade(RegisterInfoActivity.this); | 113 | HttpManager.getInstance().getgrade(RegisterInfoActivity.this); |
113 | GradeListDialog.getInstance().show(getSupportFragmentManager(), "GradeListDialog"); | 114 | GradeListDialog.getInstance().show(getSupportFragmentManager(), "GradeListDialog"); |
114 | 115 | ||
115 | } | 116 | } |
116 | //选择学校 | 117 | //选择学校 |
117 | private void choiseschool() { | 118 | private void choiseschool() { |
118 | HttpManager.getInstance().getschool(RegisterInfoActivity.this,130102,14); | ||
119 | SchoolListDialog.getInstance().show(getSupportFragmentManager(), "SchoolListDialog"); | 119 | SchoolListDialog.getInstance().show(getSupportFragmentManager(), "SchoolListDialog"); |
120 | 120 | ||
121 | } | 121 | } |
122 | 122 | ||
123 | 123 | ||
124 | @Override | 124 | @Override |
125 | public void provinceOnItemClick(AdapterView<?> parent, View view, int position, long id) { | 125 | public void provinceOnItemClick(AdapterView<?> parent, View view, int position, long id,int type) { |
126 | |||
127 | if (type==1){ | ||
128 | View gradeView = parent.getChildAt(position); | ||
129 | TextView gradeTv = (TextView)gradeView.findViewById(R.id.list_items); | ||
130 | SaveParam.getInstance().saveLoginParam(this,"sheng",gradeTv.getText().toString()); | ||
131 | CitysListDialog.getInstance(this).show(getSupportFragmentManager(), "CitysListDialog"); | ||
132 | } | ||
133 | |||
134 | if (type==2){ | ||
135 | View gradeView = parent.getChildAt(position); | ||
136 | TextView gradeTv = (TextView)gradeView.findViewById(R.id.list_items); | ||
137 | SaveParam.getInstance().saveLoginParam(this,"shi",gradeTv.getText().toString()); | ||
138 | CountryDialog.getInstance(this).show(getSupportFragmentManager(), "CountryDialog"); | ||
139 | } | ||
140 | |||
141 | if (type==3){ | ||
142 | View gradeView = parent.getChildAt(position); | ||
143 | TextView gradeTv = (TextView)gradeView.findViewById(R.id.list_items); | ||
144 | String provice = SaveParam.getInstance().getLoginParam(this,"sheng"); | ||
145 | String citys = SaveParam.getInstance().getLoginParam(this,"shi"); | ||
146 | et_region.setText(provice+citys+gradeTv.getText().toString()); | ||
147 | } | ||
126 | 148 | ||
127 | View gradeView = parent.getChildAt(position); | ||
128 | TextView gradeTv = (TextView)gradeView.findViewById(R.id.list_items); | ||
129 | et_region.setText(gradeTv.getText().toString()); | ||
130 | 149 | ||
131 | 150 | ||
132 | } | 151 | } |
133 | @Override | 152 | @Override |
134 | public boolean onKeyUp(int keyCode, KeyEvent event) { | 153 | public boolean onKeyUp(int keyCode, KeyEvent event) { |
135 | if (keyCode == KeyEvent.KEYCODE_BACK) { | 154 | if (keyCode == KeyEvent.KEYCODE_BACK) { |
136 | finish(); | 155 | finish(); |
PersonalCenter/app/src/main/java/com/hjx/personalcenter/adapter/CitysAdapter.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.hjx.personalcenter.R; | 9 | import com.hjx.personalcenter.R; |
10 | import com.hjx.personalcenter.model.CityInfo; | 10 | import com.hjx.personalcenter.model.CityInfo; |
11 | 11 | ||
12 | import java.util.ArrayList; | 12 | import java.util.ArrayList; |
13 | 13 | ||
14 | /** | 14 | /** |
15 | * Created by h on 2017/8/18. | 15 | * Created by h on 2017/8/18. |
16 | */ | 16 | */ |
17 | 17 | ||
18 | public class CitysAdapter extends BaseAdapter { | 18 | public class CitysAdapter extends BaseAdapter { |
19 | ArrayList<CityInfo.CitiesBean> objects; | 19 | ArrayList<CityInfo.CitiesBean> objects; |
20 | private Context context; | 20 | private Context context; |
21 | 21 | ||
22 | public CitysAdapter(ArrayList<CityInfo.CitiesBean> objects, Context context) { | 22 | public CitysAdapter(ArrayList<CityInfo.CitiesBean> objects, Context context) { |
23 | this.objects = objects; | 23 | this.objects = objects; |
24 | this.context = context; | 24 | this.context = context; |
25 | } | 25 | } |
26 | 26 | ||
27 | @Override | 27 | @Override |
28 | public int getCount() { | 28 | public int getCount() { |
29 | return objects.size(); | 29 | return objects.size(); |
30 | } | 30 | } |
31 | 31 | ||
32 | @Override | 32 | @Override |
33 | public Object getItem(int position) { | 33 | public Object getItem(int position) { |
34 | return position; | 34 | return position; |
35 | } | 35 | } |
36 | 36 | ||
37 | @Override | 37 | @Override |
38 | public long getItemId(int position) { | 38 | public long getItemId(int position) { |
39 | return position; | 39 | return position; |
40 | } | 40 | } |
41 | 41 | ||
42 | @Override | 42 | @Override |
43 | public View getView(final int position, View convertView, ViewGroup parent) { | 43 | public View getView(final int position, View convertView, ViewGroup parent) { |
44 | 44 | ||
45 | ProvincesAdapter.ViewHolder holder = null; | 45 | ProvincesAdapter.ViewHolder holder = null; |
46 | 46 | ||
47 | if (convertView == null) { | 47 | if (convertView == null) { |
48 | convertView = View.inflate(context, R.layout.custom_adilog_list_item, null); | 48 | convertView = View.inflate(context, R.layout.custom_adilog_list_item, null); |
49 | holder = new ProvincesAdapter.ViewHolder(); | 49 | holder = new ProvincesAdapter.ViewHolder(); |
50 | holder.nameText = (TextView) convertView.findViewById(R.id.list_items); | 50 | holder.nameText = (TextView) convertView.findViewById(R.id.list_items); |
51 | convertView.setTag(holder); | 51 | convertView.setTag(holder); |
52 | } else { | 52 | } else { |
53 | holder = (ProvincesAdapter.ViewHolder) convertView.getTag(); | 53 | holder = (ProvincesAdapter.ViewHolder) convertView.getTag(); |
54 | } | 54 | } |
55 | 55 | ||
56 | holder.nameText.setText(objects.get(position).getRegionName()); | 56 | holder.nameText.setText(objects.get(position).getRegionName()+"市"); |
57 | 57 | ||
58 | return convertView; | 58 | return convertView; |
59 | } | 59 | } |
60 | 60 | ||
61 | 61 | ||
62 | static class ViewHolder { | 62 | static class ViewHolder { |
63 | TextView nameText; | 63 | TextView nameText; |
64 | } | 64 | } |
65 | } | 65 | } |
66 | 66 |
PersonalCenter/app/src/main/java/com/hjx/personalcenter/adapter/CountryAdapter.java
File was created | 1 | package com.hjx.personalcenter.adapter; | |
2 | |||
3 | import android.content.Context; | ||
4 | import android.view.View; | ||
5 | import android.view.ViewGroup; | ||
6 | import android.widget.BaseAdapter; | ||
7 | import android.widget.TextView; | ||
8 | |||
9 | import com.hjx.personalcenter.R; | ||
10 | import com.hjx.personalcenter.model.CityInfo; | ||
11 | import com.hjx.personalcenter.model.CountyInfo; | ||
12 | |||
13 | import java.util.ArrayList; | ||
14 | |||
15 | /** | ||
16 | * Created by wei on 2017/8/21. | ||
17 | */ | ||
18 | |||
19 | public class CountryAdapter extends BaseAdapter{ | ||
20 | ArrayList<CountyInfo.CountiesBean> objects; | ||
21 | private Context context; | ||
22 | |||
23 | public CountryAdapter(ArrayList<CountyInfo.CountiesBean> objects, Context context) { | ||
24 | this.objects = objects; | ||
25 | this.context = context; | ||
26 | } | ||
27 | |||
28 | @Override | ||
29 | public int getCount() { | ||
30 | return objects.size(); | ||
31 | } | ||
32 | |||
33 | @Override | ||
34 | public Object getItem(int position) { | ||
35 | return position; | ||
36 | } | ||
37 | |||
38 | @Override | ||
39 | public long getItemId(int position) { | ||
40 | return position; | ||
41 | } | ||
42 | |||
43 | @Override | ||
44 | public View getView(final int position, View convertView, ViewGroup parent) { | ||
45 | |||
46 | ProvincesAdapter.ViewHolder holder = null; | ||
47 | |||
48 | if (convertView == null) { | ||
49 | convertView = View.inflate(context, R.layout.custom_adilog_list_item, null); | ||
50 | holder = new ProvincesAdapter.ViewHolder(); | ||
51 | holder.nameText = (TextView) convertView.findViewById(R.id.list_items); | ||
52 | convertView.setTag(holder); | ||
53 | } else { | ||
54 | holder = (ProvincesAdapter.ViewHolder) convertView.getTag(); | ||
55 | } | ||
56 | |||
57 | holder.nameText.setText(objects.get(position).getRegionName()+"区"); | ||
58 | |||
59 | return convertView; | ||
60 | } | ||
61 | |||
62 | |||
63 | static class ViewHolder { | ||
64 | TextView nameText; | ||
65 | } | ||
66 | } | ||
67 |
PersonalCenter/app/src/main/java/com/hjx/personalcenter/adapter/ProvincesAdapter.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.hjx.personalcenter.R; | 9 | import com.hjx.personalcenter.R; |
10 | import com.hjx.personalcenter.model.ProvinceInfo; | 10 | import com.hjx.personalcenter.model.ProvinceInfo; |
11 | 11 | ||
12 | import java.util.ArrayList; | 12 | import java.util.ArrayList; |
13 | 13 | ||
14 | /** | 14 | /** |
15 | * Created by l on 2017/7/18. | 15 | * Created by l on 2017/7/18. |
16 | */ | 16 | */ |
17 | 17 | ||
18 | public class ProvincesAdapter extends BaseAdapter { | 18 | public class ProvincesAdapter extends BaseAdapter { |
19 | ArrayList<ProvinceInfo.ProvincesBean> objects; | 19 | ArrayList<ProvinceInfo.ProvincesBean> objects; |
20 | private Context context; | 20 | private Context context; |
21 | 21 | ||
22 | public ProvincesAdapter(ArrayList<ProvinceInfo.ProvincesBean> objects, Context context) { | 22 | public ProvincesAdapter(ArrayList<ProvinceInfo.ProvincesBean> objects, Context context) { |
23 | this.objects = objects; | 23 | this.objects = objects; |
24 | this.context = context; | 24 | this.context = context; |
25 | } | 25 | } |
26 | 26 | ||
27 | @Override | 27 | @Override |
28 | public int getCount() { | 28 | public int getCount() { |
29 | return objects.size(); | 29 | return objects.size(); |
30 | } | 30 | } |
31 | 31 | ||
32 | @Override | 32 | @Override |
33 | public Object getItem(int position) { | 33 | public Object getItem(int position) { |
34 | return position; | 34 | return position; |
35 | } | 35 | } |
36 | 36 | ||
37 | @Override | 37 | @Override |
38 | public long getItemId(int position) { | 38 | public long getItemId(int position) { |
39 | return position; | 39 | return position; |
40 | } | 40 | } |
41 | 41 | ||
42 | @Override | 42 | @Override |
43 | public View getView(final int position, View convertView, ViewGroup parent) { | 43 | public View getView(final int position, View convertView, ViewGroup parent) { |
44 | 44 | ||
45 | ViewHolder holder = null; | 45 | ViewHolder holder = null; |
46 | 46 | ||
47 | if (convertView == null) { | 47 | if (convertView == null) { |
48 | convertView = View.inflate(context, R.layout.custom_adilog_list_item, null); | 48 | convertView = View.inflate(context, R.layout.custom_adilog_list_item, null); |
49 | holder = new ViewHolder(); | 49 | holder = new ViewHolder(); |
50 | holder.nameText = (TextView) convertView.findViewById(R.id.list_items); | 50 | holder.nameText = (TextView) convertView.findViewById(R.id.list_items); |
51 | convertView.setTag(holder); | 51 | convertView.setTag(holder); |
52 | } else { | 52 | } else { |
53 | holder = (ProvincesAdapter.ViewHolder) convertView.getTag(); | 53 | holder = (ProvincesAdapter.ViewHolder) convertView.getTag(); |
54 | } | 54 | } |
55 | 55 | ||
56 | holder.nameText.setText(objects.get(position).getRegionName()); | 56 | holder.nameText.setText(objects.get(position).getRegionName()+"省"); |
57 | 57 | ||
58 | return convertView; | 58 | return convertView; |
59 | } | 59 | } |
60 | 60 | ||
61 | 61 | ||
62 | static class ViewHolder { | 62 | static class ViewHolder { |
63 | TextView nameText; | 63 | TextView nameText; |
64 | } | 64 | } |
65 | } | 65 | } |
66 | 66 |
PersonalCenter/app/src/main/java/com/hjx/personalcenter/customdialog/CitysListDialog.java
1 | package com.hjx.personalcenter.customdialog; | 1 | package com.hjx.personalcenter.customdialog; |
2 | 2 | ||
3 | import android.content.Context; | 3 | import android.content.Context; |
4 | import android.graphics.Color; | 4 | import android.graphics.Color; |
5 | import android.os.Bundle; | 5 | import android.os.Bundle; |
6 | import android.os.Handler; | ||
7 | import android.os.Message; | ||
6 | import android.view.Gravity; | 8 | import android.view.Gravity; |
7 | import android.view.LayoutInflater; | 9 | import android.view.LayoutInflater; |
8 | import android.view.View; | 10 | import android.view.View; |
9 | import android.view.ViewGroup; | 11 | import android.view.ViewGroup; |
10 | import android.widget.AdapterView; | 12 | import android.widget.AdapterView; |
11 | import android.widget.ListView; | 13 | import android.widget.ListView; |
12 | 14 | ||
13 | import com.hjx.personalcenter.R; | 15 | import com.hjx.personalcenter.R; |
14 | import com.hjx.personalcenter.adapter.CitysAdapter; | 16 | import com.hjx.personalcenter.adapter.CitysAdapter; |
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.CityInfo; | 21 | import com.hjx.personalcenter.model.CityInfo; |
22 | import com.hjx.personalcenter.model.ProvinceInfo; | ||
18 | import com.mylhyl.circledialog.BaseCircleDialog; | 23 | import com.mylhyl.circledialog.BaseCircleDialog; |
19 | import com.mylhyl.circledialog.res.values.CircleDimen; | 24 | import com.mylhyl.circledialog.res.values.CircleDimen; |
20 | 25 | ||
21 | import java.util.ArrayList; | 26 | import java.util.ArrayList; |
27 | import java.util.List; | ||
22 | 28 | ||
23 | /** | 29 | /** |
24 | * 自定义市级列表对话框 | 30 | * 自定义市级列表对话框 |
25 | * Created by h on 2017/8/10. | 31 | * Created by h on 2017/8/10. |
26 | */ | 32 | */ |
27 | 33 | ||
28 | public class CitysListDialog extends BaseCircleDialog implements AdapterView.OnItemClickListener { | 34 | public class CitysListDialog extends BaseCircleDialog implements AdapterView.OnItemClickListener { |
29 | private CitysAdapter listadapter; | 35 | private CitysAdapter listadapter; |
30 | private ListView listView; | 36 | private ListView listView; |
31 | private DialogCallBack.CallBack mCallBack; | 37 | private DialogCallBack.CallBack mCallBack; |
32 | private ArrayList<CityInfo.CitiesBean> data = new ArrayList<>(); | 38 | private ArrayList<CityInfo.CitiesBean> data = new ArrayList<>(); |
33 | public CitysListDialog(DialogCallBack.CallBack callBack) { | 39 | public CitysListDialog(DialogCallBack.CallBack callBack) { |
34 | this.mCallBack = callBack; | 40 | this.mCallBack = callBack; |
35 | } | 41 | } |
36 | public static CitysListDialog getInstance(DialogCallBack.CallBack callBack) { | 42 | public static CitysListDialog getInstance(DialogCallBack.CallBack callBack) { |
37 | CitysListDialog dialogFragment = new CitysListDialog(callBack); | 43 | CitysListDialog dialogFragment = new CitysListDialog(callBack); |
38 | dialogFragment.setCanceledBack(true); | 44 | dialogFragment.setCanceledBack(true); |
39 | dialogFragment.setCanceledOnTouchOutside(true); | 45 | dialogFragment.setCanceledOnTouchOutside(true); |
40 | dialogFragment.setRadius(CircleDimen.RADIUS); | 46 | dialogFragment.setRadius(CircleDimen.RADIUS); |
41 | dialogFragment.setWidth(0.5f); | 47 | dialogFragment.setWidth(0.5f); |
42 | dialogFragment.setGravity(Gravity.CENTER); | 48 | dialogFragment.setGravity(Gravity.CENTER); |
43 | dialogFragment.setBackgroundColor(Color.WHITE); | 49 | dialogFragment.setBackgroundColor(Color.WHITE); |
44 | return dialogFragment; | 50 | return dialogFragment; |
45 | } | 51 | } |
52 | Handler handler = new Handler(){ | ||
53 | @Override | ||
54 | public void handleMessage(Message msg) { | ||
55 | super.handleMessage(msg); | ||
56 | switch (msg.what){ | ||
57 | case HttpCode.CITYS: | ||
58 | data.clear(); | ||
59 | data.addAll( (List<CityInfo.CitiesBean>)msg.obj); | ||
60 | listadapter.notifyDataSetChanged(); | ||
61 | break; | ||
62 | } | ||
63 | } | ||
64 | }; | ||
46 | 65 | ||
47 | @Override | 66 | @Override |
48 | public View createView(Context context, LayoutInflater inflater, ViewGroup container) { | 67 | public View createView(Context context, LayoutInflater inflater, ViewGroup container) { |
49 | return inflater.inflate(R.layout.custom_adilog_provicelist, container, false); | 68 | return inflater.inflate(R.layout.custom_adilog_provicelist, container, false); |
50 | } | 69 | } |
51 | 70 | ||
52 | @Override | 71 | @Override |
53 | public void onActivityCreated(Bundle savedInstanceState) { | 72 | public void onActivityCreated(Bundle savedInstanceState) { |
54 | super.onActivityCreated(savedInstanceState); | 73 | super.onActivityCreated(savedInstanceState); |
55 | listView = (ListView) getView().findViewById(R.id.listadapter); | 74 | listView = (ListView) getView().findViewById(R.id.listadapter); |
56 | String provinces = SaveParam.getInstance().getLoginParam(getActivity(), SaveParam.CITYS); | 75 | String citys = SaveParam.getInstance().getLoginParam(getActivity(), SaveParam.PROVINCES); |
57 | // if (provinces != null) { | ||
58 | // | ||
59 | // for (int i = 0; i < provinces.split(",").length; i++) { | ||
60 | // String[] itmt = provinces.split(","); | ||
61 | // data.add(itmt[i] + "区"); | ||
62 | // //data.add(i,provinces.replaceAll(",","省")); | ||
63 | // | ||
64 | // } | ||
65 | // } else { | ||
66 | // HttpManager.getInstance().provices(getActivity()); | ||
67 | // } | ||
68 | |||
69 | listadapter = new CitysAdapter(data,getActivity()); | 76 | listadapter = new CitysAdapter(data,getActivity()); |
70 | listView.setAdapter(listadapter); | 77 | listView.setAdapter(listadapter); |
71 | listView.setOnItemClickListener(this); | 78 | listView.setOnItemClickListener(this); |
79 | try { | ||
80 | int a = Integer.parseInt(citys); | ||
81 | HttpManager.getInstance().cityinfo(getActivity(),a,handler); | ||
82 | } catch (NumberFormatException e) { | ||
83 | e.printStackTrace(); | ||
84 | } | ||
85 |
PersonalCenter/app/src/main/java/com/hjx/personalcenter/customdialog/CountryDialog.java
File was created | 1 | package com.hjx.personalcenter.customdialog; | |
2 | |||
3 | import android.content.Context; | ||
4 | import android.graphics.Color; | ||
5 | import android.os.Bundle; | ||
6 | import android.os.Handler; | ||
7 | import android.os.Message; | ||
8 | import android.view.Gravity; | ||
9 | import android.view.LayoutInflater; | ||
10 | import android.view.View; | ||
11 | import android.view.ViewGroup; | ||
12 | import android.widget.AdapterView; | ||
13 | import android.widget.ListView; | ||
14 | |||
15 | import com.hjx.personalcenter.R; | ||
16 | import com.hjx.personalcenter.adapter.CitysAdapter; | ||
17 | import com.hjx.personalcenter.adapter.CountryAdapter; | ||
18 | import com.hjx.personalcenter.db.SaveParam; | ||
19 | import com.hjx.personalcenter.http.HttpCode; | ||
20 | import com.hjx.personalcenter.http.HttpManager; | ||
21 | import com.hjx.personalcenter.interfaces.DialogCallBack; | ||
22 | import com.hjx.personalcenter.model.CityInfo; | ||
23 | import com.hjx.personalcenter.model.CountyInfo; | ||
24 | import com.mylhyl.circledialog.BaseCircleDialog; | ||
25 | import com.mylhyl.circledialog.res.values.CircleDimen; | ||
26 | |||
27 | import java.util.ArrayList; | ||
28 | import java.util.List; | ||
29 | |||
30 | /** | ||
31 | * Created by wei on 2017/8/21. | ||
32 | */ | ||
33 | |||
34 | public class CountryDialog extends BaseCircleDialog implements AdapterView.OnItemClickListener { | ||
35 | private CountryAdapter listadapter; | ||
36 | private ListView listView; | ||
37 | private DialogCallBack.CallBack mCallBack; | ||
38 | private ArrayList<CountyInfo.CountiesBean> data = new ArrayList<>(); | ||
39 | public CountryDialog(DialogCallBack.CallBack callBack) { | ||
40 | this.mCallBack = callBack; | ||
41 | } | ||
42 | public static CountryDialog getInstance(DialogCallBack.CallBack callBack) { | ||
43 | CountryDialog dialogFragment = new CountryDialog(callBack); | ||
44 | dialogFragment.setCanceledBack(true); | ||
45 | dialogFragment.setCanceledOnTouchOutside(true); | ||
46 | dialogFragment.setRadius(CircleDimen.RADIUS); | ||
47 | dialogFragment.setWidth(0.5f); | ||
48 | dialogFragment.setGravity(Gravity.CENTER); | ||
49 | dialogFragment.setBackgroundColor(Color.WHITE); | ||
50 | return dialogFragment; | ||
51 | } | ||
52 | Handler handler = new Handler(){ | ||
53 | @Override | ||
54 | public void handleMessage(Message msg) { | ||
55 | super.handleMessage(msg); | ||
56 | switch (msg.what){ | ||
57 | case HttpCode.COUNTRY: | ||
58 | data.clear(); | ||
59 | data.addAll( (List<CountyInfo.CountiesBean>)msg.obj); | ||
60 | listadapter.notifyDataSetChanged(); | ||
61 | break; | ||
62 | } | ||
63 | } | ||
64 | }; | ||
65 | |||
66 | @Override | ||
67 | public View createView(Context context, LayoutInflater inflater, ViewGroup container) { | ||
68 | return inflater.inflate(R.layout.custom_adilog_provicelist, container, false); | ||
69 | } | ||
70 | |||
71 | @Override | ||
72 | public void onActivityCreated(Bundle savedInstanceState) { | ||
73 | super.onActivityCreated(savedInstanceState); | ||
74 | listView = (ListView) getView().findViewById(R.id.listadapter); | ||
75 | String citys = SaveParam.getInstance().getLoginParam(getActivity(), SaveParam.CITYS); | ||
76 | listadapter = new CountryAdapter(data,getActivity()); | ||
77 | listView.setAdapter(listadapter); | ||
78 | listView.setOnItemClickListener(this); | ||
79 | try { | ||
80 | int a = Integer.parseInt(citys); | ||
81 | HttpManager.getInstance().countyinfo(getActivity(),a,handler); | ||
82 | } catch (NumberFormatException e) { | ||
83 | e.printStackTrace(); | ||
84 | } | ||
85 | |||
86 | |||
87 | } | ||
88 | |||
89 | @Override | ||
90 | public void onItemClick(AdapterView<?> parent, View view, int position, long id) { | ||
91 | SaveParam.getInstance().saveLoginParam(getActivity(), SaveParam.CITYS, ""+data.get(position).getRegionId()); | ||
92 | mCallBack.provinceOnItemClick(parent,view,position,id,3); | ||
93 | dismiss(); | ||
94 | |||
95 | } | ||
96 | } | ||
97 |
PersonalCenter/app/src/main/java/com/hjx/personalcenter/customdialog/ProvinceListDialog.java
1 | package com.hjx.personalcenter.customdialog; | 1 | package com.hjx.personalcenter.customdialog; |
2 | 2 | ||
3 | import android.content.Context; | 3 | import android.content.Context; |
4 | import android.graphics.Color; | 4 | import android.graphics.Color; |
5 | import android.os.Bundle; | 5 | import android.os.Bundle; |
6 | import android.os.Handler; | ||
7 | import android.os.Message; | ||
6 | import android.view.Gravity; | 8 | import android.view.Gravity; |
7 | import android.view.LayoutInflater; | 9 | import android.view.LayoutInflater; |
8 | import android.view.View; | 10 | import android.view.View; |
9 | import android.view.ViewGroup; | 11 | import android.view.ViewGroup; |
10 | import android.widget.AdapterView; | 12 | import android.widget.AdapterView; |
11 | import android.widget.ListView; | 13 | import android.widget.ListView; |
12 | 14 | ||
13 | import com.hjx.personalcenter.R; | 15 | import com.hjx.personalcenter.R; |
16 | import com.hjx.personalcenter.activity.RegisterInfoActivity; | ||
14 | import com.hjx.personalcenter.adapter.ProvincesAdapter; | 17 | import com.hjx.personalcenter.adapter.ProvincesAdapter; |
15 | import com.hjx.personalcenter.db.SaveParam; | 18 | import com.hjx.personalcenter.db.SaveParam; |
19 | import com.hjx.personalcenter.http.HttpCode; | ||
16 | import com.hjx.personalcenter.http.HttpManager; | 20 | import com.hjx.personalcenter.http.HttpManager; |
17 | import com.hjx.personalcenter.interfaces.DialogCallBack; | 21 | import com.hjx.personalcenter.interfaces.DialogCallBack; |
18 | import com.hjx.personalcenter.model.ProvinceInfo; | 22 | import com.hjx.personalcenter.model.ProvinceInfo; |
19 | import com.mylhyl.circledialog.BaseCircleDialog; | 23 | import com.mylhyl.circledialog.BaseCircleDialog; |
20 | import com.mylhyl.circledialog.res.values.CircleDimen; | 24 | import com.mylhyl.circledialog.res.values.CircleDimen; |
21 | 25 | ||
22 | import java.util.ArrayList; | 26 | import java.util.ArrayList; |
27 | import java.util.List; | ||
23 | 28 | ||
24 | /** | 29 | /** |
25 | * 自定义年级列表对话框 | 30 | * 自定义年级列表对话框 |
26 | * Created by h on 2017/8/10. | 31 | * Created by h on 2017/8/10. |
27 | */ | 32 | */ |
28 | 33 | ||
29 | public class ProvinceListDialog extends BaseCircleDialog implements AdapterView.OnItemClickListener { | 34 | public class ProvinceListDialog extends BaseCircleDialog implements AdapterView.OnItemClickListener { |
30 | private ProvincesAdapter listadapter; | 35 | private ProvincesAdapter listadapter; |
31 | private ListView listView; | 36 | private ListView listView; |
32 | private ArrayList<ProvinceInfo.ProvincesBean> data = new ArrayList<>(); | 37 | private ArrayList<ProvinceInfo.ProvincesBean> data = new ArrayList<>(); |
33 | 38 | ||
34 | private DialogCallBack.CallBack mCallBack; | 39 | private DialogCallBack.CallBack mCallBack; |
35 | 40 | ||
41 | Handler handler = new Handler(){ | ||
42 | @Override | ||
43 | public void handleMessage(Message msg) { | ||
44 | super.handleMessage(msg); | ||
45 | switch (msg.what){ | ||
46 | case HttpCode.PROVICES: | ||
47 | data.clear(); | ||
48 | data.addAll( (List<ProvinceInfo.ProvincesBean>)msg.obj); | ||
49 | listadapter.notifyDataSetChanged(); | ||
50 | break; | ||
51 | } | ||
52 | } | ||
53 | }; | ||
36 | public ProvinceListDialog(DialogCallBack.CallBack callBack) { | 54 | public ProvinceListDialog(DialogCallBack.CallBack callBack) { |
37 | this.mCallBack = callBack; | 55 | this.mCallBack = callBack; |
38 | } | 56 | } |
39 | 57 | ||
40 | public static ProvinceListDialog getInstance(DialogCallBack.CallBack callBack) { | 58 | public static ProvinceListDialog getInstance(DialogCallBack.CallBack callBack) { |
41 | ProvinceListDialog dialogFragment = new ProvinceListDialog(callBack); | 59 | ProvinceListDialog dialogFragment = new ProvinceListDialog(callBack); |
42 | dialogFragment.setCanceledBack(true); | 60 | dialogFragment.setCanceledBack(true); |
43 | dialogFragment.setCanceledOnTouchOutside(true); | 61 | dialogFragment.setCanceledOnTouchOutside(true); |
44 | dialogFragment.setRadius(CircleDimen.RADIUS); | 62 | dialogFragment.setRadius(CircleDimen.RADIUS); |
45 | dialogFragment.setWidth(0.5f); | 63 | dialogFragment.setWidth(0.5f); |
46 | dialogFragment.setGravity(Gravity.CENTER); | 64 | dialogFragment.setGravity(Gravity.CENTER); |
47 | dialogFragment.setBackgroundColor(Color.WHITE); | 65 | dialogFragment.setBackgroundColor(Color.WHITE); |
48 | return dialogFragment; | 66 | return dialogFragment; |
49 | } | 67 | } |
50 | 68 | ||
51 | @Override | 69 | @Override |
52 | public View createView(Context context, LayoutInflater inflater, ViewGroup container) { | 70 | public View createView(Context context, LayoutInflater inflater, ViewGroup container) { |
53 | return inflater.inflate(R.layout.custom_adilog_provicelist, container, false); | 71 | return inflater.inflate(R.layout.custom_adilog_provicelist, container, false); |
54 | } | 72 | } |
55 | 73 | ||
56 | @Override | 74 | @Override |
57 | public void onActivityCreated(Bundle savedInstanceState) { | 75 | public void onActivityCreated(Bundle savedInstanceState) { |
58 | super.onActivityCreated(savedInstanceState); | 76 | super.onActivityCreated(savedInstanceState); |
59 | listView = (ListView) getView().findViewById(R.id.listadapter); | 77 | listView = (ListView) getView().findViewById(R.id.listadapter); |
60 | String provinces = SaveParam.getInstance().getLoginParam(getActivity(), SaveParam.PROVINCES); | ||
61 | if (provinces != null) { | ||
62 | |||
63 | for (int i = 0; i < provinces.split(",").length; i++) { | ||
64 | ProvinceInfo.ProvincesBean provincesBean = new ProvinceInfo.ProvincesBean(); | ||
65 | provincesBean.setRegionName(provinces.split(",")[i] + "省"); | ||
66 | data.add(provincesBean); | ||
67 | } | ||
68 | } else { | ||
69 | HttpManager.getInstance().provices(getActivity()); | ||
70 | } | ||
71 | |||
72 | listadapter = new ProvincesAdapter(data,getActivity()); | 78 | listadapter = new ProvincesAdapter(data,getActivity()); |
73 | listView.setAdapter(listadapter); | 79 | listView.setAdapter(listadapter); |
74 | listView.setOnItemClickListener(this); | 80 | listView.setOnItemClickListener(this); |
81 | HttpManager.getInstance().provices(getActivity(),handler); | ||
75 | 82 |
PersonalCenter/app/src/main/java/com/hjx/personalcenter/customdialog/SchoolListDialog.java
1 | package com.hjx.personalcenter.customdialog; | 1 | package com.hjx.personalcenter.customdialog; |
2 | 2 | ||
3 | import android.content.Context; | 3 | import android.content.Context; |
4 | import android.graphics.Color; | 4 | import android.graphics.Color; |
5 | import android.os.Bundle; | 5 | import android.os.Bundle; |
6 | import android.os.Handler; | ||
7 | import android.os.Message; | ||
6 | import android.text.Editable; | 8 | import android.text.Editable; |
7 | import android.text.TextWatcher; | 9 | import android.text.TextWatcher; |
8 | import android.view.Gravity; | 10 | import android.view.Gravity; |
9 | import android.view.LayoutInflater; | 11 | import android.view.LayoutInflater; |
10 | import android.view.View; | 12 | import android.view.View; |
11 | import android.view.ViewGroup; | 13 | import android.view.ViewGroup; |
12 | import android.widget.AdapterView; | 14 | import android.widget.AdapterView; |
13 | import android.widget.EditText; | 15 | import android.widget.EditText; |
14 | import android.widget.ListView; | 16 | import android.widget.ListView; |
15 | 17 | ||
16 | import com.hjx.personalcenter.R; | 18 | import com.hjx.personalcenter.R; |
19 | import com.hjx.personalcenter.activity.RegisterInfoActivity; | ||
17 | import com.hjx.personalcenter.adapter.SchoolAdapter; | 20 | import com.hjx.personalcenter.adapter.SchoolAdapter; |
18 | import com.hjx.personalcenter.db.SaveParam; | 21 | import com.hjx.personalcenter.db.SaveParam; |
22 | import com.hjx.personalcenter.http.HttpCode; | ||
19 | import com.hjx.personalcenter.http.HttpManager; | 23 | import com.hjx.personalcenter.http.HttpManager; |
20 | import com.hjx.personalcenter.interfaces.DialogCallBack; | 24 | import com.hjx.personalcenter.interfaces.DialogCallBack; |
25 | import com.hjx.personalcenter.model.CountyInfo; | ||
21 | import com.hjx.personalcenter.model.SchoolInfo; | 26 | import com.hjx.personalcenter.model.SchoolInfo; |
22 | import com.mylhyl.circledialog.BaseCircleDialog; | 27 | import com.mylhyl.circledialog.BaseCircleDialog; |
23 | import com.mylhyl.circledialog.res.values.CircleDimen; | 28 | import com.mylhyl.circledialog.res.values.CircleDimen; |
24 | 29 | ||
25 | import java.util.ArrayList; | 30 | import java.util.ArrayList; |
31 | import java.util.List; | ||
26 | 32 | ||
27 | /** | 33 | /** |
28 | * Created by h on 2017/8/21. | 34 | * Created by h on 2017/8/21. |
29 | */ | 35 | */ |
30 | 36 | ||
31 | public class SchoolListDialog extends BaseCircleDialog implements AdapterView.OnItemClickListener, View.OnClickListener { | 37 | public class SchoolListDialog extends BaseCircleDialog implements AdapterView.OnItemClickListener, View.OnClickListener { |
32 | private ListView school_list; | 38 | private ListView school_list; |
33 | private EditText school_sech; | 39 | private EditText school_sech; |
34 | private SchoolAdapter listadapter; | 40 | private SchoolAdapter listadapter; |
35 | private View mView; | 41 | private View mView; |
36 | boolean isFilter; | 42 | boolean isFilter; |
37 | private DialogCallBack.CallBackView mCallBack; | 43 | private DialogCallBack.CallBackView mCallBack; |
38 | ArrayList<SchoolInfo.DataBean> data = new ArrayList<>(); | 44 | ArrayList<SchoolInfo.DataBean> data = new ArrayList<>(); |
39 | 45 | ||
40 | // public SchoolListDialog(DialogCallBack.CallBackView callBack) { | 46 | // public SchoolListDialog(DialogCallBack.CallBackView callBack) { |
41 | // this.mCallBack = callBack; | 47 | // this.mCallBack = callBack; |
42 | // } | 48 | // } |
43 | 49 | ||
44 | public static SchoolListDialog getInstance() { | 50 | public static SchoolListDialog getInstance() { |
45 | SchoolListDialog dialogFragment = new SchoolListDialog(); | 51 | SchoolListDialog dialogFragment = new SchoolListDialog(); |
46 | dialogFragment.setCanceledBack(true); | 52 | dialogFragment.setCanceledBack(true); |
47 | dialogFragment.setCanceledOnTouchOutside(true); | 53 | dialogFragment.setCanceledOnTouchOutside(true); |
48 | dialogFragment.setRadius(CircleDimen.RADIUS); | 54 | dialogFragment.setRadius(CircleDimen.RADIUS); |
49 | dialogFragment.setWidth(0.5f); | 55 | dialogFragment.setWidth(0.5f); |
50 | dialogFragment.setGravity(Gravity.CENTER); | 56 | dialogFragment.setGravity(Gravity.CENTER); |
51 | dialogFragment.setBackgroundColor(Color.WHITE); | 57 | dialogFragment.setBackgroundColor(Color.WHITE); |
52 | return dialogFragment; | 58 | return dialogFragment; |
53 | } | 59 | } |
54 | 60 | Handler handler = new Handler(){ | |
61 | @Override | ||
62 | public void handleMessage(Message msg) { | ||
63 | super.handleMessage(msg); | ||
64 | switch (msg.what){ | ||
65 | case HttpCode.SCHOOL: | ||
66 | data.clear(); | ||
67 | data.addAll( (List<SchoolInfo.DataBean>)msg.obj); | ||
68 | listadapter.notifyDataSetChanged(); | ||
69 | break; | ||
70 | } | ||
71 | } | ||
72 | }; | ||
55 | @Override | 73 | @Override |
56 | public View createView(Context context, LayoutInflater inflater, ViewGroup container) { | 74 | public View createView(Context context, LayoutInflater inflater, ViewGroup container) { |
57 | 75 | ||
58 | if (mView == null) { | 76 | if (mView == null) { |
59 | mView = inflater.inflate(R.layout.custom_adilog_school_list, container, false); | 77 | mView = inflater.inflate(R.layout.custom_adilog_school_list, container, false); |
60 | //mCallBack.provinceOnItemClick(context, inflater, container); | 78 | //mCallBack.provinceOnItemClick(context, inflater, container); |
61 | } | 79 | } |
62 | return mView; | 80 | return mView; |
63 | } | 81 | } |
64 | 82 | ||
65 | @Override | 83 | @Override |
66 | public void onActivityCreated(Bundle savedInstanceState) { | 84 | public void onActivityCreated(Bundle savedInstanceState) { |
67 | super.onActivityCreated(savedInstanceState); | 85 | super.onActivityCreated(savedInstanceState); |
68 | school_list = (ListView) getView().findViewById(R.id.listschooladapter); | 86 | school_list = (ListView) getView().findViewById(R.id.listschooladapter); |
69 | school_sech = (EditText) getView().findViewById(R.id.et_school_sech); | 87 | school_sech = (EditText) getView().findViewById(R.id.et_school_sech); |
70 | String gradens = SaveParam.getInstance().getLoginParam(getActivity(), SaveParam.SCHOOL); | 88 | String citys = SaveParam.getInstance().getLoginParam(getActivity(), SaveParam.CITYS); |
71 | if (gradens != null) { | ||
72 | |||
73 | for (int i = 0; i < gradens.split(",").length; i++) { | ||
74 | SchoolInfo.DataBean dataBean = new SchoolInfo.DataBean(); | ||
75 | dataBean.setSchoolName(gradens.split(",")[i]); | ||
76 | data.add(dataBean); | ||
77 | } | ||
78 | } else { | ||
79 | HttpManager.getInstance().getschool(getActivity(),130102,14); | ||
80 | } | ||
81 | listadapter = new SchoolAdapter(data, getActivity()); | 89 | listadapter = new SchoolAdapter(data, getActivity()); |
82 | school_list.setAdapter(listadapter); | 90 | school_list.setAdapter(listadapter); |
83 | school_list.setOnItemClickListener(this); | 91 | school_list.setOnItemClickListener(this); |
84 | school_sech.setOnClickListener(this); | 92 | school_sech.setOnClickListener(this); |
93 | try { | ||
94 | int a = Integer.parseInt(citys); | ||
95 | HttpManager.getInstance().getschool(getActivity(),a,14,handler); | ||
96 | } catch (NumberFormatException e) { | ||
97 | e.printStackTrace(); | ||
98 | } | ||
85 | intiEditView(); | 99 | intiEditView(); |
86 | 100 | ||
87 | 101 | ||
88 | } | 102 | } |
89 | private void intiEditView() { | 103 | private void intiEditView() { |
90 | school_sech.addTextChangedListener(new TextWatcher() { | 104 | school_sech.addTextChangedListener(new TextWatcher() { |
91 | @Override | 105 | @Override |
92 | public void beforeTextChanged(CharSequence s, int start, int count, int after) { | 106 | public void beforeTextChanged(CharSequence s, int start, int count, int after) { |
93 | 107 | ||
94 | } | 108 | } |
95 | 109 | ||
96 | @Override | 110 | @Override |
97 | public void onTextChanged(CharSequence s, int start, int before, int count) { | 111 | public void onTextChanged(CharSequence s, int start, int before, int count) { |
98 | // mAdapter.getFilter().filter(s); | 112 | // mAdapter.getFilter().filter(s); |
99 | 113 | ||
100 | listadapter.getFilter().filter(s); | 114 | listadapter.getFilter().filter(s); |
101 | } | 115 | } |
102 | 116 | ||
103 | @Override | 117 | @Override |
104 | public void afterTextChanged(Editable s) { | 118 | public void afterTextChanged(Editable s) { |
105 | 119 | ||
106 | } | 120 | } |
107 | }); | 121 | }); |
108 | } | 122 | } |
109 | 123 | ||
110 | @Override | 124 | @Override |
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 = 1; | 9 | public static final int SUCHCARDINFO = 1; |
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 CHANGENAME_SUCESS = 12; | 29 | public static final int CITYS = 12; |
30 | //获取个人信息 | 30 | //区 |
31 | public static final int STUDENTINFO_SUCESS = 13; | 31 | public static final int COUNTRY = 13; |
32 | //意见反馈 | 32 | //学校 |
33 | public static final int FEEDBACL_SUCESS = 14; | 33 | public static final int SCHOOL = 14; |
34 | //私人订制查询 | 34 | //私人订制查询 |
35 | public static final int PRIVATEDZ = 15; | 35 | public static final int PRIVATEDZ = 15; |
36 | 36 | ||
37 | 37 | ||
38 | 38 | ||
39 | } | 39 | } |
40 | 40 |
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.ComponentName; | 5 | import android.content.ComponentName; |
6 | import android.content.Context; | 6 | import android.content.Context; |
7 | import android.content.Intent; | 7 | import android.content.Intent; |
8 | import android.os.Handler; | 8 | import android.os.Handler; |
9 | import android.os.Message; | 9 | import android.os.Message; |
10 | import android.provider.Settings; | 10 | import android.provider.Settings; |
11 | import android.support.v4.app.FragmentActivity; | 11 | import android.support.v4.app.FragmentActivity; |
12 | import android.util.Log; | 12 | import android.util.Log; |
13 | import android.view.Gravity; | 13 | import android.view.Gravity; |
14 | import android.view.View; | 14 | import android.view.View; |
15 | import android.widget.Toast; | 15 | import android.widget.Toast; |
16 | 16 | ||
17 | import com.google.gson.Gson; | 17 | import com.google.gson.Gson; |
18 | import com.hjx.personalcenter.R; | 18 | import com.hjx.personalcenter.R; |
19 | import com.hjx.personalcenter.activity.LoginAndRegisterActivity; | 19 | import com.hjx.personalcenter.activity.LoginAndRegisterActivity; |
20 | import com.hjx.personalcenter.activity.TheStartPageActivity; | 20 | import com.hjx.personalcenter.activity.TheStartPageActivity; |
21 | import com.hjx.personalcenter.db.SaveParam; | 21 | import com.hjx.personalcenter.db.SaveParam; |
22 | import com.hjx.personalcenter.gson.GsonTool; | 22 | import com.hjx.personalcenter.gson.GsonTool; |
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.DialogPermission; | 28 | import com.hjx.personalcenter.util.DialogPermission; |
29 | import com.loopj.android.http.AsyncHttpResponseHandler; | 29 | import com.loopj.android.http.AsyncHttpResponseHandler; |
30 | import com.loopj.android.http.JsonHttpResponseHandler; | 30 | import com.loopj.android.http.JsonHttpResponseHandler; |
31 | import com.loopj.android.http.RequestParams; | 31 | import com.loopj.android.http.RequestParams; |
32 | import com.mylhyl.circledialog.CircleDialog; | 32 | import com.mylhyl.circledialog.CircleDialog; |
33 | import com.mylhyl.circledialog.callback.ConfigText; | 33 | import com.mylhyl.circledialog.callback.ConfigText; |
34 | import com.mylhyl.circledialog.params.TextParams; | 34 | import com.mylhyl.circledialog.params.TextParams; |
35 | 35 | ||
36 | import org.apache.http.Header; | 36 | import org.apache.http.Header; |
37 | import org.apache.http.entity.ByteArrayEntity; | 37 | import org.apache.http.entity.ByteArrayEntity; |
38 | import org.apache.http.message.BasicHeader; | 38 | import org.apache.http.message.BasicHeader; |
39 | import org.apache.http.protocol.HTTP; | 39 | import org.apache.http.protocol.HTTP; |
40 | import org.json.JSONException; | 40 | import org.json.JSONException; |
41 | import org.json.JSONObject; | 41 | import org.json.JSONObject; |
42 | 42 | ||
43 | import java.io.UnsupportedEncodingException; | 43 | import java.io.UnsupportedEncodingException; |
44 | import java.util.List; | ||
44 | 45 | ||
45 | public class HttpManager { | 46 | public class HttpManager { |
46 | private static HttpManager instance; | 47 | private static HttpManager instance; |
47 | private ProgressDialog mProgress = null; | 48 | private ProgressDialog mProgress = null; |
48 | 49 | ||
49 | public static HttpManager getInstance() { | 50 | public static HttpManager getInstance() { |
50 | if (instance == null) { | 51 | if (instance == null) { |
51 | instance = new HttpManager(); | 52 | instance = new HttpManager(); |
52 | } | 53 | } |
53 | return instance; | 54 | return instance; |
54 | } | 55 | } |
55 | 56 | ||
56 | 57 | ||
57 | //登录接口 | 58 | //登录接口 |
58 | 59 | ||
59 | public void login(final String username, final String password, final Context mContext) { | 60 | public void login(final String username, final String password, final Context mContext) { |
60 | mProgress = DialogPermission.showProgress(mContext, null, "正在登录...", | 61 | mProgress = DialogPermission.showProgress(mContext, null, "正在登录...", |
61 | false, true, null); | 62 | false, true, null); |
62 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); | 63 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); |
63 | HttpClient.getInstance().get(HttpUrl.loginUrl + "?username=" + username + "&password=" + password, new AsyncHttpResponseHandler() { | 64 | HttpClient.getInstance().get(HttpUrl.loginUrl + "?username=" + username + "&password=" + password, new AsyncHttpResponseHandler() { |
64 | @Override | 65 | @Override |
65 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { | 66 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { |
66 | 67 | ||
67 | String str = new String(arg2); | 68 | String str = new String(arg2); |
68 | JSONObject jsonObject = null; | 69 | JSONObject jsonObject = null; |
69 | try { | 70 | try { |
70 | jsonObject = new JSONObject(new String(arg2)); | 71 | jsonObject = new JSONObject(new String(arg2)); |
71 | String status = jsonObject.getString("status"); | 72 | String status = jsonObject.getString("status"); |
72 | if (status.equals("100")) { | 73 | if (status.equals("100")) { |
73 | String access_token = jsonObject.getString("access_token"); | 74 | String access_token = jsonObject.getString("access_token"); |
74 | String userId = jsonObject.getString("userId"); | 75 | String userId = jsonObject.getString("userId"); |
75 | // //登录成功,保存登录数据并且获取个人信息 | 76 | // //登录成功,保存登录数据并且获取个人信息 |
76 | saveLoginInfo(mContext, username, password, access_token, "true", userId); | 77 | saveLoginInfo(mContext, username, password, access_token, "true", userId); |
77 | //HttpManager.getInstance().getuserinfo(username,mContext); | 78 | //HttpManager.getInstance().getuserinfo(username,mContext); |
78 | 79 | ||
79 | } else if (status.equals("200")) { | 80 | } else if (status.equals("200")) { |
80 | closeProgress(); | 81 | closeProgress(); |
81 | Toast.makeText(mContext, "用户名不存在!", Toast.LENGTH_LONG).show(); | 82 | Toast.makeText(mContext, "用户名不存在!", Toast.LENGTH_LONG).show(); |
82 | return; | 83 | return; |
83 | } else if (status.equals("204")) { | 84 | } else if (status.equals("204")) { |
84 | closeProgress(); | 85 | closeProgress(); |
85 | Toast.makeText(mContext, "密码错误!", Toast.LENGTH_LONG).show(); | 86 | Toast.makeText(mContext, "密码错误!", Toast.LENGTH_LONG).show(); |
86 | } else { | 87 | } else { |
87 | closeProgress(); | 88 | closeProgress(); |
88 | Toast.makeText(mContext, "登录失败!请检查网络", Toast.LENGTH_LONG).show(); | 89 | Toast.makeText(mContext, "登录失败!请检查网络", Toast.LENGTH_LONG).show(); |
89 | 90 | ||
90 | 91 | ||
91 | } | 92 | } |
92 | } catch (JSONException e) { | 93 | } catch (JSONException e) { |
93 | e.printStackTrace(); | 94 | e.printStackTrace(); |
94 | } | 95 | } |
95 | 96 | ||
96 | 97 | ||
97 | } | 98 | } |
98 | 99 | ||
99 | @Override | 100 | @Override |
100 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { | 101 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { |
101 | closeProgress(); | 102 | closeProgress(); |
102 | new CircleDialog.Builder((FragmentActivity) mContext) | 103 | new CircleDialog.Builder((FragmentActivity) mContext) |
103 | .setCanceledOnTouchOutside(false) | 104 | .setCanceledOnTouchOutside(false) |
104 | .setCancelable(false) | 105 | .setCancelable(false) |
105 | .setWidth(0.5f) | 106 | .setWidth(0.5f) |
106 | .configText(new ConfigText() { | 107 | .configText(new ConfigText() { |
107 | @Override | 108 | @Override |
108 | public void onConfig(TextParams params) { | 109 | public void onConfig(TextParams params) { |
109 | params.gravity = Gravity.CENTER; | 110 | params.gravity = Gravity.CENTER; |
110 | params.padding = new int[]{50, 50, 50, 50}; | 111 | params.padding = new int[]{50, 50, 50, 50}; |
111 | } | 112 | } |
112 | }) | 113 | }) |
113 | .setText("当前无网络,请检查网络设置") | 114 | .setText("当前无网络,请检查网络设置") |
114 | .setNegative("继续使用", null) | 115 | .setNegative("继续使用", null) |
115 | .setPositive("设置网络", new View.OnClickListener() { | 116 | .setPositive("设置网络", new View.OnClickListener() { |
116 | @Override | 117 | @Override |
117 | public void onClick(View v) { | 118 | public void onClick(View v) { |
118 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 | 119 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 |
119 | mContext.startActivity(intent); | 120 | mContext.startActivity(intent); |
120 | } | 121 | } |
121 | }) | 122 | }) |
122 | .show(); | 123 | .show(); |
123 | } | 124 | } |
124 | }); | 125 | }); |
125 | } | 126 | } |
126 | 127 | ||
127 | //注册接口 | 128 | //注册接口 |
128 | public void register(final Context context, String username, String password, String smscode, String source, final Handler handler) { | 129 | public void register(final Context context, String username, String password, String smscode, String source, final Handler handler) { |
129 | mProgress = DialogPermission.showProgress(context, null, "正在注册...", | 130 | mProgress = DialogPermission.showProgress(context, null, "正在注册...", |
130 | false, true, null); | 131 | false, true, null); |
131 | JSONObject jsonObject = new JSONObject(); | 132 | JSONObject jsonObject = new JSONObject(); |
132 | ByteArrayEntity entity = null; | 133 | ByteArrayEntity entity = null; |
133 | try { | 134 | try { |
134 | jsonObject.put(HttpKey.USERNAME, username); | 135 | jsonObject.put(HttpKey.USERNAME, username); |
135 | jsonObject.put(HttpKey.PASSWORD, password); | 136 | jsonObject.put(HttpKey.PASSWORD, password); |
136 | jsonObject.put(HttpKey.SMSCODE, smscode); | 137 | jsonObject.put(HttpKey.SMSCODE, smscode); |
137 | jsonObject.put(HttpKey.SOURCE, source); | 138 | jsonObject.put(HttpKey.SOURCE, source); |
138 | Log.e("test", "jsonObject" + jsonObject); | 139 | Log.e("test", "jsonObject" + jsonObject); |
139 | entity = new ByteArrayEntity(jsonObject.toString().getBytes("UTF-8")); | 140 | entity = new ByteArrayEntity(jsonObject.toString().getBytes("UTF-8")); |
140 | entity.setContentType(new BasicHeader(HTTP.CONTENT_TYPE, "application/json")); | 141 | entity.setContentType(new BasicHeader(HTTP.CONTENT_TYPE, "application/json")); |
141 | } catch (JSONException e) { | 142 | } catch (JSONException e) { |
142 | e.printStackTrace(); | 143 | e.printStackTrace(); |
143 | } catch (UnsupportedEncodingException e) { | 144 | } catch (UnsupportedEncodingException e) { |
144 | e.printStackTrace(); | 145 | e.printStackTrace(); |
145 | } | 146 | } |
146 | HttpClient.getInstance().addHeader("Accept", "*/*"); | 147 | HttpClient.getInstance().addHeader("Accept", "*/*"); |
147 | HttpClient.getInstance().post(context, HttpUrl.registeredUrl, entity, "application/json", new JsonHttpResponseHandler() { | 148 | HttpClient.getInstance().post(context, HttpUrl.registeredUrl, entity, "application/json", new JsonHttpResponseHandler() { |
148 | @Override | 149 | @Override |
149 | public void onSuccess(int statusCode, Header[] headers, JSONObject response) { | 150 | public void onSuccess(int statusCode, Header[] headers, JSONObject response) { |
150 | super.onSuccess(statusCode, headers, response); | 151 | super.onSuccess(statusCode, headers, response); |
151 | closeProgress(); | 152 | closeProgress(); |
152 | Log.e("test", "onSuccess" + response); | 153 | Log.e("test", "onSuccess" + response); |
153 | Message msg = Message.obtain(); | 154 | Message msg = Message.obtain(); |
154 | msg.what = HttpCode.REGISTERED_SUCESS; | 155 | msg.what = HttpCode.REGISTERED_SUCESS; |
155 | msg.obj = response; | 156 | msg.obj = response; |
156 | handler.sendMessage(msg); | 157 | handler.sendMessage(msg); |
157 | 158 | ||
158 | } | 159 | } |
159 | 160 | ||
160 | @Override | 161 | @Override |
161 | public void onFailure(int statusCode, Header[] headers, Throwable throwable, JSONObject errorResponse) { | 162 | public void onFailure(int statusCode, Header[] headers, Throwable throwable, JSONObject errorResponse) { |
162 | super.onFailure(statusCode, headers, throwable, errorResponse); | 163 | super.onFailure(statusCode, headers, throwable, errorResponse); |
163 | closeProgress(); | 164 | closeProgress(); |
164 | Log.e("test", "onFailure" + errorResponse); | 165 | Log.e("test", "onFailure" + errorResponse); |
165 | new CircleDialog.Builder((FragmentActivity) context) | 166 | new CircleDialog.Builder((FragmentActivity) context) |
166 | .setCanceledOnTouchOutside(false) | 167 | .setCanceledOnTouchOutside(false) |
167 | .setCancelable(false) | 168 | .setCancelable(false) |
168 | .setWidth(0.5f) | 169 | .setWidth(0.5f) |
169 | .configText(new ConfigText() { | 170 | .configText(new ConfigText() { |
170 | @Override | 171 | @Override |
171 | public void onConfig(TextParams params) { | 172 | public void onConfig(TextParams params) { |
172 | params.gravity = Gravity.CENTER; | 173 | params.gravity = Gravity.CENTER; |
173 | params.padding = new int[]{50, 50, 50, 50}; | 174 | params.padding = new int[]{50, 50, 50, 50}; |
174 | } | 175 | } |
175 | }) | 176 | }) |
176 | .setText("当前无网络,请检查网络设置") | 177 | .setText("当前无网络,请检查网络设置") |
177 | .setNegative("继续使用", null) | 178 | .setNegative("继续使用", null) |
178 | .setPositive("设置网络", new View.OnClickListener() { | 179 | .setPositive("设置网络", new View.OnClickListener() { |
179 | @Override | 180 | @Override |
180 | public void onClick(View v) { | 181 | public void onClick(View v) { |
181 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 | 182 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 |
182 | context.startActivity(intent); | 183 | context.startActivity(intent); |
183 | } | 184 | } |
184 | }) | 185 | }) |
185 | .show(); | 186 | .show(); |
186 | } | 187 | } |
187 | 188 | ||
188 | }); | 189 | }); |
189 | } | 190 | } |
190 | 191 | ||
191 | //注册验证码 | 192 | //注册验证码 |
192 | public void authCode(final String type, final String mobile, final Handler handler, final Context mContext) { | 193 | public void authCode(final String type, final String mobile, final Handler handler, final Context mContext) { |
193 | RequestParams params = new RequestParams(); | 194 | RequestParams params = new RequestParams(); |
194 | params.put(HttpKey.TYPE, type); | 195 | params.put(HttpKey.TYPE, type); |
195 | params.put(HttpKey.MOBIL, mobile); | 196 | params.put(HttpKey.MOBIL, mobile); |
196 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); | 197 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); |
197 | HttpClient.getInstance().post(HttpUrl.authCodedUrl, params, new JsonHttpResponseHandler() { | 198 | HttpClient.getInstance().post(HttpUrl.authCodedUrl, params, new JsonHttpResponseHandler() { |
198 | 199 | ||
199 | @Override | 200 | @Override |
200 | public void onSuccess(int statusCode, Header[] headers, JSONObject response) { | 201 | public void onSuccess(int statusCode, Header[] headers, JSONObject response) { |
201 | Log.e("test", "onSuccess-----" + response); | 202 | Log.e("test", "onSuccess-----" + response); |
202 | Message msg = Message.obtain(); | 203 | Message msg = Message.obtain(); |
203 | msg.what = HttpCode.AUTHCODE_SUCESS; | 204 | msg.what = HttpCode.AUTHCODE_SUCESS; |
204 | msg.obj = response; | 205 | msg.obj = response; |
205 | handler.sendMessage(msg); | 206 | handler.sendMessage(msg); |
206 | } | 207 | } |
207 | 208 | ||
208 | @Override | 209 | @Override |
209 | public void onFailure(int statusCode, Header[] headers, Throwable throwable, JSONObject errorResponse) { | 210 | public void onFailure(int statusCode, Header[] headers, Throwable throwable, JSONObject errorResponse) { |
210 | new CircleDialog.Builder((FragmentActivity) mContext) | 211 | new CircleDialog.Builder((FragmentActivity) mContext) |
211 | .setCanceledOnTouchOutside(false) | 212 | .setCanceledOnTouchOutside(false) |
212 | .setCancelable(false) | 213 | .setCancelable(false) |
213 | .setWidth(0.5f) | 214 | .setWidth(0.5f) |
214 | .configText(new ConfigText() { | 215 | .configText(new ConfigText() { |
215 | @Override | 216 | @Override |
216 | public void onConfig(TextParams params) { | 217 | public void onConfig(TextParams params) { |
217 | params.gravity = Gravity.CENTER; | 218 | params.gravity = Gravity.CENTER; |
218 | params.padding = new int[]{50, 50, 50, 50}; | 219 | params.padding = new int[]{50, 50, 50, 50}; |
219 | } | 220 | } |
220 | }) | 221 | }) |
221 | .setText("当前无网络,请检查网络设置") | 222 | .setText("当前无网络,请检查网络设置") |
222 | .setNegative("继续使用", null) | 223 | .setNegative("继续使用", null) |
223 | .setPositive("设置网络", new View.OnClickListener() { | 224 | .setPositive("设置网络", new View.OnClickListener() { |
224 | @Override | 225 | @Override |
225 | public void onClick(View v) { | 226 | public void onClick(View v) { |
226 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 | 227 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 |
227 | mContext.startActivity(intent); | 228 | mContext.startActivity(intent); |
228 | } | 229 | } |
229 | }) | 230 | }) |
230 | .show(); | 231 | .show(); |
231 | } | 232 | } |
232 | }); | 233 | }); |
233 | } | 234 | } |
234 | 235 | ||
235 | 236 | ||
236 | //手机号是否注册 | 237 | //手机号是否注册 |
237 | public void isregistered(final String mobile, final Handler handler, final Context mContext) { | 238 | public void isregistered(final String mobile, final Handler handler, final Context mContext) { |
238 | RequestParams params = new RequestParams(); | 239 | RequestParams params = new RequestParams(); |
239 | params.put(HttpKey.USERNAME, mobile); | 240 | params.put(HttpKey.USERNAME, mobile); |
240 | HttpClient.getInstance().get(HttpUrl.isRegiterUrl + "?mobile=" + mobile, new JsonHttpResponseHandler() { | 241 | HttpClient.getInstance().get(HttpUrl.isRegiterUrl + "?mobile=" + mobile, new JsonHttpResponseHandler() { |
241 | @Override | 242 | @Override |
242 | public void onSuccess(int statusCode, Header[] headers, JSONObject response) { | 243 | public void onSuccess(int statusCode, Header[] headers, JSONObject response) { |
243 | Log.e("test", "isregistered" + response.toString()); | 244 | Log.e("test", "isregistered" + response.toString()); |
244 | Message msg = Message.obtain(); | 245 | Message msg = Message.obtain(); |
245 | msg.what = HttpCode.IS_REFISTER; | 246 | msg.what = HttpCode.IS_REFISTER; |
246 | msg.obj = response; | 247 | msg.obj = response; |
247 | handler.sendMessage(msg); | 248 | handler.sendMessage(msg); |
248 | 249 | ||
249 | } | 250 | } |
250 | 251 | ||
251 | @Override | 252 | @Override |
252 | public void onFailure(int statusCode, Header[] headers, Throwable throwable, JSONObject errorResponse) { | 253 | public void onFailure(int statusCode, Header[] headers, Throwable throwable, JSONObject errorResponse) { |
253 | new CircleDialog.Builder((FragmentActivity) mContext) | 254 | new CircleDialog.Builder((FragmentActivity) mContext) |
254 | .setCanceledOnTouchOutside(false) | 255 | .setCanceledOnTouchOutside(false) |
255 | .setCancelable(false) | 256 | .setCancelable(false) |
256 | .setWidth(0.5f) | 257 | .setWidth(0.5f) |
257 | .configText(new ConfigText() { | 258 | .configText(new ConfigText() { |
258 | @Override | 259 | @Override |
259 | public void onConfig(TextParams params) { | 260 | public void onConfig(TextParams params) { |
260 | params.gravity = Gravity.CENTER; | 261 | params.gravity = Gravity.CENTER; |
261 | params.padding = new int[]{50, 50, 50, 50}; | 262 | params.padding = new int[]{50, 50, 50, 50}; |
262 | } | 263 | } |
263 | }) | 264 | }) |
264 | .setText("当前无网络,请检查网络设置") | 265 | .setText("当前无网络,请检查网络设置") |
265 | .setNegative("继续使用", null) | 266 | .setNegative("继续使用", null) |
266 | .setPositive("设置网络", new View.OnClickListener() { | 267 | .setPositive("设置网络", new View.OnClickListener() { |
267 | @Override | 268 | @Override |
268 | public void onClick(View v) { | 269 | public void onClick(View v) { |
269 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 | 270 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 |
270 | mContext.startActivity(intent); | 271 | mContext.startActivity(intent); |
271 | } | 272 | } |
272 | }) | 273 | }) |
273 | .show(); | 274 | .show(); |
274 | 275 | ||
275 | } | 276 | } |
276 | }); | 277 | }); |
277 | } | 278 | } |
278 | 279 | ||
279 | //修改密码 | 280 | //修改密码 |
280 | public void changepwd(final Context context, String username, String old_pwd1, String newpassword3) { | 281 | public void changepwd(final Context context, String username, String old_pwd1, String newpassword3) { |
281 | RequestParams params = new RequestParams(); | 282 | RequestParams params = new RequestParams(); |
282 | params.put(HttpKey.USERNAME, username); | 283 | params.put(HttpKey.USERNAME, username); |
283 | params.put(HttpKey.OLDPASS, old_pwd1); | 284 | params.put(HttpKey.OLDPASS, old_pwd1); |
284 | params.put(HttpKey.NEWPASS, newpassword3); | 285 | params.put(HttpKey.NEWPASS, newpassword3); |
285 | HttpClient.getInstance().addHeader("Accept", "*/*"); | 286 | HttpClient.getInstance().addHeader("Accept", "*/*"); |
286 | HttpClient.getInstance().setTimeout(10 * 1000); | 287 | HttpClient.getInstance().setTimeout(10 * 1000); |
287 | HttpClient.getInstance().post(HttpUrl.changepassword, params, new AsyncHttpResponseHandler() { | 288 | HttpClient.getInstance().post(HttpUrl.changepassword, params, new AsyncHttpResponseHandler() { |
288 | @Override | 289 | @Override |
289 | public void onSuccess(int i, Header[] headers, byte[] bytes) { | 290 | public void onSuccess(int i, Header[] headers, byte[] bytes) { |
290 | try { | 291 | try { |
291 | JSONObject jsonObject = new JSONObject(new String(bytes)); | 292 | JSONObject jsonObject = new JSONObject(new String(bytes)); |
292 | String status = jsonObject.optString("status"); | 293 | String status = jsonObject.optString("status"); |
293 | if (status.equals("100")) { | 294 | if (status.equals("100")) { |
294 | Log.e("test", "onSuccess" + new String(bytes)); | 295 | Log.e("test", "onSuccess" + new String(bytes)); |
295 | Toast.makeText(context, "密码修改成功!", Toast.LENGTH_LONG).show(); | 296 | Toast.makeText(context, "密码修改成功!", Toast.LENGTH_LONG).show(); |
296 | SaveParam.getInstance().clearData((Activity) context); | 297 | SaveParam.getInstance().clearData((Activity) context); |
297 | Intent intent = new Intent(); | 298 | Intent intent = new Intent(); |
298 | intent.setClass(context, LoginAndRegisterActivity.class); | 299 | intent.setClass(context, LoginAndRegisterActivity.class); |
299 | ((Activity) context).startActivity(intent); | 300 | ((Activity) context).startActivity(intent); |
300 | ((Activity) context).finish(); | 301 | ((Activity) context).finish(); |
301 | } | 302 | } |
302 | } catch (JSONException e) { | 303 | } catch (JSONException e) { |
303 | e.printStackTrace(); | 304 | e.printStackTrace(); |
304 | } | 305 | } |
305 | } | 306 | } |
306 | 307 | ||
307 | @Override | 308 | @Override |
308 | public void onFailure(int i, Header[] headers, byte[] bytes, Throwable throwable) { | 309 | public void onFailure(int i, Header[] headers, byte[] bytes, Throwable throwable) { |
309 | Log.e("test", "onFailure" + new String(bytes)); | 310 | Log.e("test", "onFailure" + new String(bytes)); |
310 | new CircleDialog.Builder((FragmentActivity) context) | 311 | new CircleDialog.Builder((FragmentActivity) context) |
311 | .setCanceledOnTouchOutside(false) | 312 | .setCanceledOnTouchOutside(false) |
312 | .setCancelable(false) | 313 | .setCancelable(false) |
313 | .setWidth(0.5f) | 314 | .setWidth(0.5f) |
314 | .configText(new ConfigText() { | 315 | .configText(new ConfigText() { |
315 | @Override | 316 | @Override |
316 | public void onConfig(TextParams params) { | 317 | public void onConfig(TextParams params) { |
317 | params.gravity = Gravity.CENTER; | 318 | params.gravity = Gravity.CENTER; |
318 | params.padding = new int[]{50, 50, 50, 50}; | 319 | params.padding = new int[]{50, 50, 50, 50}; |
319 | } | 320 | } |
320 | }) | 321 | }) |
321 | .setText("当前无网络,请检查网络设置") | 322 | .setText("当前无网络,请检查网络设置") |
322 | .setNegative("继续使用", null) | 323 | .setNegative("继续使用", null) |
323 | .setPositive("设置网络", new View.OnClickListener() { | 324 | .setPositive("设置网络", new View.OnClickListener() { |
324 | @Override | 325 | @Override |
325 | public void onClick(View v) { | 326 | public void onClick(View v) { |
326 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 | 327 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 |
327 | context.startActivity(intent); | 328 | context.startActivity(intent); |
328 | } | 329 | } |
329 | }) | 330 | }) |
330 | .show(); | 331 | .show(); |
331 | } | 332 | } |
332 | }); | 333 | }); |
333 | 334 | ||
334 | } | 335 | } |
335 | 336 | ||
336 | //忘记密码 | 337 | //忘记密码 |
337 | public void forgetpassword(final Context context, String forot_pwd_phone1, String forot_pwd_pwd3, String forot_pwd_anthcode1, Handler handler) { | 338 | public void forgetpassword(final Context context, String forot_pwd_phone1, String forot_pwd_pwd3, String forot_pwd_anthcode1, Handler handler) { |
338 | RequestParams params = new RequestParams(); | 339 | RequestParams params = new RequestParams(); |
339 | params.put(HttpKey.USERNAME, forot_pwd_phone1); | 340 | params.put(HttpKey.USERNAME, forot_pwd_phone1); |
340 | params.put(HttpKey.PASSWORD, forot_pwd_pwd3); | 341 | params.put(HttpKey.PASSWORD, forot_pwd_pwd3); |
341 | params.put(HttpKey.AUTHCODE, forot_pwd_anthcode1); | 342 | params.put(HttpKey.AUTHCODE, forot_pwd_anthcode1); |
342 | HttpClient.getInstance().addHeader("Accept", "*/*"); | 343 | HttpClient.getInstance().addHeader("Accept", "*/*"); |
343 | HttpClient.getInstance().post(HttpUrl.forgetpassword, params, new AsyncHttpResponseHandler() { | 344 | HttpClient.getInstance().post(HttpUrl.forgetpassword, params, new AsyncHttpResponseHandler() { |
344 | @Override | 345 | @Override |
345 | public void onSuccess(int i, Header[] headers, byte[] bytes) { | 346 | public void onSuccess(int i, Header[] headers, byte[] bytes) { |
346 | try { | 347 | try { |
347 | JSONObject jsonObject = new JSONObject(new String(bytes)); | 348 | JSONObject jsonObject = new JSONObject(new String(bytes)); |
348 | String status = jsonObject.optString("status"); | 349 | String status = jsonObject.optString("status"); |
349 | if (status.equals("100")) { | 350 | if (status.equals("100")) { |
350 | Log.e("test", "onSuccess" + new String(bytes)); | 351 | Log.e("test", "onSuccess" + new String(bytes)); |
351 | Toast.makeText(context, "密码修改成功!", Toast.LENGTH_LONG).show(); | 352 | Toast.makeText(context, "密码修改成功!", Toast.LENGTH_LONG).show(); |
352 | ((Activity) context).finish(); | 353 | ((Activity) context).finish(); |
353 | } | 354 | } |
354 | } catch (JSONException e) { | 355 | } catch (JSONException e) { |
355 | e.printStackTrace(); | 356 | e.printStackTrace(); |
356 | } | 357 | } |
357 | } | 358 | } |
358 | 359 | ||
359 | @Override | 360 | @Override |
360 | public void onFailure(int i, Header[] headers, byte[] bytes, Throwable throwable) { | 361 | public void onFailure(int i, Header[] headers, byte[] bytes, Throwable throwable) { |
361 | Log.e("test", "onFailure" + new String(bytes)); | 362 | Log.e("test", "onFailure" + new String(bytes)); |
362 | new CircleDialog.Builder((FragmentActivity) context) | 363 | new CircleDialog.Builder((FragmentActivity) context) |
363 | .setCanceledOnTouchOutside(false) | 364 | .setCanceledOnTouchOutside(false) |
364 | .setCancelable(false) | 365 | .setCancelable(false) |
365 | .setWidth(0.5f) | 366 | .setWidth(0.5f) |
366 | .configText(new ConfigText() { | 367 | .configText(new ConfigText() { |
367 | @Override | 368 | @Override |
368 | public void onConfig(TextParams params) { | 369 | public void onConfig(TextParams params) { |
369 | params.gravity = Gravity.CENTER; | 370 | params.gravity = Gravity.CENTER; |
370 | params.padding = new int[]{50, 50, 50, 50}; | 371 | params.padding = new int[]{50, 50, 50, 50}; |
371 | } | 372 | } |
372 | }) | 373 | }) |
373 | .setText("当前无网络,请检查网络设置") | 374 | .setText("当前无网络,请检查网络设置") |
374 | .setNegative("继续使用", null) | 375 | .setNegative("继续使用", null) |
375 | .setPositive("设置网络", new View.OnClickListener() { | 376 | .setPositive("设置网络", new View.OnClickListener() { |
376 | @Override | 377 | @Override |
377 | public void onClick(View v) { | 378 | public void onClick(View v) { |
378 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 | 379 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 |
379 | context.startActivity(intent); | 380 | context.startActivity(intent); |
380 | } | 381 | } |
381 | }) | 382 | }) |
382 | .show(); | 383 | .show(); |
383 | } | 384 | } |
384 | }); | 385 | }); |
385 | 386 | ||
386 | } | 387 | } |
387 | 388 | ||
388 | //保存用户登录信息 | 389 | //保存用户登录信息 |
389 | public void saveLoginInfo(Context context, String username, String password, String access_token, String loginStatus, String userId) { | 390 | public void saveLoginInfo(Context context, String username, String password, String access_token, String loginStatus, String userId) { |
390 | SaveParam.getInstance().saveLoginParam(context, "username", username); | 391 | SaveParam.getInstance().saveLoginParam(context, "username", username); |
391 | SaveParam.getInstance().saveLoginParam(context, "password", password); | 392 | SaveParam.getInstance().saveLoginParam(context, "password", password); |
392 | SaveParam.getInstance().saveLoginParam(context, "access_token", access_token); | 393 | SaveParam.getInstance().saveLoginParam(context, "access_token", access_token); |
393 | SaveParam.getInstance().saveLoginParam(context, "login", loginStatus); | 394 | SaveParam.getInstance().saveLoginParam(context, "login", loginStatus); |
394 | SaveParam.getInstance().saveLoginParam(context, "userId", userId); | 395 | SaveParam.getInstance().saveLoginParam(context, "userId", userId); |
395 | 396 | ||
396 | 397 | ||
397 | } | 398 | } |
398 | 399 | ||
399 | //保存用户个人信息 | 400 | //保存用户个人信息 |
400 | public void savePresonInfo(Context context, String lastname, String gender, String mobilePortrait) { | 401 | public void savePresonInfo(Context context, String lastname, String gender, String mobilePortrait) { |
401 | SaveParam.getInstance().saveLoginParam(context, "lastname", lastname); | 402 | SaveParam.getInstance().saveLoginParam(context, "lastname", lastname); |
402 | SaveParam.getInstance().saveLoginParam(context, "gender", gender); | 403 | SaveParam.getInstance().saveLoginParam(context, "gender", gender); |
403 | SaveParam.getInstance().saveLoginParam(context, "mobilePortrait", mobilePortrait); | 404 | SaveParam.getInstance().saveLoginParam(context, "mobilePortrait", mobilePortrait); |
404 | } | 405 | } |
405 | 406 | ||
406 | //提交保卡信息 | 407 | //提交保卡信息 |
407 | public void subcardinfo(final Context context, int userId, String customerName, String customerAddress, | 408 | public void subcardinfo(final Context context, int userId, String customerName, String customerAddress, |
408 | String buyAddress, String buyTime, String alterSaleCall, | 409 | String buyAddress, String buyTime, String alterSaleCall, |
409 | String productModel, String deviceNumber, String macAddress, | 410 | String productModel, String deviceNumber, String macAddress, |
410 | String mobilePhone) { | 411 | String mobilePhone) { |
411 | mProgress = DialogPermission.showProgress(context, null, "正在绑定保卡...", | 412 | mProgress = DialogPermission.showProgress(context, null, "正在绑定保卡...", |
412 | false, true, null); | 413 | false, true, null); |
413 | RequestParams params = new RequestParams(); | 414 | RequestParams params = new RequestParams(); |
414 | 415 | ||
415 | params.put(HttpKey.USEID, userId); | 416 | params.put(HttpKey.USEID, userId); |
416 | params.put(HttpKey.CUSTOMENAME, customerName); | 417 | params.put(HttpKey.CUSTOMENAME, customerName); |
417 | params.put(HttpKey.CUSTOMADRESS, customerAddress); | 418 | params.put(HttpKey.CUSTOMADRESS, customerAddress); |
418 | params.put(HttpKey.BUYADREES, buyAddress); | 419 | params.put(HttpKey.BUYADREES, buyAddress); |
419 | params.put(HttpKey.BUYTIME, buyTime); | 420 | params.put(HttpKey.BUYTIME, buyTime); |
420 | params.put(HttpKey.ALTERSALECALL, alterSaleCall); | 421 | params.put(HttpKey.ALTERSALECALL, alterSaleCall); |
421 | params.put(HttpKey.PRODUCTMODEL, productModel); | 422 | params.put(HttpKey.PRODUCTMODEL, productModel); |
422 | params.put(HttpKey.DEVICENUMBER, deviceNumber); | 423 | params.put(HttpKey.DEVICENUMBER, deviceNumber); |
423 | params.put(HttpKey.MACADRESS, macAddress); | 424 | params.put(HttpKey.MACADRESS, macAddress); |
424 | params.put(HttpKey.MOBILPHONE, mobilePhone); | 425 | params.put(HttpKey.MOBILPHONE, mobilePhone); |
425 | 426 | ||
426 | HttpClient.getInstance().addHeader("Accept", "*/*"); | 427 | HttpClient.getInstance().addHeader("Accept", "*/*"); |
427 | 428 | ||
428 | Log.e("test", "params" + params); | 429 | Log.e("test", "params" + params); |
429 | HttpClient.getInstance().setTimeout(5 * 1000); | 430 | HttpClient.getInstance().setTimeout(5 * 1000); |
430 | HttpClient.getInstance().post(context, HttpUrl.subcardinfo, params, new AsyncHttpResponseHandler() { | 431 | HttpClient.getInstance().post(context, HttpUrl.subcardinfo, params, new AsyncHttpResponseHandler() { |
431 | @Override | 432 | @Override |
432 | public void onSuccess(int i, Header[] headers, byte[] bytes) { | 433 | public void onSuccess(int i, Header[] headers, byte[] bytes) { |
433 | JSONObject jsonObject = null; | 434 | JSONObject jsonObject = null; |
434 | closeProgress(); | 435 | closeProgress(); |
435 | try { | 436 | try { |
436 | jsonObject = new JSONObject(new String(bytes)); | 437 | jsonObject = new JSONObject(new String(bytes)); |
437 | String status = jsonObject.optString("status"); | 438 | String status = jsonObject.optString("status"); |
438 | if (status.equals("1")) { | 439 | if (status.equals("1")) { |
439 | Log.e("test", "onSuccess" + jsonObject); | 440 | Log.e("test", "onSuccess" + jsonObject); |
440 | Toast.makeText(context, "保卡绑定成功!", Toast.LENGTH_LONG).show(); | 441 | Toast.makeText(context, "保卡绑定成功!", Toast.LENGTH_LONG).show(); |
441 | Intent intent = new Intent(); | 442 | Intent intent = new Intent(); |
442 | intent.setClass((Activity) context, TheStartPageActivity.class); | 443 | intent.setClass((Activity) context, TheStartPageActivity.class); |
443 | ((Activity) context).startActivity(intent); | 444 | ((Activity) context).startActivity(intent); |
444 | ((Activity) context).overridePendingTransition(R.anim.rightin, R.anim.rightout); | 445 | ((Activity) context).overridePendingTransition(R.anim.rightin, R.anim.rightout); |
445 | ((Activity) context).finish(); | 446 | ((Activity) context).finish(); |
446 | } | 447 | } |
447 | } catch (JSONException e) { | 448 | } catch (JSONException e) { |
448 | e.printStackTrace(); | 449 | e.printStackTrace(); |
449 | } | 450 | } |
450 | 451 | ||
451 | 452 | ||
452 | } | 453 | } |
453 | 454 | ||
454 | @Override | 455 | @Override |
455 | public void onFailure(int i, Header[] headers, byte[] bytes, Throwable throwable) { | 456 | public void onFailure(int i, Header[] headers, byte[] bytes, Throwable throwable) { |
456 | Log.e("test", "onFailure" + (throwable)); | 457 | Log.e("test", "onFailure" + (throwable)); |
457 | closeProgress(); | 458 | closeProgress(); |
458 | new CircleDialog.Builder((FragmentActivity) context) | 459 | new CircleDialog.Builder((FragmentActivity) context) |
459 | .setCanceledOnTouchOutside(false) | 460 | .setCanceledOnTouchOutside(false) |
460 | .setCancelable(false) | 461 | .setCancelable(false) |
461 | .setWidth(0.5f) | 462 | .setWidth(0.5f) |
462 | .configText(new ConfigText() { | 463 | .configText(new ConfigText() { |
463 | @Override | 464 | @Override |
464 | public void onConfig(TextParams params) { | 465 | public void onConfig(TextParams params) { |
465 | params.gravity = Gravity.CENTER; | 466 | params.gravity = Gravity.CENTER; |
466 | params.padding = new int[]{50, 50, 50, 50}; | 467 | params.padding = new int[]{50, 50, 50, 50}; |
467 | } | 468 | } |
468 | }) | 469 | }) |
469 | .setText("当前无网络,请检查网络设置") | 470 | .setText("当前无网络,请检查网络设置") |
470 | .setNegative("继续使用", null) | 471 | .setNegative("继续使用", null) |
471 | .setPositive("设置网络", new View.OnClickListener() { | 472 | .setPositive("设置网络", new View.OnClickListener() { |
472 | @Override | 473 | @Override |
473 | public void onClick(View v) { | 474 | public void onClick(View v) { |
474 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 | 475 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 |
475 | context.startActivity(intent); | 476 | context.startActivity(intent); |
476 | } | 477 | } |
477 | }) | 478 | }) |
478 | .show(); | 479 | .show(); |
479 | 480 | ||
480 | } | 481 | } |
481 | }); | 482 | }); |
482 | 483 | ||
483 | } | 484 | } |
484 | //获取保卡信息 | 485 | //获取保卡信息 |
485 | public void getcardinfo(final Context mContext, int userId , final Handler handler) { | 486 | public void getcardinfo(final Context mContext, int userId , final Handler handler) { |
486 | mProgress = DialogPermission.showProgress(mContext, null, "正在获取保卡信息...", | 487 | mProgress = DialogPermission.showProgress(mContext, null, "正在获取保卡信息...", |
487 | false, true, null); | 488 | false, true, null); |
488 | HttpClient.getInstance().setTimeout(5 * 1000); | 489 | HttpClient.getInstance().setTimeout(5 * 1000); |
489 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); | 490 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); |
490 | HttpClient.getInstance().get(HttpUrl.getcardinfo+ "?userId=" + userId , new AsyncHttpResponseHandler() { | 491 | HttpClient.getInstance().get(HttpUrl.getcardinfo+ "?userId=" + userId , new AsyncHttpResponseHandler() { |
491 | @Override | 492 | @Override |
492 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { | 493 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { |
493 | closeProgress(); | 494 | closeProgress(); |
494 | Log.e("test", "省" + new String(arg2)); | 495 | Log.e("test", "省" + new String(arg2)); |
495 | Message msg = Message.obtain(); | 496 | Message msg = Message.obtain(); |
496 | msg.what = HttpCode.SUCHCARDINFO; | 497 | msg.what = HttpCode.SUCHCARDINFO; |
497 | msg.obj = new String(arg2); | 498 | msg.obj = new String(arg2); |
498 | handler.sendMessage(msg); | 499 | handler.sendMessage(msg); |
499 | } | 500 | } |
500 | 501 | ||
501 | @Override | 502 | @Override |
502 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { | 503 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { |
503 | closeProgress(); | 504 | closeProgress(); |
504 | new CircleDialog.Builder((FragmentActivity) mContext) | 505 | new CircleDialog.Builder((FragmentActivity) mContext) |
505 | .setCanceledOnTouchOutside(false) | 506 | .setCanceledOnTouchOutside(false) |
506 | .setCancelable(false) | 507 | .setCancelable(false) |
507 | .setWidth(0.5f) | 508 | .setWidth(0.5f) |
508 | .configText(new ConfigText() { | 509 | .configText(new ConfigText() { |
509 | @Override | 510 | @Override |
510 | public void onConfig(TextParams params) { | 511 | public void onConfig(TextParams params) { |
511 | params.gravity = Gravity.CENTER; | 512 | params.gravity = Gravity.CENTER; |
512 | params.padding = new int[]{50, 50, 50, 50}; | 513 | params.padding = new int[]{50, 50, 50, 50}; |
513 | } | 514 | } |
514 | }) | 515 | }) |
515 | .setText("当前无网络,请检查网络设置") | 516 | .setText("当前无网络,请检查网络设置") |
516 | .setNegative("继续使用", null) | 517 | .setNegative("继续使用", null) |
517 | .setPositive("设置网络", new View.OnClickListener() { | 518 | .setPositive("设置网络", new View.OnClickListener() { |
518 | @Override | 519 | @Override |
519 | public void onClick(View v) { | 520 | public void onClick(View v) { |
520 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 | 521 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 |
521 | mContext.startActivity(intent); | 522 | mContext.startActivity(intent); |
522 | } | 523 | } |
523 | }) | 524 | }) |
524 | .show(); | 525 | .show(); |
525 | } | 526 | } |
526 | }); | 527 | }); |
527 | } | 528 | } |
528 | //修改保卡信息电话 | 529 | //修改保卡信息电话 |
529 | public void changecardinfophone(final Context mContext, int userId, final String customerPhone, String authCode) { | 530 | public void changecardinfophone(final Context mContext, int userId, final String customerPhone, String authCode) { |
530 | RequestParams params = new RequestParams(); | 531 | RequestParams params = new RequestParams(); |
531 | params.put("userId", userId); | 532 | params.put("userId", userId); |
532 | params.put("customerPhone", customerPhone); | 533 | params.put("customerPhone", customerPhone); |
533 | params.put("authCode", authCode); | 534 | params.put("authCode", authCode); |
534 | HttpClient.getInstance().addHeader("Accept", "*/*"); | 535 | HttpClient.getInstance().addHeader("Accept", "*/*"); |
535 | HttpClient.getInstance().post(HttpUrl.changecardinfo, params, new AsyncHttpResponseHandler() { | 536 | HttpClient.getInstance().post(HttpUrl.changecardinfo, params, new AsyncHttpResponseHandler() { |
536 | @Override | 537 | @Override |
537 | public void onSuccess(int i, Header[] headers, byte[] bytes) { | 538 | public void onSuccess(int i, Header[] headers, byte[] bytes) { |
538 | try { | 539 | try { |
539 | JSONObject jsonObject = new JSONObject(new String(bytes)); | 540 | JSONObject jsonObject = new JSONObject(new String(bytes)); |
540 | String status = jsonObject.optString("status"); | 541 | String status = jsonObject.optString("status"); |
541 | if (status.equals("1")) { | 542 | if (status.equals("1")) { |
542 | Toast.makeText(mContext, "手机号修改成功", Toast.LENGTH_LONG).show(); | 543 | Toast.makeText(mContext, "手机号修改成功", Toast.LENGTH_LONG).show(); |
543 | SaveParam.getInstance().saveCustomizeParam(mContext,SaveParam.CARDPHONE, customerPhone); | 544 | SaveParam.getInstance().saveCustomizeParam(mContext,SaveParam.CARDPHONE, customerPhone); |
544 | ((Activity) mContext).finish(); | 545 | ((Activity) mContext).finish(); |
545 | }else if (status.equals("1001")){ | 546 | }else if (status.equals("1001")){ |
546 | Toast.makeText(mContext, "验证码输入错误", Toast.LENGTH_LONG).show(); | 547 | Toast.makeText(mContext, "验证码输入错误", Toast.LENGTH_LONG).show(); |
547 | } | 548 | } |
548 | } catch (JSONException e) { | 549 | } catch (JSONException e) { |
549 | e.printStackTrace(); | 550 | e.printStackTrace(); |
550 | } | 551 | } |
551 | } | 552 | } |
552 | 553 | ||
553 | @Override | 554 | @Override |
554 | public void onFailure(int i, Header[] headers, byte[] bytes, Throwable throwable) { | 555 | public void onFailure(int i, Header[] headers, byte[] bytes, Throwable throwable) { |
555 | Log.e("test", "onFailure" + new String(bytes)); | 556 | Log.e("test", "onFailure" + new String(bytes)); |
556 | new CircleDialog.Builder((FragmentActivity) mContext) | 557 | new CircleDialog.Builder((FragmentActivity) mContext) |
557 | .setCanceledOnTouchOutside(false) | 558 | .setCanceledOnTouchOutside(false) |
558 | .setCancelable(false) | 559 | .setCancelable(false) |
559 | .setWidth(0.5f) | 560 | .setWidth(0.5f) |
560 | .configText(new ConfigText() { | 561 | .configText(new ConfigText() { |
561 | @Override | 562 | @Override |
562 | public void onConfig(TextParams params) { | 563 | public void onConfig(TextParams params) { |
563 | params.gravity = Gravity.CENTER; | 564 | params.gravity = Gravity.CENTER; |
564 | params.padding = new int[]{50, 50, 50, 50}; | 565 | params.padding = new int[]{50, 50, 50, 50}; |
565 | } | 566 | } |
566 | }) | 567 | }) |
567 | .setText("当前无网络,请检查网络设置") | 568 | .setText("当前无网络,请检查网络设置") |
568 | .setNegative("继续使用", null) | 569 | .setNegative("继续使用", null) |
569 | .setPositive("设置网络", new View.OnClickListener() { | 570 | .setPositive("设置网络", new View.OnClickListener() { |
570 | @Override | 571 | @Override |
571 | public void onClick(View v) { | 572 | public void onClick(View v) { |
572 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 | 573 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 |
573 | mContext.startActivity(intent); | 574 | mContext.startActivity(intent); |
574 | } | 575 | } |
575 | }) | 576 | }) |
576 | .show(); | 577 | .show(); |
577 | } | 578 | } |
578 | }); | 579 | }); |
579 | } | 580 | } |
580 | //修改保卡信息地址 | 581 | //修改保卡信息地址 |
581 | public void changecardadressinfo(final Context mContext, int userId, final String customerPhone, String authCode, final String customerAddress) { | 582 | public void changecardadressinfo(final Context mContext, int userId, final String customerPhone, String authCode, final String customerAddress) { |
582 | RequestParams params = new RequestParams(); | 583 | RequestParams params = new RequestParams(); |
583 | params.put("userId", userId); | 584 | params.put("userId", userId); |
584 | params.put("customerPhone", customerPhone); | 585 | params.put("customerPhone", customerPhone); |
585 | params.put("authCode", authCode); | 586 | params.put("authCode", authCode); |
586 | params.put("customerAddress", customerAddress); | 587 | params.put("customerAddress", customerAddress); |
587 | HttpClient.getInstance().addHeader("Accept", "*/*"); | 588 | HttpClient.getInstance().addHeader("Accept", "*/*"); |
588 | HttpClient.getInstance().post(HttpUrl.changecardinfo, params, new AsyncHttpResponseHandler() { | 589 | HttpClient.getInstance().post(HttpUrl.changecardinfo, params, new AsyncHttpResponseHandler() { |
589 | @Override | 590 | @Override |
590 | public void onSuccess(int i, Header[] headers, byte[] bytes) { | 591 | public void onSuccess(int i, Header[] headers, byte[] bytes) { |
591 | try { | 592 | try { |
592 | JSONObject jsonObject = new JSONObject(new String(bytes)); | 593 | JSONObject jsonObject = new JSONObject(new String(bytes)); |
593 | String status = jsonObject.optString("status"); | 594 | String status = jsonObject.optString("status"); |
594 | if (status.equals("1")) { | 595 | if (status.equals("1")) { |
595 | Toast.makeText(mContext, "手机号修改成功", Toast.LENGTH_LONG).show(); | 596 | Toast.makeText(mContext, "手机号修改成功", Toast.LENGTH_LONG).show(); |
596 | SaveParam.getInstance().saveCustomizeParam(mContext,SaveParam.ADRESSCUNSTEM, customerAddress); | 597 | SaveParam.getInstance().saveCustomizeParam(mContext,SaveParam.ADRESSCUNSTEM, customerAddress); |
597 | ((Activity) mContext).finish(); | 598 | ((Activity) mContext).finish(); |
598 | } | 599 | } |
599 | } catch (JSONException e) { | 600 | } catch (JSONException e) { |
600 | e.printStackTrace(); | 601 | e.printStackTrace(); |
601 | } | 602 | } |
602 | } | 603 | } |
603 | 604 | ||
604 | @Override | 605 | @Override |
605 | public void onFailure(int i, Header[] headers, byte[] bytes, Throwable throwable) { | 606 | public void onFailure(int i, Header[] headers, byte[] bytes, Throwable throwable) { |
606 | Log.e("test", "onFailure" + new String(bytes)); | 607 | Log.e("test", "onFailure" + new String(bytes)); |
607 | new CircleDialog.Builder((FragmentActivity) mContext) | 608 | new CircleDialog.Builder((FragmentActivity) mContext) |
608 | .setCanceledOnTouchOutside(false) | 609 | .setCanceledOnTouchOutside(false) |
609 | .setCancelable(false) | 610 | .setCancelable(false) |
610 | .setWidth(0.5f) | 611 | .setWidth(0.5f) |
611 | .configText(new ConfigText() { | 612 | .configText(new ConfigText() { |
612 | @Override | 613 | @Override |
613 | public void onConfig(TextParams params) { | 614 | public void onConfig(TextParams params) { |
614 | params.gravity = Gravity.CENTER; | 615 | params.gravity = Gravity.CENTER; |
615 | params.padding = new int[]{50, 50, 50, 50}; | 616 | params.padding = new int[]{50, 50, 50, 50}; |
616 | } | 617 | } |
617 | }) | 618 | }) |
618 | .setText("当前无网络,请检查网络设置") | 619 | .setText("当前无网络,请检查网络设置") |
619 | .setNegative("继续使用", null) | 620 | .setNegative("继续使用", null) |
620 | .setPositive("设置网络", new View.OnClickListener() { | 621 | .setPositive("设置网络", new View.OnClickListener() { |
621 | @Override | 622 | @Override |
622 | public void onClick(View v) { | 623 | public void onClick(View v) { |
623 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 | 624 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 |
624 | mContext.startActivity(intent); | 625 | mContext.startActivity(intent); |
625 | } | 626 | } |
626 | }) | 627 | }) |
627 | .show(); | 628 | .show(); |
628 | } | 629 | } |
629 | }); | 630 | }); |
630 | } | 631 | } |
631 | //验证是否保卡信息 | 632 | //验证是否保卡信息 |
632 | public void cardinfocheck(final Context mContext, int userId, final Handler handler) { | 633 | public void cardinfocheck(final Context mContext, int userId, final Handler handler) { |
633 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); | 634 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); |
634 | HttpClient.getInstance().get(HttpUrl.cardcheck+ "?userId=" + userId, new AsyncHttpResponseHandler() { | 635 | HttpClient.getInstance().get(HttpUrl.cardcheck+ "?userId=" + userId, new AsyncHttpResponseHandler() { |
635 | @Override | 636 | @Override |
636 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { | 637 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { |
637 | Log.e("test", "---" + new String(arg2)); | 638 | Log.e("test", "---" + new String(arg2)); |
638 | Message msg = Message.obtain(); | 639 | Message msg = Message.obtain(); |
639 | msg.what = HttpCode.CHECKCARD; | 640 | msg.what = HttpCode.CHECKCARD; |
640 | msg.obj = new String(arg2); | 641 | msg.obj = new String(arg2); |
641 | handler.sendMessage(msg); | 642 | handler.sendMessage(msg); |
642 | } | 643 | } |
643 | 644 | ||
644 | @Override | 645 | @Override |
645 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { | 646 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { |
646 | new CircleDialog.Builder((FragmentActivity) mContext) | 647 | new CircleDialog.Builder((FragmentActivity) mContext) |
647 | .setCanceledOnTouchOutside(false) | 648 | .setCanceledOnTouchOutside(false) |
648 | .setCancelable(false) | 649 | .setCancelable(false) |
649 | .configText(new ConfigText() { | 650 | .configText(new ConfigText() { |
650 | @Override | 651 | @Override |
651 | public void onConfig(TextParams params) { | 652 | public void onConfig(TextParams params) { |
652 | params.gravity = Gravity.CENTER; | 653 | params.gravity = Gravity.CENTER; |
653 | params.padding = new int[]{250, 50, 250, 50}; | 654 | params.padding = new int[]{250, 50, 250, 50}; |
654 | } | 655 | } |
655 | }) | 656 | }) |
656 | .setText("当前无网络,请检查网络设置") | 657 | .setText("当前无网络,请检查网络设置") |
657 | .setNegative("取消", null) | 658 | .setNegative("取消", null) |
658 | .setPositive("确定", new View.OnClickListener() { | 659 | .setPositive("确定", new View.OnClickListener() { |
659 | @Override | 660 | @Override |
660 | public void onClick(View v) { | 661 | public void onClick(View v) { |
661 | Intent intent = new Intent("/"); | 662 | Intent intent = new Intent("/"); |
662 | ComponentName cm = new ComponentName("com.android.settings","com.android.settings.WirelessSettings"); | 663 | ComponentName cm = new ComponentName("com.android.settings","com.android.settings.WirelessSettings"); |
663 | intent.setComponent(cm); | 664 | intent.setComponent(cm); |
664 | intent.setAction("android.intent.action.VIEW"); | 665 | intent.setAction("android.intent.action.VIEW"); |
665 | ((Activity) mContext).startActivityForResult( intent , 0); | 666 | ((Activity) mContext).startActivityForResult( intent , 0); |
666 | } | 667 | } |
667 | }) | 668 | }) |
668 | .show(); | 669 | .show(); |
669 | //Toast.makeText(mContext, "请检查网络。。" + arg3, Toast.LENGTH_LONG).show(); | 670 | //Toast.makeText(mContext, "请检查网络。。" + arg3, Toast.LENGTH_LONG).show(); |
670 | } | 671 | } |
671 | }); | 672 | }); |
672 | } | 673 | } |
673 | 674 | ||
674 | ///获取年级 | 675 | ///获取年级 |
675 | public void getgrade(final Context mContext) { | 676 | public void getgrade(final Context mContext) { |
676 | HttpClient.getInstance().addHeader("Accept", "application/json"); | 677 | HttpClient.getInstance().addHeader("Accept", "application/json"); |
677 | HttpClient.getInstance().get(HttpUrl.gradesUrl, new AsyncHttpResponseHandler() { | 678 | HttpClient.getInstance().get(HttpUrl.gradesUrl, new AsyncHttpResponseHandler() { |
678 | @Override | 679 | @Override |
679 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { | 680 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { |
680 | Log.e("test", "年级" + new String(arg2)); | 681 | Log.e("test", "年级" + new String(arg2)); |
681 | GradeInfo gradensInfo = GsonTool.getPerson(new String(arg2), GradeInfo.class);//解析json数据 | 682 | GradeInfo gradensInfo = GsonTool.getPerson(new String(arg2), GradeInfo.class);//解析json数据 |
682 | StringBuffer sb = new StringBuffer(); | 683 | StringBuffer sb = new StringBuffer(); |
683 | for (int i = 0; i < gradensInfo.getData().size(); i++) { | 684 | for (int i = 0; i < gradensInfo.getData().size(); i++) { |
684 | sb.append(gradensInfo.getData().get(i).getName() + ","); | 685 | sb.append(gradensInfo.getData().get(i).getName() + ","); |
685 | 686 | ||
686 | } | 687 | } |
687 | Log.e("test", "年级" + sb.toString()); | 688 | Log.e("test", "年级" + sb.toString()); |
688 | SaveParam.getInstance().saveLoginParam(mContext, SaveParam.GRADENS, "" + sb.toString()); | 689 | SaveParam.getInstance().saveLoginParam(mContext, SaveParam.GRADENS, "" + sb.toString()); |
689 | 690 | ||
690 | 691 | ||
691 | } | 692 | } |
692 | 693 | ||
693 | @Override | 694 | @Override |
694 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { | 695 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { |
695 | new CircleDialog.Builder((FragmentActivity) mContext) | 696 | new CircleDialog.Builder((FragmentActivity) mContext) |
696 | .setCanceledOnTouchOutside(false) | 697 | .setCanceledOnTouchOutside(false) |
697 | .setCancelable(false) | 698 | .setCancelable(false) |
698 | .setWidth(0.5f) | 699 | .setWidth(0.5f) |
699 | .configText(new ConfigText() { | 700 | .configText(new ConfigText() { |
700 | @Override | 701 | @Override |
701 | public void onConfig(TextParams params) { | 702 | public void onConfig(TextParams params) { |
702 | params.gravity = Gravity.CENTER; | 703 | params.gravity = Gravity.CENTER; |
703 | params.padding = new int[]{50, 50, 50, 50}; | 704 | params.padding = new int[]{50, 50, 50, 50}; |
704 | } | 705 | } |
705 | }) | 706 | }) |
706 | .setText("当前无网络,请检查网络设置") | 707 | .setText("当前无网络,请检查网络设置") |
707 | .setNegative("继续使用", null) | 708 | .setNegative("继续使用", null) |
708 | .setPositive("设置网络", new View.OnClickListener() { | 709 | .setPositive("设置网络", new View.OnClickListener() { |
709 | @Override | 710 | @Override |
710 | public void onClick(View v) { | 711 | public void onClick(View v) { |
711 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 | 712 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 |
712 | mContext.startActivity(intent); | 713 | mContext.startActivity(intent); |
713 | } | 714 | } |
714 | }) | 715 | }) |
715 | .show(); | 716 | .show(); |
716 | } | 717 | } |
717 | }); | 718 | }); |
718 | } | 719 | } |
719 | ///获取学校 | 720 | ///获取学校 |
720 | public void getschool(final Context mContext,int regionId,int gradeId) { | 721 | public void getschool(final Context mContext, int regionId, int gradeId, final Handler handler) { |
721 | HttpClient.getInstance().addHeader("Accept", "application/json"); | 722 | HttpClient.getInstance().addHeader("Accept", "application/json"); |
722 | HttpClient.getInstance().get(HttpUrl.schoolUrl+ "?regionId=" + regionId+ "&gradeId=" + gradeId, new AsyncHttpResponseHandler() { | 723 | HttpClient.getInstance().get(HttpUrl.schoolUrl+ "?regionId=" + regionId+ "&gradeId=" + gradeId, new AsyncHttpResponseHandler() { |
723 | @Override | 724 | @Override |
724 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { | 725 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { |
725 | Log.e("test", "学校" + new String(arg2)); | 726 | Log.e("test", "学校" + new String(arg2)); |
726 | SchoolInfo schoolInfo = GsonTool.getPerson(new String(arg2), SchoolInfo.class);//解析json数据 | 727 | SchoolInfo schoolInfo = GsonTool.getPerson(new String(arg2), SchoolInfo.class);//解析json数据 |
727 | StringBuffer sb = new StringBuffer(); | 728 | List<SchoolInfo.DataBean> schoolInfoBeanList = schoolInfo.getData(); |
728 | for (int i = 0; i < schoolInfo.getData().size(); i++) { | 729 | Message message = Message.obtain(); |
729 | sb.append(schoolInfo.getData().get(i).getSchoolName() + ","); | 730 | message.what = HttpCode.SCHOOL; |
730 | 731 | message.obj = schoolInfoBeanList; | |
731 | } | 732 | handler.sendMessage(message); |
732 | Log.e("test", "学校" + sb.toString()); | ||
733 | SaveParam.getInstance().saveLoginParam(mContext, SaveParam.SCHOOL, "" + sb.toString()); | ||
734 | |||
735 | 733 | ||
736 | } | 734 | } |
737 | 735 | ||
738 | @Override | 736 | @Override |
739 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { | 737 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { |
740 | new CircleDialog.Builder((FragmentActivity) mContext) | 738 | new CircleDialog.Builder((FragmentActivity) mContext) |
741 | .setCanceledOnTouchOutside(false) | 739 | .setCanceledOnTouchOutside(false) |
742 | .setCancelable(false) | 740 | .setCancelable(false) |
743 | .setWidth(0.5f) | 741 | .setWidth(0.5f) |
744 | .configText(new ConfigText() { | 742 | .configText(new ConfigText() { |
745 | @Override | 743 | @Override |
746 | public void onConfig(TextParams params) { | 744 | public void onConfig(TextParams params) { |
747 | params.gravity = Gravity.CENTER; | 745 | params.gravity = Gravity.CENTER; |
748 | params.padding = new int[]{50, 50, 50, 50}; | 746 | params.padding = new int[]{50, 50, 50, 50}; |
749 | } | 747 | } |
750 | }) | 748 | }) |
751 | .setText("当前无网络,请检查网络设置") | 749 | .setText("当前无网络,请检查网络设置") |
752 | .setNegative("继续使用", null) | 750 | .setNegative("继续使用", null) |
753 | .setPositive("设置网络", new View.OnClickListener() { | 751 | .setPositive("设置网络", new View.OnClickListener() { |
754 | @Override | 752 | @Override |
755 | public void onClick(View v) { | 753 | public void onClick(View v) { |
756 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 | 754 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 |
757 | mContext.startActivity(intent); | 755 | mContext.startActivity(intent); |
758 | } | 756 | } |
759 | }) | 757 | }) |
760 | .show(); | 758 | .show(); |
761 | } | 759 | } |
762 | }); | 760 | }); |
763 | } | 761 | } |
764 | 762 | ||
765 | 763 | ||
766 | 764 | ||
767 | 765 | ||
768 | 766 | ||
769 | ///省级接口 | 767 | ///省级接口 |
770 | public void provices(final Context mContext) { | 768 | public void provices(final Context mContext, final Handler handler) { |
771 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); | 769 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); |
772 | HttpClient.getInstance().get(HttpUrl.provinceUrl, new AsyncHttpResponseHandler() { | 770 | HttpClient.getInstance().get(HttpUrl.provinceUrl, new AsyncHttpResponseHandler() { |
773 | @Override | 771 | @Override |
774 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { | 772 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { |
775 | Log.e("test", "省" + new String(arg2)); | 773 | Log.e("test", "省" + new String(arg2)); |
776 | ProvinceInfo provinceInfo = GsonTool.getPerson(new String(arg2), ProvinceInfo.class);//解析json数据 | 774 | ProvinceInfo provinceInfo = GsonTool.getPerson(new String(arg2), ProvinceInfo.class);//解析json数据 |
777 | Log.e("test", "状态码" + provinceInfo.getStatus()); | 775 | Log.e("test", "状态码" + provinceInfo.getStatus()); |
778 | StringBuffer sb = new StringBuffer(); | 776 | List<ProvinceInfo.ProvincesBean> provincesBeanList = provinceInfo.getProvinces(); |
779 | for (int i = 0; i < provinceInfo.getProvinces().size(); i++) { | 777 | Message message = Message.obtain(); |
780 | sb.append(provinceInfo.getProvinces().get(i).getRegionName() + ","); | 778 | message.what = HttpCode.PROVICES; |
781 | 779 | message.obj = provincesBeanList; | |
782 | } | 780 | handler.sendMessage(message); |
783 | Log.e("test", "省" + sb.toString()); | ||
784 | SaveParam.getInstance().saveLoginParam(mContext, SaveParam.PROVINCES, "" + sb.toString()); | ||
785 | |||
786 | 781 | ||
787 | } | 782 | } |
788 | 783 | ||
789 | @Override | 784 | @Override |
790 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { | 785 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { |
791 | new CircleDialog.Builder((FragmentActivity) mContext) | 786 | new CircleDialog.Builder((FragmentActivity) mContext) |
792 | .setCanceledOnTouchOutside(false) | 787 | .setCanceledOnTouchOutside(false) |
793 | .setCancelable(false) | 788 | .setCancelable(false) |
794 | .setWidth(0.5f) | 789 | .setWidth(0.5f) |
795 | .configText(new ConfigText() { | 790 | .configText(new ConfigText() { |
796 | @Override | 791 | @Override |
797 | public void onConfig(TextParams params) { | 792 | public void onConfig(TextParams params) { |
798 | params.gravity = Gravity.CENTER; | 793 | params.gravity = Gravity.CENTER; |
799 | params.padding = new int[]{50, 50, 50, 50}; | 794 | params.padding = new int[]{50, 50, 50, 50}; |
800 | } | 795 | } |
801 | }) | 796 | }) |
802 | .setText("当前无网络,请检查网络设置") | 797 | .setText("当前无网络,请检查网络设置") |
803 | .setNegative("继续使用", null) | 798 | .setNegative("继续使用", null) |
804 | .setPositive("设置网络", new View.OnClickListener() { | 799 | .setPositive("设置网络", new View.OnClickListener() { |
805 | @Override | 800 | @Override |
806 | public void onClick(View v) { | 801 | public void onClick(View v) { |
807 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 | 802 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 |
808 | mContext.startActivity(intent); | 803 | mContext.startActivity(intent); |
809 | } | 804 | } |
810 | }) | 805 | }) |
811 | .show(); | 806 | .show(); |
812 | } | 807 | } |
813 | }); | 808 | }); |
814 | } | 809 | } |
815 | 810 | ||
816 | //市级接口 | 811 | //市级接口 |
817 | public void cityinfo(final Context mContext, int regionId) { | 812 | public void cityinfo(final Context mContext, int regionId , final Handler handler) { |
818 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); | 813 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); |
819 | HttpClient.getInstance().get(HttpUrl.cityUrl + "?regionId=" + regionId, new AsyncHttpResponseHandler() { | 814 | HttpClient.getInstance().get(HttpUrl.cityUrl + "?regionId=" + regionId, new AsyncHttpResponseHandler() { |
820 | @Override | 815 | @Override |
821 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { | 816 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { |
822 | Log.e("test", "市" + new String(arg2)); | 817 | Log.e("test", "市" + new String(arg2)); |
823 | Gson gson = new Gson(); | 818 | Gson gson = new Gson(); |
824 | CityInfo cityInfo = gson.fromJson(new String(arg2), CityInfo.class); | 819 | CityInfo cityInfo = gson.fromJson(new String(arg2), CityInfo.class); |
825 | for (int i = 0; i < cityInfo.getCities().size(); i++) { | 820 | List<CityInfo.CitiesBean> cityInfoBeanList = cityInfo.getCities(); |
826 | Log.e("test", "市" + cityInfo.getCities().get(i) | 821 | Message message = Message.obtain(); |
827 | .getParentId()); | 822 | message.what = HttpCode.CITYS; |
828 | Log.e("test", "市" + cityInfo.getCities().get(i) | 823 | message.obj = cityInfoBeanList; |
829 | .getRegionId()); | 824 | handler.sendMessage(message); |
830 | Log.e("test", "市" + cityInfo.getCities().get(i).getRegionName() + ""); | ||
831 | |||
832 | } | ||
833 | 825 | ||
834 | 826 | ||
835 | } | 827 | } |
836 | 828 | ||
837 | @Override | 829 | @Override |
838 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { | 830 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { |
839 | new CircleDialog.Builder((FragmentActivity) mContext) | 831 | new CircleDialog.Builder((FragmentActivity) mContext) |
840 | .setCanceledOnTouchOutside(false) | 832 | .setCanceledOnTouchOutside(false) |
841 | .setCancelable(false) | 833 | .setCancelable(false) |
842 | .setWidth(0.5f) | 834 | .setWidth(0.5f) |
843 | .configText(new ConfigText() { | 835 | .configText(new ConfigText() { |
844 | @Override | 836 | @Override |
845 | public void onConfig(TextParams params) { | 837 | public void onConfig(TextParams params) { |
846 | params.gravity = Gravity.CENTER; | 838 | params.gravity = Gravity.CENTER; |
847 | params.padding = new int[]{50, 50, 50, 50}; | 839 | params.padding = new int[]{50, 50, 50, 50}; |
848 | } | 840 | } |
849 | }) | 841 | }) |
850 | .setText("当前无网络,请检查网络设置") | 842 | .setText("当前无网络,请检查网络设置") |
851 | .setNegative("继续使用", null) | 843 | .setNegative("继续使用", null) |
852 | .setPositive("设置网络", new View.OnClickListener() { | 844 | .setPositive("设置网络", new View.OnClickListener() { |
853 | @Override | 845 | @Override |
854 | public void onClick(View v) { | 846 | public void onClick(View v) { |
855 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 | 847 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 |
856 | mContext.startActivity(intent); | 848 | mContext.startActivity(intent); |
857 | } | 849 | } |
858 | }) | 850 | }) |
859 | .show(); | 851 | .show(); |
860 | } | 852 | } |
861 | }); | 853 | }); |
862 | } | 854 | } |
863 | 855 | ||
864 | //区县级接口 | 856 | //区县级接口 |
865 | public void countyinfo(final Context mContext, int parentId) { | 857 | public void countyinfo(final Context mContext, int parentId, final Handler handler) { |
866 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); | 858 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); |
867 | HttpClient.getInstance().get(HttpUrl.countyUrl + "?regionId=" + parentId, new AsyncHttpResponseHandler() { | 859 | HttpClient.getInstance().get(HttpUrl.countyUrl + "?regionId=" + parentId, new AsyncHttpResponseHandler() { |
868 | @Override | 860 | @Override |
869 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { | 861 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { |
870 | Log.e("test", "区" + new String(arg2)); | 862 | Log.e("test", "区" + new String(arg2)); |
871 | Gson gson = new Gson(); | 863 | Gson gson = new Gson(); |
872 | CountyInfo countyInfo = gson.fromJson(new String(arg2), CountyInfo.class); | 864 | CountyInfo countyInfo = gson.fromJson(new String(arg2), CountyInfo.class); |
873 | for (int i = 0; i < countyInfo.getCounties().size(); i++) { | 865 | List<CountyInfo.CountiesBean> countyInfoInfoBeanList = countyInfo.getCounties(); |
874 | Log.e("test", "区" + countyInfo.getCounties().get(i) | 866 | Message message = Message.obtain(); |
875 | .getParentId()); | 867 | message.what = HttpCode.COUNTRY; |
876 | Log.e("test", "区" + countyInfo.getCounties().get(i) | 868 | message.obj = countyInfoInfoBeanList; |
877 | .getRegionId()); | 869 | handler.sendMessage(message); |
878 | Log.e("test", "区" + countyInfo.getCounties().get(i).getRegionName() + ""); | ||
879 | |||
880 | } | ||
881 | 870 | ||
882 | 871 | ||
883 | } | 872 | } |
884 | 873 | ||
885 | @Override | 874 | @Override |
886 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { | 875 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { |
887 | new CircleDialog.Builder((FragmentActivity) mContext) | 876 | new CircleDialog.Builder((FragmentActivity) mContext) |
888 | .setCanceledOnTouchOutside(false) | 877 | .setCanceledOnTouchOutside(false) |
889 | .setCancelable(false) | 878 | .setCancelable(false) |
890 | .setWidth(0.5f) | 879 | .setWidth(0.5f) |
891 | .configText(new ConfigText() { | 880 | .configText(new ConfigText() { |
892 | @Override | 881 | @Override |
893 | public void onConfig(TextParams params) { | 882 | public void onConfig(TextParams params) { |
894 | params.gravity = Gravity.CENTER; | 883 | params.gravity = Gravity.CENTER; |
895 | params.padding = new int[]{50, 50, 50, 50}; | 884 | params.padding = new int[]{50, 50, 50, 50}; |
896 | } | 885 | } |
897 | }) | 886 | }) |
898 | .setText("当前无网络,请检查网络设置") | 887 | .setText("当前无网络,请检查网络设置") |
899 | .setNegative("继续使用", null) | 888 | .setNegative("继续使用", null) |
900 | .setPositive("设置网络", new View.OnClickListener() { | 889 | .setPositive("设置网络", new View.OnClickListener() { |
901 | @Override | 890 | @Override |
902 | public void onClick(View v) { | 891 | public void onClick(View v) { |
903 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 | 892 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 |
904 | mContext.startActivity(intent); | 893 | mContext.startActivity(intent); |
905 | } | 894 | } |
906 | }) | 895 | }) |
907 | .show(); | 896 | .show(); |
908 | } | 897 | } |
909 | }); | 898 | }); |
910 | } | 899 | } |
911 | 900 | ||
912 | 901 | ||
913 | private void closeProgress() { | 902 | private void closeProgress() { |
914 | try { | 903 | try { |
915 | if (mProgress != null) { | 904 | if (mProgress != null) { |
916 | mProgress.dismiss(); | 905 | mProgress.dismiss(); |
917 | mProgress = null; | 906 | mProgress = null; |
918 | } | 907 | } |
919 | } catch (Exception e) { | 908 | } catch (Exception e) { |
920 | e.printStackTrace(); | 909 | e.printStackTrace(); |
921 | } | 910 | } |
922 | } | 911 | } |
923 | 912 | ||
924 | } | 913 | } |
PersonalCenter/app/src/main/java/com/hjx/personalcenter/interfaces/DialogCallBack.java
1 | package com.hjx.personalcenter.interfaces; | 1 | package com.hjx.personalcenter.interfaces; |
2 | 2 | ||
3 | import android.content.Context; | 3 | import android.content.Context; |
4 | import android.view.LayoutInflater; | 4 | import android.view.LayoutInflater; |
5 | import android.view.View; | 5 | import android.view.View; |
6 | import android.view.ViewGroup; | 6 | import android.view.ViewGroup; |
7 | import android.widget.AdapterView; | 7 | import android.widget.AdapterView; |
8 | 8 | ||
9 | /** | 9 | /** |
10 | * Created by wei on 2017/8/17. | 10 | * Created by wei on 2017/8/17. |
11 | */ | 11 | */ |
12 | 12 | ||
13 | public class DialogCallBack { | 13 | public class DialogCallBack { |
14 | public interface CallBack{ | 14 | public interface CallBack{ |
15 | void provinceOnItemClick(AdapterView<?> parent, View view, int position, long id); | 15 | void provinceOnItemClick(AdapterView<?> parent, View view, int position, long id,int type); |
16 | } | 16 | } |
17 | public interface CallBackView{ | 17 | public interface CallBackView{ |
18 | void provinceOnItemClick(Context context, LayoutInflater inflater, ViewGroup container); | 18 | void provinceOnItemClick(Context context, LayoutInflater inflater, ViewGroup container); |
19 | } | 19 | } |
20 | } | 20 | } |
21 | 21 |