Commit d40389f8d60faa6ee69f88487bd77b85ddbc5a06
1 parent
5750ce3862
Exists in
master
优化和注册信息检查接口调试
Showing
30 changed files
with
688 additions
and
685 deletions
Show diff stats
PersonalCenter/app/build.gradle
1 | apply plugin: 'com.android.application' | 1 | apply plugin: 'com.android.application' |
2 | 2 | ||
3 | android { | 3 | android { |
4 | compileSdkVersion 25 | 4 | compileSdkVersion 25 |
5 | buildToolsVersion "25.0.3" | 5 | buildToolsVersion "25.0.3" |
6 | defaultConfig { | 6 | defaultConfig { |
7 | applicationId "com.hjx.personalcenter" | 7 | applicationId "com.hjx.personalcenter" |
8 | minSdkVersion 15 | 8 | minSdkVersion 15 |
9 | targetSdkVersion 25 | 9 | targetSdkVersion 25 |
10 | versionCode 1 | 10 | versionCode 1 |
11 | versionName "1.0.0" | 11 | versionName "1.0.0" |
12 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" | 12 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" |
13 | } | 13 | } |
14 | buildTypes { | 14 | buildTypes { |
15 | release { | 15 | release { |
16 | minifyEnabled false | 16 | minifyEnabled false |
17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' | 17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' |
18 | } | 18 | } |
19 | } | 19 | } |
20 | useLibrary 'org.apache.http.legacy' | 20 | useLibrary 'org.apache.http.legacy' |
21 | sourceSets { | 21 | sourceSets { |
22 | main { | 22 | main { |
23 | jniLibs.srcDirs = ['libs'] | 23 | jniLibs.srcDirs = ['libs'] |
24 | } | 24 | } |
25 | } | 25 | } |
26 | } | 26 | } |
27 | 27 | ||
28 | dependencies { | 28 | dependencies { |
29 | compile fileTree(include: ['*.jar'], dir: 'libs') | 29 | compile fileTree(include: ['*.jar'], dir: 'libs') |
30 | androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { | 30 | androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { |
31 | exclude group: 'com.android.support', module: 'support-annotations' | 31 | exclude group: 'com.android.support', module: 'support-annotations' |
32 | }) | 32 | }) |
33 | compile 'com.tencent.bugly:crashreport:latest.release' | 33 | compile 'com.tencent.bugly:crashreport:latest.release' |
34 | compile 'org.apache.httpcomponents:httpcore:4.4.1' | 34 | compile 'org.apache.httpcomponents:httpcore:4.4.1' |
35 | compile 'org.apache.httpcomponents:httpclient:4.5' | 35 | compile 'org.apache.httpcomponents:httpclient:4.5' |
36 | compile 'com.android.support:appcompat-v7:25.3.1' | 36 | compile 'com.android.support:appcompat-v7:25.3.1' |
37 | testCompile 'junit:junit:4.12' | 37 | testCompile 'junit:junit:4.12' |
38 | compile project(':circledialog') | 38 | compile project(':circledialog') |
39 | compile project(':pickerview') | 39 | compile project(':pickerview') |
40 | compile files('libs/android-async-http-1.4.8.jar') | 40 | compile files('libs/android-async-http-1.4.8.jar') |
41 | compile 'com.google.code.gson:gson:2.7' | 41 | compile 'com.google.code.gson:gson:2.7' |
42 | compile 'com.zaaach:toprightmenu:1.0' | 42 | compile 'com.zaaach:toprightmenu:1.0' |
43 | compile 'com.facebook.fresco:fresco:1.1.0' | 43 | compile 'com.facebook.fresco:fresco:1.1.0' |
44 | compile 'com.android.support:recyclerview-v7:25.+' | 44 | compile 'com.android.support:recyclerview-v7:25.+' |
45 | debugCompile 'com.squareup.leakcanary:leakcanary-android:1.3' | 45 | debugCompile 'com.squareup.leakcanary:leakcanary-android:1.3' |
46 | releaseCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.3' | 46 | releaseCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.3' |
47 | compile 'com.google.zxing:core:3.3.0' | 47 | compile 'com.google.zxing:core:3.3.0' |
48 | compile 'com.google.zxing:android-core:3.3.0' | 48 | compile 'com.google.zxing:android-core:3.3.0' |
49 | compile project(':mypresonallibrary') | 49 | compile project(path: ':mypresonallibrary') |
50 | } | 50 | } |
51 | 51 |
PersonalCenter/app/src/main/java/com/hjx/personalcenter/activity/LoginAndRegisterActivity.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.provider.Settings; | ||
5 | import android.support.annotation.Nullable; | 6 | import android.support.annotation.Nullable; |
6 | import android.support.v4.app.Fragment; | 7 | import android.support.v4.app.Fragment; |
7 | import android.support.v4.view.ViewPager; | 8 | import android.support.v4.view.ViewPager; |
8 | import android.support.v7.app.AppCompatActivity; | 9 | import android.support.v7.app.AppCompatActivity; |
10 | import android.view.Gravity; | ||
11 | import android.view.View; | ||
9 | 12 | ||
10 | import com.hjx.personalcenter.R; | 13 | import com.hjx.personalcenter.R; |
11 | import com.hjx.personalcenter.adapter.LoginAndRegisterAdapter; | 14 | import com.hjx.personalcenter.adapter.LoginAndRegisterAdapter; |
12 | import com.hjx.personalcenter.db.SaveParam; | 15 | import com.hjx.personalcenter.db.SaveParam; |
13 | import com.hjx.personalcenter.fragment.RegisterFragment; | ||
14 | import com.hjx.personalcenter.fragment.LoginFragment; | 16 | import com.hjx.personalcenter.fragment.LoginFragment; |
17 | import com.hjx.personalcenter.fragment.RegisterFragment; | ||
15 | import com.hjx.personalcenter.thirdparty.SlidingTabLayout; | 18 | import com.hjx.personalcenter.thirdparty.SlidingTabLayout; |
19 | import com.hjx.personalcenter.util.NetUtils; | ||
20 | import com.mylhyl.circledialog.CircleDialog; | ||
21 | import com.mylhyl.circledialog.callback.ConfigText; | ||
22 | import com.mylhyl.circledialog.params.TextParams; | ||
16 | 23 | ||
17 | import java.util.ArrayList; | 24 | import java.util.ArrayList; |
18 | import java.util.Arrays; | 25 | import java.util.Arrays; |
19 | import java.util.List; | 26 | import java.util.List; |
20 | 27 | ||
21 | /** | 28 | /** |
22 | * 登录和注册 熊巍 | 29 | * 登录和注册 熊巍 |
23 | * Created by h on 2017/8/8. | 30 | * Created by h on 2017/8/8. |
24 | */ | 31 | */ |
25 | 32 | ||
26 | public class LoginAndRegisterActivity extends AppCompatActivity { | 33 | public class LoginAndRegisterActivity extends AppCompatActivity { |
27 | private ViewPager viewPager; | 34 | private ViewPager viewPager; |
28 | private SlidingTabLayout tableLayout; | 35 | private SlidingTabLayout tableLayout; |
29 | private List<Fragment> loginlist; | 36 | private List<Fragment> loginlist; |
30 | private LoginAndRegisterAdapter logindapter; | 37 | private LoginAndRegisterAdapter logindapter; |
31 | private List<String> title = Arrays.asList("登录", "注册"); | 38 | private List<String> title = Arrays.asList("登录", "注册"); |
32 | 39 | ||
33 | @Override | 40 | @Override |
34 | protected void onCreate(@Nullable Bundle savedInstanceState) { | 41 | protected void onCreate(@Nullable Bundle savedInstanceState) { |
35 | super.onCreate(savedInstanceState); | 42 | super.onCreate(savedInstanceState); |
43 | //检查网络 | ||
44 | boolean isconnect = NetUtils.isNetworkConnected(this); | ||
45 | if (!isconnect){ | ||
46 | new CircleDialog.Builder(this) | ||
47 | .setCanceledOnTouchOutside(false) | ||
48 | .setCancelable(false) | ||
49 | .setWidth(0.5f) | ||
50 | .configText(new ConfigText() { | ||
51 | @Override | ||
52 | public void onConfig(TextParams params) { | ||
53 | params.gravity = Gravity.CENTER; | ||
54 | params.padding = new int[]{50, 50, 50, 50}; | ||
55 | } | ||
56 | }) | ||
57 | .setText("当前无网络,请检查网络设置") | ||
58 | .setNegative("继续使用", null) | ||
59 | .setPositive("设置网络", new View.OnClickListener() { | ||
60 | @Override | ||
61 | public void onClick(View v) { | ||
62 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 | ||
63 | startActivity(intent); | ||
64 | } | ||
65 | }) | ||
66 | .show(); | ||
67 | } | ||
36 | String islogin =SaveParam.getInstance().getLoginParam(this,"login"); | 68 | String islogin =SaveParam.getInstance().getLoginParam(this,"login"); |
37 | String type =SaveParam.getInstance().getCustomizeParam(LoginAndRegisterActivity.this,SaveParam.ACCOUNT); | 69 | String type =SaveParam.getInstance().getCustomizeParam(LoginAndRegisterActivity.this,SaveParam.ACCOUNT); |
38 | if (type==null){ | 70 | if (type==null){ |
39 | SaveParam.getInstance().saveCustomizeParam(LoginAndRegisterActivity.this, SaveParam.ACCOUNT,"1"); | 71 | SaveParam.getInstance().saveCustomizeParam(LoginAndRegisterActivity.this, SaveParam.ACCOUNT,"1"); |
40 | } | 72 | } |
41 | if ("true".equals(islogin)){ | 73 | if ("true".equals(islogin)){ |
42 | Intent intent = new Intent(); | 74 | Intent intent = new Intent(); |
43 | intent.setClass(this,MainActivity.class); | 75 | intent.setClass(this,MainActivity.class); |
44 | startActivity(intent); | 76 | startActivity(intent); |
45 | overridePendingTransition(R.anim.rightin, R.anim.rightout); | 77 | overridePendingTransition(R.anim.rightin, R.anim.rightout); |
46 | finish(); | 78 | finish(); |
47 | 79 | ||
48 | } | 80 | } |
49 | setContentView(R.layout.activity_loginandregister); | 81 | setContentView(R.layout.activity_loginandregister); |
50 | initView(); | 82 | initView(); |
51 | initData(); | 83 | initData(); |
52 | setLister(); | 84 | setLister(); |
53 | } | 85 | } |
54 | 86 | ||
55 | private void initView() { | 87 | private void initView() { |
56 | viewPager = (ViewPager) findViewById(R.id.viewpager_login); | 88 | viewPager = (ViewPager) findViewById(R.id.viewpager_login); |
57 | tableLayout = (SlidingTabLayout) findViewById(R.id.TabLayout_id); | 89 | tableLayout = (SlidingTabLayout) findViewById(R.id.TabLayout_id); |
58 | } | 90 | } |
59 | 91 | ||
60 | private void initData() { | 92 | private void initData() { |
61 | loginlist = new ArrayList<>(); | 93 | loginlist = new ArrayList<>(); |
62 | for (int i = 0; i < title.size(); i++) { | 94 | for (int i = 0; i < title.size(); i++) { |
63 | if (title.get(i).equals("登录")) { | 95 | if (title.get(i).equals("登录")) { |
64 | loginlist.add(LoginFragment.newInstance(i + 1)); | 96 | loginlist.add(LoginFragment.newInstance(i + 1)); |
65 | } else { | 97 | } else { |
66 | loginlist.add(RegisterFragment.newInstance(i + 1)); | 98 | loginlist.add(RegisterFragment.newInstance(i + 1)); |
67 | } | 99 | } |
68 | } | 100 | } |
69 | 101 | ||
70 | 102 | ||
71 | //设置Tab上的标题 | 103 | //设置Tab上的标题 |
72 | tableLayout.setData(title); | 104 | tableLayout.setData(title); |
73 | //设置关联的ViewPager | 105 | //设置关联的ViewPager |
74 | tableLayout.setViewPager(viewPager, 0); | 106 | tableLayout.setViewPager(viewPager, 0); |
75 | logindapter = new LoginAndRegisterAdapter(loginlist, getSupportFragmentManager()); | 107 | logindapter = new LoginAndRegisterAdapter(loginlist, getSupportFragmentManager()); |
76 | //给ViewPager设置适配器 | 108 | //给ViewPager设置适配器 |
77 | viewPager.setAdapter(logindapter); | 109 | viewPager.setAdapter(logindapter); |
78 | //设置滑动时数据不丢失 | 110 | //设置滑动时数据不丢失 |
79 | viewPager.setOffscreenPageLimit(1); | 111 | viewPager.setOffscreenPageLimit(1); |
80 | //将TabLayout和ViewPager关联起来。 | 112 | //将TabLayout和ViewPager关联起来。 |
81 | } | 113 | } |
82 | 114 | ||
83 | private void setLister() { | 115 | private void setLister() { |
84 | 116 | ||
85 | } | 117 | } |
86 | 118 | ||
87 | 119 | ||
88 | } | 120 | } |
PersonalCenter/app/src/main/java/com/hjx/personalcenter/adapter/GridAdapter.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.facebook.drawee.view.SimpleDraweeView; | ||
10 | import com.hjx.personalcenter.R; | ||
11 | import com.hjx.personalcenter.model.DefautPublishInfo; | ||
12 | |||
13 | import java.util.ArrayList; | ||
14 | |||
15 | /** | ||
16 | * Created by h on 2017/9/12. | ||
17 | */ | ||
18 | |||
19 | public class GridAdapter extends BaseAdapter { | ||
20 | private ArrayList<DefautPublishInfo> defautPublishInfo; | ||
21 | private Context context; | ||
22 | |||
23 | public GridAdapter(ArrayList<DefautPublishInfo> defautPublishInfo, Context context) { | ||
24 | this.defautPublishInfo = defautPublishInfo; | ||
25 | this.context = context; | ||
26 | } | ||
27 | |||
28 | @Override | ||
29 | public int getCount() { | ||
30 | return defautPublishInfo.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(int position, View convertView, ViewGroup parent) { | ||
45 | ViewHolder viewHolder = new ViewHolder(); | ||
46 | if (convertView == null) { | ||
47 | convertView = View.inflate(context, R.layout.fragment_changge_version_info_itmes, null); | ||
48 | viewHolder.simpleDraweeView = (SimpleDraweeView) convertView.findViewById(R.id.image_publish); | ||
49 | viewHolder.subject = (TextView) convertView.findViewById(R.id.subject); | ||
50 | viewHolder.publish = (TextView) convertView.findViewById(R.id.tv_publish); | ||
51 | convertView.setTag(viewHolder); | ||
52 | } else { | ||
53 | viewHolder = (ViewHolder) convertView.getTag(); | ||
54 | } | ||
55 | viewHolder.simpleDraweeView.setImageURI(defautPublishInfo.get(position).getImagurl()); | ||
56 | viewHolder.subject.setText(defautPublishInfo.get(position).getSubjuct()); | ||
57 | viewHolder.publish.setText(defautPublishInfo.get(position).getPublish()); | ||
58 | return convertView; | ||
59 | } | ||
60 | |||
61 | static class ViewHolder { | ||
62 | SimpleDraweeView simpleDraweeView; | ||
63 | TextView subject; | ||
64 | TextView publish; | ||
65 | } | ||
66 | } | ||
67 |
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.annotation.SuppressLint; | ||
3 | import android.content.Context; | 4 | import android.content.Context; |
4 | import android.graphics.Color; | 5 | import android.graphics.Color; |
5 | import android.os.Bundle; | 6 | import android.os.Bundle; |
6 | import android.os.Handler; | 7 | import android.os.Handler; |
7 | import android.os.Message; | 8 | import android.os.Message; |
8 | import android.view.Gravity; | 9 | import android.view.Gravity; |
9 | import android.view.LayoutInflater; | 10 | import android.view.LayoutInflater; |
10 | import android.view.View; | 11 | import android.view.View; |
11 | import android.view.ViewGroup; | 12 | import android.view.ViewGroup; |
12 | import android.widget.AdapterView; | 13 | import android.widget.AdapterView; |
13 | import android.widget.ImageView; | 14 | import android.widget.ImageView; |
14 | import android.widget.ListView; | 15 | import android.widget.ListView; |
15 | 16 | ||
16 | import com.hjx.personalcenter.R; | 17 | import com.hjx.personalcenter.R; |
17 | import com.hjx.personalcenter.adapter.CitysAdapter; | 18 | import com.hjx.personalcenter.adapter.CitysAdapter; |
18 | import com.hjx.personalcenter.db.SaveParam; | 19 | import com.hjx.personalcenter.db.SaveParam; |
19 | import com.hjx.personalcenter.http.HttpCode; | 20 | import com.hjx.personalcenter.http.HttpCode; |
20 | import com.hjx.personalcenter.http.HttpManager; | 21 | import com.hjx.personalcenter.http.HttpManager; |
21 | import com.hjx.personalcenter.interfaces.DialogCallBack; | 22 | import com.hjx.personalcenter.interfaces.DialogCallBack; |
22 | import com.hjx.personalcenter.model.CityInfo; | 23 | import com.hjx.personalcenter.model.CityInfo; |
23 | import com.mylhyl.circledialog.BaseCircleDialog; | 24 | import com.mylhyl.circledialog.BaseCircleDialog; |
24 | import com.mylhyl.circledialog.res.values.CircleDimen; | 25 | import com.mylhyl.circledialog.res.values.CircleDimen; |
25 | 26 | ||
26 | import java.util.ArrayList; | 27 | import java.util.ArrayList; |
27 | import java.util.List; | 28 | import java.util.List; |
28 | 29 | ||
29 | /** | 30 | /** |
30 | * 自定义市级列表对话框 | 31 | * 自定义市级列表对话框 |
31 | * Created by h on 2017/8/10. | 32 | * Created by h on 2017/8/10. |
32 | */ | 33 | */ |
33 | 34 | @SuppressLint("ValidFragment") | |
34 | public class CitysListDialog extends BaseCircleDialog implements AdapterView.OnItemClickListener { | 35 | public class CitysListDialog extends BaseCircleDialog implements AdapterView.OnItemClickListener { |
35 | private CitysAdapter listadapter; | 36 | private CitysAdapter listadapter; |
36 | private ListView listView; | 37 | private ListView listView; |
37 | private ImageView cance; | 38 | private ImageView cance; |
39 | private Context context; | ||
38 | private DialogCallBack.CitysCallBack mCallBack; | 40 | private DialogCallBack.CitysCallBack mCallBack; |
39 | private ArrayList<CityInfo.CitiesBean> data = new ArrayList<>(); | 41 | private ArrayList<CityInfo.CitiesBean> data = new ArrayList<>(); |
42 | public CitysListDialog() { | ||
43 | context= getActivity(); | ||
44 | } | ||
40 | public CitysListDialog(DialogCallBack.CitysCallBack callBack) { | 45 | public CitysListDialog(DialogCallBack.CitysCallBack callBack) { |
41 | this.mCallBack = callBack; | 46 | this.mCallBack = callBack; |
42 | } | 47 | } |
48 | |||
49 | |||
43 | public static CitysListDialog getInstance(DialogCallBack.CitysCallBack callBack) { | 50 | public static CitysListDialog getInstance(DialogCallBack.CitysCallBack callBack) { |
44 | CitysListDialog dialogFragment = new CitysListDialog(callBack); | 51 | CitysListDialog dialogFragment = new CitysListDialog(callBack); |
45 | dialogFragment.setCanceledBack(true); | 52 | dialogFragment.setCanceledBack(true); |
46 | dialogFragment.setCanceledOnTouchOutside(false); | 53 | dialogFragment.setCanceledOnTouchOutside(false); |
47 | dialogFragment.setRadius(CircleDimen.RADIUS); | 54 | dialogFragment.setRadius(CircleDimen.RADIUS); |
48 | dialogFragment.setWidth(0.5f); | 55 | dialogFragment.setWidth(0.5f); |
49 | dialogFragment.setGravity(Gravity.CENTER); | 56 | dialogFragment.setGravity(Gravity.CENTER); |
50 | dialogFragment.setBackgroundColor(Color.WHITE); | 57 | dialogFragment.setBackgroundColor(Color.WHITE); |
51 | return dialogFragment; | 58 | return dialogFragment; |
52 | } | 59 | } |
53 | Handler handler = new Handler(){ | 60 | Handler handler = new Handler(){ |
54 | @Override | 61 | @Override |
55 | public void handleMessage(Message msg) { | 62 | public void handleMessage(Message msg) { |
56 | super.handleMessage(msg); | 63 | super.handleMessage(msg); |
57 | switch (msg.what){ | 64 | switch (msg.what){ |
58 | case HttpCode.CITYS: | 65 | case HttpCode.CITYS: |
59 | data.clear(); | 66 | data.clear(); |
60 | data.addAll( (List<CityInfo.CitiesBean>)msg.obj); | 67 | data.addAll( (List<CityInfo.CitiesBean>)msg.obj); |
61 | listadapter.notifyDataSetChanged(); | 68 | listadapter.notifyDataSetChanged(); |
62 | break; | 69 | break; |
63 | } | 70 | } |
64 | } | 71 | } |
65 | }; | 72 | }; |
66 | 73 | ||
67 | @Override | 74 | @Override |
68 | public View createView(Context context, LayoutInflater inflater, ViewGroup container) { | 75 | public View createView(Context context, LayoutInflater inflater, ViewGroup container) { |
69 | return inflater.inflate(R.layout.custom_adilog_cityslist, container, false); | 76 | return inflater.inflate(R.layout.custom_adilog_cityslist, container, false); |
70 | } | 77 | } |
71 | 78 | ||
72 | @Override | 79 | @Override |
73 | public void onActivityCreated(Bundle savedInstanceState) { | 80 | public void onActivityCreated(Bundle savedInstanceState) { |
74 | super.onActivityCreated(savedInstanceState); | 81 | super.onActivityCreated(savedInstanceState); |
75 | listView = (ListView) getView().findViewById(R.id.listadapter); | 82 | listView = (ListView) getView().findViewById(R.id.listadapter); |
76 | cance = (ImageView) getView().findViewById(R.id.cancel); | 83 | cance = (ImageView) getView().findViewById(R.id.cancel); |
77 | String citys = SaveParam.getInstance().getLoginParam(getActivity(), SaveParam.PROVINCES); | 84 | String citys = SaveParam.getInstance().getLoginParam(getActivity(), SaveParam.PROVINCES); |
78 | listadapter = new CitysAdapter(data,getActivity()); | 85 | listadapter = new CitysAdapter(data,getActivity()); |
79 | listView.setAdapter(listadapter); | 86 | listView.setAdapter(listadapter); |
80 | listView.setOnItemClickListener(this); | 87 | listView.setOnItemClickListener(this); |
81 | cance.setOnClickListener(new View.OnClickListener() { | 88 | cance.setOnClickListener(new View.OnClickListener() { |
82 | @Override | 89 | @Override |
83 | public void onClick(View v) { | 90 | public void onClick(View v) { |
84 | dismiss(); | 91 | dismiss(); |
85 | } | 92 | } |
86 | }); | 93 | }); |
87 | try { | 94 | try { |
88 | long a = Long.parseLong(citys); | 95 | long a = Long.parseLong(citys); |
89 | HttpManager.getInstance().cityinfo(getActivity(),a,handler); | 96 | HttpManager.getInstance().cityinfo(getActivity(),a,handler); |
90 | } catch (NumberFormatException e) { | 97 | } catch (NumberFormatException e) { |
91 | e.printStackTrace(); | 98 | e.printStackTrace(); |
92 | } | 99 | } |
93 | 100 | ||
94 | 101 | ||
95 | } | 102 | } |
96 | 103 | ||
97 | @Override | 104 | @Override |
98 | public void onItemClick(AdapterView<?> parent, View view, int position, long id) { | 105 | public void onItemClick(AdapterView<?> parent, View view, int position, long id) { |
99 | SaveParam.getInstance().saveLoginParam(getActivity(), SaveParam.CITYS, ""+data.get(position).getRegionId()); | 106 | SaveParam.getInstance().saveLoginParam(getActivity(), SaveParam.CITYS, ""+data.get(position).getRegionId()); |
100 | mCallBack.province1OnItemClick(data,position,2); | 107 | mCallBack.province1OnItemClick(data,position,2); |
101 | dismiss(); | 108 | dismiss(); |
102 | 109 | ||
103 | } | 110 | } |
104 | } | 111 | } |
105 | 112 |
PersonalCenter/app/src/main/java/com/hjx/personalcenter/customdialog/CountryDialog.java
1 | package com.hjx.personalcenter.customdialog; | 1 | package com.hjx.personalcenter.customdialog; |
2 | 2 | ||
3 | import android.annotation.SuppressLint; | ||
3 | import android.content.Context; | 4 | import android.content.Context; |
4 | import android.graphics.Color; | 5 | import android.graphics.Color; |
5 | import android.os.Bundle; | 6 | import android.os.Bundle; |
6 | import android.os.Handler; | 7 | import android.os.Handler; |
7 | import android.os.Message; | 8 | import android.os.Message; |
8 | import android.view.Gravity; | 9 | import android.view.Gravity; |
9 | import android.view.LayoutInflater; | 10 | import android.view.LayoutInflater; |
10 | import android.view.View; | 11 | import android.view.View; |
11 | import android.view.ViewGroup; | 12 | import android.view.ViewGroup; |
12 | import android.widget.AdapterView; | 13 | import android.widget.AdapterView; |
13 | import android.widget.ImageView; | 14 | import android.widget.ImageView; |
14 | import android.widget.ListView; | 15 | import android.widget.ListView; |
15 | 16 | ||
16 | import com.hjx.personalcenter.R; | 17 | import com.hjx.personalcenter.R; |
17 | import com.hjx.personalcenter.adapter.CountryAdapter; | 18 | import com.hjx.personalcenter.adapter.CountryAdapter; |
18 | import com.hjx.personalcenter.db.SaveParam; | 19 | import com.hjx.personalcenter.db.SaveParam; |
19 | import com.hjx.personalcenter.http.HttpCode; | 20 | import com.hjx.personalcenter.http.HttpCode; |
20 | import com.hjx.personalcenter.http.HttpManager; | 21 | import com.hjx.personalcenter.http.HttpManager; |
21 | import com.hjx.personalcenter.interfaces.DialogCallBack; | 22 | import com.hjx.personalcenter.interfaces.DialogCallBack; |
22 | import com.hjx.personalcenter.model.CountyInfo; | 23 | import com.hjx.personalcenter.model.CountyInfo; |
23 | import com.mylhyl.circledialog.BaseCircleDialog; | 24 | import com.mylhyl.circledialog.BaseCircleDialog; |
24 | import com.mylhyl.circledialog.res.values.CircleDimen; | 25 | import com.mylhyl.circledialog.res.values.CircleDimen; |
25 | 26 | ||
26 | import java.util.ArrayList; | 27 | import java.util.ArrayList; |
27 | import java.util.List; | 28 | import java.util.List; |
28 | 29 | ||
29 | /** | 30 | /** |
30 | * Created by wei on 2017/8/21. | 31 | * Created by wei on 2017/8/21. |
31 | */ | 32 | */ |
32 | 33 | @SuppressLint("ValidFragment") | |
33 | public class CountryDialog extends BaseCircleDialog implements AdapterView.OnItemClickListener { | 34 | public class CountryDialog extends BaseCircleDialog implements AdapterView.OnItemClickListener { |
34 | private CountryAdapter listadapter; | 35 | private CountryAdapter listadapter; |
35 | private ListView listView; | 36 | private ListView listView; |
36 | private ImageView cance; | 37 | private ImageView cance; |
37 | private DialogCallBack.CountryCallBack mCallBack; | 38 | private DialogCallBack.CountryCallBack mCallBack; |
38 | private ArrayList<CountyInfo.CountiesBean> data = new ArrayList<>(); | 39 | private ArrayList<CountyInfo.CountiesBean> data = new ArrayList<>(); |
39 | public CountryDialog(DialogCallBack.CountryCallBack callBack) { | 40 | public CountryDialog(DialogCallBack.CountryCallBack callBack) { |
40 | this.mCallBack = callBack; | 41 | this.mCallBack = callBack; |
41 | } | 42 | } |
42 | public static CountryDialog getInstance(DialogCallBack.CountryCallBack callBack) { | 43 | public static CountryDialog getInstance(DialogCallBack.CountryCallBack callBack) { |
43 | CountryDialog dialogFragment = new CountryDialog(callBack); | 44 | CountryDialog dialogFragment = new CountryDialog(callBack); |
44 | dialogFragment.setCanceledBack(true); | 45 | dialogFragment.setCanceledBack(true); |
45 | dialogFragment.setCanceledOnTouchOutside(true); | 46 | dialogFragment.setCanceledOnTouchOutside(true); |
46 | dialogFragment.setRadius(CircleDimen.RADIUS); | 47 | dialogFragment.setRadius(CircleDimen.RADIUS); |
47 | dialogFragment.setWidth(0.5f); | 48 | dialogFragment.setWidth(0.5f); |
48 | dialogFragment.setGravity(Gravity.CENTER); | 49 | dialogFragment.setGravity(Gravity.CENTER); |
49 | dialogFragment.setBackgroundColor(Color.WHITE); | 50 | dialogFragment.setBackgroundColor(Color.WHITE); |
50 | return dialogFragment; | 51 | return dialogFragment; |
51 | } | 52 | } |
52 | Handler handler = new Handler(){ | 53 | Handler handler = new Handler(){ |
53 | @Override | 54 | @Override |
54 | public void handleMessage(Message msg) { | 55 | public void handleMessage(Message msg) { |
55 | super.handleMessage(msg); | 56 | super.handleMessage(msg); |
56 | switch (msg.what){ | 57 | switch (msg.what){ |
57 | case HttpCode.COUNTRY: | 58 | case HttpCode.COUNTRY: |
58 | 59 | ||
59 | data.clear(); | 60 | data.clear(); |
60 | data.addAll( (List<CountyInfo.CountiesBean>)msg.obj); | 61 | data.addAll( (List<CountyInfo.CountiesBean>)msg.obj); |
61 | listadapter.notifyDataSetChanged(); | 62 | listadapter.notifyDataSetChanged(); |
62 | break; | 63 | break; |
63 | } | 64 | } |
64 | } | 65 | } |
65 | }; | 66 | }; |
66 | 67 | ||
67 | @Override | 68 | @Override |
68 | public View createView(Context context, LayoutInflater inflater, ViewGroup container) { | 69 | public View createView(Context context, LayoutInflater inflater, ViewGroup container) { |
69 | return inflater.inflate(R.layout.custom_adilog_countrylist, container, false); | 70 | return inflater.inflate(R.layout.custom_adilog_countrylist, container, false); |
70 | } | 71 | } |
71 | 72 | ||
72 | @Override | 73 | @Override |
73 | public void onActivityCreated(Bundle savedInstanceState) { | 74 | public void onActivityCreated(Bundle savedInstanceState) { |
74 | super.onActivityCreated(savedInstanceState); | 75 | super.onActivityCreated(savedInstanceState); |
75 | listView = (ListView) getView().findViewById(R.id.listadapter); | 76 | listView = (ListView) getView().findViewById(R.id.listadapter); |
76 | cance = (ImageView) getView().findViewById(R.id.cancel); | 77 | cance = (ImageView) getView().findViewById(R.id.cancel); |
77 | String citys = SaveParam.getInstance().getLoginParam(getActivity(), SaveParam.CITYS); | 78 | String citys = SaveParam.getInstance().getLoginParam(getActivity(), SaveParam.CITYS); |
78 | listadapter = new CountryAdapter(data,getActivity()); | 79 | listadapter = new CountryAdapter(data,getActivity()); |
79 | listView.setAdapter(listadapter); | 80 | listView.setAdapter(listadapter); |
80 | listView.setOnItemClickListener(this); | 81 | listView.setOnItemClickListener(this); |
81 | cance.setOnClickListener(new View.OnClickListener() { | 82 | cance.setOnClickListener(new View.OnClickListener() { |
82 | @Override | 83 | @Override |
83 | public void onClick(View v) { | 84 | public void onClick(View v) { |
84 | dismiss(); | 85 | dismiss(); |
85 | } | 86 | } |
86 | }); | 87 | }); |
87 | try { | 88 | try { |
88 | int a = Integer.parseInt(citys); | 89 | int a = Integer.parseInt(citys); |
89 | HttpManager.getInstance().countyinfo(getActivity(),a,handler); | 90 | HttpManager.getInstance().countyinfo(getActivity(),a,handler); |
90 | } catch (NumberFormatException e) { | 91 | } catch (NumberFormatException e) { |
91 | e.printStackTrace(); | 92 | e.printStackTrace(); |
92 | } | 93 | } |
93 | 94 | ||
94 | 95 | ||
95 | } | 96 | } |
96 | 97 | ||
97 | @Override | 98 | @Override |
98 | public void onItemClick(AdapterView<?> parent, View view, int position, long id) { | 99 | public void onItemClick(AdapterView<?> parent, View view, int position, long id) { |
99 | SaveParam.getInstance().saveLoginParam(getActivity(), SaveParam.COUNTRY, ""+data.get(position).getRegionId()); | 100 | SaveParam.getInstance().saveLoginParam(getActivity(), SaveParam.COUNTRY, ""+data.get(position).getRegionId()); |
100 | mCallBack.province2OnItemClick(data,position,3); | 101 | mCallBack.province2OnItemClick(data,position,3); |
101 | dismiss(); | 102 | dismiss(); |
102 | 103 | ||
103 | } | 104 | } |
104 | } | 105 | } |
105 | 106 |
PersonalCenter/app/src/main/java/com/hjx/personalcenter/customdialog/ElectronicCardDialog.java
1 | package com.hjx.personalcenter.customdialog; | 1 | package com.hjx.personalcenter.customdialog; |
2 | 2 | ||
3 | import android.annotation.SuppressLint; | ||
3 | import android.content.Context; | 4 | import android.content.Context; |
4 | import android.content.Intent; | 5 | import android.content.Intent; |
5 | import android.graphics.Color; | 6 | import android.graphics.Color; |
6 | import android.os.Bundle; | 7 | import android.os.Bundle; |
7 | import android.view.Gravity; | 8 | import android.view.Gravity; |
8 | import android.view.LayoutInflater; | 9 | import android.view.LayoutInflater; |
9 | import android.view.View; | 10 | import android.view.View; |
10 | import android.view.ViewGroup; | 11 | import android.view.ViewGroup; |
11 | import android.widget.ImageView; | 12 | import android.widget.ImageView; |
12 | 13 | ||
13 | import com.hjx.personalcenter.R; | 14 | import com.hjx.personalcenter.R; |
14 | import com.hjx.personalcenter.activity.ElectronicCardValidationActivity; | 15 | import com.hjx.personalcenter.activity.ElectronicCardValidationActivity; |
15 | import com.mylhyl.circledialog.BaseCircleDialog; | 16 | import com.mylhyl.circledialog.BaseCircleDialog; |
16 | import com.mylhyl.circledialog.res.values.CircleDimen; | 17 | import com.mylhyl.circledialog.res.values.CircleDimen; |
17 | 18 | ||
18 | /** | 19 | /** |
19 | * Created by h on 2017/8/10. | 20 | * Created by h on 2017/8/10. |
20 | */ | 21 | */ |
21 | 22 | @SuppressLint("ValidFragment") | |
22 | public class ElectronicCardDialog extends BaseCircleDialog { | 23 | public class ElectronicCardDialog extends BaseCircleDialog { |
23 | private ImageView cancel; | 24 | private ImageView cancel; |
24 | public static ElectronicCardDialog getInstance() { | 25 | public static ElectronicCardDialog getInstance() { |
25 | ElectronicCardDialog dialogFragment = new ElectronicCardDialog(); | 26 | ElectronicCardDialog dialogFragment = new ElectronicCardDialog(); |
26 | dialogFragment.setCanceledBack(true); | 27 | dialogFragment.setCanceledBack(true); |
27 | dialogFragment.setCanceledOnTouchOutside(true); | 28 | dialogFragment.setCanceledOnTouchOutside(true); |
28 | dialogFragment.setRadius(CircleDimen.RADIUS); | 29 | dialogFragment.setRadius(CircleDimen.RADIUS); |
29 | dialogFragment.setWidth(0.8f); | 30 | dialogFragment.setWidth(0.8f); |
30 | dialogFragment.setGravity(Gravity.CENTER); | 31 | dialogFragment.setGravity(Gravity.CENTER); |
31 | dialogFragment.setBackgroundColor(Color.WHITE); | 32 | dialogFragment.setBackgroundColor(Color.WHITE); |
32 | return dialogFragment; | 33 | return dialogFragment; |
33 | } | 34 | } |
34 | @Override | 35 | @Override |
35 | public View createView(Context context, LayoutInflater inflater, ViewGroup container) { | 36 | public View createView(Context context, LayoutInflater inflater, ViewGroup container) { |
36 | return inflater.inflate(R.layout.custom_adilog_electroniccard, container, false); | 37 | return inflater.inflate(R.layout.custom_adilog_electroniccard, container, false); |
37 | } | 38 | } |
38 | @Override | 39 | @Override |
39 | public void onActivityCreated(Bundle savedInstanceState) { | 40 | public void onActivityCreated(Bundle savedInstanceState) { |
40 | super.onActivityCreated(savedInstanceState); | 41 | super.onActivityCreated(savedInstanceState); |
41 | getView().findViewById(R.id.fill_card).setOnClickListener(new View.OnClickListener() { | 42 | getView().findViewById(R.id.fill_card).setOnClickListener(new View.OnClickListener() { |
42 | @Override | 43 | @Override |
43 | public void onClick(View v) { | 44 | public void onClick(View v) { |
44 | Intent intent = new Intent(); | 45 | Intent intent = new Intent(); |
45 | intent.setClass(getActivity(),ElectronicCardValidationActivity.class); | 46 | intent.setClass(getActivity(),ElectronicCardValidationActivity.class); |
46 | startActivity(intent); | 47 | startActivity(intent); |
47 | getActivity().overridePendingTransition(R.anim.rightin, R.anim.rightout); | 48 | getActivity().overridePendingTransition(R.anim.rightin, R.anim.rightout); |
48 | 49 | ||
49 | } | 50 | } |
50 | }); | 51 | }); |
51 | getView().findViewById(R.id.cancel).setOnClickListener(new View.OnClickListener() { | 52 | getView().findViewById(R.id.cancel).setOnClickListener(new View.OnClickListener() { |
52 | @Override | 53 | @Override |
53 | public void onClick(View v) { | 54 | public void onClick(View v) { |
54 | dismiss(); | 55 | dismiss(); |
55 | } | 56 | } |
56 | }); | 57 | }); |
57 | 58 | ||
58 | } | 59 | } |
59 | 60 | ||
60 | } | 61 | } |
61 | 62 |
PersonalCenter/app/src/main/java/com/hjx/personalcenter/customdialog/GradeListDialog.java
1 | package com.hjx.personalcenter.customdialog; | 1 | package com.hjx.personalcenter.customdialog; |
2 | 2 | ||
3 | import android.annotation.SuppressLint; | ||
3 | import android.content.Context; | 4 | import android.content.Context; |
4 | import android.graphics.Color; | 5 | import android.graphics.Color; |
5 | import android.os.Bundle; | 6 | import android.os.Bundle; |
6 | import android.os.Handler; | 7 | import android.os.Handler; |
7 | import android.os.Message; | 8 | import android.os.Message; |
8 | import android.view.Gravity; | 9 | import android.view.Gravity; |
9 | import android.view.LayoutInflater; | 10 | import android.view.LayoutInflater; |
10 | import android.view.View; | 11 | import android.view.View; |
11 | import android.view.ViewGroup; | 12 | import android.view.ViewGroup; |
12 | import android.widget.AdapterView; | 13 | import android.widget.AdapterView; |
13 | import android.widget.ImageView; | 14 | import android.widget.ImageView; |
14 | import android.widget.ListView; | 15 | import android.widget.ListView; |
15 | 16 | ||
16 | import com.hjx.personalcenter.R; | 17 | import com.hjx.personalcenter.R; |
17 | import com.hjx.personalcenter.adapter.GrandeAdapter; | 18 | import com.hjx.personalcenter.adapter.GrandeAdapter; |
18 | import com.hjx.personalcenter.db.SaveParam; | 19 | import com.hjx.personalcenter.db.SaveParam; |
19 | import com.hjx.personalcenter.http.HttpCode; | 20 | import com.hjx.personalcenter.http.HttpCode; |
20 | import com.hjx.personalcenter.http.HttpManager; | 21 | import com.hjx.personalcenter.http.HttpManager; |
21 | import com.hjx.personalcenter.interfaces.DialogCallBack; | 22 | import com.hjx.personalcenter.interfaces.DialogCallBack; |
22 | import com.hjx.personalcenter.model.GradeInfo; | 23 | import com.hjx.personalcenter.model.GradeInfo; |
23 | import com.mylhyl.circledialog.BaseCircleDialog; | 24 | import com.mylhyl.circledialog.BaseCircleDialog; |
24 | import com.mylhyl.circledialog.res.values.CircleDimen; | 25 | import com.mylhyl.circledialog.res.values.CircleDimen; |
25 | 26 | ||
26 | import java.util.ArrayList; | 27 | import java.util.ArrayList; |
27 | import java.util.List; | 28 | import java.util.List; |
28 | 29 | ||
29 | /**自定义年级列表对话框 | 30 | /**自定义年级列表对话框 |
30 | * Created by h on 2017/8/10. | 31 | * Created by h on 2017/8/10. |
31 | */ | 32 | */ |
32 | 33 | @SuppressLint("ValidFragment") | |
33 | public class GradeListDialog extends BaseCircleDialog implements AdapterView.OnItemClickListener { | 34 | public class GradeListDialog extends BaseCircleDialog implements AdapterView.OnItemClickListener { |
34 | private GrandeAdapter listadapter; | 35 | private GrandeAdapter listadapter; |
35 | private ListView listView; | 36 | private ListView listView; |
36 | private ImageView cance; | 37 | private ImageView cance; |
37 | ArrayList<GradeInfo.DataBean.ChildrenBean> data = new ArrayList<>(); | 38 | ArrayList<GradeInfo.DataBean.ChildrenBean> data = new ArrayList<>(); |
38 | private DialogCallBack.GradeCallBack mCallBack; | 39 | private DialogCallBack.GradeCallBack mCallBack; |
39 | public GradeListDialog(DialogCallBack.GradeCallBack callBack) { | 40 | public GradeListDialog(DialogCallBack.GradeCallBack callBack) { |
40 | this.mCallBack = callBack; | 41 | this.mCallBack = callBack; |
41 | } | 42 | } |
42 | public static GradeListDialog getInstance(DialogCallBack.GradeCallBack callBack) { | 43 | public static GradeListDialog getInstance(DialogCallBack.GradeCallBack callBack) { |
43 | GradeListDialog dialogFragment = new GradeListDialog(callBack); | 44 | GradeListDialog dialogFragment = new GradeListDialog(callBack); |
44 | dialogFragment.setCanceledBack(true); | 45 | dialogFragment.setCanceledBack(true); |
45 | dialogFragment.setCanceledOnTouchOutside(true); | 46 | dialogFragment.setCanceledOnTouchOutside(true); |
46 | dialogFragment.setRadius(CircleDimen.RADIUS); | 47 | dialogFragment.setRadius(CircleDimen.RADIUS); |
47 | dialogFragment.setWidth(0.5f); | 48 | dialogFragment.setWidth(0.5f); |
48 | dialogFragment.setGravity(Gravity.CENTER); | 49 | dialogFragment.setGravity(Gravity.CENTER); |
49 | dialogFragment.setBackgroundColor(Color.WHITE); | 50 | dialogFragment.setBackgroundColor(Color.WHITE); |
50 | return dialogFragment; | 51 | return dialogFragment; |
51 | } | 52 | } |
52 | Handler handler = new Handler(){ | 53 | Handler handler = new Handler(){ |
53 | @Override | 54 | @Override |
54 | public void handleMessage(Message msg) { | 55 | public void handleMessage(Message msg) { |
55 | super.handleMessage(msg); | 56 | super.handleMessage(msg); |
56 | switch (msg.what){ | 57 | switch (msg.what){ |
57 | case HttpCode.GRADER: | 58 | case HttpCode.GRADER: |
58 | data.clear(); | 59 | data.clear(); |
59 | data.addAll( (List<GradeInfo.DataBean.ChildrenBean>)msg.obj); | 60 | data.addAll( (List<GradeInfo.DataBean.ChildrenBean>)msg.obj); |
60 | listadapter.notifyDataSetChanged(); | 61 | listadapter.notifyDataSetChanged(); |
61 | break; | 62 | break; |
62 | } | 63 | } |
63 | } | 64 | } |
64 | }; | 65 | }; |
65 | @Override | 66 | @Override |
66 | public View createView(Context context, LayoutInflater inflater, ViewGroup container) { | 67 | public View createView(Context context, LayoutInflater inflater, ViewGroup container) { |
67 | 68 | ||
68 | return inflater.inflate(R.layout.custom_adilog_gradelist, container, false); | 69 | return inflater.inflate(R.layout.custom_adilog_gradelist, container, false); |
69 | } | 70 | } |
70 | @Override | 71 | @Override |
71 | public void onActivityCreated(Bundle savedInstanceState) { | 72 | public void onActivityCreated(Bundle savedInstanceState) { |
72 | super.onActivityCreated(savedInstanceState); | 73 | super.onActivityCreated(savedInstanceState); |
73 | listView = (ListView) getView().findViewById(R.id.listadapter); | 74 | listView = (ListView) getView().findViewById(R.id.listadapter); |
74 | cance = (ImageView) getView().findViewById(R.id.cancel); | 75 | cance = (ImageView) getView().findViewById(R.id.cancel); |
75 | listadapter = new GrandeAdapter(data,getActivity()); | 76 | listadapter = new GrandeAdapter(data,getActivity()); |
76 | listView.setAdapter(listadapter); | 77 | listView.setAdapter(listadapter); |
77 | listView.setOnItemClickListener(this); | 78 | listView.setOnItemClickListener(this); |
78 | cance.setOnClickListener(new View.OnClickListener() { | 79 | cance.setOnClickListener(new View.OnClickListener() { |
79 | @Override | 80 | @Override |
80 | public void onClick(View v) { | 81 | public void onClick(View v) { |
81 | dismiss(); | 82 | dismiss(); |
82 | } | 83 | } |
83 | }); | 84 | }); |
84 | HttpManager.getInstance().getgrade(getActivity(),handler); | 85 | HttpManager.getInstance().getgrade(getActivity(),handler); |
85 | 86 | ||
86 | } | 87 | } |
87 | 88 | ||
88 | @Override | 89 | @Override |
89 | public void onItemClick(AdapterView<?> parent, View view, int position, long id) { | 90 | public void onItemClick(AdapterView<?> parent, View view, int position, long id) { |
90 | 91 | ||
91 | SaveParam.getInstance().saveLoginParam(getActivity(), SaveParam.GRADENS, ""+data.get(position).getId()); | 92 | SaveParam.getInstance().saveLoginParam(getActivity(), SaveParam.GRADENS, ""+data.get(position).getId()); |
92 | mCallBack.province3OnItemClick(data,position,5); | 93 | mCallBack.province3OnItemClick(data,position,5); |
93 | dismiss(); | 94 | dismiss(); |
94 | 95 | ||
95 | 96 | ||
96 | } | 97 | } |
97 | } | 98 | } |
98 | 99 |
PersonalCenter/app/src/main/java/com/hjx/personalcenter/customdialog/HeadDialog.java
1 | package com.hjx.personalcenter.customdialog; | 1 | package com.hjx.personalcenter.customdialog; |
2 | 2 | ||
3 | import android.annotation.SuppressLint; | ||
3 | import android.content.Context; | 4 | import android.content.Context; |
4 | import android.graphics.Color; | 5 | import android.graphics.Color; |
5 | import android.os.Bundle; | 6 | import android.os.Bundle; |
6 | import android.view.Gravity; | 7 | import android.view.Gravity; |
7 | import android.view.LayoutInflater; | 8 | import android.view.LayoutInflater; |
8 | import android.view.View; | 9 | import android.view.View; |
9 | import android.view.ViewGroup; | 10 | import android.view.ViewGroup; |
10 | import android.widget.LinearLayout; | 11 | import android.widget.LinearLayout; |
11 | import android.widget.RadioButton; | 12 | import android.widget.RadioButton; |
12 | import android.widget.TextView; | 13 | import android.widget.TextView; |
13 | 14 | ||
14 | import com.hjx.personalcenter.R; | 15 | import com.hjx.personalcenter.R; |
15 | import com.hjx.personalcenter.interfaces.DialogCallBack; | 16 | import com.hjx.personalcenter.interfaces.DialogCallBack; |
16 | import com.mylhyl.circledialog.BaseCircleDialog; | 17 | import com.mylhyl.circledialog.BaseCircleDialog; |
17 | import com.mylhyl.circledialog.res.values.CircleDimen; | 18 | import com.mylhyl.circledialog.res.values.CircleDimen; |
18 | 19 | ||
19 | /** | 20 | /** |
20 | * Created by h on 2017/8/20. | 21 | * Created by h on 2017/8/20. |
21 | */ | 22 | */ |
22 | 23 | @SuppressLint("ValidFragment") | |
23 | public class HeadDialog extends BaseCircleDialog implements View.OnClickListener { | 24 | public class HeadDialog extends BaseCircleDialog implements View.OnClickListener { |
24 | private View mView; | 25 | private View mView; |
25 | private TextView oktakephone, cancetakephone; | 26 | private TextView oktakephone, cancetakephone; |
26 | private LinearLayout take_pic,xiangce; | 27 | private LinearLayout take_pic,xiangce; |
27 | private DialogCallBack.CallBackView mCallBack; | 28 | private DialogCallBack.CallBackView mCallBack; |
28 | //默认头像选择 | 29 | //默认头像选择 |
29 | RadioButton radio_head1,radio_head2,radio_head3,radio_head4; | 30 | RadioButton radio_head1,radio_head2,radio_head3,radio_head4; |
30 | 31 | ||
31 | public HeadDialog(DialogCallBack.CallBackView callBack) { | 32 | public HeadDialog(DialogCallBack.CallBackView callBack) { |
32 | this.mCallBack = callBack; | 33 | this.mCallBack = callBack; |
33 | } | 34 | } |
34 | 35 | ||
35 | public static HeadDialog getInstance(DialogCallBack.CallBackView callBackview) { | 36 | public static HeadDialog getInstance(DialogCallBack.CallBackView callBackview) { |
36 | HeadDialog dialogFragment = new HeadDialog(callBackview); | 37 | HeadDialog dialogFragment = new HeadDialog(callBackview); |
37 | dialogFragment.setCanceledBack(true); | 38 | dialogFragment.setCanceledBack(true); |
38 | dialogFragment.setCanceledOnTouchOutside(false); | 39 | dialogFragment.setCanceledOnTouchOutside(false); |
39 | dialogFragment.setRadius(CircleDimen.RADIUS); | 40 | dialogFragment.setRadius(CircleDimen.RADIUS); |
40 | dialogFragment.setWidth(0.4f); | 41 | dialogFragment.setWidth(0.4f); |
41 | dialogFragment.setGravity(Gravity.CENTER); | 42 | dialogFragment.setGravity(Gravity.CENTER); |
42 | dialogFragment.setBackgroundColor(Color.WHITE); | 43 | dialogFragment.setBackgroundColor(Color.WHITE); |
43 | return dialogFragment; | 44 | return dialogFragment; |
44 | } | 45 | } |
45 | 46 | ||
46 | @Override | 47 | @Override |
47 | public View createView(Context context, LayoutInflater inflater, ViewGroup container) { | 48 | public View createView(Context context, LayoutInflater inflater, ViewGroup container) { |
48 | 49 | ||
49 | if (mView == null) { | 50 | if (mView == null) { |
50 | mView = inflater.inflate(R.layout.custom_adilog_lhead, container, false); | 51 | mView = inflater.inflate(R.layout.custom_adilog_lhead, container, false); |
51 | } | 52 | } |
52 | return mView; | 53 | return mView; |
53 | } | 54 | } |
54 | 55 | ||
55 | @Override | 56 | @Override |
56 | public void onActivityCreated(Bundle savedInstanceState) { | 57 | public void onActivityCreated(Bundle savedInstanceState) { |
57 | super.onActivityCreated(savedInstanceState); | 58 | super.onActivityCreated(savedInstanceState); |
58 | oktakephone = (TextView) mView.findViewById(R.id.oktakephone); | 59 | oktakephone = (TextView) mView.findViewById(R.id.oktakephone); |
59 | cancetakephone = (TextView) mView.findViewById(R.id.canceltakephone); | 60 | cancetakephone = (TextView) mView.findViewById(R.id.canceltakephone); |
60 | take_pic = (LinearLayout) mView.findViewById(R.id.take_pic); | 61 | take_pic = (LinearLayout) mView.findViewById(R.id.take_pic); |
61 | xiangce = (LinearLayout) mView.findViewById(R.id.xiangce); | 62 | xiangce = (LinearLayout) mView.findViewById(R.id.xiangce); |
62 | radio_head1 = (RadioButton)mView .findViewById(R.id.radio_head1); | 63 | radio_head1 = (RadioButton)mView .findViewById(R.id.radio_head1); |
63 | radio_head2 = (RadioButton)mView .findViewById(R.id.radio_head2); | 64 | radio_head2 = (RadioButton)mView .findViewById(R.id.radio_head2); |
64 | radio_head3 = (RadioButton)mView .findViewById(R.id.radio_head3); | 65 | radio_head3 = (RadioButton)mView .findViewById(R.id.radio_head3); |
65 | radio_head4 = (RadioButton)mView .findViewById(R.id.radio_head4); | 66 | radio_head4 = (RadioButton)mView .findViewById(R.id.radio_head4); |
66 | oktakephone.setOnClickListener(this); | 67 | oktakephone.setOnClickListener(this); |
67 | cancetakephone.setOnClickListener(this); | 68 | cancetakephone.setOnClickListener(this); |
68 | take_pic.setOnClickListener(this); | 69 | take_pic.setOnClickListener(this); |
69 | xiangce.setOnClickListener(this); | 70 | xiangce.setOnClickListener(this); |
70 | 71 | ||
71 | 72 | ||
72 | } | 73 | } |
73 | 74 | ||
74 | @Override | 75 | @Override |
75 | public void onClick(View v) { | 76 | public void onClick(View v) { |
76 | int headweizhi; | 77 | int headweizhi; |
77 | if (radio_head1.isChecked()){ | 78 | if (radio_head1.isChecked()){ |
78 | headweizhi =1; | 79 | headweizhi =1; |
79 | } else if (radio_head2.isChecked()) { | 80 | } else if (radio_head2.isChecked()) { |
80 | headweizhi =2; | 81 | headweizhi =2; |
81 | }else if (radio_head3.isChecked()) { | 82 | }else if (radio_head3.isChecked()) { |
82 | headweizhi =3; | 83 | headweizhi =3; |
83 | }else if (radio_head4.isChecked()) { | 84 | }else if (radio_head4.isChecked()) { |
84 | headweizhi =4; | 85 | headweizhi =4; |
85 | }else { | 86 | }else { |
86 | headweizhi =0; | 87 | headweizhi =0; |
87 | } | 88 | } |
88 | mCallBack.heard(getActivity(), v,headweizhi); | 89 | mCallBack.heard(getActivity(), v,headweizhi); |
89 | dismiss(); | 90 | dismiss(); |
90 | } | 91 | } |
91 | } | 92 | } |
92 | 93 |
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.annotation.SuppressLint; | ||
3 | import android.content.Context; | 4 | import android.content.Context; |
4 | import android.graphics.Color; | 5 | import android.graphics.Color; |
5 | import android.os.Bundle; | 6 | import android.os.Bundle; |
6 | import android.os.Handler; | 7 | import android.os.Handler; |
7 | import android.os.Message; | 8 | import android.os.Message; |
8 | import android.view.Gravity; | 9 | import android.view.Gravity; |
9 | import android.view.LayoutInflater; | 10 | import android.view.LayoutInflater; |
10 | import android.view.View; | 11 | import android.view.View; |
11 | import android.view.ViewGroup; | 12 | import android.view.ViewGroup; |
12 | import android.widget.AdapterView; | 13 | import android.widget.AdapterView; |
13 | import android.widget.ImageView; | 14 | import android.widget.ImageView; |
14 | import android.widget.ListView; | 15 | import android.widget.ListView; |
15 | 16 | ||
16 | import com.hjx.personalcenter.R; | 17 | import com.hjx.personalcenter.R; |
17 | import com.hjx.personalcenter.adapter.ProvincesAdapter; | 18 | import com.hjx.personalcenter.adapter.ProvincesAdapter; |
18 | import com.hjx.personalcenter.db.SaveParam; | 19 | import com.hjx.personalcenter.db.SaveParam; |
19 | import com.hjx.personalcenter.http.HttpCode; | 20 | import com.hjx.personalcenter.http.HttpCode; |
20 | import com.hjx.personalcenter.http.HttpManager; | 21 | import com.hjx.personalcenter.http.HttpManager; |
21 | import com.hjx.personalcenter.interfaces.DialogCallBack; | 22 | import com.hjx.personalcenter.interfaces.DialogCallBack; |
22 | import com.hjx.personalcenter.model.ProvinceInfo; | 23 | import com.hjx.personalcenter.model.ProvinceInfo; |
23 | import com.mylhyl.circledialog.BaseCircleDialog; | 24 | import com.mylhyl.circledialog.BaseCircleDialog; |
24 | import com.mylhyl.circledialog.res.values.CircleDimen; | 25 | import com.mylhyl.circledialog.res.values.CircleDimen; |
25 | 26 | ||
26 | import java.util.ArrayList; | 27 | import java.util.ArrayList; |
27 | import java.util.List; | 28 | import java.util.List; |
28 | 29 | ||
29 | /** | 30 | /** |
30 | * 自定义年级列表对话框 | 31 | * 自定义年级列表对话框 |
31 | * Created by h on 2017/8/10. | 32 | * Created by h on 2017/8/10. |
32 | */ | 33 | */ |
33 | 34 | @SuppressLint("ValidFragment") | |
34 | public class ProvinceListDialog extends BaseCircleDialog implements AdapterView.OnItemClickListener { | 35 | public class ProvinceListDialog extends BaseCircleDialog implements AdapterView.OnItemClickListener { |
35 | private ProvincesAdapter listadapter; | 36 | private ProvincesAdapter listadapter; |
36 | private ImageView cance; | 37 | private ImageView cance; |
37 | private ListView listView; | 38 | private ListView listView; |
38 | private ArrayList<ProvinceInfo.ProvincesBean> data = new ArrayList<>(); | 39 | private ArrayList<ProvinceInfo.ProvincesBean> data = new ArrayList<>(); |
39 | 40 | ||
40 | private DialogCallBack.ProvincesCallBack mCallBack; | 41 | private DialogCallBack.ProvincesCallBack mCallBack; |
41 | 42 | ||
42 | Handler handler = new Handler(){ | 43 | Handler handler = new Handler(){ |
43 | @Override | 44 | @Override |
44 | public void handleMessage(Message msg) { | 45 | public void handleMessage(Message msg) { |
45 | super.handleMessage(msg); | 46 | super.handleMessage(msg); |
46 | switch (msg.what){ | 47 | switch (msg.what){ |
47 | case HttpCode.PROVICES: | 48 | case HttpCode.PROVICES: |
48 | data.clear(); | 49 | data.clear(); |
49 | data.addAll( (List<ProvinceInfo.ProvincesBean>)msg.obj); | 50 | data.addAll( (List<ProvinceInfo.ProvincesBean>)msg.obj); |
50 | listadapter.notifyDataSetChanged(); | 51 | listadapter.notifyDataSetChanged(); |
51 | 52 | ||
52 | break; | 53 | break; |
53 | } | 54 | } |
54 | } | 55 | } |
55 | }; | 56 | }; |
56 | public ProvinceListDialog(DialogCallBack.ProvincesCallBack callBack) { | 57 | public ProvinceListDialog(DialogCallBack.ProvincesCallBack callBack) { |
57 | this.mCallBack = callBack; | 58 | this.mCallBack = callBack; |
58 | } | 59 | } |
59 | 60 | ||
60 | public static ProvinceListDialog getInstance(DialogCallBack.ProvincesCallBack callBack) { | 61 | public static ProvinceListDialog getInstance(DialogCallBack.ProvincesCallBack callBack) { |
61 | ProvinceListDialog dialogFragment = new ProvinceListDialog(callBack); | 62 | ProvinceListDialog dialogFragment = new ProvinceListDialog(callBack); |
62 | dialogFragment.setCanceledBack(true); | 63 | dialogFragment.setCanceledBack(true); |
63 | dialogFragment.setCanceledOnTouchOutside(true); | 64 | dialogFragment.setCanceledOnTouchOutside(true); |
64 | dialogFragment.setRadius(CircleDimen.RADIUS); | 65 | dialogFragment.setRadius(CircleDimen.RADIUS); |
65 | dialogFragment.setWidth(0.5f); | 66 | dialogFragment.setWidth(0.5f); |
66 | dialogFragment.setGravity(Gravity.CENTER); | 67 | dialogFragment.setGravity(Gravity.CENTER); |
67 | dialogFragment.setBackgroundColor(Color.WHITE); | 68 | dialogFragment.setBackgroundColor(Color.WHITE); |
68 | return dialogFragment; | 69 | return dialogFragment; |
69 | } | 70 | } |
70 | 71 | ||
71 | @Override | 72 | @Override |
72 | public View createView(Context context, LayoutInflater inflater, ViewGroup container) { | 73 | public View createView(Context context, LayoutInflater inflater, ViewGroup container) { |
73 | return inflater.inflate(R.layout.custom_adilog_provicelist, container, false); | 74 | return inflater.inflate(R.layout.custom_adilog_provicelist, container, false); |
74 | } | 75 | } |
75 | 76 | ||
76 | @Override | 77 | @Override |
77 | public void onActivityCreated(Bundle savedInstanceState) { | 78 | public void onActivityCreated(Bundle savedInstanceState) { |
78 | super.onActivityCreated(savedInstanceState); | 79 | super.onActivityCreated(savedInstanceState); |
79 | listView = (ListView) getView().findViewById(R.id.listadapter); | 80 | listView = (ListView) getView().findViewById(R.id.listadapter); |
80 | cance = (ImageView) getView().findViewById(R.id.cancel); | 81 | cance = (ImageView) getView().findViewById(R.id.cancel); |
81 | listadapter = new ProvincesAdapter(data,getActivity()); | 82 | listadapter = new ProvincesAdapter(data,getActivity()); |
82 | listView.setAdapter(listadapter); | 83 | listView.setAdapter(listadapter); |
83 | listView.setOnItemClickListener(this); | 84 | listView.setOnItemClickListener(this); |
84 | cance.setOnClickListener(new View.OnClickListener() { | 85 | cance.setOnClickListener(new View.OnClickListener() { |
85 | @Override | 86 | @Override |
86 | public void onClick(View v) { | 87 | public void onClick(View v) { |
87 | dismiss(); | 88 | dismiss(); |
88 | } | 89 | } |
89 | }); | 90 | }); |
90 | HttpManager.getInstance().provices(getActivity(),handler); | 91 | HttpManager.getInstance().provices(getActivity(),handler); |
91 | 92 | ||
92 | } | 93 | } |
93 | 94 | ||
94 | @Override | 95 | @Override |
95 | public void onItemClick(AdapterView<?> parent, View view, int position, long id) { | 96 | public void onItemClick(AdapterView<?> parent, View view, int position, long id) { |
96 | //Toast.makeText(getActivity(), "你点击了第" + position + "个", Toast.LENGTH_LONG).show(); | 97 | //Toast.makeText(getActivity(), "你点击了第" + position + "个", Toast.LENGTH_LONG).show(); |
97 | SaveParam.getInstance().saveLoginParam(getActivity(), SaveParam.PROVINCES, ""+data.get(position).getRegionId()); | 98 | SaveParam.getInstance().saveLoginParam(getActivity(), SaveParam.PROVINCES, ""+data.get(position).getRegionId()); |
98 | mCallBack.provinceOnItemClick(data,position,1); | 99 | mCallBack.provinceOnItemClick(data,position,1); |
99 | dismiss(); | 100 | dismiss(); |
100 | 101 | ||
101 | } | 102 | } |
102 | } | 103 | } |
103 | 104 |
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.annotation.SuppressLint; | ||
3 | import android.content.Context; | 4 | import android.content.Context; |
4 | import android.graphics.Color; | 5 | import android.graphics.Color; |
5 | import android.os.Bundle; | 6 | import android.os.Bundle; |
6 | import android.os.Handler; | 7 | import android.os.Handler; |
7 | import android.os.Message; | 8 | import android.os.Message; |
8 | import android.text.Editable; | 9 | import android.text.Editable; |
9 | import android.text.TextWatcher; | 10 | import android.text.TextWatcher; |
10 | import android.view.Gravity; | 11 | import android.view.Gravity; |
11 | import android.view.LayoutInflater; | 12 | import android.view.LayoutInflater; |
12 | import android.view.View; | 13 | import android.view.View; |
13 | import android.view.ViewGroup; | 14 | import android.view.ViewGroup; |
14 | import android.widget.AdapterView; | 15 | import android.widget.AdapterView; |
15 | import android.widget.EditText; | 16 | import android.widget.EditText; |
16 | import android.widget.ImageView; | 17 | import android.widget.ImageView; |
17 | import android.widget.ListView; | 18 | import android.widget.ListView; |
18 | 19 | ||
19 | import com.hjx.personalcenter.R; | 20 | import com.hjx.personalcenter.R; |
20 | import com.hjx.personalcenter.adapter.SchoolAdapter; | 21 | import com.hjx.personalcenter.adapter.SchoolAdapter; |
21 | import com.hjx.personalcenter.db.SaveParam; | 22 | import com.hjx.personalcenter.db.SaveParam; |
22 | import com.hjx.personalcenter.http.HttpCode; | 23 | import com.hjx.personalcenter.http.HttpCode; |
23 | import com.hjx.personalcenter.http.HttpManager; | 24 | import com.hjx.personalcenter.http.HttpManager; |
24 | import com.hjx.personalcenter.interfaces.DialogCallBack; | 25 | import com.hjx.personalcenter.interfaces.DialogCallBack; |
25 | import com.hjx.personalcenter.model.SchoolInfo; | 26 | import com.hjx.personalcenter.model.SchoolInfo; |
26 | import com.mylhyl.circledialog.BaseCircleDialog; | 27 | import com.mylhyl.circledialog.BaseCircleDialog; |
27 | import com.mylhyl.circledialog.res.values.CircleDimen; | 28 | import com.mylhyl.circledialog.res.values.CircleDimen; |
28 | 29 | ||
29 | import java.util.ArrayList; | 30 | import java.util.ArrayList; |
30 | import java.util.List; | 31 | import java.util.List; |
31 | 32 | ||
32 | /** | 33 | /** |
33 | * Created by h on 2017/8/21. | 34 | * Created by h on 2017/8/21. |
34 | */ | 35 | */ |
35 | 36 | @SuppressLint("ValidFragment") | |
36 | public class SchoolListDialog extends BaseCircleDialog implements AdapterView.OnItemClickListener { | 37 | public class SchoolListDialog extends BaseCircleDialog implements AdapterView.OnItemClickListener { |
37 | private ListView school_list; | 38 | private ListView school_list; |
38 | private EditText school_sech; | 39 | private EditText school_sech; |
39 | private SchoolAdapter listadapter; | 40 | private SchoolAdapter listadapter; |
40 | private ImageView cance; | 41 | private ImageView cance; |
41 | private View mView; | 42 | private View mView; |
42 | boolean isFilter; | 43 | boolean isFilter; |
43 | ArrayList<SchoolInfo.DataBean> data = new ArrayList<>(); | 44 | ArrayList<SchoolInfo.DataBean> data = new ArrayList<>(); |
44 | private DialogCallBack.SchoolCallBack mCallBack; | 45 | private DialogCallBack.SchoolCallBack mCallBack; |
45 | 46 | ||
46 | // public SchoolListDialog(DialogCallBack.CallBackView callBack) { | 47 | // public SchoolListDialog(DialogCallBack.CallBackView callBack) { |
47 | // this.mCallBack = callBack; | 48 | // this.mCallBack = callBack; |
48 | // } | 49 | // } |
49 | public SchoolListDialog(DialogCallBack.SchoolCallBack callBack) { | 50 | public SchoolListDialog(DialogCallBack.SchoolCallBack callBack) { |
50 | this.mCallBack = callBack; | 51 | this.mCallBack = callBack; |
51 | } | 52 | } |
52 | 53 | ||
53 | public static SchoolListDialog getInstance(DialogCallBack.SchoolCallBack mCallBack) { | 54 | public static SchoolListDialog getInstance(DialogCallBack.SchoolCallBack mCallBack) { |
54 | SchoolListDialog dialogFragment = new SchoolListDialog(mCallBack); | 55 | SchoolListDialog dialogFragment = new SchoolListDialog(mCallBack); |
55 | dialogFragment.setCanceledBack(true); | 56 | dialogFragment.setCanceledBack(true); |
56 | dialogFragment.setCanceledOnTouchOutside(true); | 57 | dialogFragment.setCanceledOnTouchOutside(true); |
57 | dialogFragment.setRadius(CircleDimen.RADIUS); | 58 | dialogFragment.setRadius(CircleDimen.RADIUS); |
58 | dialogFragment.setWidth(0.5f); | 59 | dialogFragment.setWidth(0.5f); |
59 | dialogFragment.setGravity(Gravity.CENTER); | 60 | dialogFragment.setGravity(Gravity.CENTER); |
60 | dialogFragment.setBackgroundColor(Color.WHITE); | 61 | dialogFragment.setBackgroundColor(Color.WHITE); |
61 | return dialogFragment; | 62 | return dialogFragment; |
62 | } | 63 | } |
63 | 64 | ||
64 | Handler handler = new Handler(){ | 65 | Handler handler = new Handler(){ |
65 | @Override | 66 | @Override |
66 | public void handleMessage(Message msg) { | 67 | public void handleMessage(Message msg) { |
67 | super.handleMessage(msg); | 68 | super.handleMessage(msg); |
68 | switch (msg.what){ | 69 | switch (msg.what){ |
69 | case HttpCode.SCHOOL: | 70 | case HttpCode.SCHOOL: |
70 | data.clear(); | 71 | data.clear(); |
71 | data.addAll( (List<SchoolInfo.DataBean>)msg.obj); | 72 | data.addAll( (List<SchoolInfo.DataBean>)msg.obj); |
72 | listadapter.notifyDataSetChanged(); | 73 | listadapter.notifyDataSetChanged(); |
73 | break; | 74 | break; |
74 | } | 75 | } |
75 | } | 76 | } |
76 | }; | 77 | }; |
77 | 78 | ||
78 | 79 | ||
79 | @Override | 80 | @Override |
80 | public View createView(Context context, LayoutInflater inflater, ViewGroup container) { | 81 | public View createView(Context context, LayoutInflater inflater, ViewGroup container) { |
81 | 82 | ||
82 | if (mView == null) { | 83 | if (mView == null) { |
83 | mView = inflater.inflate(R.layout.custom_adilog_school_list, container, false); | 84 | mView = inflater.inflate(R.layout.custom_adilog_school_list, container, false); |
84 | //mCallBack.provinceOnItemClick(context, inflater, container); | 85 | //mCallBack.provinceOnItemClick(context, inflater, container); |
85 | } | 86 | } |
86 | return mView; | 87 | return mView; |
87 | } | 88 | } |
88 | 89 | ||
89 | @Override | 90 | @Override |
90 | public void onActivityCreated(Bundle savedInstanceState) { | 91 | public void onActivityCreated(Bundle savedInstanceState) { |
91 | super.onActivityCreated(savedInstanceState); | 92 | super.onActivityCreated(savedInstanceState); |
92 | school_list = (ListView) getView().findViewById(R.id.listschooladapter); | 93 | school_list = (ListView) getView().findViewById(R.id.listschooladapter); |
93 | school_sech = (EditText) getView().findViewById(R.id.et_school_sech); | 94 | school_sech = (EditText) getView().findViewById(R.id.et_school_sech); |
94 | cance = (ImageView) getView().findViewById(R.id.cancel); | 95 | cance = (ImageView) getView().findViewById(R.id.cancel); |
95 | String citys = SaveParam.getInstance().getLoginParam(getActivity(), SaveParam.CITYS); | 96 | String citys = SaveParam.getInstance().getLoginParam(getActivity(), SaveParam.CITYS); |
96 | String grade = SaveParam.getInstance().getLoginParam(getActivity(), SaveParam.GRADENS); | 97 | String grade = SaveParam.getInstance().getLoginParam(getActivity(), SaveParam.GRADENS); |
97 | listadapter = new SchoolAdapter(data, getActivity()); | 98 | listadapter = new SchoolAdapter(data, getActivity()); |
98 | school_list.setAdapter(listadapter); | 99 | school_list.setAdapter(listadapter); |
99 | school_list.setOnItemClickListener(this); | 100 | school_list.setOnItemClickListener(this); |
100 | cance.setOnClickListener(new View.OnClickListener() { | 101 | cance.setOnClickListener(new View.OnClickListener() { |
101 | @Override | 102 | @Override |
102 | public void onClick(View v) { | 103 | public void onClick(View v) { |
103 | dismiss(); | 104 | dismiss(); |
104 | } | 105 | } |
105 | }); | 106 | }); |
106 | try { | 107 | try { |
107 | int a = Integer.parseInt(citys); | 108 | int a = Integer.parseInt(citys); |
108 | int b = Integer.parseInt(grade); | 109 | int b = Integer.parseInt(grade); |
109 | HttpManager.getInstance().getschool(getActivity(),a,b,handler); | 110 | HttpManager.getInstance().getschool(getActivity(),a,b,handler); |
110 | } catch (NumberFormatException e) { | 111 | } catch (NumberFormatException e) { |
111 | e.printStackTrace(); | 112 | e.printStackTrace(); |
112 | } | 113 | } |
113 | intiEditView(); | 114 | intiEditView(); |
114 | 115 | ||
115 | 116 | ||
116 | } | 117 | } |
117 | private void intiEditView() { | 118 | private void intiEditView() { |
118 | school_sech.addTextChangedListener(new TextWatcher() { | 119 | school_sech.addTextChangedListener(new TextWatcher() { |
119 | @Override | 120 | @Override |
120 | public void beforeTextChanged(CharSequence s, int start, int count, int after) { | 121 | public void beforeTextChanged(CharSequence s, int start, int count, int after) { |
121 | 122 | ||
122 | } | 123 | } |
123 | 124 | ||
124 | @Override | 125 | @Override |
125 | public void onTextChanged(CharSequence s, int start, int before, int count) { | 126 | public void onTextChanged(CharSequence s, int start, int before, int count) { |
126 | // mAdapter.getFilter().filter(s); | 127 | // mAdapter.getFilter().filter(s); |
127 | 128 | ||
128 | listadapter.getFilter().filter(s); | 129 | listadapter.getFilter().filter(s); |
129 | } | 130 | } |
130 | 131 | ||
131 | @Override | 132 | @Override |
132 | public void afterTextChanged(Editable s) { | 133 | public void afterTextChanged(Editable s) { |
133 | 134 | ||
134 | } | 135 | } |
135 | }); | 136 | }); |
136 | } | 137 | } |
137 | 138 | ||
138 | @Override | 139 | @Override |
139 | public void onItemClick(AdapterView<?> parent, View view, int position, long id) { | 140 | public void onItemClick(AdapterView<?> parent, View view, int position, long id) { |
140 | SaveParam.getInstance().saveLoginParam(getActivity(), SaveParam.SCHOOOlID, ""+data.get(position).getSchoolId()); | 141 | SaveParam.getInstance().saveLoginParam(getActivity(), SaveParam.SCHOOOlID, ""+data.get(position).getSchoolId()); |
141 | mCallBack.provinceO4nItemClick(data,position,4); | 142 | mCallBack.provinceO4nItemClick(data,position,4); |
142 | dismiss(); | 143 | dismiss(); |
143 | 144 | ||
144 | } | 145 | } |
145 | } | 146 | } |
146 | 147 |
PersonalCenter/app/src/main/java/com/hjx/personalcenter/customdialog/VerSionDialog.java
1 | package com.hjx.personalcenter.customdialog; | 1 | package com.hjx.personalcenter.customdialog; |
2 | 2 | ||
3 | import android.annotation.SuppressLint; | ||
3 | import android.content.Context; | 4 | import android.content.Context; |
4 | import android.graphics.Color; | 5 | import android.graphics.Color; |
5 | import android.os.Bundle; | 6 | import android.os.Bundle; |
6 | import android.os.Handler; | 7 | import android.os.Handler; |
7 | import android.os.Message; | 8 | import android.os.Message; |
8 | import android.util.Log; | 9 | import android.util.Log; |
9 | import android.view.Gravity; | 10 | import android.view.Gravity; |
10 | import android.view.LayoutInflater; | 11 | import android.view.LayoutInflater; |
11 | import android.view.View; | 12 | import android.view.View; |
12 | import android.view.ViewGroup; | 13 | import android.view.ViewGroup; |
13 | import android.widget.AdapterView; | 14 | import android.widget.AdapterView; |
14 | import android.widget.ImageView; | 15 | import android.widget.ImageView; |
15 | import android.widget.ListView; | 16 | import android.widget.ListView; |
16 | 17 | ||
17 | import com.hjx.personalcenter.R; | 18 | import com.hjx.personalcenter.R; |
18 | import com.hjx.personalcenter.adapter.VersionAdapter; | 19 | import com.hjx.personalcenter.adapter.VersionAdapter; |
19 | import com.hjx.personalcenter.db.SaveParam; | 20 | import com.hjx.personalcenter.db.SaveParam; |
20 | import com.hjx.personalcenter.http.HttpCode; | 21 | import com.hjx.personalcenter.http.HttpCode; |
21 | import com.hjx.personalcenter.http.HttpManager; | 22 | import com.hjx.personalcenter.http.HttpManager; |
22 | import com.hjx.personalcenter.interfaces.DialogCallBack; | 23 | import com.hjx.personalcenter.interfaces.DialogCallBack; |
23 | import com.hjx.personalcenter.model.VersionInfo; | 24 | import com.hjx.personalcenter.model.VersionInfo; |
24 | import com.mylhyl.circledialog.BaseCircleDialog; | 25 | import com.mylhyl.circledialog.BaseCircleDialog; |
25 | import com.mylhyl.circledialog.res.values.CircleDimen; | 26 | import com.mylhyl.circledialog.res.values.CircleDimen; |
26 | 27 | ||
27 | import java.util.ArrayList; | 28 | import java.util.ArrayList; |
28 | import java.util.List; | 29 | import java.util.List; |
29 | 30 | ||
30 | /** | 31 | /** |
31 | * 自定义版本信息列表对话框 | 32 | * 自定义版本信息列表对话框 |
32 | * Created by h on 2017/8/10. | 33 | * Created by h on 2017/8/10. |
33 | */ | 34 | */ |
34 | 35 | @SuppressLint("ValidFragment") | |
35 | public class VerSionDialog extends BaseCircleDialog implements AdapterView.OnItemClickListener { | 36 | public class VerSionDialog extends BaseCircleDialog implements AdapterView.OnItemClickListener { |
36 | private VersionAdapter listadapter; | 37 | private VersionAdapter listadapter; |
37 | private ImageView cance; | 38 | private ImageView cance; |
38 | private ListView listView; | 39 | private ListView listView; |
39 | private ArrayList<VersionInfo.DataBean> data = new ArrayList<>(); | 40 | private ArrayList<VersionInfo.DataBean> data = new ArrayList<>(); |
40 | 41 | ||
41 | private DialogCallBack.VersionCallBack mCallBack; | 42 | private DialogCallBack.VersionCallBack mCallBack; |
42 | 43 | ||
43 | Handler handler = new Handler(){ | 44 | Handler handler = new Handler(){ |
44 | @Override | 45 | @Override |
45 | public void handleMessage(Message msg) { | 46 | public void handleMessage(Message msg) { |
46 | super.handleMessage(msg); | 47 | super.handleMessage(msg); |
47 | switch (msg.what){ | 48 | switch (msg.what){ |
48 | case HttpCode.VERSION_SUCESS: | 49 | case HttpCode.VERSION_SUCESS: |
49 | data.clear(); | 50 | data.clear(); |
50 | data.addAll( (List<VersionInfo.DataBean>)msg.obj); | 51 | data.addAll( (List<VersionInfo.DataBean>)msg.obj); |
51 | listadapter.notifyDataSetChanged(); | 52 | listadapter.notifyDataSetChanged(); |
52 | 53 | ||
53 | break; | 54 | break; |
54 | } | 55 | } |
55 | } | 56 | } |
56 | }; | 57 | }; |
57 | public VerSionDialog(DialogCallBack.VersionCallBack callBack) { | 58 | public VerSionDialog(DialogCallBack.VersionCallBack callBack) { |
58 | this.mCallBack = callBack; | 59 | this.mCallBack = callBack; |
59 | } | 60 | } |
60 | 61 | ||
61 | public static VerSionDialog getInstance(DialogCallBack.VersionCallBack callBack) { | 62 | public static VerSionDialog getInstance(DialogCallBack.VersionCallBack callBack) { |
62 | VerSionDialog dialogFragment = new VerSionDialog(callBack); | 63 | VerSionDialog dialogFragment = new VerSionDialog(callBack); |
63 | dialogFragment.setCanceledBack(true); | 64 | dialogFragment.setCanceledBack(true); |
64 | dialogFragment.setCanceledOnTouchOutside(true); | 65 | dialogFragment.setCanceledOnTouchOutside(true); |
65 | dialogFragment.setRadius(CircleDimen.RADIUS); | 66 | dialogFragment.setRadius(CircleDimen.RADIUS); |
66 | dialogFragment.setWidth(0.5f); | 67 | dialogFragment.setWidth(0.5f); |
67 | dialogFragment.setGravity(Gravity.CENTER); | 68 | dialogFragment.setGravity(Gravity.CENTER); |
68 | dialogFragment.setBackgroundColor(Color.WHITE); | 69 | dialogFragment.setBackgroundColor(Color.WHITE); |
69 | return dialogFragment; | 70 | return dialogFragment; |
70 | } | 71 | } |
71 | 72 | ||
72 | @Override | 73 | @Override |
73 | public View createView(Context context, LayoutInflater inflater, ViewGroup container) { | 74 | public View createView(Context context, LayoutInflater inflater, ViewGroup container) { |
74 | return inflater.inflate(R.layout.custom_adilog_provicelist, container, false); | 75 | return inflater.inflate(R.layout.custom_adilog_provicelist, container, false); |
75 | } | 76 | } |
76 | 77 | ||
77 | @Override | 78 | @Override |
78 | public void onActivityCreated(Bundle savedInstanceState) { | 79 | public void onActivityCreated(Bundle savedInstanceState) { |
79 | super.onActivityCreated(savedInstanceState); | 80 | super.onActivityCreated(savedInstanceState); |
80 | listView = (ListView) getView().findViewById(R.id.listadapter); | 81 | listView = (ListView) getView().findViewById(R.id.listadapter); |
81 | cance = (ImageView) getView().findViewById(R.id.cancel); | 82 | cance = (ImageView) getView().findViewById(R.id.cancel); |
82 | listadapter = new VersionAdapter(data,getActivity()); | 83 | listadapter = new VersionAdapter(data,getActivity()); |
83 | listView.setAdapter(listadapter); | 84 | listView.setAdapter(listadapter); |
84 | listView.setOnItemClickListener(this); | 85 | listView.setOnItemClickListener(this); |
85 | cance.setOnClickListener(new View.OnClickListener() { | 86 | cance.setOnClickListener(new View.OnClickListener() { |
86 | @Override | 87 | @Override |
87 | public void onClick(View v) { | 88 | public void onClick(View v) { |
88 | dismiss(); | 89 | dismiss(); |
89 | } | 90 | } |
90 | }); | 91 | }); |
91 | String subjectName = SaveParam.getInstance().getLoginParam(getActivity(),SaveParam.VERSION); | 92 | String subjectName = SaveParam.getInstance().getLoginParam(getActivity(),SaveParam.VERSION); |
92 | Log.e("test","选择的科目"+subjectName); | 93 | Log.e("test","选择的科目"+subjectName); |
93 | HttpManager.getInstance().versioninfo(getActivity(),subjectName,handler); | 94 | HttpManager.getInstance().versioninfo(getActivity(),subjectName,handler); |
94 | 95 | ||
95 | } | 96 | } |
96 | 97 | ||
97 | @Override | 98 | @Override |
98 | public void onItemClick(AdapterView<?> parent, View view, int position, long id) { | 99 | public void onItemClick(AdapterView<?> parent, View view, int position, long id) { |
99 | //Toast.makeText(getActivity(), "你点击了第" + position + "个", Toast.LENGTH_LONG).show(); | 100 | //Toast.makeText(getActivity(), "你点击了第" + position + "个", Toast.LENGTH_LONG).show(); |
100 | //SaveParam.getInstance().saveLoginParam(getActivity(), SaveParam.PROVINCES, ""+data.get(position).getRegionId()); | 101 | //SaveParam.getInstance().saveLoginParam(getActivity(), SaveParam.PROVINCES, ""+data.get(position).getRegionId()); |
101 | mCallBack.versionOnItemClick(data,position,1); | 102 | mCallBack.versionOnItemClick(data,position,1); |
102 | dismiss(); | 103 | dismiss(); |
103 | 104 | ||
104 | } | 105 | } |
105 | } | 106 | } |
106 | 107 |
PersonalCenter/app/src/main/java/com/hjx/personalcenter/fragment/LoginFragment.java
1 | package com.hjx.personalcenter.fragment; | 1 | package com.hjx.personalcenter.fragment; |
2 | 2 | ||
3 | import android.content.Intent; | 3 | import android.content.Intent; |
4 | import android.os.Bundle; | 4 | import android.os.Bundle; |
5 | import android.os.Handler; | 5 | import android.os.Handler; |
6 | import android.os.Message; | 6 | import android.os.Message; |
7 | import android.support.annotation.Nullable; | 7 | import android.support.annotation.Nullable; |
8 | import android.support.v4.app.Fragment; | 8 | import android.support.v4.app.Fragment; |
9 | import android.text.TextUtils; | 9 | import android.text.TextUtils; |
10 | import android.view.LayoutInflater; | 10 | import android.view.LayoutInflater; |
11 | import android.view.View; | 11 | import android.view.View; |
12 | import android.view.ViewGroup; | 12 | import android.view.ViewGroup; |
13 | import android.widget.Button; | 13 | import android.widget.Button; |
14 | import android.widget.EditText; | 14 | import android.widget.EditText; |
15 | import android.widget.TextView; | 15 | import android.widget.TextView; |
16 | import android.widget.Toast; | 16 | import android.widget.Toast; |
17 | 17 | ||
18 | import com.hjx.personalcenter.R; | 18 | import com.hjx.personalcenter.R; |
19 | import com.hjx.personalcenter.activity.ForgotPasswordActivity; | 19 | import com.hjx.personalcenter.activity.ForgotPasswordActivity; |
20 | import com.hjx.personalcenter.activity.MainActivity; | 20 | import com.hjx.personalcenter.activity.MainActivity; |
21 | import com.hjx.personalcenter.activity.RegisterInfoActivity; | ||
21 | import com.hjx.personalcenter.customdialog.ElectronicCardDialog; | 22 | import com.hjx.personalcenter.customdialog.ElectronicCardDialog; |
23 | import com.hjx.personalcenter.db.SaveParam; | ||
22 | import com.hjx.personalcenter.http.HttpCode; | 24 | import com.hjx.personalcenter.http.HttpCode; |
23 | import com.hjx.personalcenter.http.HttpManager; | 25 | import com.hjx.personalcenter.http.HttpManager; |
24 | import com.hjx.personalcenter.util.AlertUtils; | 26 | import com.hjx.personalcenter.util.AlertUtils; |
25 | import com.hjx.personalcenter.util.PhoneNumCheckUtils; | 27 | import com.hjx.personalcenter.util.PhoneNumCheckUtils; |
26 | 28 | ||
27 | import org.json.JSONException; | 29 | import org.json.JSONException; |
28 | import org.json.JSONObject; | 30 | import org.json.JSONObject; |
29 | 31 | ||
30 | /** | 32 | /** |
31 | * 登录 | 33 | * 登录 |
32 | * Created by h on 2017/8/8. | 34 | * Created by h on 2017/8/8. |
33 | */ | 35 | */ |
34 | 36 | ||
35 | public class LoginFragment extends Fragment implements View.OnClickListener { | 37 | public class LoginFragment extends Fragment implements View.OnClickListener { |
36 | private View mView; | 38 | private View mView; |
37 | private int type; | 39 | private int type; |
38 | private TextView tv_forget_pwd; | 40 | private TextView tv_forget_pwd; |
39 | private Button btn_login; | 41 | private Button btn_login; |
40 | private EditText phonenumber,login_pwwd; | 42 | private EditText phonenumber,login_pwwd; |
41 | public static String TABLAYOUT_FRAGMENT = "tab_fragment"; | 43 | public static String TABLAYOUT_FRAGMENT = "tab_fragment"; |
42 | Intent intent = new Intent(); | 44 | Intent intent = new Intent(); |
43 | public static LoginFragment newInstance(int type) { | 45 | public static LoginFragment newInstance(int type) { |
44 | LoginFragment fragment = new LoginFragment(); | 46 | LoginFragment fragment = new LoginFragment(); |
45 | Bundle bundle = new Bundle(); | 47 | Bundle bundle = new Bundle(); |
46 | bundle.putSerializable(TABLAYOUT_FRAGMENT, type); | 48 | bundle.putSerializable(TABLAYOUT_FRAGMENT, type); |
47 | fragment.setArguments(bundle); | 49 | fragment.setArguments(bundle); |
48 | return fragment; | 50 | return fragment; |
49 | 51 | ||
50 | } | 52 | } |
51 | Handler handler = new Handler(){ | 53 | Handler handler = new Handler(){ |
52 | @Override | 54 | @Override |
53 | public void handleMessage(Message msg) { | 55 | public void handleMessage(Message msg) { |
54 | super.handleMessage(msg); | 56 | super.handleMessage(msg); |
55 | 57 | ||
56 | switch (msg.what){ | 58 | switch (msg.what){ |
57 | case HttpCode.LOGIN_SUCESS: | 59 | case HttpCode.LOGIN_SUCESS: |
58 | JSONObject jsonObject; | 60 | JSONObject jsonObject; |
59 | String status; | 61 | String status; |
60 | try { | 62 | try { |
61 | jsonObject = new JSONObject((String) msg.obj); | 63 | jsonObject = new JSONObject((String) msg.obj); |
62 | status = jsonObject.getString("status"); | 64 | status = jsonObject.getString("status"); |
63 | if (status.equals("100")) { | 65 | if (status.equals("100")) { |
64 | String access_token = jsonObject.getString("access_token"); | 66 | String access_token = jsonObject.getString("access_token"); |
65 | String userId = jsonObject.getString("userId"); | 67 | String userId = jsonObject.getString("userId"); |
66 | final String name = phonenumber.getText().toString().trim(); | 68 | final String name = phonenumber.getText().toString().trim(); |
67 | final String pwd = login_pwwd.getText().toString().trim(); | 69 | final String pwd = login_pwwd.getText().toString().trim(); |
68 | // | 70 | // |
69 | try { | 71 | try { |
70 | long auserID = Long.parseLong(userId); | 72 | long auserID = Long.parseLong(userId); |
71 | //是否填写保卡 | ||
72 | HttpManager.getInstance().cardinfocheck(getActivity(),auserID,handler); | ||
73 | //登录成功,保存登录数据并且获取个人信息 | 73 | //登录成功,保存登录数据并且获取个人信息 |
74 | HttpManager.getInstance().saveLoginInfo(getActivity(), name, pwd, access_token, "true", userId); | 74 | HttpManager.getInstance().saveLoginInfo(getActivity(), name, pwd, access_token, "true", userId); |
75 | //检测注册信息是否完整 | ||
76 | HttpManager.getInstance().registerinfocheck(getActivity(),auserID,handler); | ||
77 | |||
78 | |||
79 | |||
75 | } catch (NumberFormatException e) { | 80 | } catch (NumberFormatException e) { |
76 | e.printStackTrace(); | 81 | e.printStackTrace(); |
77 | } | 82 | } |
78 | 83 | ||
79 | 84 | ||
80 | } else if (status.equals("200")) { | 85 | } else if (status.equals("200")) { |
81 | Toast.makeText(getActivity(), "用户名不存在!", Toast.LENGTH_LONG).show(); | 86 | Toast.makeText(getActivity(), "用户名不存在!", Toast.LENGTH_LONG).show(); |
82 | return; | 87 | return; |
83 | } else if (status.equals("204")) { | 88 | } else if (status.equals("204")) { |
84 | Toast.makeText(getActivity(), "密码错误!", Toast.LENGTH_LONG).show(); | 89 | Toast.makeText(getActivity(), "密码错误!", Toast.LENGTH_LONG).show(); |
85 | } else { | 90 | } else { |
86 | Toast.makeText(getActivity(), "登录失败!请检查网络", Toast.LENGTH_LONG).show(); | 91 | Toast.makeText(getActivity(), "登录失败!请检查网络", Toast.LENGTH_LONG).show(); |
87 | 92 | ||
88 | 93 | ||
89 | } | 94 | } |
90 | } catch (JSONException e) { | 95 | } catch (JSONException e) { |
91 | e.printStackTrace(); | 96 | e.printStackTrace(); |
92 | } | 97 | } |
93 | break; | 98 | break; |
99 | case HttpCode.REGISTER_SUCESS: | ||
100 | try { | ||
101 | jsonObject = new JSONObject( (String) msg.obj); | ||
102 | status = jsonObject.optString("status"); | ||
103 | JSONObject isregisterinfo = (JSONObject) jsonObject.opt("data"); | ||
104 | boolean isRegisterInfoComplete =isregisterinfo.optBoolean("isRegisterInfoComplete"); | ||
105 | if (status.equals("1")){ | ||
106 | if (!isRegisterInfoComplete){ | ||
107 | Intent intent = new Intent(); | ||
108 | intent.setClass(getActivity(), RegisterInfoActivity.class); | ||
109 | getActivity().startActivity(intent); | ||
110 | getActivity().overridePendingTransition(R.anim.rightin, R.anim.rightout); | ||
111 | }else { | ||
112 | String userID = SaveParam.getInstance().getLoginParam(getActivity(),"userId"); | ||
113 | try { | ||
114 | long auserID = Long.parseLong(userID); | ||
115 | //是否填写保卡 | ||
116 | HttpManager.getInstance().cardinfocheck(getActivity(),auserID,handler); | ||
117 | } catch (NumberFormatException e) { | ||
118 | e.printStackTrace(); | ||
119 | } | ||
120 | |||
121 | |||
122 | } | ||
123 | |||
124 | }else{ | ||
125 | Toast.makeText(getActivity(), "请检查网络", Toast.LENGTH_LONG).show(); | ||
126 | } | ||
127 | |||
128 | } catch (JSONException e) { | ||
129 | e.printStackTrace(); | ||
130 | } | ||
131 | |||
132 | break; | ||
94 | case HttpCode.CHECKCARD: | 133 | case HttpCode.CHECKCARD: |
95 | try { | 134 | try { |
96 | jsonObject = new JSONObject( (String) msg.obj); | 135 | jsonObject = new JSONObject( (String) msg.obj); |
97 | status = jsonObject.optString("status"); | 136 | status = jsonObject.optString("status"); |
98 | if (status.equals("1")){ | 137 | if (status.equals("1")){ |
99 | Intent intent = new Intent(); | 138 | Intent intent = new Intent(); |
100 | intent.setClass(getActivity(), MainActivity.class); | 139 | intent.setClass(getActivity(), MainActivity.class); |
101 | getActivity().startActivity(intent); | 140 | getActivity().startActivity(intent); |
102 | getActivity().overridePendingTransition(R.anim.rightin, R.anim.rightout); | 141 | getActivity().overridePendingTransition(R.anim.rightin, R.anim.rightout); |
103 | }else if(status.equals("2001")){ | 142 | }else if(status.equals("2001")){ |
104 | ElectronicCardDialog.getInstance().show(getChildFragmentManager(), "ElectronicCardDialog"); | 143 | ElectronicCardDialog.getInstance().show(getChildFragmentManager(), "ElectronicCardDialog"); |
105 | }else{ | 144 | }else{ |
106 | Toast.makeText(getActivity(), "请检查网络", Toast.LENGTH_LONG).show(); | 145 | Toast.makeText(getActivity(), "请检查网络", Toast.LENGTH_LONG).show(); |
107 | } | 146 | } |
108 | 147 | ||
109 | } catch (JSONException e) { | 148 | } catch (JSONException e) { |
110 | e.printStackTrace(); | 149 | e.printStackTrace(); |
111 | } | 150 | } |
112 | 151 | ||
113 | break; | 152 | break; |
114 | } | 153 | } |
115 | } | 154 | } |
116 | }; | 155 | }; |
117 | 156 | ||
118 | @Override | 157 | @Override |
119 | public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { | 158 | public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { |
120 | if (mView == null) { | 159 | if (mView == null) { |
121 | mView = inflater.inflate(R.layout.fragment_loginandregister_login, container, false); | 160 | mView = inflater.inflate(R.layout.fragment_loginandregister_login, container, false); |
122 | initView(mView); | 161 | initView(mView); |
123 | initData(); | 162 | initData(); |
124 | setLister(); | 163 | setLister(); |
125 | 164 | ||
126 | 165 | ||
127 | } | 166 | } |
128 | return mView; | 167 | return mView; |
129 | } | 168 | } |
130 | //初始化 | 169 | //初始化 |
131 | private void initView(View mView) { | 170 | private void initView(View mView) { |
132 | tv_forget_pwd = (TextView) mView.findViewById(R.id.tv_forget_pwd); | 171 | tv_forget_pwd = (TextView) mView.findViewById(R.id.tv_forget_pwd); |
133 | phonenumber = (EditText) mView.findViewById(R.id.et_phonenumber); | 172 | phonenumber = (EditText) mView.findViewById(R.id.et_phonenumber); |
134 | login_pwwd = (EditText) mView.findViewById(R.id.et_password); | 173 | login_pwwd = (EditText) mView.findViewById(R.id.et_password); |
135 | btn_login = (Button) mView.findViewById(R.id.btn_login); | 174 | btn_login = (Button) mView.findViewById(R.id.btn_login); |
136 | 175 | ||
137 | } | 176 | } |
138 | private void initData() { | 177 | private void initData() { |
139 | } | 178 | } |
140 | private void setLister() { | 179 | private void setLister() { |
141 | tv_forget_pwd.setOnClickListener(this); | 180 | tv_forget_pwd.setOnClickListener(this); |
142 | btn_login.setOnClickListener(this); | 181 | btn_login.setOnClickListener(this); |
143 | } | 182 | } |
144 | 183 | ||
145 | 184 | ||
146 | @Override | 185 | @Override |
147 | public void onClick(View v) { | 186 | public void onClick(View v) { |
148 | switch (v.getId()){ | 187 | switch (v.getId()){ |
149 | case R.id.tv_forget_pwd: | 188 | case R.id.tv_forget_pwd: |
150 | intent.setClass(getActivity(),ForgotPasswordActivity.class); | 189 | intent.setClass(getActivity(),ForgotPasswordActivity.class); |
151 | startActivity(intent); | 190 | startActivity(intent); |
152 | getActivity().overridePendingTransition(R.anim.rightin, R.anim.rightout); | 191 | getActivity().overridePendingTransition(R.anim.rightin, R.anim.rightout); |
153 | break; | 192 | break; |
154 | case R.id.btn_login: | 193 | case R.id.btn_login: |
155 | login(); | 194 | login(); |
156 | break; | 195 | break; |
157 | } | 196 | } |
158 | 197 | ||
159 | } | 198 | } |
160 | 199 | ||
161 | private void login() { | 200 | private void login() { |
162 | final String name = phonenumber.getText().toString().trim(); | 201 | final String name = phonenumber.getText().toString().trim(); |
163 | final String pwd = login_pwwd.getText().toString().trim(); | 202 | final String pwd = login_pwwd.getText().toString().trim(); |
164 | if (TextUtils.isEmpty(name) || TextUtils.isEmpty(pwd)) { | 203 | if (TextUtils.isEmpty(name) || TextUtils.isEmpty(pwd)) { |
165 | AlertUtils.showToast(getActivity(), "请输入手机号和密码"); | 204 | AlertUtils.showToast(getActivity(), "请输入手机号和密码"); |
166 | return; | 205 | return; |
167 | }else if (!PhoneNumCheckUtils.isPhone(name)){ | 206 | }else if (!PhoneNumCheckUtils.isPhone(name)){ |
168 | AlertUtils.showToast(getActivity(), "请输入正确的手机号"); | 207 | AlertUtils.showToast(getActivity(), "请输入正确的手机号"); |
169 | }else { | 208 | }else { |
170 | //登录接口 | 209 | //登录接口 |
171 | HttpManager.getInstance().login(name,pwd, getActivity(),handler); | 210 | HttpManager.getInstance().login(name,pwd, getActivity(),handler); |
172 | } | 211 | } |
173 | 212 | ||
174 | 213 | ||
175 | } | 214 | } |
PersonalCenter/app/src/main/java/com/hjx/personalcenter/fragment/RegisterFragment.java
1 | package com.hjx.personalcenter.fragment; | 1 | package com.hjx.personalcenter.fragment; |
2 | 2 | ||
3 | import android.content.Intent; | 3 | import android.content.Intent; |
4 | import android.os.Bundle; | 4 | import android.os.Bundle; |
5 | import android.os.Handler; | 5 | import android.os.Handler; |
6 | import android.os.Message; | 6 | import android.os.Message; |
7 | import android.support.annotation.Nullable; | 7 | import android.support.annotation.Nullable; |
8 | import android.support.v4.app.Fragment; | 8 | import android.support.v4.app.Fragment; |
9 | import android.text.TextUtils; | 9 | import android.text.TextUtils; |
10 | import android.text.method.HideReturnsTransformationMethod; | 10 | import android.text.method.HideReturnsTransformationMethod; |
11 | import android.text.method.PasswordTransformationMethod; | 11 | import android.text.method.PasswordTransformationMethod; |
12 | import android.view.LayoutInflater; | 12 | import android.view.LayoutInflater; |
13 | import android.view.View; | 13 | import android.view.View; |
14 | import android.view.ViewGroup; | 14 | import android.view.ViewGroup; |
15 | import android.widget.Button; | 15 | import android.widget.Button; |
16 | import android.widget.EditText; | 16 | import android.widget.EditText; |
17 | import android.widget.ImageView; | 17 | import android.widget.ImageView; |
18 | 18 | ||
19 | import com.hjx.personalcenter.R; | 19 | import com.hjx.personalcenter.R; |
20 | import com.hjx.personalcenter.activity.RegisterInfoActivity; | 20 | import com.hjx.personalcenter.activity.RegisterInfoActivity; |
21 | import com.hjx.personalcenter.db.Content; | 21 | import com.hjx.personalcenter.db.Content; |
22 | import com.hjx.personalcenter.http.HttpCode; | 22 | import com.hjx.personalcenter.http.HttpCode; |
23 | import com.hjx.personalcenter.http.HttpManager; | 23 | import com.hjx.personalcenter.http.HttpManager; |
24 | import com.hjx.personalcenter.util.AlertUtils; | 24 | import com.hjx.personalcenter.util.AlertUtils; |
25 | import com.hjx.personalcenter.util.PasswordCheckUtils; | 25 | import com.hjx.personalcenter.util.PasswordCheckUtils; |
26 | import com.hjx.personalcenter.util.PhoneNumCheckUtils; | 26 | import com.hjx.personalcenter.util.PhoneNumCheckUtils; |
27 | 27 | ||
28 | import org.json.JSONException; | 28 | import org.json.JSONException; |
29 | import org.json.JSONObject; | 29 | import org.json.JSONObject; |
30 | 30 | ||
31 | import java.util.TimerTask; | 31 | import java.util.TimerTask; |
32 | 32 | ||
33 | /** | 33 | /** |
34 | * 注册 | 34 | * 注册 |
35 | * Created by Administrator on 2016/11/7. | 35 | * Created by Administrator on 2016/11/7. |
36 | */ | 36 | */ |
37 | 37 | ||
38 | public class RegisterFragment extends Fragment implements View.OnClickListener { | 38 | public class RegisterFragment extends Fragment implements View.OnClickListener { |
39 | private View mView; | 39 | private View mView; |
40 | 40 | ||
41 | private Button btn_register,get_authcode; | 41 | private Button btn_register,get_authcode; |
42 | private EditText phonenumber,password,anth_6num;//;//密码 | 42 | private EditText phonenumber,password,anth_6num;//;//密码 |
43 | private ImageView openeyes; | 43 | private ImageView openeyes; |
44 | private String sourceStr ="android"; | 44 | private String sourceStr ="android"; |
45 | private String typeStr = "register"; | 45 | private String typeStr = "register"; |
46 | private int delayTime=60; | 46 | private int delayTime=60; |
47 | private java.util.Timer Delaytimer; | 47 | private java.util.Timer Delaytimer; |
48 | private int type; | 48 | private int type; |
49 | public static Boolean showPassword = false; | 49 | public static Boolean showPassword = false; |
50 | public static String TABLAYOUT_FRAGMENT = "tab_fragment"; | 50 | public static String TABLAYOUT_FRAGMENT = "tab_fragment"; |
51 | 51 | ||
52 | public static RegisterFragment newInstance(int type) { | 52 | public static RegisterFragment newInstance(int type) { |
53 | RegisterFragment fragment = new RegisterFragment(); | 53 | RegisterFragment fragment = new RegisterFragment(); |
54 | Bundle bundle = new Bundle(); | 54 | Bundle bundle = new Bundle(); |
55 | bundle.putSerializable(TABLAYOUT_FRAGMENT, type); | 55 | bundle.putSerializable(TABLAYOUT_FRAGMENT, type); |
56 | fragment.setArguments(bundle); | 56 | fragment.setArguments(bundle); |
57 | return fragment; | 57 | return fragment; |
58 | 58 | ||
59 | } | 59 | } |
60 | Handler handler = new Handler() { | 60 | Handler handler = new Handler() { |
61 | @Override | 61 | @Override |
62 | public void handleMessage(Message msg) { | 62 | public void handleMessage(Message msg) { |
63 | super.handleMessage(msg); | 63 | super.handleMessage(msg); |
64 | try { | 64 | try { |
65 | JSONObject jsonObject; | 65 | JSONObject jsonObject; |
66 | String status; | 66 | String status; |
67 | switch (msg.what) { | 67 | switch (msg.what) { |
68 | case HttpCode.REGISTERED_SUCESS: | 68 | case HttpCode.REGISTERED_SUCESS: |
69 | jsonObject = (JSONObject) msg.obj; | 69 | jsonObject = (JSONObject) msg.obj; |
70 | status = jsonObject.getString("status"); | 70 | status = jsonObject.getString("status"); |
71 | //AlertUtils.showToast(RegisterActivity.this, jsonObject.optString("message")); | 71 | //AlertUtils.showToast(RegisterActivity.this, jsonObject.optString("message")); |
72 | String access_token = jsonObject.getString("access_token"); | 72 | String access_token = jsonObject.getString("access_token"); |
73 | String userId = jsonObject.getString("userId"); | 73 | String userId = jsonObject.getString("userId"); |
74 | if (status.equals("100")) { | 74 | if (status.equals("100")) { |
75 | String usernameStr = phonenumber.getText().toString().trim(); | 75 | String usernameStr = phonenumber.getText().toString().trim(); |
76 | String passwordStr = password.getText().toString().trim(); | 76 | String passwordStr = password.getText().toString().trim(); |
77 | HttpManager.getInstance().saveLoginInfo(getActivity(),usernameStr,passwordStr,access_token,"true",userId); | 77 | HttpManager.getInstance().saveLoginInfo(getActivity(),usernameStr,passwordStr,access_token,"true",userId); |
78 | AlertUtils.showToast(getActivity(), "注册成功!"); | 78 | AlertUtils.showToast(getActivity(), "注册成功!"); |
79 | Content.accountflag =1; | 79 | Content.accountflag =1; |
80 | //检查信息是否填写完整 | ||
81 | Intent intent = new Intent(); | 80 | Intent intent = new Intent(); |
82 | intent.setClass(getActivity(),RegisterInfoActivity.class); | 81 | intent.setClass(getActivity(),RegisterInfoActivity.class); |
83 | startActivity(intent); | 82 | startActivity(intent); |
84 | getActivity().overridePendingTransition(R.anim.rightin, R.anim.rightout); | 83 | getActivity().overridePendingTransition(R.anim.rightin, R.anim.rightout); |
85 | getActivity().finish(); | 84 | getActivity().finish(); |
86 | } | 85 | } |
87 | break; | 86 | break; |
88 | case HttpCode.REGISTERED_FAIL: | 87 | case HttpCode.REGISTERED_FAIL: |
89 | AlertUtils.showToast(getActivity(), "注册失败"); | 88 | AlertUtils.showToast(getActivity(), "注册失败"); |
90 | break; | 89 | break; |
91 | case HttpCode.AUTHCODE_SUCESS: | 90 | case HttpCode.AUTHCODE_SUCESS: |
92 | jsonObject = (JSONObject) msg.obj; | 91 | jsonObject = (JSONObject) msg.obj; |
93 | status = jsonObject.optString("status"); | 92 | status = jsonObject.optString("status"); |
94 | if (status.equals("100")) { | 93 | if (status.equals("100")) { |
95 | AlertUtils.showToast(getActivity(), "验证码发送成功"); | 94 | AlertUtils.showToast(getActivity(), "验证码发送成功"); |
96 | } | 95 | } |
97 | 96 | ||
98 | break; | 97 | break; |
99 | case HttpCode.AUTHCODE_FAIL: | 98 | case HttpCode.AUTHCODE_FAIL: |
100 | jsonObject = (JSONObject) msg.obj; | 99 | jsonObject = (JSONObject) msg.obj; |
101 | AlertUtils.showToast(getActivity(), "验证码发送失败"); | 100 | AlertUtils.showToast(getActivity(), "验证码发送失败"); |
102 | break; | 101 | break; |
103 | case HttpCode.IS_REFISTER: | 102 | case HttpCode.IS_REFISTER: |
104 | jsonObject = (JSONObject) msg.obj; | 103 | jsonObject = (JSONObject) msg.obj; |
105 | status = jsonObject.getString("status"); | 104 | status = jsonObject.getString("status"); |
106 | if (!status.equals("true")) { | 105 | if (!status.equals("true")) { |
107 | getauthcode(); | 106 | getauthcode(); |
108 | 107 | ||
109 | }else { | 108 | }else { |
110 | AlertUtils.showToast(getActivity(), "该手机号已经注册过了"); | 109 | AlertUtils.showToast(getActivity(), "该手机号已经注册过了"); |
111 | } | 110 | } |
112 | break; | 111 | break; |
113 | case 21: | 112 | case 21: |
114 | if(delayTime<=0){ | 113 | if(delayTime<=0){ |
115 | if(Delaytimer!=null){ | 114 | if(Delaytimer!=null){ |
116 | Delaytimer.cancel(); | 115 | Delaytimer.cancel(); |
117 | } | 116 | } |
118 | get_authcode.setEnabled(true); | 117 | get_authcode.setEnabled(true); |
119 | get_authcode.setClickable(true); | 118 | get_authcode.setClickable(true); |
120 | get_authcode.setText("获取验证码"); | 119 | get_authcode.setText("获取验证码"); |
121 | delayTime=60; | 120 | delayTime=60; |
122 | }else{ | 121 | }else{ |
123 | get_authcode.setEnabled(false); | 122 | get_authcode.setEnabled(false); |
124 | get_authcode.setClickable(false); | 123 | get_authcode.setClickable(false); |
125 | get_authcode.setText(delayTime + " s"); | 124 | get_authcode.setText(delayTime + " s"); |
126 | } | 125 | } |
127 | break; | 126 | break; |
128 | } | 127 | } |
129 | } catch (JSONException e) { | 128 | } catch (JSONException e) { |
130 | e.printStackTrace(); | 129 | e.printStackTrace(); |
131 | } | 130 | } |
132 | } | 131 | } |
133 | }; | 132 | }; |
134 | @Override | 133 | @Override |
135 | public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { | 134 | public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { |
136 | if (mView == null) { | 135 | if (mView == null) { |
137 | mView = inflater.inflate(R.layout.fragment_loginandregister_register, container, false); | 136 | mView = inflater.inflate(R.layout.fragment_loginandregister_register, container, false); |
138 | initView(mView); | 137 | initView(mView); |
139 | initData(); | 138 | initData(); |
140 | setLister(); | 139 | setLister(); |
141 | 140 | ||
142 | 141 | ||
143 | } | 142 | } |
144 | return mView; | 143 | return mView; |
145 | } | 144 | } |
146 | 145 | ||
147 | private void initView(View mView) { | 146 | private void initView(View mView) { |
148 | get_authcode = (Button) mView.findViewById(R.id.btn_authcode); | 147 | get_authcode = (Button) mView.findViewById(R.id.btn_authcode); |
149 | anth_6num = (EditText) mView.findViewById(R.id.et_authcode); | 148 | anth_6num = (EditText) mView.findViewById(R.id.et_authcode); |
150 | phonenumber = (EditText) mView.findViewById(R.id.et_phonenumber); | 149 | phonenumber = (EditText) mView.findViewById(R.id.et_phonenumber); |
151 | password = (EditText) mView.findViewById(R.id.et_password); | 150 | password = (EditText) mView.findViewById(R.id.et_password); |
152 | openeyes= (ImageView) mView.findViewById(R.id.iv_pwd_change); | 151 | openeyes= (ImageView) mView.findViewById(R.id.iv_pwd_change); |
153 | btn_register = (Button) mView.findViewById(R.id.btn_register); | 152 | btn_register = (Button) mView.findViewById(R.id.btn_register); |
154 | 153 | ||
155 | } | 154 | } |
156 | private void initData() { | 155 | private void initData() { |
157 | } | 156 | } |
158 | private void setLister() { | 157 | private void setLister() { |
159 | get_authcode.setOnClickListener(this); | 158 | get_authcode.setOnClickListener(this); |
160 | openeyes.setOnClickListener(this); | 159 | openeyes.setOnClickListener(this); |
161 | btn_register.setOnClickListener(this); | 160 | btn_register.setOnClickListener(this); |
162 | } | 161 | } |
163 | 162 | ||
164 | 163 | ||
165 | @Override | 164 | @Override |
166 | public void onClick(View v) { | 165 | public void onClick(View v) { |
167 | switch (v.getId()){ | 166 | switch (v.getId()){ |
168 | case R.id.btn_register: | 167 | case R.id.btn_register: |
169 | //测试 | 168 | //测试 |
170 | // | 169 | // |
171 | 170 | ||
172 | String usernameStr = phonenumber.getText().toString().trim(); | 171 | String usernameStr = phonenumber.getText().toString().trim(); |
173 | String authcodeStr = anth_6num.getText().toString().trim(); | 172 | String authcodeStr = anth_6num.getText().toString().trim(); |
174 | String passwordStr = password.getText().toString().trim(); | 173 | String passwordStr = password.getText().toString().trim(); |
175 | if (TextUtils.isEmpty(usernameStr) || TextUtils.isEmpty(authcodeStr)||TextUtils.isEmpty(passwordStr)) { | 174 | if (TextUtils.isEmpty(usernameStr) || TextUtils.isEmpty(authcodeStr)||TextUtils.isEmpty(passwordStr)) { |
176 | AlertUtils.showToast(getActivity(), "手机号,密码和验证码不能为空"); | 175 | AlertUtils.showToast(getActivity(), "手机号,密码和验证码不能为空"); |
177 | return; | 176 | return; |
178 | } else if(passwordStr.length()<8){ | 177 | } else if(passwordStr.length()<8){ |
179 | AlertUtils.showToast(getActivity(), "密码不能少于8位"); | 178 | AlertUtils.showToast(getActivity(), "密码不能少于8位"); |
180 | }else if (!PhoneNumCheckUtils.isPhone(usernameStr)){ | 179 | }else if (!PhoneNumCheckUtils.isPhone(usernameStr)){ |
181 | AlertUtils.showToast(getActivity(), "手机号码输入错误"); | 180 | AlertUtils.showToast(getActivity(), "手机号码输入错误"); |
182 | 181 | ||
183 | }else if(!passwordStr.matches(PasswordCheckUtils.PASSWORD_CHAR_AND_NUMBER)){ | 182 | }else if(!passwordStr.matches(PasswordCheckUtils.PASSWORD_CHAR_AND_NUMBER)){ |
184 | AlertUtils.showToast(getActivity(), "密码由英文和数字组成"); | 183 | AlertUtils.showToast(getActivity(), "密码由英文和数字组成"); |
185 | }else { | 184 | }else { |
186 | register(); | 185 | register(); |
187 | } | 186 | } |
188 | 187 | ||
189 | break; | 188 | break; |
190 | case R.id.iv_pwd_change: | 189 | case R.id.iv_pwd_change: |
191 | if(showPassword){//显示密码 | 190 | if(showPassword){//显示密码 |
192 | showPassword = !showPassword; | 191 | showPassword = !showPassword; |
193 | openeyes.setImageResource(R.mipmap.pwd_open); | 192 | openeyes.setImageResource(R.mipmap.pwd_open); |
194 | password.setTransformationMethod(HideReturnsTransformationMethod.getInstance()); | 193 | password.setTransformationMethod(HideReturnsTransformationMethod.getInstance()); |
195 | password.setSelection(password.getText().toString().length()); | 194 | password.setSelection(password.getText().toString().length()); |
196 | }else{//隐藏密码 | 195 | }else{//隐藏密码 |
197 | showPassword = !showPassword; | 196 | showPassword = !showPassword; |
198 | openeyes.setImageResource(R.mipmap.pwd_hide); | 197 | openeyes.setImageResource(R.mipmap.pwd_hide); |
199 | password.setTransformationMethod(PasswordTransformationMethod.getInstance()); | 198 | password.setTransformationMethod(PasswordTransformationMethod.getInstance()); |
200 | password.setSelection(password.getText().toString().length()); | 199 | password.setSelection(password.getText().toString().length()); |
201 | } | 200 | } |
202 | break; | 201 | break; |
203 | case R.id.btn_authcode: | 202 | case R.id.btn_authcode: |
204 | usernameStr = phonenumber.getText().toString().trim(); | 203 | usernameStr = phonenumber.getText().toString().trim(); |
205 | if (!PhoneNumCheckUtils.isPhone(usernameStr)){ | 204 | if (!PhoneNumCheckUtils.isPhone(usernameStr)){ |
206 | AlertUtils.showToast(getActivity(), "请输入正确的手机号"); | 205 | AlertUtils.showToast(getActivity(), "请输入正确的手机号"); |
207 | }else { | 206 | }else { |
208 | anth_6num.requestFocus(); | 207 | anth_6num.requestFocus(); |
209 | ifregister(); | 208 | ifregister(); |
210 | } | 209 | } |
211 | 210 | ||
212 | break; | 211 | break; |
213 | } | 212 | } |
214 | 213 | ||
215 | } | 214 | } |
216 | //获取验证码 | 215 | //获取验证码 |
217 | private void getauthcode() { | 216 | private void getauthcode() { |
218 | String usernameStr = phonenumber.getText().toString().trim(); | 217 | String usernameStr = phonenumber.getText().toString().trim(); |
219 | HttpManager.getInstance().authCode(typeStr, usernameStr, handler, getActivity()); | 218 | HttpManager.getInstance().authCode(typeStr, usernameStr, handler, getActivity()); |
220 | valiDelay(); | 219 | valiDelay(); |
221 | } | 220 | } |
222 | 221 | ||
223 | private void ifregister() { | 222 | private void ifregister() { |
224 | String usernameStr = phonenumber.getText().toString().trim(); | 223 | String usernameStr = phonenumber.getText().toString().trim(); |
225 | HttpManager.getInstance().isregistered(usernameStr, handler, getActivity()); | 224 | HttpManager.getInstance().isregistered(usernameStr, handler, getActivity()); |
226 | } | 225 | } |
227 | 226 | ||
228 | private void register() { | 227 | private void register() { |
229 | String usernameStr = phonenumber.getText().toString().trim(); | 228 | String usernameStr = phonenumber.getText().toString().trim(); |
230 | String authcodeStr = anth_6num.getText().toString().trim(); | 229 | String authcodeStr = anth_6num.getText().toString().trim(); |
231 | String passwordStr = password.getText().toString().trim(); | 230 | String passwordStr = password.getText().toString().trim(); |
232 | HttpManager.getInstance().register(getActivity(), usernameStr, passwordStr, authcodeStr, sourceStr,handler); | 231 | HttpManager.getInstance().register(getActivity(), usernameStr, passwordStr, authcodeStr, sourceStr,handler); |
233 | } | 232 | } |
234 | // 线程类 定时器 | 233 | // 线程类 定时器 |
235 | public void valiDelay() { | 234 | public void valiDelay() { |
236 | 235 | ||
237 | Delaytimer = new java.util.Timer(true); | 236 | Delaytimer = new java.util.Timer(true); |
238 | 237 | ||
239 | 238 | ||
240 | TimerTask task = new TimerTask() { | 239 | TimerTask task = new TimerTask() { |
241 | public void run() { | 240 | public void run() { |
242 | //每次需要执行的代码放到这里面。 | 241 | //每次需要执行的代码放到这里面。 |
243 | delayTime--; | 242 | delayTime--; |
244 | handler.sendEmptyMessage(21); | 243 | handler.sendEmptyMessage(21); |
245 | } | 244 | } |
246 | }; | 245 | }; |
247 | Delaytimer.schedule(task, 1000,1000); | 246 | Delaytimer.schedule(task, 1000,1000); |
248 | } | 247 | } |
249 | } | 248 | } |
250 | 249 |
PersonalCenter/app/src/main/java/com/hjx/personalcenter/fragment/VersionsInfoFragment.java
1 | package com.hjx.personalcenter.fragment; | 1 | package com.hjx.personalcenter.fragment; |
2 | 2 | ||
3 | import android.os.Bundle; | 3 | import android.os.Bundle; |
4 | import android.support.annotation.Nullable; | 4 | import android.support.annotation.Nullable; |
5 | import android.support.v4.app.Fragment; | 5 | import android.support.v4.app.Fragment; |
6 | import android.view.LayoutInflater; | 6 | import android.view.LayoutInflater; |
7 | import android.view.View; | 7 | import android.view.View; |
8 | import android.view.ViewGroup; | 8 | import android.view.ViewGroup; |
9 | import android.widget.AdapterView; | 9 | import android.widget.AdapterView; |
10 | import android.widget.GridView; | 10 | import android.widget.GridView; |
11 | import android.widget.SimpleAdapter; | ||
12 | 11 | ||
13 | import com.hjx.personalcenter.R; | 12 | import com.hjx.personalcenter.R; |
13 | import com.hjx.personalcenter.adapter.GridAdapter; | ||
14 | import com.hjx.personalcenter.customdialog.VerSionDialog; | 14 | import com.hjx.personalcenter.customdialog.VerSionDialog; |
15 | import com.hjx.personalcenter.db.SaveParam; | 15 | import com.hjx.personalcenter.db.SaveParam; |
16 | import com.hjx.personalcenter.interfaces.DialogCallBack; | 16 | import com.hjx.personalcenter.interfaces.DialogCallBack; |
17 | import com.hjx.personalcenter.model.VersionInfo; | 17 | import com.hjx.personalcenter.model.DefautPublishInfo; |
18 | import com.hjx.personalcenter.util.AlertUtils; | ||
19 | 18 | ||
20 | import java.util.ArrayList; | 19 | import java.util.ArrayList; |
21 | import java.util.HashMap; | ||
22 | import java.util.List; | ||
23 | import java.util.Map; | ||
24 | 20 | ||
25 | /** | 21 | /** |
26 | * Created by h on 2017/8/12. | 22 | * Created by h on 2017/8/12. |
27 | */ | 23 | */ |
28 | 24 | ||
29 | public class VersionsInfoFragment extends Fragment implements AdapterView.OnItemClickListener,DialogCallBack.VersionCallBack { | 25 | public class VersionsInfoFragment extends Fragment implements AdapterView.OnItemClickListener{ |
30 | private GridView gridView; | 26 | private GridView gridView; |
31 | private List<Map<String, Object>> data_list; | 27 | private ArrayList<DefautPublishInfo> defautPublishInfos = new ArrayList<>(); |
32 | private SimpleAdapter sim_adapter; | 28 | private GridAdapter sim_adapter; |
33 | private View mView; | 29 | private View mView; |
34 | private int type; | 30 | private int type; |
35 | public static String TABLAYOUT_FRAGMENT = "tab_fragment"; | 31 | public static String TABLAYOUT_FRAGMENT = "tab_fragment"; |
36 | 32 | ||
37 | public static VersionsInfoFragment newInstance(int type) { | 33 | public static VersionsInfoFragment newInstance(int type) { |
38 | VersionsInfoFragment fragment = new VersionsInfoFragment(); | 34 | VersionsInfoFragment fragment = new VersionsInfoFragment(); |
39 | Bundle bundle = new Bundle(); | 35 | Bundle bundle = new Bundle(); |
40 | bundle.putSerializable(TABLAYOUT_FRAGMENT, type); | 36 | bundle.putSerializable(TABLAYOUT_FRAGMENT, type); |
41 | fragment.setArguments(bundle); | 37 | fragment.setArguments(bundle); |
42 | return fragment; | 38 | return fragment; |
43 | 39 | ||
44 | } | 40 | } |
45 | // 图片封装为一个数组 | ||
46 | private int[] icon = { R.mipmap.ic_launcher, R.mipmap.ic_launcher, | ||
47 | R.mipmap.ic_launcher, R.mipmap.ic_launcher, R.mipmap.ic_launcher, | ||
48 | R.mipmap.ic_launcher, R.mipmap.ic_launcher, R.mipmap.ic_launcher, | ||
49 | R.mipmap.ic_launcher}; | ||
50 | private String[] subject = { "语文", "数学", "英语", "物理", "化学", "生物", "政治", | ||
51 | "历史", "地理" }; | ||
52 | private String[] publish = { "人民教育出版社", "人民教育出版社", "人民教育出版社", | ||
53 | "人民教育出版社", "人民教育出版社", "人民教育出版社", "人民教育出版社", | ||
54 | "人民教育出版社", "人民教育出版社" }; | ||
55 | @Override | 41 | @Override |
56 | public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { | 42 | public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { |
57 | if (mView == null) { | 43 | if (mView == null) { |
58 | mView = inflater.inflate(R.layout.fragment_changge_version_info, container, false); | 44 | mView = inflater.inflate(R.layout.fragment_changge_version_info, container, false); |
59 | initView(mView); | 45 | initView(mView); |
60 | initData(); | 46 | initData(); |
61 | setLister(); | 47 | setLister(); |
62 | 48 | ||
63 | 49 | ||
64 | } | 50 | } |
65 | return mView; | 51 | return mView; |
66 | } | 52 | } |
67 | //初始化 | 53 | //初始化 |
68 | private void initView(View mView) { | 54 | private void initView(View mView) { |
69 | gridView =(GridView) mView.findViewById(R.id.grideview); | 55 | gridView =(GridView) mView.findViewById(R.id.grideview); |
70 | 56 | ||
71 | } | 57 | } |
72 | private void initData() { | 58 | private void initData() { |
73 | data_list = new ArrayList<Map<String, Object>>(); | 59 | DefautPublishInfo defautPublishInfo = new DefautPublishInfo(); |
74 | getData(); | 60 | defautPublishInfo.setImagurl("http://hjxprodbucket.oss.aliyuncs.com/static/upload/boss_api/announcement/2017-08-29/8480ff7b-42f1-4d64-b848-c8f4f3afd385.png"); |
75 | String [] from ={"image","text","text1"}; | 61 | defautPublishInfo.setSubjuct("语文"); |
76 | int [] to = {R.id.image,R.id.text}; | 62 | defautPublishInfo.setPublish("人民教育出版社"); |
77 | sim_adapter = new SimpleAdapter(getActivity(), data_list, R.layout.fragment_changge_version_info_itmes, from, to); | 63 | DefautPublishInfo defautPublishInfo1 = new DefautPublishInfo(); |
64 | defautPublishInfo1.setImagurl("http://hjxprodbucket.oss.aliyuncs.com/static/upload/boss_api/announcement/2017-08-29/8480ff7b-42f1-4d64-b848-c8f4f3afd385.png"); | ||
65 | defautPublishInfo1.setSubjuct("数学"); | ||
66 | defautPublishInfo1.setPublish("人民教育出版社"); | ||
67 | DefautPublishInfo defautPublishInfo2 = new DefautPublishInfo(); | ||
68 | defautPublishInfo2.setImagurl("http://hjxprodbucket.oss.aliyuncs.com/static/upload/boss_api/announcement/2017-08-29/8480ff7b-42f1-4d64-b848-c8f4f3afd385.png"); | ||
69 | defautPublishInfo2.setSubjuct("英语"); | ||
70 | defautPublishInfo2.setPublish("人民教育出版社"); | ||
71 | defautPublishInfos.add(defautPublishInfo); | ||
72 | defautPublishInfos.add(defautPublishInfo1); | ||
73 | defautPublishInfos.add(defautPublishInfo2); | ||
74 | sim_adapter = new GridAdapter(defautPublishInfos,getActivity()); | ||
78 | //配置适配器 | 75 | //配置适配器 |
79 | gridView.setAdapter(sim_adapter); | 76 | gridView.setAdapter(sim_adapter); |
80 | } | 77 | } |
81 | public List<Map<String, Object>> getData(){ | ||
82 | //cion和iconName的长度是相同的,这里任选其一都可以 | ||
83 | for(int i=0;i<icon.length;i++){ | ||
84 | Map<String, Object> map = new HashMap<String, Object>(); | ||
85 | map.put("image", icon[i]); | ||
86 | map.put("text", subject[i]); | ||
87 | map.put("text1", publish[i]); | ||
88 | data_list.add(map); | ||
89 | } | ||
90 | 78 | ||
91 | return data_list; | ||
92 | } | ||
93 | private void setLister() { | 79 | private void setLister() { |
94 | gridView.setOnItemClickListener(this); | 80 | gridView.setOnItemClickListener(this); |
95 | } | 81 | } |
96 | 82 | ||
97 | @Override | 83 | @Override |
98 | public void onItemClick(AdapterView<?> parent, View view, int position, long id) { | 84 | public void onItemClick(AdapterView<?> parent, View view, int position, long id) { |
99 | switch (position){ | 85 | switch (position){ |
100 | 86 | ||
101 | case 0: | 87 | case 0: |
102 | SaveParam.getInstance().saveLoginParam(getActivity(),SaveParam.VERSION,"语文"); | 88 | SaveParam.getInstance().saveLoginParam(getActivity(),SaveParam.VERSION,"语文"); |
103 | break; | 89 | break; |
104 | case 1: | 90 | case 1: |
105 | SaveParam.getInstance().saveLoginParam(getActivity(),SaveParam.VERSION,"数学"); | 91 | SaveParam.getInstance().saveLoginParam(getActivity(),SaveParam.VERSION,"数学"); |
106 | break; | 92 | break; |
107 | case 2: | 93 | case 2: |
108 | SaveParam.getInstance().saveLoginParam(getActivity(),SaveParam.VERSION,"英语"); | 94 | SaveParam.getInstance().saveLoginParam(getActivity(),SaveParam.VERSION,"英语"); |
109 | break; | 95 | break; |
110 | case 3: | 96 | case 3: |
111 | SaveParam.getInstance().saveLoginParam(getActivity(),SaveParam.VERSION,"物理"); | 97 | SaveParam.getInstance().saveLoginParam(getActivity(),SaveParam.VERSION,"物理"); |
112 | break; | 98 | break; |
113 | case 4: | 99 | case 4: |
114 | SaveParam.getInstance().saveLoginParam(getActivity(),SaveParam.VERSION,"化学"); | 100 | SaveParam.getInstance().saveLoginParam(getActivity(),SaveParam.VERSION,"化学"); |
115 | break; | 101 | break; |
116 | case 5: | 102 | case 5: |
117 | SaveParam.getInstance().saveLoginParam(getActivity(),SaveParam.VERSION,"生物"); | 103 | SaveParam.getInstance().saveLoginParam(getActivity(),SaveParam.VERSION,"生物"); |
118 | break; | 104 | break; |
119 | case 6: | 105 | case 6: |
120 | SaveParam.getInstance().saveLoginParam(getActivity(),SaveParam.VERSION,"政治"); | 106 | SaveParam.getInstance().saveLoginParam(getActivity(),SaveParam.VERSION,"政治"); |
121 | break; | 107 | break; |
122 | case 7: | 108 | case 7: |
123 | SaveParam.getInstance().saveLoginParam(getActivity(),SaveParam.VERSION,"历史"); | 109 | SaveParam.getInstance().saveLoginParam(getActivity(),SaveParam.VERSION,"历史"); |
124 | break; | 110 | break; |
125 | case 8: | 111 | case 8: |
126 | SaveParam.getInstance().saveLoginParam(getActivity(),SaveParam.VERSION,"地理"); | 112 | SaveParam.getInstance().saveLoginParam(getActivity(),SaveParam.VERSION,"地理"); |
127 | break; | 113 | break; |
128 | } | 114 | } |
129 | 115 | ||
130 | VerSionDialog.getInstance((DialogCallBack.VersionCallBack) this).show(getChildFragmentManager(), "VerSionDialog"); | 116 | VerSionDialog.getInstance((DialogCallBack.VersionCallBack) this).show(getChildFragmentManager(), "VerSionDialog"); |
131 | 117 |
PersonalCenter/app/src/main/java/com/hjx/personalcenter/http/HttpCode.java
1 | package com.hjx.personalcenter.http; | 1 | package com.hjx.personalcenter.http; |
2 | 2 | ||
3 | /** | 3 | /** |
4 | * Created by wei on 2017/6/21. | 4 | * Created by wei on 2017/6/21. |
5 | */ | 5 | */ |
6 | 6 | ||
7 | public class HttpCode { | 7 | public class HttpCode { |
8 | //查询保卡信息 | 8 | //查询保卡信息 |
9 | public static final int SUCHCARDINFO = 0; | 9 | public static final int SUCHCARDINFO = 0; |
10 | //是否填写保卡信息 | 10 | //是否填写保卡信息 |
11 | public static final int CHECKCARD = 1; | 11 | public static final int CHECKCARD = 1; |
12 | //注册 | 12 | //注册 |
13 | public static final int REGISTERED_SUCESS = 2; | 13 | public static final int REGISTERED_SUCESS = 2; |
14 | public static final int REGISTERED_FAIL = 3; | 14 | public static final int REGISTERED_FAIL = 3; |
15 | //注册验证码 | 15 | //注册验证码 |
16 | public static final int AUTHCODE_SUCESS = 4; | 16 | public static final int AUTHCODE_SUCESS = 4; |
17 | public static final int AUTHCODE_FAIL = 5; | 17 | public static final int AUTHCODE_FAIL = 5; |
18 | //忘记密码验证码 | 18 | //忘记密码验证码 |
19 | public static final int AUTHCODE_SUCESS1 = 6; | 19 | public static final int AUTHCODE_SUCESS1 = 6; |
20 | public static final int AUTHCODE_FAIL1 = 7; | 20 | public static final int AUTHCODE_FAIL1 = 7; |
21 | //是否已经注册 | 21 | //是否已经注册 |
22 | public static final int IS_REFISTER = 8; | 22 | public static final int IS_REFISTER = 8; |
23 | //忘记密码 | 23 | //忘记密码 |
24 | public static final int PASSWORD_SUCESS = 9; | 24 | public static final int PASSWORD_SUCESS = 9; |
25 | public static final int PASSWORD_FAIL = 10; | 25 | public static final int PASSWORD_FAIL = 10; |
26 | //s省 | 26 | //s省 |
27 | public static final int PROVICES = 11; | 27 | public static final int PROVICES = 11; |
28 | //市 | 28 | //市 |
29 | public static final int CITYS = 12; | 29 | public static final int CITYS = 12; |
30 | //区 | 30 | //区 |
31 | public static final int COUNTRY = 13; | 31 | public static final int COUNTRY = 13; |
32 | //学校 | 32 | //学校 |
33 | public static final int SCHOOL = 14; | 33 | public static final int SCHOOL = 14; |
34 | //年级 | 34 | //年级 |
35 | public static final int GRADER = 15; | 35 | public static final int GRADER = 15; |
36 | //获取个人信息 | 36 | //获取个人信息 |
37 | public static final int GETINFO = 16; | 37 | public static final int GETINFO = 16; |
38 | //获取个性签名 | 38 | //获取个性签名 |
39 | public static final int SIGN = 17; | 39 | public static final int SIGN = 17; |
40 | //登录 | 40 | //登录 |
41 | public static final int LOGIN_SUCESS = 18; | 41 | public static final int LOGIN_SUCESS = 18; |
42 | //获取子账户信息 | 42 | //获取子账户信息 |
43 | public static final int CHILDS_SUCESS = 19; | 43 | public static final int CHILDS_SUCESS = 19; |
44 | //版本升级 | 44 | //版本升级 |
45 | public static final int APPUPDATE_SUCESS = 20; | 45 | public static final int APPUPDATE_SUCESS = 20; |
46 | //获取版本信息 | 46 | //获取版本信息 |
47 | public static final int VERSION_SUCESS = 22; | 47 | public static final int VERSION_SUCESS = 22; |
48 | //注册信息是否完整 | ||
49 | public static final int REGISTER_SUCESS = 23; | ||
48 | 50 | ||
49 | 51 | ||
50 | 52 | ||
51 | 53 | ||
52 | } | 54 | } |
53 | 55 |
PersonalCenter/app/src/main/java/com/hjx/personalcenter/http/HttpManager.java
1 | package com.hjx.personalcenter.http; | 1 | package com.hjx.personalcenter.http; |
2 | 2 | ||
3 | import android.app.Activity; | 3 | import android.app.Activity; |
4 | import android.app.ProgressDialog; | 4 | import android.app.ProgressDialog; |
5 | import android.content.Context; | 5 | import android.content.Context; |
6 | import android.content.Intent; | 6 | import android.content.Intent; |
7 | import android.os.Handler; | 7 | import android.os.Handler; |
8 | import android.os.Message; | 8 | import android.os.Message; |
9 | import android.provider.Settings; | ||
10 | import android.support.v4.app.FragmentActivity; | ||
11 | import android.util.Log; | 9 | import android.util.Log; |
12 | import android.view.Gravity; | ||
13 | import android.view.View; | ||
14 | import android.widget.Toast; | 10 | import android.widget.Toast; |
15 | 11 | ||
16 | import com.google.gson.Gson; | 12 | import com.google.gson.Gson; |
17 | import com.hjx.personalcenter.R; | 13 | import com.hjx.personalcenter.R; |
18 | import com.hjx.personalcenter.activity.LoginAndRegisterActivity; | 14 | import com.hjx.personalcenter.activity.LoginAndRegisterActivity; |
19 | import com.hjx.personalcenter.activity.TheStartPageActivity; | 15 | import com.hjx.personalcenter.activity.TheStartPageActivity; |
20 | import com.hjx.personalcenter.db.Content; | 16 | import com.hjx.personalcenter.db.Content; |
21 | import com.hjx.personalcenter.db.SaveParam; | 17 | import com.hjx.personalcenter.db.SaveParam; |
22 | import com.hjx.personalcenter.gson.GsonTool; | 18 | import com.hjx.personalcenter.gson.GsonTool; |
23 | import com.hjx.personalcenter.model.AppVersion; | 19 | import com.hjx.personalcenter.model.AppVersion; |
24 | import com.hjx.personalcenter.model.CardInfo; | 20 | import com.hjx.personalcenter.model.CardInfo; |
25 | import com.hjx.personalcenter.model.ChildsInfo; | 21 | import com.hjx.personalcenter.model.ChildsInfo; |
26 | import com.hjx.personalcenter.model.CityInfo; | 22 | import com.hjx.personalcenter.model.CityInfo; |
27 | import com.hjx.personalcenter.model.CountyInfo; | 23 | import com.hjx.personalcenter.model.CountyInfo; |
28 | import com.hjx.personalcenter.model.GradeInfo; | 24 | import com.hjx.personalcenter.model.GradeInfo; |
29 | import com.hjx.personalcenter.model.PesonalInfo; | 25 | import com.hjx.personalcenter.model.PesonalInfo; |
30 | import com.hjx.personalcenter.model.ProvinceInfo; | 26 | import com.hjx.personalcenter.model.ProvinceInfo; |
31 | import com.hjx.personalcenter.model.SchoolInfo; | 27 | import com.hjx.personalcenter.model.SchoolInfo; |
32 | import com.hjx.personalcenter.model.SignInfo; | 28 | import com.hjx.personalcenter.model.SignInfo; |
33 | import com.hjx.personalcenter.model.VersionInfo; | 29 | import com.hjx.personalcenter.model.VersionInfo; |
34 | import com.hjx.personalcenter.util.AlertUtils; | 30 | import com.hjx.personalcenter.util.AlertUtils; |
35 | import com.hjx.personalcenter.util.DialogPermission; | 31 | import com.hjx.personalcenter.util.DialogPermission; |
36 | import com.loopj.android.http.AsyncHttpResponseHandler; | 32 | import com.loopj.android.http.AsyncHttpResponseHandler; |
37 | import com.loopj.android.http.JsonHttpResponseHandler; | 33 | import com.loopj.android.http.JsonHttpResponseHandler; |
38 | import com.loopj.android.http.RequestParams; | 34 | import com.loopj.android.http.RequestParams; |
39 | import com.mylhyl.circledialog.CircleDialog; | ||
40 | import com.mylhyl.circledialog.callback.ConfigText; | ||
41 | import com.mylhyl.circledialog.params.TextParams; | ||
42 | 35 | ||
43 | import org.apache.http.Header; | 36 | import org.apache.http.Header; |
44 | import org.apache.http.entity.ByteArrayEntity; | 37 | import org.apache.http.entity.ByteArrayEntity; |
45 | import org.apache.http.message.BasicHeader; | 38 | import org.apache.http.message.BasicHeader; |
46 | import org.apache.http.protocol.HTTP; | 39 | import org.apache.http.protocol.HTTP; |
47 | import org.json.JSONException; | 40 | import org.json.JSONException; |
48 | import org.json.JSONObject; | 41 | import org.json.JSONObject; |
49 | 42 | ||
50 | import java.io.File; | 43 | import java.io.File; |
51 | import java.io.FileNotFoundException; | 44 | import java.io.FileNotFoundException; |
52 | import java.io.UnsupportedEncodingException; | 45 | import java.io.UnsupportedEncodingException; |
53 | import java.util.ArrayList; | 46 | import java.util.ArrayList; |
54 | import java.util.List; | 47 | import java.util.List; |
55 | 48 | ||
56 | public class HttpManager { | 49 | public class HttpManager { |
57 | private static HttpManager instance; | 50 | private static HttpManager instance; |
58 | private ProgressDialog mProgress = null; | 51 | private ProgressDialog mProgress = null; |
59 | 52 | ||
60 | public static HttpManager getInstance() { | 53 | public static HttpManager getInstance() { |
61 | if (instance == null) { | 54 | if (instance == null) { |
62 | instance = new HttpManager(); | 55 | instance = new HttpManager(); |
63 | } | 56 | } |
64 | return instance; | 57 | return instance; |
65 | } | 58 | } |
66 | 59 | ||
67 | 60 | ||
68 | //登录接口 | 61 | //登录接口 |
69 | 62 | ||
70 | public void login(final String username, final String password, final Context mContext, final Handler handler) { | 63 | public void login(final String username, final String password, final Context mContext, final Handler handler) { |
71 | mProgress = DialogPermission.showProgress(mContext, null, "正在登录...", | 64 | mProgress = DialogPermission.showProgress(mContext, null, "正在登录...", |
72 | false, true, null); | 65 | false, true, null); |
73 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); | 66 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); |
74 | HttpClient.getInstance().get(HttpUrl.loginUrl + "?username=" + username + "&password=" + password, new AsyncHttpResponseHandler() { | 67 | HttpClient.getInstance().get(HttpUrl.loginUrl + "?username=" + username + "&password=" + password, new AsyncHttpResponseHandler() { |
75 | @Override | 68 | @Override |
76 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { | 69 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { |
77 | closeProgress(); | 70 | closeProgress(); |
78 | Message msg = Message.obtain(); | 71 | Message msg = Message.obtain(); |
79 | msg.what = HttpCode.LOGIN_SUCESS; | 72 | msg.what = HttpCode.LOGIN_SUCESS; |
80 | msg.obj = new String(arg2); | 73 | msg.obj = new String(arg2); |
81 | handler.sendMessage(msg); | 74 | handler.sendMessage(msg); |
82 | 75 | ||
83 | 76 | ||
84 | } | 77 | } |
85 | 78 | ||
86 | @Override | 79 | @Override |
87 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { | 80 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { |
88 | closeProgress(); | 81 | closeProgress(); |
89 | new CircleDialog.Builder((FragmentActivity) mContext) | 82 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); |
90 | .setCanceledOnTouchOutside(false) | ||
91 | .setCancelable(false) | ||
92 | .setWidth(0.5f) | ||
93 | .configText(new ConfigText() { | ||
94 | @Override | ||
95 | public void onConfig(TextParams params) { | ||
96 | params.gravity = Gravity.CENTER; | ||
97 | params.padding = new int[]{50, 50, 50, 50}; | ||
98 | } | ||
99 | }) | ||
100 | .setText("当前无网络,请检查网络设置") | ||
101 | .setNegative("继续使用", null) | ||
102 | .setPositive("设置网络", new View.OnClickListener() { | ||
103 | @Override | ||
104 | public void onClick(View v) { | ||
105 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 | ||
106 | mContext.startActivity(intent); | ||
107 | } | ||
108 | }) | ||
109 | .show(); | ||
110 | } | 83 | } |
111 | }); | 84 | }); |
112 | } | 85 | } |
113 | 86 | ||
114 | //注册接口 | 87 | //注册接口 |
115 | public void register(final Context context, String username, String password, String smscode, String source, final Handler handler) { | 88 | public void register(final Context context, String username, String password, String smscode, String source, final Handler handler) { |
116 | mProgress = DialogPermission.showProgress(context, null, "正在注册...", | 89 | mProgress = DialogPermission.showProgress(context, null, "正在注册...", |
117 | false, true, null); | 90 | false, true, null); |
118 | JSONObject jsonObject = new JSONObject(); | 91 | JSONObject jsonObject = new JSONObject(); |
119 | ByteArrayEntity entity = null; | 92 | ByteArrayEntity entity = null; |
120 | try { | 93 | try { |
121 | jsonObject.put(HttpKey.USERNAME, username); | 94 | jsonObject.put(HttpKey.USERNAME, username); |
122 | jsonObject.put(HttpKey.PASSWORD, password); | 95 | jsonObject.put(HttpKey.PASSWORD, password); |
123 | jsonObject.put(HttpKey.SMSCODE, smscode); | 96 | jsonObject.put(HttpKey.SMSCODE, smscode); |
124 | jsonObject.put(HttpKey.SOURCE, source); | 97 | jsonObject.put(HttpKey.SOURCE, source); |
125 | Log.e("test", "jsonObject" + jsonObject); | 98 | Log.e("test", "jsonObject" + jsonObject); |
126 | entity = new ByteArrayEntity(jsonObject.toString().getBytes("UTF-8")); | 99 | entity = new ByteArrayEntity(jsonObject.toString().getBytes("UTF-8")); |
127 | entity.setContentType(new BasicHeader(HTTP.CONTENT_TYPE, "application/json")); | 100 | entity.setContentType(new BasicHeader(HTTP.CONTENT_TYPE, "application/json")); |
128 | } catch (JSONException e) { | 101 | } catch (JSONException e) { |
129 | e.printStackTrace(); | 102 | e.printStackTrace(); |
130 | } catch (UnsupportedEncodingException e) { | 103 | } catch (UnsupportedEncodingException e) { |
131 | e.printStackTrace(); | 104 | e.printStackTrace(); |
132 | } | 105 | } |
133 | HttpClient.getInstance().addHeader("Accept", "*/*"); | 106 | HttpClient.getInstance().addHeader("Accept", "*/*"); |
134 | HttpClient.getInstance().post(context, HttpUrl.registeredUrl, entity, "application/json", new JsonHttpResponseHandler() { | 107 | HttpClient.getInstance().post(context, HttpUrl.registeredUrl, entity, "application/json", new JsonHttpResponseHandler() { |
135 | @Override | 108 | @Override |
136 | public void onSuccess(int statusCode, Header[] headers, JSONObject response) { | 109 | public void onSuccess(int statusCode, Header[] headers, JSONObject response) { |
137 | super.onSuccess(statusCode, headers, response); | 110 | super.onSuccess(statusCode, headers, response); |
138 | closeProgress(); | 111 | closeProgress(); |
139 | Log.e("test", "onSuccess" + response); | 112 | Log.e("test", "onSuccess" + response); |
140 | Message msg = Message.obtain(); | 113 | Message msg = Message.obtain(); |
141 | msg.what = HttpCode.REGISTERED_SUCESS; | 114 | msg.what = HttpCode.REGISTERED_SUCESS; |
142 | msg.obj = response; | 115 | msg.obj = response; |
143 | handler.sendMessage(msg); | 116 | handler.sendMessage(msg); |
144 | 117 | ||
145 | } | 118 | } |
146 | 119 | ||
147 | @Override | 120 | @Override |
148 | public void onFailure(int statusCode, Header[] headers, Throwable throwable, JSONObject errorResponse) { | 121 | public void onFailure(int statusCode, Header[] headers, Throwable throwable, JSONObject errorResponse) { |
149 | super.onFailure(statusCode, headers, throwable, errorResponse); | 122 | super.onFailure(statusCode, headers, throwable, errorResponse); |
150 | closeProgress(); | 123 | closeProgress(); |
151 | Log.e("test", "onFailure" + errorResponse); | 124 | Log.e("test", "onFailure" + errorResponse); |
152 | new CircleDialog.Builder((FragmentActivity) context) | 125 | AlertUtils.showToast(context, "无法链接到服务器,请检查您的网络或稍后重试!"); |
153 | .setCanceledOnTouchOutside(false) | ||
154 | .setCancelable(false) | ||
155 | .setWidth(0.5f) | ||
156 | .configText(new ConfigText() { | ||
157 | @Override | ||
158 | public void onConfig(TextParams params) { | ||
159 | params.gravity = Gravity.CENTER; | ||
160 | params.padding = new int[]{50, 50, 50, 50}; | ||
161 | } | ||
162 | }) | ||
163 | .setText("当前无网络,请检查网络设置") | ||
164 | .setNegative("继续使用", null) | ||
165 | .setPositive("设置网络", new View.OnClickListener() { | ||
166 | @Override | ||
167 | public void onClick(View v) { | ||
168 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 | ||
169 | context.startActivity(intent); | ||
170 | } | ||
171 | }) | ||
172 | .show(); | ||
173 | } | 126 | } |
174 | 127 | ||
175 | }); | 128 | }); |
176 | } | 129 | } |
177 | 130 | ||
178 | //注册验证码 | 131 | //注册验证码 |
179 | public void authCode(final String type, final String mobile, final Handler handler, final Context mContext) { | 132 | public void authCode(final String type, final String mobile, final Handler handler, final Context mContext) { |
180 | RequestParams params = new RequestParams(); | 133 | RequestParams params = new RequestParams(); |
181 | params.put(HttpKey.TYPE, type); | 134 | params.put(HttpKey.TYPE, type); |
182 | params.put(HttpKey.MOBIL, mobile); | 135 | params.put(HttpKey.MOBIL, mobile); |
183 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); | 136 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); |
184 | HttpClient.getInstance().post(HttpUrl.authCodedUrl, params, new JsonHttpResponseHandler() { | 137 | HttpClient.getInstance().post(HttpUrl.authCodedUrl, params, new JsonHttpResponseHandler() { |
185 | 138 | ||
186 | @Override | 139 | @Override |
187 | public void onSuccess(int statusCode, Header[] headers, JSONObject response) { | 140 | public void onSuccess(int statusCode, Header[] headers, JSONObject response) { |
188 | Log.e("test", "onSuccess-----" + response); | 141 | Log.e("test", "onSuccess-----" + response); |
189 | Message msg = Message.obtain(); | 142 | Message msg = Message.obtain(); |
190 | msg.what = HttpCode.AUTHCODE_SUCESS; | 143 | msg.what = HttpCode.AUTHCODE_SUCESS; |
191 | msg.obj = response; | 144 | msg.obj = response; |
192 | handler.sendMessage(msg); | 145 | handler.sendMessage(msg); |
193 | } | 146 | } |
194 | 147 | ||
195 | @Override | 148 | @Override |
196 | public void onFailure(int statusCode, Header[] headers, Throwable throwable, JSONObject errorResponse) { | 149 | public void onFailure(int statusCode, Header[] headers, Throwable throwable, JSONObject errorResponse) { |
197 | new CircleDialog.Builder((FragmentActivity) mContext) | 150 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); |
198 | .setCanceledOnTouchOutside(false) | ||
199 | .setCancelable(false) | ||
200 | .setWidth(0.5f) | ||
201 | .configText(new ConfigText() { | ||
202 | @Override | ||
203 | public void onConfig(TextParams params) { | ||
204 | params.gravity = Gravity.CENTER; | ||
205 | params.padding = new int[]{50, 50, 50, 50}; | ||
206 | } | ||
207 | }) | ||
208 | .setText("当前无网络,请检查网络设置") | ||
209 | .setNegative("继续使用", null) | ||
210 | .setPositive("设置网络", new View.OnClickListener() { | ||
211 | @Override | ||
212 | public void onClick(View v) { | ||
213 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 | ||
214 | mContext.startActivity(intent); | ||
215 | } | ||
216 | }) | ||
217 | .show(); | ||
218 | } | 151 | } |
219 | }); | 152 | }); |
220 | } | 153 | } |
221 | 154 | ||
222 | 155 | ||
223 | //手机号是否注册 | 156 | //手机号是否注册 |
224 | public void isregistered(final String mobile, final Handler handler, final Context mContext) { | 157 | public void isregistered(final String mobile, final Handler handler, final Context mContext) { |
225 | RequestParams params = new RequestParams(); | 158 | RequestParams params = new RequestParams(); |
226 | params.put(HttpKey.USERNAME, mobile); | 159 | params.put(HttpKey.USERNAME, mobile); |
227 | HttpClient.getInstance().get(HttpUrl.isRegiterUrl + "?mobile=" + mobile, new JsonHttpResponseHandler() { | 160 | HttpClient.getInstance().get(HttpUrl.isRegiterUrl + "?mobile=" + mobile, new JsonHttpResponseHandler() { |
228 | @Override | 161 | @Override |
229 | public void onSuccess(int statusCode, Header[] headers, JSONObject response) { | 162 | public void onSuccess(int statusCode, Header[] headers, JSONObject response) { |
230 | Log.e("test", "isregistered" + response.toString()); | 163 | Log.e("test", "isregistered" + response.toString()); |
231 | Message msg = Message.obtain(); | 164 | Message msg = Message.obtain(); |
232 | msg.what = HttpCode.IS_REFISTER; | 165 | msg.what = HttpCode.IS_REFISTER; |
233 | msg.obj = response; | 166 | msg.obj = response; |
234 | handler.sendMessage(msg); | 167 | handler.sendMessage(msg); |
235 | 168 | ||
236 | } | 169 | } |
237 | 170 | ||
238 | @Override | 171 | @Override |
239 | public void onFailure(int statusCode, Header[] headers, Throwable throwable, JSONObject errorResponse) { | 172 | public void onFailure(int statusCode, Header[] headers, Throwable throwable, JSONObject errorResponse) { |
240 | new CircleDialog.Builder((FragmentActivity) mContext) | 173 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); |
241 | .setCanceledOnTouchOutside(false) | ||
242 | .setCancelable(false) | ||
243 | .setWidth(0.5f) | ||
244 | .configText(new ConfigText() { | ||
245 | @Override | ||
246 | public void onConfig(TextParams params) { | ||
247 | params.gravity = Gravity.CENTER; | ||
248 | params.padding = new int[]{50, 50, 50, 50}; | ||
249 | } | ||
250 | }) | ||
251 | .setText("当前无网络,请检查网络设置") | ||
252 | .setNegative("继续使用", null) | ||
253 | .setPositive("设置网络", new View.OnClickListener() { | ||
254 | @Override | ||
255 | public void onClick(View v) { | ||
256 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 | ||
257 | mContext.startActivity(intent); | ||
258 | } | ||
259 | }) | ||
260 | .show(); | ||
261 | 174 | ||
262 | } | 175 | } |
263 | }); | 176 | }); |
264 | } | 177 | } |
265 | 178 | ||
266 | //修改密码 | 179 | //修改密码 |
267 | public void changepwd(final Context context, String username, String old_pwd1, String newpassword3) { | 180 | public void changepwd(final Context context, String username, String old_pwd1, String newpassword3) { |
268 | RequestParams params = new RequestParams(); | 181 | RequestParams params = new RequestParams(); |
269 | params.put(HttpKey.USERNAME, username); | 182 | params.put(HttpKey.USERNAME, username); |
270 | params.put(HttpKey.OLDPASS, old_pwd1); | 183 | params.put(HttpKey.OLDPASS, old_pwd1); |
271 | params.put(HttpKey.NEWPASS, newpassword3); | 184 | params.put(HttpKey.NEWPASS, newpassword3); |
272 | HttpClient.getInstance().addHeader("Accept", "*/*"); | 185 | HttpClient.getInstance().addHeader("Accept", "*/*"); |
273 | HttpClient.getInstance().setTimeout(10 * 1000); | 186 | HttpClient.getInstance().setTimeout(10 * 1000); |
274 | HttpClient.getInstance().post(HttpUrl.changepassword, params, new AsyncHttpResponseHandler() { | 187 | HttpClient.getInstance().post(HttpUrl.changepassword, params, new AsyncHttpResponseHandler() { |
275 | @Override | 188 | @Override |
276 | public void onSuccess(int i, Header[] headers, byte[] bytes) { | 189 | public void onSuccess(int i, Header[] headers, byte[] bytes) { |
277 | try { | 190 | try { |
278 | JSONObject jsonObject = new JSONObject(new String(bytes)); | 191 | JSONObject jsonObject = new JSONObject(new String(bytes)); |
279 | String status = jsonObject.optString("status"); | 192 | String status = jsonObject.optString("status"); |
280 | if (status.equals("100")) { | 193 | if (status.equals("100")) { |
281 | Log.e("test", "onSuccess" + new String(bytes)); | 194 | Log.e("test", "onSuccess" + new String(bytes)); |
282 | Toast.makeText(context, "密码修改成功!", Toast.LENGTH_LONG).show(); | 195 | Toast.makeText(context, "密码修改成功!", Toast.LENGTH_LONG).show(); |
283 | SaveParam.getInstance().clearData((Activity) context); | 196 | SaveParam.getInstance().clearData((Activity) context); |
284 | Intent intent = new Intent(); | 197 | Intent intent = new Intent(); |
285 | intent.setClass(context, LoginAndRegisterActivity.class); | 198 | intent.setClass(context, LoginAndRegisterActivity.class); |
286 | ((Activity) context).startActivity(intent); | 199 | ((Activity) context).startActivity(intent); |
287 | ((Activity) context).finish(); | 200 | ((Activity) context).finish(); |
288 | } else { | 201 | } else { |
289 | Toast.makeText(context, "密码修改失败!", Toast.LENGTH_LONG).show(); | 202 | Toast.makeText(context, "密码修改失败!", Toast.LENGTH_LONG).show(); |
290 | } | 203 | } |
291 | } catch (JSONException e) { | 204 | } catch (JSONException e) { |
292 | e.printStackTrace(); | 205 | e.printStackTrace(); |
293 | } | 206 | } |
294 | } | 207 | } |
295 | 208 | ||
296 | @Override | 209 | @Override |
297 | public void onFailure(int i, Header[] headers, byte[] bytes, Throwable throwable) { | 210 | public void onFailure(int i, Header[] headers, byte[] bytes, Throwable throwable) { |
298 | Log.e("test", "onFailure" + new String(bytes)); | 211 | Log.e("test", "onFailure" + new String(bytes)); |
299 | new CircleDialog.Builder((FragmentActivity) context) | 212 | AlertUtils.showToast(context, "无法链接到服务器,请检查您的网络或稍后重试!"); |
300 | .setCanceledOnTouchOutside(false) | ||
301 | .setCancelable(false) | ||
302 | .setWidth(0.5f) | ||
303 | .configText(new ConfigText() { | ||
304 | @Override | ||
305 | public void onConfig(TextParams params) { | ||
306 | params.gravity = Gravity.CENTER; | ||
307 | params.padding = new int[]{50, 50, 50, 50}; | ||
308 | } | ||
309 | }) | ||
310 | .setText("当前无网络,请检查网络设置") | ||
311 | .setNegative("继续使用", null) | ||
312 | .setPositive("设置网络", new View.OnClickListener() { | ||
313 | @Override | ||
314 | public void onClick(View v) { | ||
315 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 | ||
316 | context.startActivity(intent); | ||
317 | } | ||
318 | }) | ||
319 | .show(); | ||
320 | } | 213 | } |
321 | }); | 214 | }); |
322 | 215 | ||
323 | } | 216 | } |
324 | 217 | ||
325 | //忘记密码 | 218 | //忘记密码 |
326 | public void forgetpassword(final Context context, String forot_pwd_phone1, String forot_pwd_pwd3, String forot_pwd_anthcode1, Handler handler) { | 219 | public void forgetpassword(final Context context, String forot_pwd_phone1, String forot_pwd_pwd3, String forot_pwd_anthcode1, Handler handler) { |
327 | RequestParams params = new RequestParams(); | 220 | RequestParams params = new RequestParams(); |
328 | params.put(HttpKey.USERNAME, forot_pwd_phone1); | 221 | params.put(HttpKey.USERNAME, forot_pwd_phone1); |
329 | params.put(HttpKey.PASSWORD, forot_pwd_pwd3); | 222 | params.put(HttpKey.PASSWORD, forot_pwd_pwd3); |
330 | params.put(HttpKey.AUTHCODE, forot_pwd_anthcode1); | 223 | params.put(HttpKey.AUTHCODE, forot_pwd_anthcode1); |
331 | HttpClient.getInstance().addHeader("Accept", "*/*"); | 224 | HttpClient.getInstance().addHeader("Accept", "*/*"); |
332 | HttpClient.getInstance().post(HttpUrl.forgetpassword, params, new AsyncHttpResponseHandler() { | 225 | HttpClient.getInstance().post(HttpUrl.forgetpassword, params, new AsyncHttpResponseHandler() { |
333 | @Override | 226 | @Override |
334 | public void onSuccess(int i, Header[] headers, byte[] bytes) { | 227 | public void onSuccess(int i, Header[] headers, byte[] bytes) { |
335 | try { | 228 | try { |
336 | JSONObject jsonObject = new JSONObject(new String(bytes)); | 229 | JSONObject jsonObject = new JSONObject(new String(bytes)); |
337 | String status = jsonObject.optString("status"); | 230 | String status = jsonObject.optString("status"); |
338 | if (status.equals("100")) { | 231 | if (status.equals("100")) { |
339 | Log.e("test", "onSuccess" + new String(bytes)); | 232 | Log.e("test", "onSuccess" + new String(bytes)); |
340 | Toast.makeText(context, "密码修改成功!", Toast.LENGTH_LONG).show(); | 233 | Toast.makeText(context, "密码修改成功!", Toast.LENGTH_LONG).show(); |
341 | ((Activity) context).finish(); | 234 | ((Activity) context).finish(); |
342 | } else { | 235 | } else { |
343 | Toast.makeText(context, "密码修改失败!", Toast.LENGTH_LONG).show(); | 236 | Toast.makeText(context, "密码修改失败!", Toast.LENGTH_LONG).show(); |
344 | } | 237 | } |
345 | } catch (JSONException e) { | 238 | } catch (JSONException e) { |
346 | e.printStackTrace(); | 239 | e.printStackTrace(); |
347 | } | 240 | } |
348 | } | 241 | } |
349 | 242 | ||
350 | @Override | 243 | @Override |
351 | public void onFailure(int i, Header[] headers, byte[] bytes, Throwable throwable) { | 244 | public void onFailure(int i, Header[] headers, byte[] bytes, Throwable throwable) { |
352 | Log.e("test", "onFailure" + new String(bytes)); | 245 | Log.e("test", "onFailure" + new String(bytes)); |
353 | new CircleDialog.Builder((FragmentActivity) context) | 246 | AlertUtils.showToast(context, "无法链接到服务器,请检查您的网络或稍后重试!"); |
354 | .setCanceledOnTouchOutside(false) | ||
355 | .setCancelable(false) | ||
356 | .setWidth(0.5f) | ||
357 | .configText(new ConfigText() { | ||
358 | @Override | ||
359 | public void onConfig(TextParams params) { | ||
360 | params.gravity = Gravity.CENTER; | ||
361 | params.padding = new int[]{50, 50, 50, 50}; | ||
362 | } | ||
363 | }) | ||
364 | .setText("当前无网络,请检查网络设置") | ||
365 | .setNegative("继续使用", null) | ||
366 | .setPositive("设置网络", new View.OnClickListener() { | ||
367 | @Override | ||
368 | public void onClick(View v) { | ||
369 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 | ||
370 | context.startActivity(intent); | ||
371 | } | ||
372 | }) | ||
373 | .show(); | ||
374 | } | 247 | } |
375 | }); | 248 | }); |
376 | 249 | ||
377 | } | 250 | } |
378 | 251 | ||
379 | //保存用户登录信息 | 252 | //保存用户登录信息 |
380 | public void saveLoginInfo(Context context, String username, String password, String access_token, String loginStatus, String userId) { | 253 | public void saveLoginInfo(Context context, String username, String password, String access_token, String loginStatus, String userId) { |
381 | SaveParam.getInstance().saveLoginParam(context, "username", username); | 254 | SaveParam.getInstance().saveLoginParam(context, "username", username); |
382 | SaveParam.getInstance().saveLoginParam(context, "password", password); | 255 | SaveParam.getInstance().saveLoginParam(context, "password", password); |
383 | SaveParam.getInstance().saveLoginParam(context, "access_token", access_token); | 256 | SaveParam.getInstance().saveLoginParam(context, "access_token", access_token); |
384 | SaveParam.getInstance().saveLoginParam(context, "login", loginStatus); | 257 | SaveParam.getInstance().saveLoginParam(context, "login", loginStatus); |
385 | SaveParam.getInstance().saveLoginParam(context, "userId", userId); | 258 | SaveParam.getInstance().saveLoginParam(context, "userId", userId); |
386 | 259 | ||
387 | 260 | ||
388 | } | 261 | } |
389 | 262 | ||
390 | //提交保卡信息 | 263 | //提交保卡信息 |
391 | public void subcardinfo(final Context context, long userId, String customerName, String customerAddress, | 264 | public void subcardinfo(final Context context, long userId, String customerName, String customerAddress, |
392 | String buyAddress, String buyTime, String alterSaleCall, | 265 | String buyAddress, String buyTime, String alterSaleCall, |
393 | String productModel, String deviceNumber, String macAddress, | 266 | String productModel, String deviceNumber, String macAddress, |
394 | String mobilePhone) { | 267 | String mobilePhone) { |
395 | mProgress = DialogPermission.showProgress(context, null, "正在绑定保卡...", | 268 | mProgress = DialogPermission.showProgress(context, null, "正在绑定保卡...", |
396 | false, true, null); | 269 | false, true, null); |
397 | RequestParams params = new RequestParams(); | 270 | RequestParams params = new RequestParams(); |
398 | 271 | ||
399 | params.put(HttpKey.USEID, userId); | 272 | params.put(HttpKey.USEID, userId); |
400 | params.put(HttpKey.CUSTOMENAME, customerName); | 273 | params.put(HttpKey.CUSTOMENAME, customerName); |
401 | params.put(HttpKey.CUSTOMADRESS, customerAddress); | 274 | params.put(HttpKey.CUSTOMADRESS, customerAddress); |
402 | params.put(HttpKey.BUYADREES, buyAddress); | 275 | params.put(HttpKey.BUYADREES, buyAddress); |
403 | params.put(HttpKey.BUYTIME, buyTime); | 276 | params.put(HttpKey.BUYTIME, buyTime); |
404 | params.put(HttpKey.ALTERSALECALL, alterSaleCall); | 277 | params.put(HttpKey.ALTERSALECALL, alterSaleCall); |
405 | params.put(HttpKey.PRODUCTMODEL, productModel); | 278 | params.put(HttpKey.PRODUCTMODEL, productModel); |
406 | params.put(HttpKey.DEVICENUMBER, deviceNumber); | 279 | params.put(HttpKey.DEVICENUMBER, deviceNumber); |
407 | params.put(HttpKey.MACADRESS, macAddress); | 280 | params.put(HttpKey.MACADRESS, macAddress); |
408 | params.put(HttpKey.MOBILPHONE, mobilePhone); | 281 | params.put(HttpKey.MOBILPHONE, mobilePhone); |
409 | 282 | ||
410 | HttpClient.getInstance().addHeader("Accept", "*/*"); | 283 | HttpClient.getInstance().addHeader("Accept", "*/*"); |
411 | 284 | ||
412 | Log.e("test", "params" + params); | 285 | Log.e("test", "params" + params); |
413 | HttpClient.getInstance().setTimeout(5 * 1000); | 286 | HttpClient.getInstance().setTimeout(5 * 1000); |
414 | HttpClient.getInstance().post(context, HttpUrl.subcardinfo, params, new AsyncHttpResponseHandler() { | 287 | HttpClient.getInstance().post(context, HttpUrl.subcardinfo, params, new AsyncHttpResponseHandler() { |
415 | @Override | 288 | @Override |
416 | public void onSuccess(int i, Header[] headers, byte[] bytes) { | 289 | public void onSuccess(int i, Header[] headers, byte[] bytes) { |
417 | JSONObject jsonObject = null; | 290 | JSONObject jsonObject = null; |
418 | closeProgress(); | 291 | closeProgress(); |
419 | try { | 292 | try { |
420 | jsonObject = new JSONObject(new String(bytes)); | 293 | jsonObject = new JSONObject(new String(bytes)); |
421 | String status = jsonObject.optString("status"); | 294 | String status = jsonObject.optString("status"); |
422 | if (status.equals("1")) { | 295 | if (status.equals("1")) { |
423 | Log.e("test", "onSuccess" + jsonObject); | 296 | Log.e("test", "onSuccess" + jsonObject); |
424 | Toast.makeText(context, "保卡绑定成功!", Toast.LENGTH_LONG).show(); | 297 | Toast.makeText(context, "保卡绑定成功!", Toast.LENGTH_LONG).show(); |
425 | Intent intent = new Intent(); | 298 | Intent intent = new Intent(); |
426 | intent.setClass((Activity) context, TheStartPageActivity.class); | 299 | intent.setClass((Activity) context, TheStartPageActivity.class); |
427 | ((Activity) context).startActivity(intent); | 300 | ((Activity) context).startActivity(intent); |
428 | ((Activity) context).overridePendingTransition(R.anim.rightin, R.anim.rightout); | 301 | ((Activity) context).overridePendingTransition(R.anim.rightin, R.anim.rightout); |
429 | ((Activity) context).finish(); | 302 | ((Activity) context).finish(); |
430 | } else { | 303 | } else { |
431 | Toast.makeText(context, "保卡绑定失败!", Toast.LENGTH_LONG).show(); | 304 | Toast.makeText(context, "保卡绑定失败!", Toast.LENGTH_LONG).show(); |
432 | } | 305 | } |
433 | } catch (JSONException e) { | 306 | } catch (JSONException e) { |
434 | e.printStackTrace(); | 307 | e.printStackTrace(); |
435 | } | 308 | } |
436 | 309 | ||
437 | 310 | ||
438 | } | 311 | } |
439 | 312 | ||
440 | @Override | 313 | @Override |
441 | public void onFailure(int i, Header[] headers, byte[] bytes, Throwable throwable) { | 314 | public void onFailure(int i, Header[] headers, byte[] bytes, Throwable throwable) { |
442 | Log.e("test", "onFailure" + (throwable)); | 315 | Log.e("test", "onFailure" + (throwable)); |
443 | closeProgress(); | 316 | closeProgress(); |
444 | new CircleDialog.Builder((FragmentActivity) context) | 317 | AlertUtils.showToast(context, "无法链接到服务器,请检查您的网络或稍后重试!"); |
445 | .setCanceledOnTouchOutside(false) | ||
446 | .setCancelable(false) | ||
447 | .setWidth(0.5f) | ||
448 | .configText(new ConfigText() { | ||
449 | @Override | ||
450 | public void onConfig(TextParams params) { | ||
451 | params.gravity = Gravity.CENTER; | ||
452 | params.padding = new int[]{50, 50, 50, 50}; | ||
453 | } | ||
454 | }) | ||
455 | .setText("当前无网络,请检查网络设置") | ||
456 | .setNegative("继续使用", null) | ||
457 | .setPositive("设置网络", new View.OnClickListener() { | ||
458 | @Override | ||
459 | public void onClick(View v) { | ||
460 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 | ||
461 | context.startActivity(intent); | ||
462 | } | ||
463 | }) | ||
464 | .show(); | ||
465 | 318 | ||
466 | } | 319 | } |
467 | }); | 320 | }); |
468 | 321 | ||
469 | } | 322 | } |
470 | 323 | ||
471 | //获取保卡信息 | 324 | //获取保卡信息 |
472 | public void getcardinfo(final Context mContext, long userId, final Handler handler) { | 325 | public void getcardinfo(final Context mContext, long userId, final Handler handler) { |
473 | mProgress = DialogPermission.showProgress(mContext, null, "正在获取保卡信息...", | 326 | mProgress = DialogPermission.showProgress(mContext, null, "正在获取保卡信息...", |
474 | false, true, null); | 327 | false, true, null); |
475 | HttpClient.getInstance().setTimeout(5 * 1000); | 328 | HttpClient.getInstance().setTimeout(5 * 1000); |
476 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); | 329 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); |
477 | HttpClient.getInstance().get(HttpUrl.getcardinfo + "?userId=" + userId, new AsyncHttpResponseHandler() { | 330 | HttpClient.getInstance().get(HttpUrl.getcardinfo + "?userId=" + userId, new AsyncHttpResponseHandler() { |
478 | @Override | 331 | @Override |
479 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { | 332 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { |
480 | closeProgress(); | 333 | closeProgress(); |
481 | Log.e("test", "保卡信息" + new String(arg2)); | 334 | Log.e("test", "保卡信息" + new String(arg2)); |
482 | try { | 335 | try { |
483 | JSONObject jsonObject = new JSONObject(new String(arg2)); | 336 | JSONObject jsonObject = new JSONObject(new String(arg2)); |
484 | int status = jsonObject.optInt("status"); | 337 | int status = jsonObject.optInt("status"); |
485 | if (status == 1) { | 338 | if (status == 1) { |
486 | CardInfo cardInfo = GsonTool.getPerson(new String(arg2), CardInfo.class);//解析json数据 | 339 | CardInfo cardInfo = GsonTool.getPerson(new String(arg2), CardInfo.class);//解析json数据 |
487 | CardInfo.DataBean schoolInfoBeanList = cardInfo.getData(); | 340 | CardInfo.DataBean schoolInfoBeanList = cardInfo.getData(); |
488 | Message msg = Message.obtain(); | 341 | Message msg = Message.obtain(); |
489 | msg.what = HttpCode.SUCHCARDINFO; | 342 | msg.what = HttpCode.SUCHCARDINFO; |
490 | msg.obj = schoolInfoBeanList; | 343 | msg.obj = schoolInfoBeanList; |
491 | handler.sendMessage(msg); | 344 | handler.sendMessage(msg); |
492 | 345 | ||
493 | 346 | ||
494 | } else { | 347 | } else { |
495 | AlertUtils.showToast(mContext, "你好,服务器异常,请稍后重试!"); | 348 | AlertUtils.showToast(mContext, "你好,服务器异常,请稍后重试!"); |
496 | 349 | ||
497 | } | 350 | } |
498 | } catch (JSONException e) { | 351 | } catch (JSONException e) { |
499 | e.printStackTrace(); | 352 | e.printStackTrace(); |
500 | } | 353 | } |
501 | 354 | ||
502 | } | 355 | } |
503 | 356 | ||
504 | @Override | 357 | @Override |
505 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { | 358 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { |
506 | closeProgress(); | 359 | closeProgress(); |
507 | new CircleDialog.Builder((FragmentActivity) mContext) | 360 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); |
508 | .setCanceledOnTouchOutside(false) | ||
509 | .setCancelable(false) | ||
510 | .setWidth(0.5f) | ||
511 | .configText(new ConfigText() { | ||
512 | @Override | ||
513 | public void onConfig(TextParams params) { | ||
514 | params.gravity = Gravity.CENTER; | ||
515 | params.padding = new int[]{50, 50, 50, 50}; | ||
516 | } | ||
517 | }) | ||
518 | .setText("当前无网络,请检查网络设置") | ||
519 | .setNegative("继续使用", null) | ||
520 | .setPositive("设置网络", new View.OnClickListener() { | ||
521 | @Override | ||
522 | public void onClick(View v) { | ||
523 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 | ||
524 | mContext.startActivity(intent); | ||
525 | } | ||
526 | }) | ||
527 | .show(); | ||
528 | } | 361 | } |
529 | }); | 362 | }); |
530 | } | 363 | } |
531 | 364 | ||
532 | //修改保卡信息电话 | 365 | //修改保卡信息电话 |
533 | public void changecardinfophone(final Context mContext, long userId, final String customerPhone, String authCode) { | 366 | public void changecardinfophone(final Context mContext, long userId, final String customerPhone, String authCode) { |
534 | RequestParams params = new RequestParams(); | 367 | RequestParams params = new RequestParams(); |
535 | params.put("userId", userId); | 368 | params.put("userId", userId); |
536 | params.put("customerPhone", customerPhone); | 369 | params.put("customerPhone", customerPhone); |
537 | params.put("authCode", authCode); | 370 | params.put("authCode", authCode); |
538 | HttpClient.getInstance().addHeader("Accept", "*/*"); | 371 | HttpClient.getInstance().addHeader("Accept", "*/*"); |
539 | HttpClient.getInstance().post(HttpUrl.changecardinfo, params, new AsyncHttpResponseHandler() { | 372 | HttpClient.getInstance().post(HttpUrl.changecardinfo, params, new AsyncHttpResponseHandler() { |
540 | @Override | 373 | @Override |
541 | public void onSuccess(int i, Header[] headers, byte[] bytes) { | 374 | public void onSuccess(int i, Header[] headers, byte[] bytes) { |
542 | try { | 375 | try { |
543 | JSONObject jsonObject = new JSONObject(new String(bytes)); | 376 | JSONObject jsonObject = new JSONObject(new String(bytes)); |
544 | String status = jsonObject.optString("status"); | 377 | String status = jsonObject.optString("status"); |
545 | if (status.equals("1")) { | 378 | if (status.equals("1")) { |
546 | Toast.makeText(mContext, "手机号修改成功", Toast.LENGTH_LONG).show(); | 379 | Toast.makeText(mContext, "手机号修改成功", Toast.LENGTH_LONG).show(); |
547 | if (Content.authcodeflag==2){ | 380 | if (Content.authcodeflag==2){ |
548 | SaveParam.getInstance().saveCustomizeParam(mContext, SaveParam.CARDPHONE, customerPhone); | 381 | SaveParam.getInstance().saveCustomizeParam(mContext, SaveParam.CARDPHONE, customerPhone); |
549 | }else if (Content.authcodeflag==1){ | 382 | }else if (Content.authcodeflag==1){ |
550 | SaveParam.getInstance().saveLoginParam(mContext, "username", customerPhone); | 383 | SaveParam.getInstance().saveLoginParam(mContext, "username", customerPhone); |
551 | }else { | 384 | }else { |
552 | AlertUtils.showToast(mContext, "修改未知的手机号"); | 385 | AlertUtils.showToast(mContext, "修改未知的手机号"); |
553 | } | 386 | } |
554 | ((Activity) mContext).finish(); | 387 | ((Activity) mContext).finish(); |
555 | } else if (status.equals("1001")) { | 388 | } else if (status.equals("1001")) { |
556 | Toast.makeText(mContext, "验证码输入错误", Toast.LENGTH_LONG).show(); | 389 | Toast.makeText(mContext, "验证码输入错误", Toast.LENGTH_LONG).show(); |
557 | } else { | 390 | } else { |
558 | AlertUtils.showToast(mContext, "您好,服务器异常,请稍后重试"); | 391 | AlertUtils.showToast(mContext, "您好,服务器异常,请稍后重试"); |
559 | } | 392 | } |
560 | } catch (JSONException e) { | 393 | } catch (JSONException e) { |
561 | e.printStackTrace(); | 394 | e.printStackTrace(); |
562 | } | 395 | } |
563 | } | 396 | } |
564 | 397 | ||
565 | @Override | 398 | @Override |
566 | public void onFailure(int i, Header[] headers, byte[] bytes, Throwable throwable) { | 399 | public void onFailure(int i, Header[] headers, byte[] bytes, Throwable throwable) { |
567 | Log.e("test", "onFailure" + new String(bytes)); | 400 | Log.e("test", "onFailure" + new String(bytes)); |
568 | new CircleDialog.Builder((FragmentActivity) mContext) | 401 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); |
569 | .setCanceledOnTouchOutside(false) | ||
570 | .setCancelable(false) | ||
571 | .setWidth(0.5f) | ||
572 | .configText(new ConfigText() { | ||
573 | @Override | ||
574 | public void onConfig(TextParams params) { | ||
575 | params.gravity = Gravity.CENTER; | ||
576 | params.padding = new int[]{50, 50, 50, 50}; | ||
577 | } | ||
578 | }) | ||
579 | .setText("当前无网络,请检查网络设置") | ||
580 | .setNegative("继续使用", null) | ||
581 | .setPositive("设置网络", new View.OnClickListener() { | ||
582 | @Override | ||
583 | public void onClick(View v) { | ||
584 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 | ||
585 | mContext.startActivity(intent); | ||
586 | } | ||
587 | }) | ||
588 | .show(); | ||
589 | } | 402 | } |
590 | }); | 403 | }); |
591 | } | 404 | } |
592 | 405 | ||
593 | //修改保卡信息地址 | 406 | //修改保卡信息地址 |
594 | public void changecardadressinfo(final Context mContext, long userId, final String customerPhone, String authCode, final String customerAddress) { | 407 | public void changecardadressinfo(final Context mContext, long userId, final String customerPhone, String authCode, final String customerAddress) { |
595 | RequestParams params = new RequestParams(); | 408 | RequestParams params = new RequestParams(); |
596 | params.put("userId", userId); | 409 | params.put("userId", userId); |
597 | params.put("customerPhone", customerPhone); | 410 | params.put("customerPhone", customerPhone); |
598 | params.put("authCode", authCode); | 411 | params.put("authCode", authCode); |
599 | params.put("customerAddress", customerAddress); | 412 | params.put("customerAddress", customerAddress); |
600 | HttpClient.getInstance().addHeader("Accept", "*/*"); | 413 | HttpClient.getInstance().addHeader("Accept", "*/*"); |
601 | HttpClient.getInstance().post(HttpUrl.changecardinfo, params, new AsyncHttpResponseHandler() { | 414 | HttpClient.getInstance().post(HttpUrl.changecardinfo, params, new AsyncHttpResponseHandler() { |
602 | @Override | 415 | @Override |
603 | public void onSuccess(int i, Header[] headers, byte[] bytes) { | 416 | public void onSuccess(int i, Header[] headers, byte[] bytes) { |
604 | try { | 417 | try { |
605 | JSONObject jsonObject = new JSONObject(new String(bytes)); | 418 | JSONObject jsonObject = new JSONObject(new String(bytes)); |
606 | String status = jsonObject.optString("status"); | 419 | String status = jsonObject.optString("status"); |
607 | if (status.equals("1")) { | 420 | if (status.equals("1")) { |
608 | Toast.makeText(mContext, "手机号修改成功", Toast.LENGTH_LONG).show(); | 421 | Toast.makeText(mContext, "修改成功", Toast.LENGTH_LONG).show(); |
609 | SaveParam.getInstance().saveCustomizeParam(mContext, SaveParam.ADRESSCUNSTEM, customerAddress); | 422 | SaveParam.getInstance().saveCustomizeParam(mContext, SaveParam.ADRESSCUNSTEM, customerAddress); |
610 | ((Activity) mContext).finish(); | 423 | ((Activity) mContext).finish(); |
611 | } else { | 424 | } else { |
612 | AlertUtils.showToast(mContext, "您好,服务器异常,请稍后重试"); | 425 | AlertUtils.showToast(mContext, "您好,服务器异常,请稍后重试"); |
613 | } | 426 | } |
614 | } catch (JSONException e) { | 427 | } catch (JSONException e) { |
615 | e.printStackTrace(); | 428 | e.printStackTrace(); |
616 | } | 429 | } |
617 | } | 430 | } |
618 | 431 | ||
619 | @Override | 432 | @Override |
620 | public void onFailure(int i, Header[] headers, byte[] bytes, Throwable throwable) { | 433 | public void onFailure(int i, Header[] headers, byte[] bytes, Throwable throwable) { |
621 | Log.e("test", "onFailure" + new String(bytes)); | 434 | Log.e("test", "onFailure" + new String(bytes)); |
622 | new CircleDialog.Builder((FragmentActivity) mContext) | 435 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); |
623 | .setCanceledOnTouchOutside(false) | ||
624 | .setCancelable(false) | ||
625 | .setWidth(0.5f) | ||
626 | .configText(new ConfigText() { | ||
627 | @Override | ||
628 | public void onConfig(TextParams params) { | ||
629 | params.gravity = Gravity.CENTER; | ||
630 | params.padding = new int[]{50, 50, 50, 50}; | ||
631 | } | ||
632 | }) | ||
633 | .setText("当前无网络,请检查网络设置") | ||
634 | .setNegative("继续使用", null) | ||
635 | .setPositive("设置网络", new View.OnClickListener() { | ||
636 | @Override | ||
637 | public void onClick(View v) { | ||
638 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 | ||
639 | mContext.startActivity(intent); | ||
640 | } | ||
641 | }) | ||
642 | .show(); | ||
643 | } | 436 | } |
644 | }); | 437 | }); |
645 | } | 438 | } |
646 | 439 | ||
647 | //验证是否保卡信息 | 440 | //验证是否保卡信息 |
648 | public void cardinfocheck(final Context mContext, long userId, final Handler handler) { | 441 | public void cardinfocheck(final Context mContext, long userId, final Handler handler) { |
649 | mProgress = DialogPermission.showProgress(mContext, null, "正在验证保卡信息...", | 442 | mProgress = DialogPermission.showProgress(mContext, null, "正在验证保卡信息...", |
650 | false, true, null); | 443 | false, true, null); |
651 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); | 444 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); |
652 | HttpClient.getInstance().get(HttpUrl.cardcheck + "?userId=" + userId, new AsyncHttpResponseHandler() { | 445 | HttpClient.getInstance().get(HttpUrl.cardcheck + "?userId=" + userId, new AsyncHttpResponseHandler() { |
653 | @Override | 446 | @Override |
654 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { | 447 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { |
655 | Log.e("test", "---" + new String(arg2)); | 448 | Log.e("test", "---" + new String(arg2)); |
656 | closeProgress(); | 449 | closeProgress(); |
657 | Message msg = Message.obtain(); | 450 | Message msg = Message.obtain(); |
658 | msg.what = HttpCode.CHECKCARD; | 451 | msg.what = HttpCode.CHECKCARD; |
659 | msg.obj = new String(arg2); | 452 | msg.obj = new String(arg2); |
660 | handler.sendMessage(msg); | 453 | handler.sendMessage(msg); |
661 | 454 | ||
662 | 455 | ||
663 | } | 456 | } |
664 | 457 | ||
665 | @Override | 458 | @Override |
666 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { | 459 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { |
667 | closeProgress(); | 460 | closeProgress(); |
668 | new CircleDialog.Builder((FragmentActivity) mContext) | 461 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); |
669 | .setCanceledOnTouchOutside(false) | ||
670 | .setCancelable(false) | ||
671 | .setWidth(0.5f) | ||
672 | .configText(new ConfigText() { | ||
673 | @Override | ||
674 | public void onConfig(TextParams params) { | ||
675 | params.gravity = Gravity.CENTER; | ||
676 | params.padding = new int[]{50, 50, 50, 50}; | ||
677 | } | ||
678 | }) | ||
679 | .setText("当前无网络,请检查网络设置") | ||
680 | .setNegative("继续使用", null) | ||
681 | .setPositive("设置网络", new View.OnClickListener() { | ||
682 | @Override | ||
683 | public void onClick(View v) { | ||
684 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 | ||
685 | mContext.startActivity(intent); | ||
686 | } | ||
687 | }) | ||
688 | .show(); | ||
689 | //Toast.makeText(mContext, "请检查网络。。" + arg3, Toast.LENGTH_LONG).show(); | 462 | //Toast.makeText(mContext, "请检查网络。。" + arg3, Toast.LENGTH_LONG).show(); |
690 | } | 463 | } |
691 | }); | 464 | }); |
692 | } | 465 | } |
693 | 466 | ||
694 | ///获取年级 | 467 | ///获取年级 |
695 | public void getgrade(final Context mContext, final Handler handler) { | 468 | public void getgrade(final Context mContext, final Handler handler) { |
696 | HttpClient.getInstance().addHeader("Accept", "application/json"); | 469 | HttpClient.getInstance().addHeader("Accept", "application/json"); |
697 | HttpClient.getInstance().get(HttpUrl.gradesUrl, new AsyncHttpResponseHandler() { | 470 | HttpClient.getInstance().get(HttpUrl.gradesUrl, new AsyncHttpResponseHandler() { |
698 | @Override | 471 | @Override |
699 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { | 472 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { |
700 | Log.e("test", "年级" + new String(arg2)); | 473 | Log.e("test", "年级" + new String(arg2)); |
701 | GradeInfo gradeInfo = GsonTool.getPerson(new String(arg2), GradeInfo.class);//解析json数据 | 474 | GradeInfo gradeInfo = GsonTool.getPerson(new String(arg2), GradeInfo.class);//解析json数据 |
702 | List<GradeInfo.DataBean.ChildrenBean> gradeInfoLists = new ArrayList<GradeInfo.DataBean.ChildrenBean>(); | 475 | List<GradeInfo.DataBean.ChildrenBean> gradeInfoLists = new ArrayList<GradeInfo.DataBean.ChildrenBean>(); |
703 | for (int i = 0; i < gradeInfo.getData().size() - 2; i++) { | 476 | for (int i = 0; i < gradeInfo.getData().size() - 2; i++) { |
704 | String name = gradeInfo.getData().get(i).getName(); | 477 | String name = gradeInfo.getData().get(i).getName(); |
705 | int id = gradeInfo.getData().get(i).getId(); | 478 | int id = gradeInfo.getData().get(i).getId(); |
706 | List<GradeInfo.DataBean.ChildrenBean> gradeinfoList = gradeInfo.getData().get(i).getChildren(); | 479 | List<GradeInfo.DataBean.ChildrenBean> gradeinfoList = gradeInfo.getData().get(i).getChildren(); |
707 | for (int j = 0; j < gradeinfoList.size(); j++) { | 480 | for (int j = 0; j < gradeinfoList.size(); j++) { |
708 | String secondname = gradeinfoList.get(j).getName(); | 481 | String secondname = gradeinfoList.get(j).getName(); |
709 | int secondid = gradeinfoList.get(j).getId(); | 482 | int secondid = gradeinfoList.get(j).getId(); |
710 | GradeInfo.DataBean.ChildrenBean dataBean = new GradeInfo.DataBean.ChildrenBean(); | 483 | GradeInfo.DataBean.ChildrenBean dataBean = new GradeInfo.DataBean.ChildrenBean(); |
711 | dataBean.setName(secondname); | 484 | dataBean.setName(secondname); |
712 | dataBean.setId(secondid); | 485 | dataBean.setId(secondid); |
713 | gradeInfoLists.add(dataBean); | 486 | gradeInfoLists.add(dataBean); |
714 | } | 487 | } |
715 | 488 | ||
716 | } | 489 | } |
717 | 490 | ||
718 | Message message = Message.obtain(); | 491 | Message message = Message.obtain(); |
719 | message.what = HttpCode.GRADER; | 492 | message.what = HttpCode.GRADER; |
720 | message.obj = gradeInfoLists; | 493 | message.obj = gradeInfoLists; |
721 | handler.sendMessage(message); | 494 | handler.sendMessage(message); |
722 | 495 | ||
723 | 496 | ||
724 | } | 497 | } |
725 | 498 | ||
726 | @Override | 499 | @Override |
727 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { | 500 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { |
728 | new CircleDialog.Builder((FragmentActivity) mContext) | 501 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); |
729 | .setCanceledOnTouchOutside(false) | ||
730 | .setCancelable(false) | ||
731 | .setWidth(0.5f) | ||
732 | .configText(new ConfigText() { | ||
733 | @Override | ||
734 | public void onConfig(TextParams params) { | ||
735 | params.gravity = Gravity.CENTER; | ||
736 | params.padding = new int[]{50, 50, 50, 50}; | ||
737 | } | ||
738 | }) | ||
739 | .setText("当前无网络,请检查网络设置") | ||
740 | .setNegative("继续使用", null) | ||
741 | .setPositive("设置网络", new View.OnClickListener() { | ||
742 | @Override | ||
743 | public void onClick(View v) { | ||
744 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 | ||
745 | mContext.startActivity(intent); | ||
746 | } | ||
747 | }) | ||
748 | .show(); | ||
749 | } | 502 | } |
750 | }); | 503 | }); |
751 | } | 504 | } |
752 | 505 | ||
753 | /** | 506 | /** |
754 | * 获取学校 | 507 | * 获取学校 |
755 | * | 508 | * |
756 | * @param mContext | 509 | * @param mContext |
757 | * @param regionId | 510 | * @param regionId |
758 | * @param gradeId | 511 | * @param gradeId |
759 | * @param handler | 512 | * @param handler |
760 | */ | 513 | */ |
761 | public void getschool(final Context mContext, int regionId, int gradeId, final Handler handler) { | 514 | public void getschool(final Context mContext, int regionId, int gradeId, final Handler handler) { |
762 | HttpClient.getInstance().addHeader("Accept", "application/json"); | 515 | HttpClient.getInstance().addHeader("Accept", "application/json"); |
763 | HttpClient.getInstance().get(HttpUrl.schoolUrl + "?regionId=" + regionId + "&gradeId=" + gradeId, new AsyncHttpResponseHandler() { | 516 | HttpClient.getInstance().get(HttpUrl.schoolUrl + "?regionId=" + regionId + "&gradeId=" + gradeId, new AsyncHttpResponseHandler() { |
764 | @Override | 517 | @Override |
765 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { | 518 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { |
766 | Log.e("test", "学校" + new String(arg2)); | 519 | Log.e("test", "学校" + new String(arg2)); |
767 | try { | 520 | try { |
768 | JSONObject jsonObject = new JSONObject(new String(arg2)); | 521 | JSONObject jsonObject = new JSONObject(new String(arg2)); |
769 | int status = jsonObject.optInt("status"); | 522 | int status = jsonObject.optInt("status"); |
770 | if (status == 1) { | 523 | if (status == 1) { |
771 | SchoolInfo schoolInfo = GsonTool.getPerson(new String(arg2), SchoolInfo.class);//解析json数据 | 524 | SchoolInfo schoolInfo = GsonTool.getPerson(new String(arg2), SchoolInfo.class);//解析json数据 |
772 | List<SchoolInfo.DataBean> schoolInfoBeanList = schoolInfo.getData(); | 525 | List<SchoolInfo.DataBean> schoolInfoBeanList = schoolInfo.getData(); |
773 | Message message = Message.obtain(); | 526 | Message message = Message.obtain(); |
774 | message.what = HttpCode.SCHOOL; | 527 | message.what = HttpCode.SCHOOL; |
775 | message.obj = schoolInfoBeanList; | 528 | message.obj = schoolInfoBeanList; |
776 | handler.sendMessage(message); | 529 | handler.sendMessage(message); |
777 | 530 | ||
778 | 531 | ||
779 | } else { | 532 | } else { |
780 | AlertUtils.showToast(mContext, "你好,服务器异常,请稍后重试!"); | 533 | AlertUtils.showToast(mContext, "你好,服务器异常,请稍后重试!"); |
781 | 534 | ||
782 | } | 535 | } |
783 | } catch (JSONException e) { | 536 | } catch (JSONException e) { |
784 | e.printStackTrace(); | 537 | e.printStackTrace(); |
785 | } | 538 | } |
786 | 539 | ||
787 | } | 540 | } |
788 | 541 | ||
789 | @Override | 542 | @Override |
790 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { | 543 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { |
791 | new CircleDialog.Builder((FragmentActivity) mContext) | 544 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); |
792 | .setCanceledOnTouchOutside(false) | ||
793 | .setCancelable(false) | ||
794 | .setWidth(0.5f) | ||
795 | .configText(new ConfigText() { | ||
796 | @Override | ||
797 | public void onConfig(TextParams params) { | ||
798 | params.gravity = Gravity.CENTER; | ||
799 | params.padding = new int[]{50, 50, 50, 50}; | ||
800 | } | ||
801 | }) | ||
802 | .setText("当前无网络,请检查网络设置") | ||
803 | .setNegative("继续使用", null) | ||
804 | .setPositive("设置网络", new View.OnClickListener() { | ||
805 | @Override | ||
806 | public void onClick(View v) { | ||
807 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 | ||
808 | mContext.startActivity(intent); | ||
809 | } | ||
810 | }) | ||
811 | .show(); | ||
812 | } | 545 | } |
813 | }); | 546 | }); |
814 | } | 547 | } |
815 | 548 | ||
816 | 549 | ||
817 | /** | 550 | /** |
818 | * 获取个人信息 | 551 | * 获取个人信息 |
819 | * | 552 | * |
820 | * @param mContext | 553 | * @param mContext |
821 | * @param userId | 554 | * @param userId |
822 | * @param handler | 555 | * @param handler |
823 | */ | 556 | */ |
824 | public void getpresonalinfo(final Context mContext, long userId, int type, final Handler handler) { | 557 | public void getpresonalinfo(final Context mContext, long userId, int type, final Handler handler) { |
825 | mProgress = DialogPermission.showProgress(mContext, null, "正在获取个人信息...", | 558 | mProgress = DialogPermission.showProgress(mContext, null, "正在获取个人信息...", |
826 | false, true, null); | 559 | false, true, null); |
827 | HttpClient.getInstance().addHeader("Accept", "application/json"); | 560 | HttpClient.getInstance().addHeader("Accept", "application/json"); |
828 | HttpClient.getInstance().setConnectTimeout(5 * 1000); | 561 | HttpClient.getInstance().setConnectTimeout(5 * 1000); |
829 | HttpClient.getInstance().get(HttpUrl.getpresonalinfo + "?userId=" + userId + "&type=" + type, new AsyncHttpResponseHandler() { | 562 | HttpClient.getInstance().get(HttpUrl.getpresonalinfo + "?userId=" + userId + "&type=" + type, new AsyncHttpResponseHandler() { |
830 | @Override | 563 | @Override |
831 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { | 564 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { |
832 | closeProgress(); | 565 | closeProgress(); |
833 | Log.e("test", "个人信息" + new String(arg2)); | 566 | Log.e("test", "个人信息" + new String(arg2)); |
834 | try { | 567 | try { |
835 | JSONObject jsonObject = new JSONObject(new String(arg2)); | 568 | JSONObject jsonObject = new JSONObject(new String(arg2)); |
836 | int status = jsonObject.optInt("status"); | 569 | int status = jsonObject.optInt("status"); |
837 | if (status == 1) { | 570 | if (status == 1) { |
838 | PesonalInfo pesonalInfo = GsonTool.getPerson(new String(arg2), PesonalInfo.class);//解析json数据 | 571 | PesonalInfo pesonalInfo = GsonTool.getPerson(new String(arg2), PesonalInfo.class);//解析json数据 |
839 | PesonalInfo.DataBean pesonalInfoBeanList = pesonalInfo.getData(); | 572 | PesonalInfo.DataBean pesonalInfoBeanList = pesonalInfo.getData(); |
840 | Message message = Message.obtain(); | 573 | Message message = Message.obtain(); |
841 | message.what = HttpCode.GETINFO; | 574 | message.what = HttpCode.GETINFO; |
842 | message.obj = pesonalInfoBeanList; | 575 | message.obj = pesonalInfoBeanList; |
843 | handler.sendMessage(message); | 576 | handler.sendMessage(message); |
844 | 577 | ||
845 | 578 | ||
846 | } else { | 579 | } else { |
847 | AlertUtils.showToast(mContext, "你好,服务器异常,请稍后重试!"); | 580 | AlertUtils.showToast(mContext, "你好,服务器异常,请稍后重试!"); |
848 | 581 | ||
849 | } | 582 | } |
850 | } catch (JSONException e) { | 583 | } catch (JSONException e) { |
851 | e.printStackTrace(); | 584 | e.printStackTrace(); |
852 | } | 585 | } |
853 | 586 | ||
854 | 587 | ||
855 | } | 588 | } |
856 | 589 | ||
857 | @Override | 590 | @Override |
858 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { | 591 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { |
859 | closeProgress(); | 592 | closeProgress(); |
860 | new CircleDialog.Builder((FragmentActivity) mContext) | 593 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); |
861 | .setCanceledOnTouchOutside(false) | ||
862 | .setCancelable(false) | ||
863 | .setWidth(0.5f) | ||
864 | .configText(new ConfigText() { | ||
865 | @Override | ||
866 | public void onConfig(TextParams params) { | ||
867 | params.gravity = Gravity.CENTER; | ||
868 | params.padding = new int[]{50, 50, 50, 50}; | ||
869 | } | ||
870 | }) | ||
871 | .setText("当前无网络,请检查网络设置") | ||
872 | .setNegative("继续使用", null) | ||
873 | .setPositive("设置网络", new View.OnClickListener() { | ||
874 | @Override | ||
875 | public void onClick(View v) { | ||
876 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 | ||
877 | mContext.startActivity(intent); | ||
878 | } | ||
879 | }) | ||
880 | .show(); | ||
881 | } | 594 | } |
882 | }); | 595 | }); |
883 | } | 596 | } |
884 | 597 | ||
885 | //修改个人信息 | 598 | //修改个人信息 |
886 | public void changepresonalinfo(final Context mContext, Long id, int type | 599 | public void changepresonalinfo(final Context mContext, Long id, int type |
887 | , String name, String birthday, int gradeId, long regionId, | 600 | , String name, String birthday, int gradeId, long regionId, |
888 | Object schoolId, String qq, String gender | 601 | Object schoolId, String qq, String gender |
889 | , String regionName, String devicenumber) throws UnsupportedEncodingException { | 602 | , String regionName, String devicenumber) throws UnsupportedEncodingException { |
890 | mProgress = DialogPermission.showProgress(mContext, null, "正在保存个人信息...", | 603 | mProgress = DialogPermission.showProgress(mContext, null, "正在保存个人信息...", |
891 | false, true, null); | 604 | false, true, null); |
892 | RequestParams params = new RequestParams(); | 605 | RequestParams params = new RequestParams(); |
893 | 606 | ||
894 | params.put(HttpKey.USEID, id); | 607 | params.put(HttpKey.USEID, id); |
895 | params.put(HttpKey.TYPE, type); | 608 | params.put(HttpKey.TYPE, type); |
896 | params.put(HttpKey.NAME, name); | 609 | params.put(HttpKey.NAME, name); |
897 | params.put(HttpKey.BIRDays, birthday); | 610 | params.put(HttpKey.BIRDays, birthday); |
898 | params.put(HttpKey.GRADE, gradeId); | 611 | params.put(HttpKey.GRADE, gradeId); |
899 | params.put(HttpKey.REGION, regionId); | 612 | params.put(HttpKey.REGION, regionId); |
900 | params.put(HttpKey.SCHOOL, schoolId); | 613 | params.put(HttpKey.SCHOOL, schoolId); |
901 | params.put(HttpKey.QQ, qq); | 614 | params.put(HttpKey.QQ, qq); |
902 | params.put(HttpKey.GENDER, gender); | 615 | params.put(HttpKey.GENDER, gender); |
903 | params.put(HttpKey.REGIONNAME, regionName); | 616 | params.put(HttpKey.REGIONNAME, regionName); |
904 | params.put(HttpKey.DEVINUMBER, devicenumber); | 617 | params.put(HttpKey.DEVINUMBER, devicenumber); |
905 | Log.e("test", "个人信息" + params); | 618 | Log.e("test", "个人信息" + params); |
906 | HttpClient.getInstance().addHeader("Accept", "*/*"); | 619 | HttpClient.getInstance().addHeader("Accept", "*/*"); |
907 | HttpClient.getInstance().post(mContext, HttpUrl.changepresonalinfo, params, new JsonHttpResponseHandler() { | 620 | HttpClient.getInstance().post(mContext, HttpUrl.changepresonalinfo, params, new JsonHttpResponseHandler() { |
908 | @Override | 621 | @Override |
909 | public void onSuccess(int statusCode, Header[] headers, JSONObject response) { | 622 | public void onSuccess(int statusCode, Header[] headers, JSONObject response) { |
910 | super.onSuccess(statusCode, headers, response); | 623 | super.onSuccess(statusCode, headers, response); |
911 | closeProgress(); | 624 | closeProgress(); |
912 | String status = response.optString("status"); | 625 | String status = response.optString("status"); |
913 | if (status.equals("1")) { | 626 | if (status.equals("1")) { |
914 | Toast.makeText(mContext, "个人信息保存成功", Toast.LENGTH_LONG).show(); | 627 | Toast.makeText(mContext, "个人信息保存成功", Toast.LENGTH_LONG).show(); |
915 | ((Activity) mContext).finish(); | 628 | ((Activity) mContext).finish(); |
916 | } else { | 629 | } else { |
917 | AlertUtils.showToast(mContext, "您好,服务器异常,请稍后重试"); | 630 | AlertUtils.showToast(mContext, "您好,服务器异常,请稍后重试"); |
918 | } | 631 | } |
919 | 632 | ||
920 | } | 633 | } |
921 | 634 | ||
922 | @Override | 635 | @Override |
923 | public void onFailure(int statusCode, Header[] headers, Throwable throwable, JSONObject errorResponse) { | 636 | public void onFailure(int statusCode, Header[] headers, Throwable throwable, JSONObject errorResponse) { |
924 | super.onFailure(statusCode, headers, throwable, errorResponse); | 637 | super.onFailure(statusCode, headers, throwable, errorResponse); |
925 | closeProgress(); | 638 | closeProgress(); |
926 | Log.e("test", "onFailure" + errorResponse); | 639 | Log.e("test", "onFailure" + errorResponse); |
927 | new CircleDialog.Builder((FragmentActivity) mContext) | 640 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); |
928 | .setCanceledOnTouchOutside(false) | ||
929 | .setCancelable(false) | ||
930 | .setWidth(0.5f) | ||
931 | .configText(new ConfigText() { | ||
932 | @Override | ||
933 | public void onConfig(TextParams params) { | ||
934 | params.gravity = Gravity.CENTER; | ||
935 | params.padding = new int[]{50, 50, 50, 50}; | ||
936 | } | ||
937 | }) | ||
938 | .setText("当前无网络,请检查网络设置") | ||
939 | .setNegative("继续使用", null) | ||
940 | .setPositive("设置网络", new View.OnClickListener() { | ||
941 | @Override | ||
942 | public void onClick(View v) { | ||
943 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 | ||
944 | mContext.startActivity(intent); | ||
945 | } | ||
946 | }) | ||
947 | .show(); | ||
948 | } | 641 | } |
949 | 642 | ||
950 | }); | 643 | }); |
951 | } | 644 | } |
952 | 645 | ||
953 | //修改个性签名 | 646 | //修改个性签名 |
954 | public void changsignature(final Context mContext, long userId, int type, final String signature) { | 647 | public void changsignature(final Context mContext, long userId, int type, final String signature) { |
955 | RequestParams params = new RequestParams(); | 648 | RequestParams params = new RequestParams(); |
956 | params.put("userId", userId); | 649 | params.put("userId", userId); |
957 | params.put("type", type); | 650 | params.put("type", type); |
958 | params.put("signature", signature); | 651 | params.put("signature", signature); |
959 | HttpClient.getInstance().addHeader("Accept", "*/*"); | 652 | HttpClient.getInstance().addHeader("Accept", "*/*"); |
960 | HttpClient.getInstance().post(HttpUrl.signature, params, new AsyncHttpResponseHandler() { | 653 | HttpClient.getInstance().post(HttpUrl.signature, params, new AsyncHttpResponseHandler() { |
961 | @Override | 654 | @Override |
962 | public void onSuccess(int i, Header[] headers, byte[] bytes) { | 655 | public void onSuccess(int i, Header[] headers, byte[] bytes) { |
963 | try { | 656 | try { |
964 | JSONObject jsonObject = new JSONObject(new String(bytes)); | 657 | JSONObject jsonObject = new JSONObject(new String(bytes)); |
965 | String status = jsonObject.optString("status"); | 658 | String status = jsonObject.optString("status"); |
966 | if (status.equals("1")) { | 659 | if (status.equals("1")) { |
967 | Toast.makeText(mContext, "个性签名修改成功", Toast.LENGTH_LONG).show(); | 660 | Toast.makeText(mContext, "个性签名修改成功", Toast.LENGTH_LONG).show(); |
968 | } else { | 661 | } else { |
969 | AlertUtils.showToast(mContext, "你好,服务器异常,请稍后重试"); | 662 | AlertUtils.showToast(mContext, "你好,服务器异常,请稍后重试"); |
970 | } | 663 | } |
971 | } catch (JSONException e) { | 664 | } catch (JSONException e) { |
972 | e.printStackTrace(); | 665 | e.printStackTrace(); |
973 | } | 666 | } |
974 | } | 667 | } |
975 | 668 | ||
976 | @Override | 669 | @Override |
977 | public void onFailure(int i, Header[] headers, byte[] bytes, Throwable throwable) { | 670 | public void onFailure(int i, Header[] headers, byte[] bytes, Throwable throwable) { |
978 | Log.e("test", "onFailure" + new String(bytes)); | 671 | Log.e("test", "onFailure" + new String(bytes)); |
979 | new CircleDialog.Builder((FragmentActivity) mContext) | 672 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); |
980 | .setCanceledOnTouchOutside(false) | ||
981 | .setCancelable(false) | ||
982 | .setWidth(0.5f) | ||
983 | .configText(new ConfigText() { | ||
984 | @Override | ||
985 | public void onConfig(TextParams params) { | ||
986 | params.gravity = Gravity.CENTER; | ||
987 | params.padding = new int[]{50, 50, 50, 50}; | ||
988 | } | ||
989 | }) | ||
990 | .setText("当前无网络,请检查网络设置") | ||
991 | .setNegative("继续使用", null) | ||
992 | .setPositive("设置网络", new View.OnClickListener() { | ||
993 | @Override | ||
994 | public void onClick(View v) { | ||
995 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 | ||
996 | mContext.startActivity(intent); | ||
997 | } | ||
998 | }) | ||
999 | .show(); | ||
1000 | } | 673 | } |
1001 | }); | 674 | }); |
1002 | } | 675 | } |
1003 | 676 | ||
1004 | /** | 677 | /** |
1005 | * 获取个性签名 | 678 | * 获取个性签名 |
1006 | * | 679 | * |
1007 | * @param mContext | 680 | * @param mContext |
1008 | * @param userId | 681 | * @param userId |
1009 | * @param handler | 682 | * @param handler |
1010 | */ | 683 | */ |
1011 | public void getsignatures(final Context mContext, long userId, int type, final Handler handler) { | 684 | public void getsignatures(final Context mContext, long userId, int type, final Handler handler) { |
1012 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); | 685 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); |
1013 | HttpClient.getInstance().get(HttpUrl.getsignature + "?userId=" + userId + "&type=" + type, new AsyncHttpResponseHandler() { | 686 | HttpClient.getInstance().get(HttpUrl.getsignature + "?userId=" + userId + "&type=" + type, new AsyncHttpResponseHandler() { |
1014 | @Override | 687 | @Override |
1015 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { | 688 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { |
1016 | Log.e("test", "个性签名" + new String(arg2)); | 689 | Log.e("test", "个性签名" + new String(arg2)); |
1017 | try { | 690 | try { |
1018 | JSONObject jsonObject = new JSONObject(new String(arg2)); | 691 | JSONObject jsonObject = new JSONObject(new String(arg2)); |
1019 | int status = jsonObject.optInt("status"); | 692 | int status = jsonObject.optInt("status"); |
1020 | if (status == 1) { | 693 | if (status == 1) { |
1021 | SignInfo signInfo = GsonTool.getPerson(new String(arg2), SignInfo.class);//解析json数据 | 694 | SignInfo signInfo = GsonTool.getPerson(new String(arg2), SignInfo.class);//解析json数据 |
1022 | SignInfo.DataBean signInfoBeanList = signInfo.getData(); | 695 | SignInfo.DataBean signInfoBeanList = signInfo.getData(); |
1023 | Message message = Message.obtain(); | 696 | Message message = Message.obtain(); |
1024 | message.what = HttpCode.SIGN; | 697 | message.what = HttpCode.SIGN; |
1025 | message.obj = signInfoBeanList; | 698 | message.obj = signInfoBeanList; |
1026 | handler.sendMessage(message); | 699 | handler.sendMessage(message); |
1027 | 700 | ||
1028 | 701 | ||
1029 | } else if (status == 1000) { | 702 | } else if (status == 1000) { |
1030 | AlertUtils.showToast(mContext, "您还没有签名哦"); | 703 | AlertUtils.showToast(mContext, "您还没有签名哦"); |
1031 | 704 | ||
1032 | } else { | 705 | } else { |
1033 | AlertUtils.showToast(mContext, "你好,服务器异常,请稍后重试!"); | 706 | AlertUtils.showToast(mContext, "你好,服务器异常,请稍后重试!"); |
1034 | } | 707 | } |
1035 | } catch (JSONException e) { | 708 | } catch (JSONException e) { |
1036 | e.printStackTrace(); | 709 | e.printStackTrace(); |
1037 | } | 710 | } |
1038 | 711 | ||
1039 | 712 | ||
1040 | } | 713 | } |
1041 | 714 | ||
1042 | @Override | 715 | @Override |
1043 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { | 716 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { |
1044 | Log.e("test", "失败原因" + arg3); | 717 | Log.e("test", "失败原因" + arg3); |
1045 | AlertUtils.showToast(mContext, "你好,服务器异常,请稍后重试!"); | 718 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); |
1046 | } | 719 | } |
1047 | }); | 720 | }); |
1048 | } | 721 | } |
1049 | 722 | ||
1050 | /** | 723 | /** |
1051 | * 用户反馈 | 724 | * 用户反馈 |
1052 | * | 725 | * |
1053 | * @param mContext | 726 | * @param mContext |
1054 | * @param userId | 727 | * @param userId |
1055 | * @param content | 728 | * @param content |
1056 | * @param contact | 729 | * @param contact |
1057 | * @param imgs | 730 | * @param imgs |
1058 | * @param feedtype | 731 | * @param feedtype |
1059 | * @throws UnsupportedEncodingException | 732 | * @throws UnsupportedEncodingException |
1060 | */ | 733 | */ |
1061 | public void feedback(final Context mContext, String userId, String content, | 734 | public void feedback(final Context mContext, String userId, String content, |
1062 | String contact, String imgs, String feedtype) throws UnsupportedEncodingException { | 735 | String contact, String imgs, String feedtype) throws UnsupportedEncodingException { |
1063 | mProgress = DialogPermission.showProgress(mContext, null, "正在提交反馈内容...", | 736 | mProgress = DialogPermission.showProgress(mContext, null, "正在提交反馈内容...", |
1064 | false, true, null); | 737 | false, true, null); |
1065 | File file = new File(imgs); | 738 | File file = new File(imgs); |
1066 | if (file.exists() && file.length() > 0) { | 739 | if (file.exists() && file.length() > 0) { |
1067 | RequestParams params = new RequestParams(); | 740 | RequestParams params = new RequestParams(); |
1068 | try { | 741 | try { |
1069 | params.put("userId", userId); | 742 | params.put("userId", userId); |
1070 | params.put("content", content); | 743 | params.put("content", content); |
1071 | params.put("contact", contact); | 744 | params.put("contact", contact); |
1072 | params.put("imgs", file); | 745 | params.put("imgs", file); |
1073 | params.put("feedtype", feedtype); | 746 | params.put("feedtype", feedtype); |
1074 | } catch (FileNotFoundException e) { | 747 | } catch (FileNotFoundException e) { |
1075 | e.printStackTrace(); | 748 | e.printStackTrace(); |
1076 | } | 749 | } |
1077 | Log.e("test", "onSuccess" + params); | 750 | Log.e("test", "onSuccess" + params); |
1078 | HttpClient.getInstance().post(HttpUrl.feedbackURL, params, new AsyncHttpResponseHandler() { | 751 | HttpClient.getInstance().post(HttpUrl.feedbackURL, params, new AsyncHttpResponseHandler() { |
1079 | @Override | 752 | @Override |
1080 | public void onSuccess(int i, Header[] headers, byte[] bytes) { | 753 | public void onSuccess(int i, Header[] headers, byte[] bytes) { |
1081 | closeProgress(); | 754 | closeProgress(); |
1082 | Log.e("test", "onSuccess" + new String(bytes)); | 755 | Log.e("test", "onSuccess" + new String(bytes)); |
1083 | try { | 756 | try { |
1084 | JSONObject jsonObject = new JSONObject(new String(bytes)); | 757 | JSONObject jsonObject = new JSONObject(new String(bytes)); |
1085 | String status = jsonObject.optString("status"); | 758 | String status = jsonObject.optString("status"); |
1086 | if (status.equals("1")) { | 759 | if (status.equals("1")) { |
1087 | Toast.makeText(mContext, "您的宝贵意见已经提交成功。", Toast.LENGTH_LONG).show(); | 760 | Toast.makeText(mContext, "您的宝贵意见已经提交成功。", Toast.LENGTH_LONG).show(); |
1088 | ((Activity) mContext).finish(); | 761 | ((Activity) mContext).finish(); |
1089 | } else { | 762 | } else { |
1090 | AlertUtils.showToast(mContext, "你好,服务器异常,请稍后重试"); | 763 | AlertUtils.showToast(mContext, "你好,服务器异常,请稍后重试"); |
1091 | } | 764 | } |
1092 | } catch (JSONException e) { | 765 | } catch (JSONException e) { |
1093 | e.printStackTrace(); | 766 | e.printStackTrace(); |
1094 | } | 767 | } |
1095 | } | 768 | } |
1096 | 769 | ||
1097 | @Override | 770 | @Override |
1098 | public void onFailure(int i, Header[] headers, byte[] bytes, Throwable throwable) { | 771 | public void onFailure(int i, Header[] headers, byte[] bytes, Throwable throwable) { |
1099 | closeProgress(); | 772 | closeProgress(); |
1100 | Log.e("test", "错误信息" + new String(bytes)); | 773 | Log.e("test", "错误信息" + new String(bytes)); |
1101 | new CircleDialog.Builder((FragmentActivity) mContext) | 774 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); |
1102 | .setCanceledOnTouchOutside(false) | ||
1103 | .setCancelable(false) | ||
1104 | .setWidth(0.5f) | ||
1105 | .configText(new ConfigText() { | ||
1106 | @Override | ||
1107 | public void onConfig(TextParams params) { | ||
1108 | params.gravity = Gravity.CENTER; | ||
1109 | params.padding = new int[]{50, 50, 50, 50}; | ||
1110 | } | ||
1111 | }) | ||
1112 | .setText("当前无网络,请检查网络设置") | ||
1113 | .setNegative("继续使用", null) | ||
1114 | .setPositive("设置网络", new View.OnClickListener() { | ||
1115 | @Override | ||
1116 | public void onClick(View v) { | ||
1117 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 | ||
1118 | mContext.startActivity(intent); | ||
1119 | } | ||
1120 | }) | ||
1121 | .show(); | ||
1122 | 775 | ||
1123 | } | 776 | } |
1124 | }); | 777 | }); |
1125 | } else { | 778 | } else { |
1126 | Toast.makeText(mContext, "文件不存在", Toast.LENGTH_LONG).show(); | 779 | Toast.makeText(mContext, "文件不存在", Toast.LENGTH_LONG).show(); |
1127 | } | 780 | } |
1128 | } | 781 | } |
1129 | 782 | ||
1130 | /** | 783 | /** |
1131 | * 查询子账户信息 | 784 | * 查询子账户信息 |
1132 | * | 785 | * |
1133 | * @param mContext | 786 | * @param mContext |
1134 | * @param userId | 787 | * @param userId |
1135 | * @param handler | 788 | * @param handler |
1136 | */ | 789 | */ |
1137 | public void getchildAccountinfo(final Context mContext, long userId, String deviceNumber, final Handler handler) { | 790 | public void getchildAccountinfo(final Context mContext, long userId, String deviceNumber, final Handler handler) { |
1138 | mProgress = DialogPermission.showProgress(mContext, null, "正在获取信息...", | 791 | mProgress = DialogPermission.showProgress(mContext, null, "正在获取信息...", |
1139 | false, true, null); | 792 | false, true, null); |
1140 | 793 | ||
1141 | Log.e("test", "ID" + userId + "deviceNumber" + deviceNumber); | 794 | Log.e("test", "ID" + userId + "deviceNumber" + deviceNumber); |
1142 | HttpClient.getInstance().setTimeout(5 * 1000); | 795 | HttpClient.getInstance().setTimeout(5 * 1000); |
1143 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); | 796 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); |
1144 | HttpClient.getInstance().get(HttpUrl.childUserURL + "?userId=" + userId + "&deviceNumber=" + deviceNumber, new AsyncHttpResponseHandler() { | 797 | HttpClient.getInstance().get(HttpUrl.childUserURL + "?userId=" + userId + "&deviceNumber=" + deviceNumber, new AsyncHttpResponseHandler() { |
1145 | @Override | 798 | @Override |
1146 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { | 799 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { |
1147 | closeProgress(); | 800 | closeProgress(); |
1148 | Log.e("test", "子账户信息" + new String(arg2)); | 801 | Log.e("test", "子账户信息" + new String(arg2)); |
1149 | try { | 802 | try { |
1150 | JSONObject jsonObject = new JSONObject(new String(arg2)); | 803 | JSONObject jsonObject = new JSONObject(new String(arg2)); |
1151 | int status = jsonObject.optInt("status"); | 804 | int status = jsonObject.optInt("status"); |
1152 | if (status == 1) { | 805 | if (status == 1) { |
1153 | ChildsInfo childsInfo = GsonTool.getPerson(new String(arg2), ChildsInfo.class);//解析json数据 | 806 | ChildsInfo childsInfo = GsonTool.getPerson(new String(arg2), ChildsInfo.class);//解析json数据 |
1154 | Log.e("test", "子账户信息" + childsInfo); | 807 | Log.e("test", "子账户信息" + childsInfo); |
1155 | List<ChildsInfo.DataBean> schoolInfoBeanList = childsInfo.getData(); | 808 | List<ChildsInfo.DataBean> schoolInfoBeanList = childsInfo.getData(); |
1156 | Log.e("test", "子账户信息" + schoolInfoBeanList); | 809 | Log.e("test", "子账户信息" + schoolInfoBeanList); |
1157 | Message msg = Message.obtain(); | 810 | Message msg = Message.obtain(); |
1158 | msg.what = HttpCode.CHILDS_SUCESS; | 811 | msg.what = HttpCode.CHILDS_SUCESS; |
1159 | msg.obj = schoolInfoBeanList; | 812 | msg.obj = schoolInfoBeanList; |
1160 | handler.sendMessage(msg); | 813 | handler.sendMessage(msg); |
1161 | 814 | ||
1162 | }else { | 815 | }else { |
1163 | AlertUtils.showToast(mContext, "你好,服务器异常,请稍后再试!"); | 816 | AlertUtils.showToast(mContext, "你好,服务器异常,请稍后再试!"); |
1164 | 817 | ||
1165 | } | 818 | } |
1166 | } catch (JSONException e) { | 819 | } catch (JSONException e) { |
1167 | e.printStackTrace(); | 820 | e.printStackTrace(); |
1168 | 821 | ||
1169 | } | 822 | } |
1170 | 823 | ||
1171 | } | 824 | } |
1172 | 825 | ||
1173 | @Override | 826 | @Override |
1174 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { | 827 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { |
1175 | closeProgress(); | 828 | closeProgress(); |
1176 | // Log.e("test", "错误信息" + new String(arg2)); | 829 | // Log.e("test", "错误信息" + new String(arg2)); |
1177 | new CircleDialog.Builder((FragmentActivity) mContext) | 830 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); |
1178 | .setCanceledOnTouchOutside(false) | ||
1179 | .setCancelable(false) | ||
1180 | .setWidth(0.5f) | ||
1181 | .configText(new ConfigText() { | ||
1182 | @Override | ||
1183 | public void onConfig(TextParams params) { | ||
1184 | params.gravity = Gravity.CENTER; | ||
1185 | params.padding = new int[]{50, 50, 50, 50}; | ||
1186 | } | ||
1187 | }) | ||
1188 | .setText("当前无网络,请检查网络设置") | ||
1189 | .setNegative("继续使用", null) | ||
1190 | .setPositive("设置网络", new View.OnClickListener() { | ||
1191 | @Override | ||
1192 | public void onClick(View v) { | ||
1193 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 | ||
1194 | mContext.startActivity(intent); | ||
1195 | } | ||
1196 | }) | ||
1197 | .show(); | ||
1198 | } | 831 | } |
1199 | }); | 832 | }); |
1200 | 833 | ||
1201 | } | 834 | } |
1202 | 835 | ||
1203 | /** | 836 | /** |
1204 | * 删除子账户信息 | 837 | * 删除子账户信息 |
1205 | * | 838 | * |
1206 | * @param mContext | 839 | * @param mContext |
1207 | * @param subAccountId | 840 | * @param subAccountId |
1208 | */ | 841 | */ |
1209 | public void deletechildAccountinfo(final Context mContext, String subAccountId) { | 842 | public void deletechildAccountinfo(final Context mContext, String subAccountId) { |
1210 | mProgress = DialogPermission.showProgress(mContext, null, "正在删除子账户...", | 843 | mProgress = DialogPermission.showProgress(mContext, null, "正在删除子账户...", |
1211 | false, true, null); | 844 | false, true, null); |
1212 | HttpClient.getInstance().setTimeout(5 * 1000); | 845 | HttpClient.getInstance().setTimeout(5 * 1000); |
1213 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); | 846 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); |
1214 | HttpClient.getInstance().get(HttpUrl.deletechildUserURL + "?subAccountId=" + subAccountId, new AsyncHttpResponseHandler() { | 847 | HttpClient.getInstance().get(HttpUrl.deletechildUserURL + "?subAccountId=" + subAccountId, new AsyncHttpResponseHandler() { |
1215 | @Override | 848 | @Override |
1216 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { | 849 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { |
1217 | closeProgress(); | 850 | closeProgress(); |
1218 | Log.e("test", "子账户信息" + new String(arg2)); | 851 | Log.e("test", "子账户信息" + new String(arg2)); |
1219 | try { | 852 | try { |
1220 | JSONObject jsonObject = new JSONObject(new String(arg2)); | 853 | JSONObject jsonObject = new JSONObject(new String(arg2)); |
1221 | int status = jsonObject.optInt("status"); | 854 | int status = jsonObject.optInt("status"); |
1222 | if (status == 1) { | 855 | if (status == 1) { |
1223 | AlertUtils.showToast(mContext, "子账号删除成功!"); | 856 | AlertUtils.showToast(mContext, "子账号删除成功!"); |
1224 | ((Activity) mContext).finish(); | 857 | ((Activity) mContext).finish(); |
1225 | } else { | 858 | } else { |
1226 | AlertUtils.showToast(mContext, "你好,子账号删除失败!"); | 859 | AlertUtils.showToast(mContext, "你好,子账号删除失败!"); |
1227 | 860 | ||
1228 | } | 861 | } |
1229 | } catch (JSONException e) { | 862 | } catch (JSONException e) { |
1230 | e.printStackTrace(); | 863 | e.printStackTrace(); |
1231 | } | 864 | } |
1232 | 865 | ||
1233 | } | 866 | } |
1234 | 867 | ||
1235 | @Override | 868 | @Override |
1236 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { | 869 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { |
1237 | closeProgress(); | 870 | closeProgress(); |
1238 | Log.e("test", "错误信息" + new String(arg2)); | 871 | Log.e("test", "错误信息" + new String(arg2)); |
1239 | new CircleDialog.Builder((FragmentActivity) mContext) | 872 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); |
1240 | .setCanceledOnTouchOutside(false) | ||
1241 | .setCancelable(false) | ||
1242 | .setWidth(0.5f) | ||
1243 | .configText(new ConfigText() { | ||
1244 | @Override | ||
1245 | public void onConfig(TextParams params) { | ||
1246 | params.gravity = Gravity.CENTER; | ||
1247 | params.padding = new int[]{50, 50, 50, 50}; | ||
1248 | } | ||
1249 | }) | ||
1250 | .setText("当前无网络,请检查网络设置") | ||
1251 | .setNegative("继续使用", null) | ||
1252 | .setPositive("设置网络", new View.OnClickListener() { | ||
1253 | @Override | ||
1254 | public void onClick(View v) { | ||
1255 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 | ||
1256 | mContext.startActivity(intent); | ||
1257 | } | ||
1258 | }) | ||
1259 | .show(); | ||
1260 | } | 873 | } |
1261 | }); | 874 | }); |
1262 | 875 | ||
1263 | } | 876 | } |
1264 | 877 | ||
1265 | /** | 878 | /** |
1266 | * 添加子账户信息 | 879 | * 添加子账户信息 |
1267 | */ | 880 | */ |
1268 | public void addchildAccountinfo(final Context mContext, long parentId, String image, | 881 | public void addchildAccountinfo(final Context mContext, long parentId, String image, |
1269 | String name, Long grade, Object school, Long region | 882 | String name, Long grade, Object school, Long region |
1270 | , String deviceNumber, String regionName) { | 883 | , String deviceNumber, String regionName) { |
1271 | mProgress = DialogPermission.showProgress(mContext, null, "正在添加子账户...", | 884 | mProgress = DialogPermission.showProgress(mContext, null, "正在添加子账户...", |
1272 | false, true, null); | 885 | false, true, null); |
1273 | RequestParams params = new RequestParams(); | 886 | RequestParams params = new RequestParams(); |
1274 | 887 | ||
1275 | params.put(HttpKey.PARENTID, parentId); | 888 | params.put(HttpKey.PARENTID, parentId); |
1276 | params.put(HttpKey.IMAGE, image); | 889 | params.put(HttpKey.IMAGE, image); |
1277 | params.put(HttpKey.NAME, name); | 890 | params.put(HttpKey.NAME, name); |
1278 | params.put(HttpKey.GRADE, grade); | 891 | params.put(HttpKey.GRADE, grade); |
1279 | params.put(HttpKey.SCHOOL, school); | 892 | params.put(HttpKey.SCHOOL, school); |
1280 | params.put(HttpKey.REGION, region); | 893 | params.put(HttpKey.REGION, region); |
1281 | params.put(HttpKey.DEVINUMBER, deviceNumber); | 894 | params.put(HttpKey.DEVINUMBER, deviceNumber); |
1282 | params.put(HttpKey.REGIONNAME, regionName); | 895 | params.put(HttpKey.REGIONNAME, regionName); |
1283 | 896 | ||
1284 | Log.e("test", "子账户信息" + params); | 897 | Log.e("test", "子账户信息" + params); |
1285 | HttpClient.getInstance().addHeader("Accept", "*/*"); | 898 | HttpClient.getInstance().addHeader("Accept", "*/*"); |
1286 | HttpClient.getInstance().setTimeout(5 * 1000); | 899 | HttpClient.getInstance().setTimeout(5 * 1000); |
1287 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); | 900 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); |
1288 | HttpClient.getInstance().post(HttpUrl.addchildUserURL, params, new AsyncHttpResponseHandler() { | 901 | HttpClient.getInstance().post(HttpUrl.addchildUserURL, params, new AsyncHttpResponseHandler() { |
1289 | @Override | 902 | @Override |
1290 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { | 903 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { |
1291 | closeProgress(); | 904 | closeProgress(); |
1292 | 905 | ||
1293 | Log.e("test", "子账户信息" + new String(arg2)); | 906 | Log.e("test", "子账户信息" + new String(arg2)); |
1294 | try { | 907 | try { |
1295 | JSONObject jsonObject = new JSONObject(new String(arg2)); | 908 | JSONObject jsonObject = new JSONObject(new String(arg2)); |
1296 | int status = jsonObject.optInt("status"); | 909 | int status = jsonObject.optInt("status"); |
1297 | if (status == 1) { | 910 | if (status == 1) { |
1298 | AlertUtils.showToast(mContext, "子账号添加成功!"); | 911 | AlertUtils.showToast(mContext, "子账号添加成功!"); |
1299 | ((Activity) mContext).finish(); | 912 | ((Activity) mContext).finish(); |
1300 | } else { | 913 | } else { |
1301 | AlertUtils.showToast(mContext, "你好,子账号添加失败!"); | 914 | AlertUtils.showToast(mContext, "你好,子账号添加失败!"); |
1302 | 915 | ||
1303 | } | 916 | } |
1304 | } catch (JSONException e) { | 917 | } catch (JSONException e) { |
1305 | e.printStackTrace(); | 918 | e.printStackTrace(); |
1306 | } | 919 | } |
1307 | 920 | ||
1308 | } | 921 | } |
1309 | 922 | ||
1310 | @Override | 923 | @Override |
1311 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { | 924 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { |
1312 | closeProgress(); | 925 | closeProgress(); |
1313 | Log.e("test", "错误信息" + new String(arg2)); | 926 | Log.e("test", "错误信息" + new String(arg2)); |
1314 | new CircleDialog.Builder((FragmentActivity) mContext) | 927 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); |
1315 | .setCanceledOnTouchOutside(false) | ||
1316 | .setCancelable(false) | ||
1317 | .setWidth(0.5f) | ||
1318 | .configText(new ConfigText() { | ||
1319 | @Override | ||
1320 | public void onConfig(TextParams params) { | ||
1321 | params.gravity = Gravity.CENTER; | ||
1322 | params.padding = new int[]{50, 50, 50, 50}; | ||
1323 | } | ||
1324 | }) | ||
1325 | .setText("当前无网络,请检查网络设置") | ||
1326 | .setNegative("继续使用", null) | ||
1327 | .setPositive("设置网络", new View.OnClickListener() { | ||
1328 | @Override | ||
1329 | public void onClick(View v) { | ||
1330 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 | ||
1331 | mContext.startActivity(intent); | ||
1332 | } | ||
1333 | }) | ||
1334 | .show(); | ||
1335 | } | 928 | } |
1336 | }); | 929 | }); |
1337 | 930 | ||
1338 | } | 931 | } |
1339 | 932 | ||
1340 | /** | 933 | /** |
1341 | * 切换子账户信息 | 934 | * 切换子账户信息 |
1342 | * | 935 | * |
1343 | * @param mContext | 936 | * @param mContext |
1344 | * @param subAccountId | 937 | * @param subAccountId |
1345 | */ | 938 | */ |
1346 | public void changechildAccountinfo(final Context mContext, String subAccountId, long userId | 939 | public void changechildAccountinfo(final Context mContext, String subAccountId, long userId |
1347 | , String deviceNumber, int type) { | 940 | , String deviceNumber, int type) { |
1348 | mProgress = DialogPermission.showProgress(mContext, null, "正在切换子账户...", | 941 | mProgress = DialogPermission.showProgress(mContext, null, "正在切换子账户...", |
1349 | false, true, null); | 942 | false, true, null); |
1350 | HttpClient.getInstance().setTimeout(5 * 1000); | 943 | HttpClient.getInstance().setTimeout(5 * 1000); |
1351 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); | 944 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); |
1352 | HttpClient.getInstance().get(HttpUrl.changechildUserURL + "?subAccountId=" + subAccountId + "&userId=" + userId | 945 | HttpClient.getInstance().get(HttpUrl.changechildUserURL + "?subAccountId=" + subAccountId + "&userId=" + userId |
1353 | + "&deviceNumber=" + deviceNumber + "&type=" + type, new AsyncHttpResponseHandler() { | 946 | + "&deviceNumber=" + deviceNumber + "&type=" + type, new AsyncHttpResponseHandler() { |
1354 | @Override | 947 | @Override |
1355 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { | 948 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { |
1356 | closeProgress(); | 949 | closeProgress(); |
1357 | Log.e("test", "子账户信息" + new String(arg2)); | 950 | Log.e("test", "子账户信息" + new String(arg2)); |
1358 | try { | 951 | try { |
1359 | JSONObject jsonObject = new JSONObject(new String(arg2)); | 952 | JSONObject jsonObject = new JSONObject(new String(arg2)); |
1360 | int status = jsonObject.optInt("status"); | 953 | int status = jsonObject.optInt("status"); |
1361 | if (status == 1) { | 954 | if (status == 1) { |
1362 | AlertUtils.showToast(mContext, "子账号切换成功!"); | 955 | AlertUtils.showToast(mContext, "子账号切换成功!"); |
1363 | ((Activity) mContext).finish(); | 956 | ((Activity) mContext).finish(); |
1364 | 957 | ||
1365 | } else { | 958 | } else { |
1366 | AlertUtils.showToast(mContext, "你好,子账号切换失败!"); | 959 | AlertUtils.showToast(mContext, "你好,子账号切换失败!"); |
1367 | 960 | ||
1368 | } | 961 | } |
1369 | } catch (JSONException e) { | 962 | } catch (JSONException e) { |
1370 | e.printStackTrace(); | 963 | e.printStackTrace(); |
1371 | } | 964 | } |
1372 | 965 | ||
1373 | } | 966 | } |
1374 | 967 | ||
1375 | @Override | 968 | @Override |
1376 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { | 969 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { |
1377 | closeProgress(); | 970 | closeProgress(); |
1378 | Log.e("test", "错误信息" + new String(arg2)); | 971 | Log.e("test", "错误信息" + new String(arg2)); |
1379 | new CircleDialog.Builder((FragmentActivity) mContext) | 972 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); |
1380 | .setCanceledOnTouchOutside(false) | ||
1381 | .setCancelable(false) | ||
1382 | .setWidth(0.5f) | ||
1383 | .configText(new ConfigText() { | ||
1384 | @Override | ||
1385 | public void onConfig(TextParams params) { | ||
1386 | params.gravity = Gravity.CENTER; | ||
1387 | params.padding = new int[]{50, 50, 50, 50}; | ||
1388 | } | ||
1389 | }) | ||
1390 | .setText("当前无网络,请检查网络设置") | ||
1391 | .setNegative("继续使用", null) | ||
1392 | .setPositive("设置网络", new View.OnClickListener() { | ||
1393 | @Override | ||
1394 | public void onClick(View v) { | ||
1395 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 | ||
1396 | mContext.startActivity(intent); | ||
1397 | } | ||
1398 | }) | ||
1399 | .show(); | ||
1400 | } | 973 | } |
1401 | }); | 974 | }); |
1402 | 975 | ||
1403 | } | 976 | } |
1404 | 977 | ||
1405 | /** | 978 | /** |
1406 | * 切换主账户信息 | 979 | * 切换主账户信息 |
1407 | * | 980 | * |
1408 | * @param mContext | 981 | * @param mContext |
1409 | * @param type | 982 | * @param type |
1410 | */ | 983 | */ |
1411 | public void Accountinfo(final Context mContext, long userId | 984 | public void Accountinfo(final Context mContext, long userId |
1412 | , String deviceNumber, int type) { | 985 | , String deviceNumber, int type) { |
1413 | mProgress = DialogPermission.showProgress(mContext, null, "正在切换主账户...", | 986 | mProgress = DialogPermission.showProgress(mContext, null, "正在切换主账户...", |
1414 | false, true, null); | 987 | false, true, null); |
1415 | HttpClient.getInstance().setTimeout(5 * 1000); | 988 | HttpClient.getInstance().setTimeout(5 * 1000); |
1416 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); | 989 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); |
1417 | HttpClient.getInstance().get(HttpUrl.changechildUserURL + "?userId=" + userId + "&deviceNumber=" + deviceNumber | 990 | HttpClient.getInstance().get(HttpUrl.changechildUserURL + "?userId=" + userId + "&deviceNumber=" + deviceNumber |
1418 | + "&type=" + type, new AsyncHttpResponseHandler() { | 991 | + "&type=" + type, new AsyncHttpResponseHandler() { |
1419 | @Override | 992 | @Override |
1420 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { | 993 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { |
1421 | closeProgress(); | 994 | closeProgress(); |
1422 | Log.e("test", "子账户信息" + new String(arg2)); | 995 | Log.e("test", "子账户信息" + new String(arg2)); |
1423 | try { | 996 | try { |
1424 | JSONObject jsonObject = new JSONObject(new String(arg2)); | 997 | JSONObject jsonObject = new JSONObject(new String(arg2)); |
1425 | int status = jsonObject.optInt("status"); | 998 | int status = jsonObject.optInt("status"); |
1426 | if (status == 1) { | 999 | if (status == 1) { |
1427 | AlertUtils.showToast(mContext, "主账号切换成功!"); | 1000 | AlertUtils.showToast(mContext, "主账号切换成功!"); |
1428 | ((Activity) mContext).finish(); | 1001 | ((Activity) mContext).finish(); |
1429 | 1002 | ||
1430 | } else { | 1003 | } else { |
1431 | AlertUtils.showToast(mContext, "你好,主账号切换失败!"); | 1004 | AlertUtils.showToast(mContext, "你好,主账号切换失败!"); |
1432 | 1005 | ||
1433 | } | 1006 | } |
1434 | } catch (JSONException e) { | 1007 | } catch (JSONException e) { |
1435 | e.printStackTrace(); | 1008 | e.printStackTrace(); |
1436 | } | 1009 | } |
1437 | 1010 | ||
1438 | } | 1011 | } |
1439 | 1012 | ||
1440 | @Override | 1013 | @Override |
1441 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { | 1014 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { |
1442 | closeProgress(); | 1015 | closeProgress(); |
1443 | Log.e("test", "错误信息" + new String(arg2)); | 1016 | Log.e("test", "错误信息" + new String(arg2)); |
1444 | new CircleDialog.Builder((FragmentActivity) mContext) | 1017 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); |
1445 | .setCanceledOnTouchOutside(false) | ||
1446 | .setCancelable(false) | ||
1447 | .setWidth(0.5f) | ||
1448 | .configText(new ConfigText() { | ||
1449 | @Override | ||
1450 | public void onConfig(TextParams params) { | ||
1451 | params.gravity = Gravity.CENTER; | ||
1452 | params.padding = new int[]{50, 50, 50, 50}; | ||
1453 | } | ||
1454 | }) | ||
1455 | .setText("当前无网络,请检查网络设置") | ||
1456 | .setNegative("继续使用", null) | ||
1457 | .setPositive("设置网络", new View.OnClickListener() { | ||
1458 | @Override | ||
1459 | public void onClick(View v) { | ||
1460 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 | ||
1461 | mContext.startActivity(intent); | ||
1462 | } | ||
1463 | }) | ||
1464 | .show(); | ||
1465 | } | 1018 | } |
1466 | }); | 1019 | }); |
1467 | 1020 | ||
1468 | } | 1021 | } |
1469 | 1022 | ||
1470 | /** | 1023 | /** |
1471 | * 头像拍张 | 1024 | * 头像拍张 |
1472 | * | 1025 | * |
1473 | * @param mContext | 1026 | * @param mContext |
1474 | * @param userId | 1027 | * @param userId |
1475 | * @param img | 1028 | * @param img |
1476 | * @throws UnsupportedEncodingException | 1029 | * @throws UnsupportedEncodingException |
1477 | */ | 1030 | */ |
1478 | public void header(final Context mContext, String userId, String type, String img) throws UnsupportedEncodingException { | 1031 | public void header(final Context mContext, String userId, String type, String img) throws UnsupportedEncodingException { |
1479 | File file = new File(img); | 1032 | File file = new File(img); |
1480 | if (file.exists() && file.length() > 0) { | 1033 | if (file.exists() && file.length() > 0) { |
1481 | RequestParams params = new RequestParams(); | 1034 | RequestParams params = new RequestParams(); |
1482 | try { | 1035 | try { |
1483 | params.put("userId", userId); | 1036 | params.put("userId", userId); |
1484 | params.put("type", type); | 1037 | params.put("type", type); |
1485 | params.put("img", file); | 1038 | params.put("img", file); |
1486 | } catch (FileNotFoundException e) { | 1039 | } catch (FileNotFoundException e) { |
1487 | e.printStackTrace(); | 1040 | e.printStackTrace(); |
1488 | } | 1041 | } |
1489 | Log.e("test", "params" + params); | 1042 | Log.e("test", "params" + params); |
1490 | HttpClient.getInstance().setTimeout(5 * 1000); | 1043 | HttpClient.getInstance().setTimeout(5 * 1000); |
1491 | HttpClient.getInstance().post(HttpUrl.headerURL, params, new AsyncHttpResponseHandler() { | 1044 | HttpClient.getInstance().post(HttpUrl.headerURL, params, new AsyncHttpResponseHandler() { |
1492 | @Override | 1045 | @Override |
1493 | public void onSuccess(int i, Header[] headers, byte[] bytes) { | 1046 | public void onSuccess(int i, Header[] headers, byte[] bytes) { |
1494 | Log.e("test", "onSuccess" + new String(bytes)); | 1047 | Log.e("test", "onSuccess" + new String(bytes)); |
1495 | try { | 1048 | try { |
1496 | JSONObject jsonObject = new JSONObject(new String(bytes)); | 1049 | JSONObject jsonObject = new JSONObject(new String(bytes)); |
1497 | String status = jsonObject.optString("status"); | 1050 | String status = jsonObject.optString("status"); |
1498 | JSONObject jsonObject1 =jsonObject.getJSONObject("data"); | 1051 | JSONObject jsonObject1 =jsonObject.getJSONObject("data"); |
1499 | String imagUrl = jsonObject1.optString("imgUrl"); | 1052 | String imagUrl = jsonObject1.optString("imgUrl"); |
1500 | SaveParam.getInstance().saveLoginParam(mContext,SaveParam.HEADURL,imagUrl); | 1053 | SaveParam.getInstance().saveLoginParam(mContext,SaveParam.HEADURL,imagUrl); |
1501 | if (status.equals("1")) { | 1054 | if (status.equals("1")) { |
1502 | Toast.makeText(mContext, "头像上传成功。", Toast.LENGTH_LONG).show(); | 1055 | Toast.makeText(mContext, "头像上传成功。", Toast.LENGTH_LONG).show(); |
1503 | } else { | 1056 | } else { |
1504 | AlertUtils.showToast(mContext, "你好,服务器异常,请稍后重试"); | 1057 | AlertUtils.showToast(mContext, "你好,服务器异常,请稍后重试"); |
1505 | } | 1058 | } |
1506 | } catch (JSONException e) { | 1059 | } catch (JSONException e) { |
1507 | e.printStackTrace(); | 1060 | e.printStackTrace(); |
1508 | } | 1061 | } |
1509 | } | 1062 | } |
1510 | 1063 | ||
1511 | @Override | 1064 | @Override |
1512 | public void onFailure(int i, Header[] headers, byte[] bytes, Throwable throwable) { | 1065 | public void onFailure(int i, Header[] headers, byte[] bytes, Throwable throwable) { |
1513 | closeProgress(); | 1066 | closeProgress(); |
1514 | Log.e("test", "错误信息" + new String(bytes)); | 1067 | Log.e("test", "错误信息" + new String(bytes)); |
1515 | new CircleDialog.Builder((FragmentActivity) mContext) | 1068 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); |
1516 | .setCanceledOnTouchOutside(false) | ||
1517 | .setCancelable(false) | ||
1518 | .setWidth(0.5f) | ||
1519 | .configText(new ConfigText() { | ||
1520 | @Override | ||
1521 | public void onConfig(TextParams params) { | ||
1522 | params.gravity = Gravity.CENTER; | ||
1523 | params.padding = new int[]{50, 50, 50, 50}; | ||
1524 | } | ||
1525 | }) | ||
1526 | .setText("当前无网络,请检查网络设置") | ||
1527 | .setNegative("继续使用", null) | ||
1528 | .setPositive("设置网络", new View.OnClickListener() { | ||
1529 | @Override | ||
1530 | public void onClick(View v) { | ||
1531 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 | ||
1532 | mContext.startActivity(intent); | ||
1533 | } | ||
1534 | }) | ||
1535 | .show(); | ||
1536 | 1069 | ||
1537 | } | 1070 | } |
1538 | }); | 1071 | }); |
1539 | } else { | 1072 | } else { |
1540 | Toast.makeText(mContext, "文件不存在", Toast.LENGTH_LONG).show(); | 1073 | Toast.makeText(mContext, "文件不存在", Toast.LENGTH_LONG).show(); |
1541 | } | 1074 | } |
1542 | } | 1075 | } |
1543 | /** | 1076 | /** |
1544 | * 头像默认 | 1077 | * 头像默认 |
1545 | * | 1078 | * |
1546 | * @param mContext | 1079 | * @param mContext |
1547 | * @param userId | 1080 | * @param userId |
1548 | * @param | 1081 | * @param |
1549 | * @throws UnsupportedEncodingException | 1082 | * @throws UnsupportedEncodingException |
1550 | */ | 1083 | */ |
1551 | public void headerdeft(final Context mContext, String userId, String type,String defaultImg) throws UnsupportedEncodingException { | 1084 | public void headerdeft(final Context mContext, String userId, String type,String defaultImg) throws UnsupportedEncodingException { |
1552 | RequestParams params = new RequestParams(); | 1085 | RequestParams params = new RequestParams(); |
1553 | params.put("userId", userId); | 1086 | params.put("userId", userId); |
1554 | params.put("type", type); | 1087 | params.put("type", type); |
1555 | params.put("defaultImg", defaultImg); | 1088 | params.put("defaultImg", defaultImg); |
1556 | Log.e("test", "params" + params); | 1089 | Log.e("test", "params" + params); |
1557 | HttpClient.getInstance().setTimeout(5 * 1000); | 1090 | HttpClient.getInstance().setTimeout(5 * 1000); |
1558 | HttpClient.getInstance().post(HttpUrl.headerdefaultURL, params, new AsyncHttpResponseHandler() { | 1091 | HttpClient.getInstance().post(HttpUrl.headerdefaultURL, params, new AsyncHttpResponseHandler() { |
1559 | @Override | 1092 | @Override |
1560 | public void onSuccess(int i, Header[] headers, byte[] bytes) { | 1093 | public void onSuccess(int i, Header[] headers, byte[] bytes) { |
1561 | Log.e("test", "onSuccess" + new String(bytes)); | 1094 | Log.e("test", "onSuccess" + new String(bytes)); |
1562 | try { | 1095 | try { |
1563 | JSONObject jsonObject = new JSONObject(new String(bytes)); | 1096 | JSONObject jsonObject = new JSONObject(new String(bytes)); |
1564 | String status = jsonObject.optString("status"); | 1097 | String status = jsonObject.optString("status"); |
1565 | JSONObject jsonObject1 =jsonObject.getJSONObject("data"); | 1098 | JSONObject jsonObject1 =jsonObject.getJSONObject("data"); |
1566 | String imagUrl = jsonObject1.optString("imgUrl"); | 1099 | String imagUrl = jsonObject1.optString("imgUrl"); |
1567 | SaveParam.getInstance().saveLoginParam(mContext,SaveParam.HEADURL,imagUrl); | 1100 | SaveParam.getInstance().saveLoginParam(mContext,SaveParam.HEADURL,imagUrl); |
1568 | if (status.equals("1")) { | 1101 | if (status.equals("1")) { |
1569 | Toast.makeText(mContext, "头像上传成功。", Toast.LENGTH_LONG).show(); | 1102 | Toast.makeText(mContext, "头像上传成功。", Toast.LENGTH_LONG).show(); |
1570 | } else { | 1103 | } else { |
1571 | AlertUtils.showToast(mContext, "你好,服务器异常,请稍后重试"); | 1104 | AlertUtils.showToast(mContext, "你好,服务器异常,请稍后重试"); |
1572 | } | 1105 | } |
1573 | } catch (JSONException e) { | 1106 | } catch (JSONException e) { |
1574 | e.printStackTrace(); | 1107 | e.printStackTrace(); |
1575 | } | 1108 | } |
1576 | } | 1109 | } |
1577 | 1110 | ||
1578 | @Override | 1111 | @Override |
1579 | public void onFailure(int i, Header[] headers, byte[] bytes, Throwable throwable) { | 1112 | public void onFailure(int i, Header[] headers, byte[] bytes, Throwable throwable) { |
1580 | closeProgress(); | 1113 | closeProgress(); |
1581 | Log.e("test", "错误信息" + new String(bytes)); | 1114 | Log.e("test", "错误信息" + new String(bytes)); |
1582 | new CircleDialog.Builder((FragmentActivity) mContext) | 1115 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); |
1583 | .setCanceledOnTouchOutside(false) | ||
1584 | .setCancelable(false) | ||
1585 | .setWidth(0.5f) | ||
1586 | .configText(new ConfigText() { | ||
1587 | @Override | ||
1588 | public void onConfig(TextParams params) { | ||
1589 | params.gravity = Gravity.CENTER; | ||
1590 | params.padding = new int[]{50, 50, 50, 50}; | ||
1591 | } | ||
1592 | }) | ||
1593 | .setText("当前无网络,请检查网络设置") | ||
1594 | .setNegative("继续使用", null) | ||
1595 | .setPositive("设置网络", new View.OnClickListener() { | ||
1596 | @Override | ||
1597 | public void onClick(View v) { | ||
1598 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 | ||
1599 | mContext.startActivity(intent); | ||
1600 | } | ||
1601 | }) | ||
1602 | .show(); | ||
1603 | 1116 | ||
1604 | } | 1117 | } |
1605 | }); | 1118 | }); |
1606 | } | 1119 | } |
1607 | 1120 | ||
1121 | /** | ||
1122 | * 检查注册信息是否完整 | ||
1123 | * @param mContext | ||
1124 | * @param userId | ||
1125 | */ | ||
1126 | public void registerinfocheck(final Context mContext, long userId, final Handler handler) { | ||
1127 | mProgress = DialogPermission.showProgress(mContext, null, "正在检查注册信息是否完整...", | ||
1128 | false, true, null); | ||
1129 | HttpClient.getInstance().setTimeout(5 * 1000); | ||
1130 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); | ||
1131 | HttpClient.getInstance().get(HttpUrl.isRegisterInfoCompleteURL + "?userId=" + userId , new AsyncHttpResponseHandler() { | ||
1132 | @Override | ||
1133 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { | ||
1134 | closeProgress(); | ||
1135 | Log.e("test", "注册信息" + new String(arg2)); | ||
1136 | Message msg = Message.obtain(); | ||
1137 | msg.what = HttpCode.REGISTER_SUCESS; | ||
1138 | msg.obj = new String(arg2); | ||
1139 | handler.sendMessage(msg); | ||
1140 | |||
1141 | } | ||
1142 | |||
1143 | @Override | ||
1144 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { | ||
1145 | closeProgress(); | ||
1146 | Log.e("test", "错误信息" + new String(arg2)); | ||
1147 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); | ||
1148 | |||
1149 | } | ||
1150 | }); | ||
1151 | |||
1152 | } | ||
1608 | 1153 | ||
1609 | /** | 1154 | /** |
1610 | * 系统升级 | 1155 | * 系统升级 |
1611 | * | 1156 | * |
1612 | * @param mContext | 1157 | * @param mContext |
1613 | * @param pid appName | 1158 | * @param pid appName |
1614 | */ | 1159 | */ |
1615 | public void updateAPP(final Context mContext, String pid, String appName, final Handler handler) { | 1160 | public void updateAPP(final Context mContext, String pid, String appName, final Handler handler) { |
1616 | mProgress = DialogPermission.showProgress(mContext, null, "正在切换子账户...", | 1161 | mProgress = DialogPermission.showProgress(mContext, null, "正在检测是否版本信息...", |
1617 | false, true, null); | 1162 | false, true, null); |
1618 | HttpClient.getInstance().setTimeout(5 * 1000); | 1163 | HttpClient.getInstance().setTimeout(5 * 1000); |
1619 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); | 1164 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); |
1620 | HttpClient.getInstance().get(HttpUrl.updateappURL + "?pid=" + pid + "&appName=" + appName, new AsyncHttpResponseHandler() { | 1165 | HttpClient.getInstance().get(HttpUrl.updateappURL + "?pid=" + pid + "&appName=" + appName, new AsyncHttpResponseHandler() { |
1621 | @Override | 1166 | @Override |
1622 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { | 1167 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { |
1623 | closeProgress(); | 1168 | closeProgress(); |
1624 | Log.e("test", "版本升级信息" + new String(arg2)); | 1169 | Log.e("test", "版本升级信息" + new String(arg2)); |
1625 | AppVersion appVersion = GsonTool.getPerson(new String(arg2), AppVersion.class);//解析json数据 | 1170 | AppVersion appVersion = GsonTool.getPerson(new String(arg2), AppVersion.class);//解析json数据 |
1626 | Message msg = Message.obtain(); | 1171 | Message msg = Message.obtain(); |
1627 | msg.what = HttpCode.APPUPDATE_SUCESS; | 1172 | msg.what = HttpCode.APPUPDATE_SUCESS; |
1628 | msg.obj = appVersion; | 1173 | msg.obj = appVersion; |
1629 | handler.sendMessage(msg); | 1174 | handler.sendMessage(msg); |
1630 | 1175 | ||
1631 | 1176 | ||
1632 | } | 1177 | } |
1633 | 1178 | ||
1634 | @Override | 1179 | @Override |
1635 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { | 1180 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { |
1636 | closeProgress(); | 1181 | closeProgress(); |
1637 | Log.e("test", "错误信息" + new String(arg2)); | 1182 | Log.e("test", "错误信息" + new String(arg2)); |
1638 | new CircleDialog.Builder((FragmentActivity) mContext) | ||
1639 | .setCanceledOnTouchOutside(false) | ||
1640 | .setCancelable(false) | ||
1641 | .setWidth(0.5f) | ||
1642 | .configText(new ConfigText() { | ||
1643 | @Override | ||
1644 | public void onConfig(TextParams params) { | ||
1645 | params.gravity = Gravity.CENTER; | ||
1646 | params.padding = new int[]{50, 50, 50, 50}; | ||
1647 | } | ||
1648 | }) | ||
1649 | .setText("当前无网络,请检查网络设置") | ||
1650 | .setNegative("继续使用", null) | ||
1651 | .setPositive("设置网络", new View.OnClickListener() { | ||
1652 | @Override | ||
1653 | public void onClick(View v) { | ||
1654 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 | ||
1655 | mContext.startActivity(intent); | ||
1656 | } | ||
1657 | }) | ||
1658 | .show(); | ||
1659 | } | 1183 | } |
1660 | }); | 1184 | }); |
1661 | 1185 | ||
1662 | } | 1186 | } |
1663 | //版本信息 | 1187 | //版本信息 |
1664 | public void versioninfo(final Context mContext,String subjectName, final Handler handler) { | 1188 | public void versioninfo(final Context mContext,String subjectName, final Handler handler) { |
1665 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); | 1189 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); |
1666 | HttpClient.getInstance().get(HttpUrl.getversionURL+"?subjectName="+subjectName, new AsyncHttpResponseHandler() { | 1190 | HttpClient.getInstance().get(HttpUrl.getversionURL+"?subjectName="+subjectName, new AsyncHttpResponseHandler() { |
1667 | @Override | 1191 | @Override |
1668 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { | 1192 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { |
1669 | Log.e("test", "版本信息" + new String(arg2)); | 1193 | Log.e("test", "版本信息" + new String(arg2)); |
1670 | try { | 1194 | try { |
1671 | JSONObject jsonObject = new JSONObject(new String(arg2)); | 1195 | JSONObject jsonObject = new JSONObject(new String(arg2)); |
1672 | int status = jsonObject.optInt("status"); | 1196 | int status = jsonObject.optInt("status"); |
1673 | if (status == 1) { | 1197 | if (status == 1) { |
1674 | VersionInfo versionInfo = GsonTool.getPerson(new String(arg2), VersionInfo.class);//解析json数据 | 1198 | VersionInfo versionInfo = GsonTool.getPerson(new String(arg2), VersionInfo.class);//解析json数据 |
1675 | List<VersionInfo.DataBean> versionInfoList = versionInfo.getData(); | 1199 | List<VersionInfo.DataBean> versionInfoList = versionInfo.getData(); |
1676 | Message message = Message.obtain(); | 1200 | Message message = Message.obtain(); |
1677 | message.what = HttpCode.VERSION_SUCESS; | 1201 | message.what = HttpCode.VERSION_SUCESS; |
1678 | message.obj = versionInfoList; | 1202 | message.obj = versionInfoList; |
1679 | handler.sendMessage(message); | 1203 | handler.sendMessage(message); |
1680 | 1204 | ||
1681 | } else if(status == 1000){ | 1205 | } else if(status == 1000){ |
1682 | AlertUtils.showToast(mContext, "你好,该科目没有版本信息"); | 1206 | AlertUtils.showToast(mContext, "你好,该科目没有版本信息"); |
1683 | 1207 | ||
1684 | }else { | 1208 | }else { |
1685 | AlertUtils.showToast(mContext, "你好,服务器异常,请稍后重试!"); | 1209 | AlertUtils.showToast(mContext, "你好,服务器异常,请稍后重试!"); |
1686 | } | 1210 | } |
1687 | } catch (JSONException e) { | 1211 | } catch (JSONException e) { |
1688 | e.printStackTrace(); | 1212 | e.printStackTrace(); |
1689 | } | 1213 | } |
1690 | 1214 | ||
1691 | 1215 | ||
1692 | } | 1216 | } |
1693 | 1217 | ||
1694 | @Override | 1218 | @Override |
1695 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { | 1219 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { |
1696 | new CircleDialog.Builder((FragmentActivity) mContext) | 1220 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); |
1697 | .setCanceledOnTouchOutside(false) | ||
1698 | .setCancelable(false) | ||
1699 | .setWidth(0.5f) | ||
1700 | .configText(new ConfigText() { | ||
1701 | @Override | ||
1702 | public void onConfig(TextParams params) { | ||
1703 | params.gravity = Gravity.CENTER; | ||
1704 | params.padding = new int[]{50, 50, 50, 50}; | ||
1705 | } | ||
1706 | }) | ||
1707 | .setText("当前无网络,请检查网络设置") | ||
1708 | .setNegative("继续使用", null) | ||
1709 | .setPositive("设置网络", new View.OnClickListener() { | ||
1710 | @Override | ||
1711 | public void onClick(View v) { | ||
1712 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 | ||
1713 | mContext.startActivity(intent); | ||
1714 | } | ||
1715 | }) | ||
1716 | .show(); | ||
1717 | } | 1221 | } |
1718 | }); | 1222 | }); |
1719 | } | 1223 | } |
1720 | 1224 | ||
1721 | 1225 | ||
1722 | ///省级接口 | 1226 | ///省级接口 |
1723 | public void provices(final Context mContext, final Handler handler) { | 1227 | public void provices(final Context mContext, final Handler handler) { |
1724 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); | 1228 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); |
1725 | HttpClient.getInstance().get(HttpUrl.provinceUrl, new AsyncHttpResponseHandler() { | 1229 | HttpClient.getInstance().get(HttpUrl.provinceUrl, new AsyncHttpResponseHandler() { |
1726 | @Override | 1230 | @Override |
1727 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { | 1231 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { |
1728 | Log.e("test", "省" + new String(arg2)); | 1232 | Log.e("test", "省" + new String(arg2)); |
1729 | try { | 1233 | try { |
1730 | JSONObject jsonObject = new JSONObject(new String(arg2)); | 1234 | JSONObject jsonObject = new JSONObject(new String(arg2)); |
1731 | int status = jsonObject.optInt("status"); | 1235 | int status = jsonObject.optInt("status"); |
1732 | if (status == 100) { | 1236 | if (status == 100) { |
1733 | ProvinceInfo provinceInfo = GsonTool.getPerson(new String(arg2), ProvinceInfo.class);//解析json数据 | 1237 | ProvinceInfo provinceInfo = GsonTool.getPerson(new String(arg2), ProvinceInfo.class);//解析json数据 |
1734 | Log.e("test", "状态码" + provinceInfo.getStatus()); | 1238 | Log.e("test", "状态码" + provinceInfo.getStatus()); |
1735 | List<ProvinceInfo.ProvincesBean> provincesBeanList = provinceInfo.getProvinces(); | 1239 | List<ProvinceInfo.ProvincesBean> provincesBeanList = provinceInfo.getProvinces(); |
1736 | Message message = Message.obtain(); | 1240 | Message message = Message.obtain(); |
1737 | message.what = HttpCode.PROVICES; | 1241 | message.what = HttpCode.PROVICES; |
1738 | message.obj = provincesBeanList; | 1242 | message.obj = provincesBeanList; |
1739 | handler.sendMessage(message); | 1243 | handler.sendMessage(message); |
1740 | 1244 | ||
1741 | 1245 | ||
1742 | } else { | 1246 | } else { |
1743 | AlertUtils.showToast(mContext, "你好,服务器异常,请稍后重试!"); | 1247 | AlertUtils.showToast(mContext, "你好,服务器异常,请稍后重试!"); |
1744 | 1248 | ||
1745 | } | 1249 | } |
1746 | } catch (JSONException e) { | 1250 | } catch (JSONException e) { |
1747 | e.printStackTrace(); | 1251 | e.printStackTrace(); |
1748 | } | 1252 | } |
1749 | 1253 | ||
1750 | 1254 | ||
1751 | } | 1255 | } |
1752 | 1256 | ||
1753 | @Override | 1257 | @Override |
1754 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { | 1258 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { |
1755 | new CircleDialog.Builder((FragmentActivity) mContext) | 1259 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); |
1756 | .setCanceledOnTouchOutside(false) | ||
1757 | .setCancelable(false) | ||
1758 | .setWidth(0.5f) | ||
1759 | .configText(new ConfigText() { | ||
1760 | @Override | ||
1761 | public void onConfig(TextParams params) { | ||
1762 | params.gravity = Gravity.CENTER; | ||
1763 | params.padding = new int[]{50, 50, 50, 50}; | ||
1764 | } | ||
1765 | }) | ||
1766 | .setText("当前无网络,请检查网络设置") | ||
1767 | .setNegative("继续使用", null) | ||
1768 | .setPositive("设置网络", new View.OnClickListener() { | ||
1769 | @Override | ||
1770 | public void onClick(View v) { | ||
1771 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 | ||
1772 | mContext.startActivity(intent); | ||
1773 | } | ||
1774 | }) | ||
1775 | .show(); | ||
1776 | } | 1260 | } |
1777 | }); | 1261 | }); |
1778 | } | 1262 | } |
1779 | 1263 | ||
1780 | //市级接口 | 1264 | //市级接口 |
1781 | public void cityinfo(final Context mContext, long regionId, final Handler handler) { | 1265 | public void cityinfo(final Context mContext, long regionId, final Handler handler) { |
1782 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); | 1266 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); |
1783 | HttpClient.getInstance().get(HttpUrl.cityUrl + "?regionId=" + regionId, new AsyncHttpResponseHandler() { | 1267 | HttpClient.getInstance().get(HttpUrl.cityUrl + "?regionId=" + regionId, new AsyncHttpResponseHandler() { |
1784 | @Override | 1268 | @Override |
1785 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { | 1269 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { |
1786 | Log.e("test", "市" + new String(arg2)); | 1270 | Log.e("test", "市" + new String(arg2)); |
1787 | try { | 1271 | try { |
1788 | JSONObject jsonObject = new JSONObject(new String(arg2)); | 1272 | JSONObject jsonObject = new JSONObject(new String(arg2)); |
1789 | int status = jsonObject.optInt("status"); | 1273 | int status = jsonObject.optInt("status"); |
1790 | if (status == 100) { | 1274 | if (status == 100) { |
1791 | Gson gson = new Gson(); | 1275 | Gson gson = new Gson(); |
1792 | CityInfo cityInfo = gson.fromJson(new String(arg2), CityInfo.class); | 1276 | CityInfo cityInfo = gson.fromJson(new String(arg2), CityInfo.class); |
1793 | List<CityInfo.CitiesBean> cityInfoBeanList = cityInfo.getCities(); | 1277 | List<CityInfo.CitiesBean> cityInfoBeanList = cityInfo.getCities(); |
1794 | Message message = Message.obtain(); | 1278 | Message message = Message.obtain(); |
1795 | message.what = HttpCode.CITYS; | 1279 | message.what = HttpCode.CITYS; |
1796 | message.obj = cityInfoBeanList; | 1280 | message.obj = cityInfoBeanList; |
1797 | handler.sendMessage(message); | 1281 | handler.sendMessage(message); |
1798 | 1282 | ||
1799 | } else { | 1283 | } else { |
1800 | AlertUtils.showToast(mContext, "你好,服务器异常,请稍后重试!"); | 1284 | AlertUtils.showToast(mContext, "你好,服务器异常,请稍后重试!"); |
1801 | 1285 | ||
1802 | } | 1286 | } |
1803 | } catch (JSONException e) { | 1287 | } catch (JSONException e) { |
1804 | e.printStackTrace(); | 1288 | e.printStackTrace(); |
1805 | } | 1289 | } |
1806 | 1290 | ||
1807 | 1291 | ||
1808 | } | 1292 | } |
1809 | 1293 | ||
1810 | @Override | 1294 | @Override |
1811 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { | 1295 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { |
1812 | new CircleDialog.Builder((FragmentActivity) mContext) | 1296 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); |
1813 | .setCanceledOnTouchOutside(false) | ||
1814 | .setCancelable(false) | ||
1815 | .setWidth(0.5f) | ||
1816 | .configText(new ConfigText() { | ||
1817 | @Override | ||
1818 | public void onConfig(TextParams params) { | ||
1819 | params.gravity = Gravity.CENTER; | ||
1820 | params.padding = new int[]{50, 50, 50, 50}; | ||
1821 | } | ||
1822 | }) | ||
1823 | .setText("当前无网络,请检查网络设置") | ||
1824 | .setNegative("继续使用", null) | ||
1825 | .setPositive("设置网络", new View.OnClickListener() { | ||
1826 | @Override | ||
1827 | public void onClick(View v) { | ||
1828 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 | ||
1829 | mContext.startActivity(intent); | ||
1830 | } | ||
1831 | }) | ||
1832 | .show(); | ||
1833 | } | 1297 | } |
1834 | }); | 1298 | }); |
1835 | } | 1299 | } |
1836 | 1300 | ||
1837 | //区县级接口 | 1301 | //区县级接口 |
1838 | public void countyinfo(final Context mContext, int parentId, final Handler handler) { | 1302 | public void countyinfo(final Context mContext, int parentId, final Handler handler) { |
1839 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); | 1303 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); |
1840 | HttpClient.getInstance().get(HttpUrl.countyUrl + "?regionId=" + parentId, new AsyncHttpResponseHandler() { | 1304 | HttpClient.getInstance().get(HttpUrl.countyUrl + "?regionId=" + parentId, new AsyncHttpResponseHandler() { |
1841 | @Override | 1305 | @Override |
1842 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { | 1306 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { |
1843 | Log.e("test", "区" + new String(arg2)); | 1307 | Log.e("test", "区" + new String(arg2)); |
1844 | try { | 1308 | try { |
1845 | JSONObject jsonObject = new JSONObject(new String(arg2)); | 1309 | JSONObject jsonObject = new JSONObject(new String(arg2)); |
1846 | int status = jsonObject.optInt("status"); | 1310 | int status = jsonObject.optInt("status"); |
1847 | if (status == 100) { | 1311 | if (status == 100) { |
1848 | Gson gson = new Gson(); | 1312 | Gson gson = new Gson(); |
1849 | CountyInfo countyInfo = gson.fromJson(new String(arg2), CountyInfo.class); | 1313 | CountyInfo countyInfo = gson.fromJson(new String(arg2), CountyInfo.class); |
1850 | List<CountyInfo.CountiesBean> countyInfoInfoBeanList = countyInfo.getCounties(); | 1314 | List<CountyInfo.CountiesBean> countyInfoInfoBeanList = countyInfo.getCounties(); |
1851 | Message message = Message.obtain(); | 1315 | Message message = Message.obtain(); |
1852 | message.what = HttpCode.COUNTRY; | 1316 | message.what = HttpCode.COUNTRY; |
1853 | message.obj = countyInfoInfoBeanList; | 1317 | message.obj = countyInfoInfoBeanList; |
1854 | handler.sendMessage(message); | 1318 | handler.sendMessage(message); |
1855 | } else { | 1319 | } else { |
1856 | AlertUtils.showToast(mContext, "你好,服务器异常,请稍后重试!"); | 1320 | AlertUtils.showToast(mContext, "你好,服务器异常,请稍后重试!"); |
1857 | 1321 | ||
1858 | } | 1322 | } |
1859 | } catch (JSONException e) { | 1323 | } catch (JSONException e) { |
1860 | e.printStackTrace(); | 1324 | e.printStackTrace(); |
1861 | } | 1325 | } |
1862 | 1326 | ||
1863 | 1327 | ||
1864 | } | 1328 | } |
1865 | 1329 | ||
1866 | @Override | 1330 | @Override |
1867 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { | 1331 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { |
1868 | new CircleDialog.Builder((FragmentActivity) mContext) | 1332 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); |
1869 | .setCanceledOnTouchOutside(false) | ||
1870 | .setCancelable(false) | ||
1871 | .setWidth(0.5f) | ||
1872 | .configText(new ConfigText() { | ||
1873 | @Override | ||
1874 | public void onConfig(TextParams params) { |
PersonalCenter/app/src/main/java/com/hjx/personalcenter/http/HttpUrl.java
1 | package com.hjx.personalcenter.http; | 1 | package com.hjx.personalcenter.http; |
2 | 2 | ||
3 | /** | 3 | /** |
4 | * Created by h on 2017/8/15. | 4 | * Created by h on 2017/8/15. |
5 | */ | 5 | */ |
6 | 6 | ||
7 | public class HttpUrl { | 7 | public class HttpUrl { |
8 | private final static String Enviroment = "DEVELOPMENT"; | 8 | private final static String Enviroment = "DEVELOPMENT"; |
9 | 9 | ||
10 | public static String GetDomain(){ | 10 | public static String GetDomain(){ |
11 | return Enviroment.equals("DEVELOPMENT") ? "http://boss.test.hjx.com" : "http://boss.hjx.com"; | 11 | return Enviroment.equals("DEVELOPMENT") ? "http://boss.test.hjx.com" : "http://boss.hjx.com"; |
12 | } | 12 | } |
13 | 13 | ||
14 | public static String loginUrl = GetDomain()+"/user/access_token";//登录 | 14 | public static String loginUrl = GetDomain()+"/user/access_token";//登录 |
15 | public static String schoolUrl = GetDomain()+"/school/get";//学校 | 15 | public static String schoolUrl = GetDomain()+"/school/get";//学校 |
16 | public static String gradesUrl = GetDomain()+"/grades";//年级 | 16 | public static String gradesUrl = GetDomain()+"/grades";//年级 |
17 | public static String provinceUrl = GetDomain()+"/ozing/provinces";//省 | 17 | public static String provinceUrl = GetDomain()+"/ozing/provinces";//省 |
18 | public static String cityUrl = GetDomain()+"/ozing/cities";//市 | 18 | public static String cityUrl = GetDomain()+"/ozing/cities";//市 |
19 | public static String countyUrl = GetDomain()+"/ozing/counties";//区县 | 19 | public static String countyUrl = GetDomain()+"/ozing/counties";//区县 |
20 | public static String forgetpassword=GetDomain()+"/ozing/timer/user/newpassword";//忘记密码/ | 20 | public static String forgetpassword=GetDomain()+"/ozing/timer/user/newpassword";//忘记密码/ |
21 | public static String registeredUrl=GetDomain()+"/ozing/timer/anking/user";//注册 | 21 | public static String registeredUrl=GetDomain()+"/ozing/timer/anking/user";//注册 |
22 | public static String authCodedUrl=GetDomain()+"/ozing/timer/user/fetchAuthCode";//验证码 | 22 | public static String authCodedUrl=GetDomain()+"/ozing/timer/user/fetchAuthCode";//验证码 |
23 | public static String isRegiterUrl=GetDomain()+"/ozing/timer/user/registered";//手机号是否注册 | 23 | public static String isRegiterUrl=GetDomain()+"/ozing/timer/user/registered";//手机号是否注册 |
24 | public static String changepassword=GetDomain()+"/ozing/timer/user/changepassword";//修改密码 | 24 | public static String changepassword=GetDomain()+"/ozing/timer/user/changepassword";//修改密码 |
25 | public static String subcardinfo=GetDomain()+"/electronicCard/addCustomer";//提交保卡信息 | 25 | public static String subcardinfo=GetDomain()+"/electronicCard/addCustomer";//提交保卡信息 |
26 | public static String getcardinfo=GetDomain()+"/electronicCard/info";//得到保卡信息 | 26 | public static String getcardinfo=GetDomain()+"/electronicCard/info";//得到保卡信息 |
27 | public static String changecardinfo=GetDomain()+"/electronicCard/updateByUserId";//修改保卡信息 | 27 | public static String changecardinfo=GetDomain()+"/electronicCard/updateByUserId";//修改保卡信息 |
28 | public static String cardcheck=GetDomain()+"/electronicCard/check";//检查保卡是否填写 | 28 | public static String cardcheck=GetDomain()+"/electronicCard/check";//检查保卡是否填写 |
29 | public static String changepresonalinfo=GetDomain()+"/personal/update";//修改个人信息 | 29 | public static String changepresonalinfo=GetDomain()+"/personal/update";//修改个人信息 |
30 | public static String getpresonalinfo=GetDomain()+"/personal/get";//获取个人信息 | 30 | public static String getpresonalinfo=GetDomain()+"/personal/get";//获取个人信息 |
31 | public static String signature=GetDomain()+"/signature/addOrUpdateSignature";//修改个性签名 | 31 | public static String signature=GetDomain()+"/signature/addOrUpdateSignature";//修改个性签名 |
32 | public static String getsignature=GetDomain()+"/signature/info";//获取个性签名 | 32 | public static String getsignature=GetDomain()+"/signature/info";//获取个性签名 |
33 | public static String feedbackURL=GetDomain()+"/feedback/add";//用户反馈 | 33 | public static String feedbackURL=GetDomain()+"/feedback/add";//用户反馈 |
34 | public static String childUserURL=GetDomain()+"/childUser/info";//获取子账户信息 | 34 | public static String childUserURL=GetDomain()+"/childUser/info";//获取子账户信息 |
35 | public static String deletechildUserURL=GetDomain()+"/childUser/delete";//删除子账户 | 35 | public static String deletechildUserURL=GetDomain()+"/childUser/delete";//删除子账户 |
36 | public static String addchildUserURL=GetDomain()+"/childUser/addChildUser";//添加子账户 | 36 | public static String addchildUserURL=GetDomain()+"/childUser/addChildUser";//添加子账户 |
37 | public static String changechildUserURL=GetDomain()+"/childUser/update";//切换子账户 | 37 | public static String changechildUserURL=GetDomain()+"/childUser/update";//切换子账户 |
38 | public static String updateappURL=GetDomain()+"/general/release/version";//系统升级 | 38 | public static String updateappURL=GetDomain()+"/general/release/version";//系统升级 |
39 | public static String headerURL=GetDomain()+"/profile/picture/update";//头像上传 | 39 | public static String headerURL=GetDomain()+"/profile/picture/update";//头像上传 |
40 | public static String headerdefaultURL=GetDomain()+"/profile/picture/default";//默认头像上传 | 40 | public static String headerdefaultURL=GetDomain()+"/profile/picture/default";//默认头像上传 |
41 | public static String getversionURL=GetDomain()+"/press/list";//获取版本信息 | 41 | public static String getversionURL=GetDomain()+"/press/list";//获取版本信息 |
42 | public static String isRegisterInfoCompleteURL=GetDomain()+"/register/extrainfo/check";//注册信息是否完整 | ||
42 | 43 | ||
43 | 44 | ||
44 | 45 | ||
45 | 46 | ||
46 | 47 | ||
47 | 48 | ||
48 | } | 49 | } |
49 | 50 |
PersonalCenter/app/src/main/java/com/hjx/personalcenter/model/DefautPublishInfo.java
File was created | 1 | package com.hjx.personalcenter.model; | |
2 | |||
3 | import java.io.Serializable; | ||
4 | |||
5 | /** | ||
6 | * Created by h on 2017/9/12. | ||
7 | */ | ||
8 | |||
9 | public class DefautPublishInfo implements Serializable{ | ||
10 | private String imagurl; | ||
11 | |||
12 | public String getImagurl() { | ||
13 | return imagurl; | ||
14 | } | ||
15 | |||
16 | public void setImagurl(String imagurl) { | ||
17 | this.imagurl = imagurl; | ||
18 | } | ||
19 | |||
20 | public String getSubjuct() { | ||
21 | return subjuct; | ||
22 | } | ||
23 | |||
24 | public void setSubjuct(String subjuct) { | ||
25 | this.subjuct = subjuct; | ||
26 | } | ||
27 | |||
28 | public String getPublish() { | ||
29 | return publish; | ||
30 | } | ||
31 | |||
32 | public void setPublish(String publish) { | ||
33 | this.publish = publish; | ||
34 | } | ||
35 | |||
36 | private String subjuct; | ||
37 | private String publish; | ||
38 | } | ||
39 |
PersonalCenter/app/src/main/java/com/hjx/personalcenter/model/LoginInfo.java
File was created | 1 | package com.hjx.personalcenter.model; | |
2 | |||
3 | import java.io.Serializable; | ||
4 | |||
5 | /** | ||
6 | * Created by h on 2017/9/12. | ||
7 | */ | ||
8 | |||
9 | public class LoginInfo implements Serializable { | ||
10 | private String username; | ||
11 | private String password; | ||
12 | |||
13 | public String getUsername() { | ||
14 | return username; | ||
15 | } | ||
16 | |||
17 | public void setUsername(String username) { | ||
18 | this.username = username; | ||
19 | } | ||
20 | |||
21 | public String getPassword() { | ||
22 | return password; | ||
23 | } | ||
24 | |||
25 | public void setPassword(String password) { | ||
26 | this.password = password; | ||
27 | } | ||
28 | |||
29 | public String getAccess_token() { | ||
30 | return access_token; | ||
31 | } | ||
32 | |||
33 | public void setAccess_token(String access_token) { | ||
34 | this.access_token = access_token; | ||
35 | } | ||
36 | |||
37 | public String getLoginStatus() { | ||
38 | return loginStatus; | ||
39 | } | ||
40 | |||
41 | public void setLoginStatus(String loginStatus) { | ||
42 | this.loginStatus = loginStatus; | ||
43 | } | ||
44 | |||
45 | public String getUserId() { | ||
46 | return userId; | ||
47 | } | ||
48 | |||
49 | public void setUserId(String userId) { | ||
50 | this.userId = userId; | ||
51 | } | ||
52 | |||
53 | private String access_token; | ||
54 | private String loginStatus; | ||
55 | private String userId; | ||
56 | } | ||
57 |
PersonalCenter/app/src/main/java/com/hjx/personalcenter/service/CenterService.java
1 | package com.hjx.personalcenter.service; | 1 | package com.hjx.personalcenter.service; |
2 | 2 | ||
3 | import android.content.Intent; | 3 | import android.content.Intent; |
4 | import android.os.IBinder; | 4 | import android.os.IBinder; |
5 | import android.os.RemoteException; | 5 | import android.os.RemoteException; |
6 | import android.util.Log; | ||
7 | |||
8 | import com.google.gson.Gson; | ||
9 | import com.hjx.personalcenter.activity.LoginAndRegisterActivity; | ||
10 | import com.hjx.personalcenter.db.SaveParam; | ||
11 | import com.hjx.personalcenter.model.CardInfo; | ||
12 | import com.hjx.personalcenter.model.LoginInfo; | ||
13 | import com.hjx.personalcenter.util.GetDevicesUtil; | ||
6 | 14 | ||
7 | /** | 15 | /** |
8 | * Created by h on 2017/9/1. | 16 | * Created by h on 2017/9/1. |
9 | */ | 17 | */ |
10 | 18 | ||
11 | public class CenterService extends BaseService { | 19 | public class CenterService extends BaseService { |
20 | enum ACTIVITY_ACTION{ | ||
21 | userinfo_activity | ||
22 | } | ||
12 | public CenterService(){ | 23 | public CenterService(){ |
13 | 24 | ||
14 | } | 25 | } |
15 | IPresonalInterface.Stub binder = new IPresonalInterface.Stub() { | 26 | IPresonalInterface.Stub binder = new IPresonalInterface.Stub() { |
16 | @Override | 27 | @Override |
17 | public String sayHello() throws RemoteException { | 28 | public String sayHello() throws RemoteException { |
18 | return "这是测试AIDL的方法"; | 29 | return "这是测试AIDL的方法"; |
19 | } | 30 | } |
20 | 31 | ||
21 | @Override | 32 | @Override |
22 | public String viewPage(String action) throws RemoteException { | 33 | public String viewPage(String action) throws RemoteException { |
23 | return null; | 34 | String result = null; |
35 | if(action.equals(ACTIVITY_ACTION.userinfo_activity.toString())){ | ||
36 | //登录界面 | ||
37 | Intent intent = new Intent(); | ||
38 | intent.setClass(CenterService.this, LoginAndRegisterActivity.class); | ||
39 | intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); | ||
40 | startActivity(intent); | ||
41 | result= "跳转成功"; | ||
42 | } | ||
43 | |||
44 | return result; | ||
24 | } | 45 | } |
25 | 46 | ||
26 | @Override | 47 | @Override |
27 | public String getSimpleUser() throws RemoteException { | 48 | public String getSimpleUser() throws RemoteException { |
49 | String logininfo = null; | ||
50 | Gson gson = new Gson(); | ||
51 | LoginInfo loginInfo = new LoginInfo(); | ||
52 | String islogin = SaveParam.getInstance().getLoginParam(getApplication(),"login"); | ||
53 | if ("true".equals(islogin)){ | ||
54 | loginInfo.setUsername(SaveParam.getInstance().getLoginParam(getApplication(), "username")); | ||
55 | loginInfo.setPassword(SaveParam.getInstance().getLoginParam(getApplication(), "password")); | ||
56 | loginInfo.setAccess_token(SaveParam.getInstance().getLoginParam(getApplication(), "access_token")); | ||
57 | loginInfo.setLoginStatus(SaveParam.getInstance().getLoginParam(getApplication(), "login")); | ||
58 | loginInfo.setUserId(SaveParam.getInstance().getLoginParam(getApplication(), "userId")); | ||
59 | |||
60 | logininfo =gson.toJson(loginInfo); | ||
61 | |||
62 | Log.e("test","登录信息"+logininfo); | ||
63 | |||
64 | } | ||
65 | |||
66 | return logininfo; | ||
67 | } | ||
68 | //保卡信息 | ||
69 | @Override | ||
70 | public String getcardUser() throws RemoteException { | ||
71 | String results = null; | ||
72 | CardInfo cardInfo = new CardInfo(); | ||
73 | CardInfo.DataBean dataBean = new CardInfo.DataBean(); | ||
74 | Gson gson = new Gson(); | ||
75 | |||
76 | //获取设备信息 | ||
77 | dataBean.setProductModel(GetDevicesUtil.getDevicesInfo(getApplication()).getDeviceModel()); | ||
78 | dataBean.setDeviceNumber(GetDevicesUtil.getDevicesInfo(getApplication()).getDeviceNumber()); | ||
79 | dataBean.setMacAddress(GetDevicesUtil.getDevicesInfo(getApplication()).getMac()); | ||
80 | //获取保卡信息 | ||
81 | dataBean.setCustomerName(SaveParam.getInstance().getCustomizeParam(getApplication(),SaveParam.CUNSTEMNAME)); | ||
82 | dataBean.setCustomerAddress(SaveParam.getInstance().getCustomizeParam(getApplication(),SaveParam.ADRESSCUNSTEM)); | ||
83 | dataBean.setBuyTime(SaveParam.getInstance().getCustomizeParam(getApplication(),SaveParam.SHOPTIME)); | ||
84 | dataBean.setBuyAddress(SaveParam.getInstance().getCustomizeParam(getApplication(),SaveParam.SHOPADRESS)); | ||
85 | dataBean.setAlterSaleCall(SaveParam.getInstance().getCustomizeParam(getApplication(),SaveParam.SHOPTLEPHONE)); | ||
86 | dataBean.setMobilePhone(SaveParam.getInstance().getCustomizeParam(getApplication(),SaveParam.CARDPHONE)); | ||
87 | cardInfo.setData(dataBean); | ||
88 | results =gson.toJson(cardInfo); | ||
89 | |||
90 | return results; | ||
91 | } | ||
92 | |||
93 | @Override | ||
94 | public String getUserInfo() throws RemoteException { | ||
28 | return null; | 95 | return null; |
29 | } | 96 | } |
30 | 97 | ||
31 | @Override | 98 | @Override |
32 | public String getcardUser() throws RemoteException { | 99 | public String logout() throws RemoteException { |
100 | return null; | ||
101 | } | ||
102 | |||
103 | @Override | ||
104 | public String validateToken() throws RemoteException { | ||
105 | return null; | ||
106 | } | ||
107 | |||
108 | @Override | ||
109 | public String getDeviceID() throws RemoteException { | ||
110 | return null; | ||
111 | } | ||
112 | |||
113 | @Override | ||
114 | public String getChildsInfo() throws RemoteException { | ||
33 | return null; | 115 | return null; |
34 | } | 116 | } |
35 | }; | 117 | }; |
36 | 118 | ||
37 | @Override | 119 | @Override |
38 | public IBinder onBind(Intent intent) { | 120 | public IBinder onBind(Intent intent) { |
39 | return binder; | 121 | return binder; |
40 | } | 122 | } |
41 | } | 123 | } |
42 | 124 |
PersonalCenter/app/src/main/java/com/hjx/personalcenter/util/NetUtils.java
File was created | 1 | package com.hjx.personalcenter.util; | |
2 | |||
3 | import android.content.Context; | ||
4 | import android.net.ConnectivityManager; | ||
5 | import android.net.NetworkInfo; | ||
6 | |||
7 | /** | ||
8 | * Created by h on 2017/9/13. | ||
9 | */ | ||
10 | |||
11 | public class NetUtils { | ||
12 | // 判断网络连接状态 | ||
13 | public static boolean isNetworkConnected(Context context) { | ||
14 | if (context != null) { | ||
15 | ConnectivityManager mConnectivityManager = (ConnectivityManager) context | ||
16 | .getSystemService(Context.CONNECTIVITY_SERVICE); | ||
17 | NetworkInfo mNetworkInfo = mConnectivityManager | ||
18 | .getActiveNetworkInfo(); | ||
19 | if (mNetworkInfo != null) { | ||
20 | return mNetworkInfo.isAvailable(); | ||
21 | } | ||
22 | } | ||
23 | return false; | ||
24 | } | ||
25 | |||
26 | // 判断wifi状态 | ||
27 | public static boolean isWifiConnected(Context context) { | ||
28 | if (context != null) { | ||
29 | ConnectivityManager mConnectivityManager = (ConnectivityManager) context | ||
30 | .getSystemService(Context.CONNECTIVITY_SERVICE); | ||
31 | NetworkInfo mWiFiNetworkInfo = mConnectivityManager | ||
32 | .getNetworkInfo(ConnectivityManager.TYPE_WIFI); | ||
33 | if (mWiFiNetworkInfo != null) { | ||
34 | return mWiFiNetworkInfo.isAvailable(); | ||
35 | } | ||
36 | } | ||
37 | return false; | ||
38 | } | ||
39 | |||
40 | // 判断移动网络 | ||
41 | public static boolean isMobileConnected(Context context) { | ||
42 | if (context != null) { | ||
43 | ConnectivityManager mConnectivityManager = (ConnectivityManager) context | ||
44 | .getSystemService(Context.CONNECTIVITY_SERVICE); | ||
45 | NetworkInfo mMobileNetworkInfo = mConnectivityManager | ||
46 | .getNetworkInfo(ConnectivityManager.TYPE_MOBILE); | ||
47 | if (mMobileNetworkInfo != null) { | ||
48 | return mMobileNetworkInfo.isAvailable(); | ||
49 | } | ||
50 | } | ||
51 | return false; | ||
52 | } | ||
53 | |||
54 | // 获取连接类型 | ||
55 | public static int getConnectedType(Context context) { | ||
56 | if (context != null) { | ||
57 | ConnectivityManager mConnectivityManager = (ConnectivityManager) context | ||
58 | .getSystemService(Context.CONNECTIVITY_SERVICE); | ||
59 | NetworkInfo mNetworkInfo = mConnectivityManager | ||
60 | .getActiveNetworkInfo(); | ||
61 | if (mNetworkInfo != null && mNetworkInfo.isAvailable()) { | ||
62 | return mNetworkInfo.getType(); | ||
63 | } | ||
64 | } | ||
65 | return -1; | ||
66 | } | ||
67 | |||
68 | } | ||
69 |
PersonalCenter/app/src/main/res/layout/activity_main.xml
1 | <?xml version="1.0" encoding="utf-8"?> | 1 | <?xml version="1.0" encoding="utf-8"?> |
2 | <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | 2 | <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" |
3 | android:layout_width="match_parent" | 3 | android:layout_width="match_parent" |
4 | android:layout_height="match_parent" | 4 | android:layout_height="match_parent" |
5 | xmlns:fresco="http://schemas.android.com/apk/res-auto" | 5 | xmlns:fresco="http://schemas.android.com/apk/res-auto" |
6 | android:orientation="vertical"> | 6 | android:orientation="vertical"> |
7 | 7 | ||
8 | <RelativeLayout | 8 | <RelativeLayout |
9 | android:id="@+id/title" | 9 | android:id="@+id/title" |
10 | android:layout_width="match_parent" | 10 | android:layout_width="match_parent" |
11 | android:layout_height="50dp" | 11 | android:layout_height="50dp" |
12 | android:background="@color/login_text_blue"> | 12 | android:background="@color/login_text_blue"> |
13 | 13 | ||
14 | <ImageView | 14 | <ImageView |
15 | android:id="@+id/cancel" | 15 | android:id="@+id/cancel" |
16 | android:layout_width="wrap_content" | 16 | android:layout_width="wrap_content" |
17 | android:layout_height="match_parent" | 17 | android:layout_height="match_parent" |
18 | android:paddingLeft="20dp" | 18 | android:paddingLeft="20dp" |
19 | android:paddingRight="20dp" | 19 | android:paddingRight="20dp" |
20 | android:visibility="gone" | 20 | android:visibility="gone" |
21 | android:src="@mipmap/title_back" /> | 21 | android:src="@mipmap/title_back" /> |
22 | 22 | ||
23 | <TextView | 23 | <TextView |
24 | android:id="@+id/menu_title" | 24 | android:id="@+id/menu_title" |
25 | android:layout_width="wrap_content" | 25 | android:layout_width="wrap_content" |
26 | android:layout_height="match_parent" | 26 | android:layout_height="match_parent" |
27 | android:layout_centerInParent="true" | 27 | android:layout_centerInParent="true" |
28 | android:gravity="center_vertical" | 28 | android:gravity="center_vertical" |
29 | android:text="@string/titel_preson" | 29 | android:text="@string/titel_preson" |
30 | android:textColor="@android:color/white" | 30 | android:textColor="@android:color/white" |
31 | android:textSize="22sp" /> | 31 | android:textSize="22sp" /> |
32 | 32 | ||
33 | <ImageView | 33 | <ImageView |
34 | android:id="@+id/iv_setting" | 34 | android:id="@+id/iv_setting" |
35 | android:layout_width="wrap_content" | 35 | android:layout_width="wrap_content" |
36 | android:layout_height="match_parent" | 36 | android:layout_height="match_parent" |
37 | android:layout_marginRight="10dp" | 37 | android:layout_marginRight="10dp" |
38 | android:layout_toLeftOf="@+id/iv_skin" | 38 | android:layout_toLeftOf="@+id/iv_skin" |
39 | android:gravity="center_vertical" | 39 | android:gravity="center_vertical" |
40 | android:padding="10dp" | 40 | android:padding="10dp" |
41 | android:src="@mipmap/shezhi" | 41 | android:src="@mipmap/shezhi" |
42 | android:textColor="@android:color/white" | 42 | android:textColor="@android:color/white" |
43 | android:textSize="22sp" /> | 43 | android:textSize="22sp" /> |
44 | 44 | ||
45 | <ImageView | 45 | <ImageView |
46 | android:id="@+id/iv_skin" | 46 | android:id="@+id/iv_skin" |
47 | android:layout_width="wrap_content" | 47 | android:layout_width="wrap_content" |
48 | android:layout_height="match_parent" | 48 | android:layout_height="match_parent" |
49 | android:layout_marginRight="10dp" | 49 | android:layout_marginRight="10dp" |
50 | android:layout_toLeftOf="@+id/iv_imformatioan" | 50 | android:layout_toLeftOf="@+id/iv_imformatioan" |
51 | android:gravity="center_vertical" | 51 | android:gravity="center_vertical" |
52 | android:padding="10dp" | 52 | android:padding="10dp" |
53 | android:src="@mipmap/pifu" | 53 | android:src="@mipmap/pifu" |
54 | android:textColor="@android:color/white" | 54 | android:textColor="@android:color/white" |
55 | android:textSize="22sp" /> | 55 | android:textSize="22sp" /> |
56 | 56 | ||
57 | <ImageView | 57 | <ImageView |
58 | android:id="@+id/iv_imformatioan" | 58 | android:id="@+id/iv_imformatioan" |
59 | android:layout_width="wrap_content" | 59 | android:layout_width="wrap_content" |
60 | android:layout_height="match_parent" | 60 | android:layout_height="match_parent" |
61 | android:layout_alignParentRight="true" | 61 | android:layout_alignParentRight="true" |
62 | android:layout_marginRight="10dp" | 62 | android:layout_marginRight="10dp" |
63 | android:gravity="center_vertical" | 63 | android:gravity="center_vertical" |
64 | android:padding="10dp" | 64 | android:padding="10dp" |
65 | android:src="@mipmap/fankui" | 65 | android:src="@mipmap/fankui" |
66 | android:textColor="@android:color/white" | 66 | android:textColor="@android:color/white" |
67 | android:textSize="22sp" /> | 67 | android:textSize="22sp" /> |
68 | 68 | ||
69 | 69 | ||
70 | </RelativeLayout> | 70 | </RelativeLayout> |
71 | 71 | ||
72 | <LinearLayout | 72 | <LinearLayout |
73 | android:layout_width="match_parent" | 73 | android:layout_width="match_parent" |
74 | android:layout_height="match_parent"> | 74 | android:layout_height="match_parent"> |
75 | 75 | ||
76 | <LinearLayout | 76 | <LinearLayout |
77 | android:layout_width="0dp" | 77 | android:layout_width="0dp" |
78 | android:layout_height="match_parent" | 78 | android:layout_height="match_parent" |
79 | android:layout_weight="1" | 79 | android:layout_weight="1" |
80 | android:orientation="vertical"> | 80 | android:orientation="vertical"> |
81 | 81 | ||
82 | <LinearLayout | 82 | <LinearLayout |
83 | android:layout_width="match_parent" | 83 | android:layout_width="match_parent" |
84 | android:layout_height="wrap_content" | 84 | android:layout_height="wrap_content" |
85 | android:layout_marginTop="20dp" | 85 | android:layout_marginTop="20dp" |
86 | android:orientation="horizontal"> | 86 | android:orientation="horizontal"> |
87 | <ImageView | 87 | <ImageView |
88 | android:id="@+id/iv_look_card" | 88 | android:id="@+id/iv_look_card" |
89 | android:layout_width="wrap_content" | 89 | android:layout_width="wrap_content" |
90 | android:layout_height="wrap_content" | 90 | android:layout_height="wrap_content" |
91 | android:padding="10dp" | 91 | android:padding="10dp" |
92 | android:layout_marginLeft="20dp" | 92 | android:layout_marginLeft="20dp" |
93 | android:src="@mipmap/card_icoc" /> | 93 | android:src="@mipmap/card_icoc" /> |
94 | <com.facebook.drawee.view.SimpleDraweeView | 94 | <com.facebook.drawee.view.SimpleDraweeView |
95 | android:id="@+id/iv_head" | 95 | android:id="@+id/iv_head" |
96 | android:layout_width="60dp" | 96 | android:layout_width="60dp" |
97 | android:layout_height="60dp" | 97 | android:layout_height="60dp" |
98 | android:layout_marginLeft="60dp" | 98 | android:layout_marginLeft="60dp" |
99 | android:layout_gravity="center" | 99 | android:layout_gravity="center" |
100 | fresco:placeholderImage="@mipmap/header_default" | 100 | fresco:placeholderImage="@mipmap/header_default" |
101 | fresco:roundAsCircle="true" | 101 | fresco:roundAsCircle="true" |
102 | fresco:placeholderImageScaleType="fitCenter" /> | 102 | fresco:placeholderImageScaleType="fitCenter" /> |
103 | 103 | ||
104 | <TextView | 104 | <TextView |
105 | android:layout_width="wrap_content" | 105 | android:layout_width="wrap_content" |
106 | android:layout_height="wrap_content" | 106 | android:layout_height="wrap_content" |
107 | android:layout_marginLeft="18dp" | 107 | android:layout_marginLeft="18dp" |
108 | android:layout_marginTop="20dp" | 108 | android:layout_marginTop="20dp" |
109 | android:background="@drawable/corcle_blue_bg" | 109 | android:background="@drawable/corcle_blue_bg" |
110 | android:paddingLeft="5dp" | 110 | android:paddingLeft="5dp" |
111 | android:paddingRight="5dp" | 111 | android:paddingRight="5dp" |
112 | android:gravity="center_vertical" | 112 | android:gravity="center_vertical" |
113 | android:text="签到" | 113 | android:text="签到" |
114 | android:textColor="@color/login_text_blue" | 114 | android:textColor="@color/login_text_blue" |
115 | android:textSize="18sp" /> | 115 | android:textSize="18sp" /> |
116 | 116 | ||
117 | </LinearLayout> | 117 | </LinearLayout> |
118 | 118 | ||
119 | <LinearLayout | 119 | <LinearLayout |
120 | android:layout_width="match_parent" | 120 | android:layout_width="match_parent" |
121 | android:layout_height="wrap_content" | 121 | android:layout_height="wrap_content" |
122 | android:layout_marginLeft="20dp" | 122 | android:layout_marginLeft="20dp" |
123 | android:layout_marginTop="20dp" | 123 | android:layout_marginTop="20dp" |
124 | android:orientation="horizontal"> | 124 | android:orientation="horizontal"> |
125 | 125 | ||
126 | <TextView | 126 | <TextView |
127 | android:id="@+id/tv_username" | 127 | android:id="@+id/tv_username" |
128 | android:layout_width="wrap_content" | 128 | android:layout_width="wrap_content" |
129 | android:layout_height="wrap_content" | 129 | android:layout_height="wrap_content" |
130 | android:text="姓名" | 130 | android:text="姓名" |
131 | android:textSize="20dp" /> | 131 | android:textSize="20dp" /> |
132 | 132 | ||
133 | <ImageView | 133 | <ImageView |
134 | android:id="@+id/iv_sex" | 134 | android:id="@+id/iv_sex" |
135 | android:layout_width="wrap_content" | 135 | android:layout_width="wrap_content" |
136 | android:layout_height="wrap_content" | 136 | android:layout_height="wrap_content" |
137 | android:layout_gravity="center_vertical" | ||
137 | android:layout_marginLeft="50dp" | 138 | android:layout_marginLeft="50dp" |
138 | android:src="@mipmap/men" /> | 139 | android:src="@mipmap/men" /> |
139 | 140 | ||
140 | </LinearLayout> | 141 | </LinearLayout> |
141 | 142 | ||
142 | <LinearLayout | 143 | <LinearLayout |
143 | android:layout_width="match_parent" | 144 | android:layout_width="match_parent" |
144 | android:layout_height="wrap_content" | 145 | android:layout_height="wrap_content" |
145 | android:layout_marginLeft="20dp" | 146 | android:layout_marginLeft="20dp" |
146 | android:layout_marginTop="20dp" | 147 | android:layout_marginTop="20dp" |
147 | android:gravity="center" | 148 | android:gravity="center" |
148 | android:orientation="horizontal"> | 149 | android:orientation="horizontal"> |
149 | 150 | ||
150 | <TextView | 151 | <TextView |
151 | android:id="@+id/tv_sign" | 152 | android:id="@+id/tv_sign" |
152 | android:layout_width="0dp" | 153 | android:layout_width="0dp" |
153 | android:layout_height="wrap_content" | 154 | android:layout_height="wrap_content" |
154 | android:layout_weight="5" | 155 | android:layout_weight="5" |
155 | android:text="请输入个性签名" | 156 | android:text="请输入个性签名" |
156 | android:textSize="18sp" /> | 157 | android:textSize="18sp" /> |
157 | 158 | ||
158 | <ImageView | 159 | <ImageView |
159 | android:id="@+id/iv_sign" | 160 | android:id="@+id/iv_sign" |
160 | android:layout_width="0dp" | 161 | android:layout_width="0dp" |
161 | android:layout_height="wrap_content" | 162 | android:layout_height="wrap_content" |
162 | android:layout_weight="1" | 163 | android:layout_weight="1" |
163 | android:padding="10dp" | 164 | android:padding="10dp" |
164 | android:src="@mipmap/pencil" /> | 165 | android:src="@mipmap/pencil" /> |
165 | 166 | ||
166 | 167 | ||
167 | </LinearLayout> | 168 | </LinearLayout> |
168 | 169 | ||
169 | <View | 170 | <View |
170 | android:layout_width="match_parent" | 171 | android:layout_width="match_parent" |
171 | android:layout_height="0.7dp" | 172 | android:layout_height="0.7dp" |
172 | android:layout_marginTop="20dp" | 173 | android:layout_marginTop="20dp" |
173 | android:background="@color/cutoff_line"> | 174 | android:background="@color/cutoff_line"> |
174 | 175 | ||
175 | </View> | 176 | </View> |
176 | 177 | ||
177 | <LinearLayout | 178 | <LinearLayout |
178 | android:id="@+id/linel_mycuoti" | 179 | android:id="@+id/linel_mycuoti" |
179 | android:layout_width="match_parent" | 180 | android:layout_width="match_parent" |
180 | android:layout_height="wrap_content" | 181 | android:layout_height="wrap_content" |
181 | android:layout_marginTop="30dp" | 182 | android:layout_marginTop="30dp" |
182 | android:orientation="vertical"> | 183 | android:orientation="vertical"> |
183 | 184 | ||
184 | <LinearLayout | 185 | <LinearLayout |
185 | android:layout_width="match_parent" | 186 | android:layout_width="match_parent" |
186 | android:layout_height="wrap_content" | 187 | android:layout_height="wrap_content" |
187 | android:gravity="center_vertical" | 188 | android:gravity="center_vertical" |
188 | android:orientation="horizontal"> | 189 | android:orientation="horizontal"> |
189 | 190 | ||
190 | <ImageView | 191 | <ImageView |
191 | android:layout_width="0dp" | 192 | android:layout_width="0dp" |
192 | android:layout_height="wrap_content" | 193 | android:layout_height="wrap_content" |
193 | android:layout_weight="1" | 194 | android:layout_weight="1" |
194 | android:src="@mipmap/wodecuoti" /> | 195 | android:src="@mipmap/wodecuoti" /> |
195 | 196 | ||
196 | <TextView | 197 | <TextView |
197 | android:layout_width="0dp" | 198 | android:layout_width="0dp" |
198 | android:layout_height="wrap_content" | 199 | android:layout_height="wrap_content" |
199 | android:layout_weight="5" | 200 | android:layout_weight="5" |
200 | android:text="我的错题" | 201 | android:text="我的错题" |
201 | android:textSize="20sp" /> | 202 | android:textSize="20sp" /> |
202 | 203 | ||
203 | <ImageView | 204 | <ImageView |
204 | android:layout_width="0dp" | 205 | android:layout_width="0dp" |
205 | android:layout_height="wrap_content" | 206 | android:layout_height="wrap_content" |
206 | android:layout_weight="1" | 207 | android:layout_weight="1" |
207 | android:src="@mipmap/youjiantou" /> | 208 | android:src="@mipmap/youjiantou" /> |
208 | 209 | ||
209 | </LinearLayout> | 210 | </LinearLayout> |
210 | 211 | ||
211 | <LinearLayout | 212 | <LinearLayout |
212 | android:id="@+id/linel_mynote" | 213 | android:id="@+id/linel_mynote" |
213 | android:layout_width="match_parent" | 214 | android:layout_width="match_parent" |
214 | android:layout_height="wrap_content" | 215 | android:layout_height="wrap_content" |
215 | android:layout_marginTop="35dp" | 216 | android:layout_marginTop="35dp" |
216 | android:gravity="center_vertical" | 217 | android:gravity="center_vertical" |
217 | android:orientation="horizontal"> | 218 | android:orientation="horizontal"> |
218 | 219 | ||
219 | <ImageView | 220 | <ImageView |
220 | android:layout_width="0dp" | 221 | android:layout_width="0dp" |
221 | android:layout_height="wrap_content" | 222 | android:layout_height="wrap_content" |
222 | android:layout_weight="1" | 223 | android:layout_weight="1" |
223 | android:src="@mipmap/wodebiji" /> | 224 | android:src="@mipmap/wodebiji" /> |
224 | 225 | ||
225 | <TextView | 226 | <TextView |
226 | android:layout_width="0dp" | 227 | android:layout_width="0dp" |
227 | android:layout_height="wrap_content" | 228 | android:layout_height="wrap_content" |
228 | android:layout_weight="5" | 229 | android:layout_weight="5" |
229 | android:text="我的笔记" | 230 | android:text="我的笔记" |
230 | android:textSize="20sp" /> | 231 | android:textSize="20sp" /> |
231 | 232 | ||
232 | <ImageView | 233 | <ImageView |
233 | android:layout_width="0dp" | 234 | android:layout_width="0dp" |
234 | android:layout_height="wrap_content" | 235 | android:layout_height="wrap_content" |
235 | android:layout_weight="1" | 236 | android:layout_weight="1" |
236 | android:src="@mipmap/youjiantou" /> | 237 | android:src="@mipmap/youjiantou" /> |
237 | 238 | ||
238 | </LinearLayout> | 239 | </LinearLayout> |
239 | 240 | ||
240 | <LinearLayout | 241 | <LinearLayout |
241 | android:id="@+id/linel_mycollege" | 242 | android:id="@+id/linel_mycollege" |
242 | android:layout_width="match_parent" | 243 | android:layout_width="match_parent" |
243 | android:layout_height="wrap_content" | 244 | android:layout_height="wrap_content" |
244 | android:layout_marginTop="35dp" | 245 | android:layout_marginTop="35dp" |
245 | android:gravity="center_vertical" | 246 | android:gravity="center_vertical" |
246 | android:orientation="horizontal"> | 247 | android:orientation="horizontal"> |
247 | 248 | ||
248 | <ImageView | 249 | <ImageView |
249 | android:layout_width="0dp" | 250 | android:layout_width="0dp" |
250 | android:layout_height="wrap_content" | 251 | android:layout_height="wrap_content" |
251 | android:layout_weight="1" | 252 | android:layout_weight="1" |
252 | android:src="@mipmap/wodeshoucang" /> | 253 | android:src="@mipmap/wodeshoucang" /> |
253 | 254 | ||
254 | <TextView | 255 | <TextView |
255 | android:layout_width="0dp" | 256 | android:layout_width="0dp" |
256 | android:layout_height="wrap_content" | 257 | android:layout_height="wrap_content" |
257 | android:layout_weight="5" | 258 | android:layout_weight="5" |
258 | android:text="我的收藏" | 259 | android:text="我的收藏" |
259 | android:textSize="20sp" /> | 260 | android:textSize="20sp" /> |
260 | 261 | ||
261 | <ImageView | 262 | <ImageView |
262 | android:layout_width="0dp" | 263 | android:layout_width="0dp" |
263 | android:layout_height="wrap_content" | 264 | android:layout_height="wrap_content" |
264 | android:layout_weight="1" | 265 | android:layout_weight="1" |
265 | android:src="@mipmap/youjiantou" /> | 266 | android:src="@mipmap/youjiantou" /> |
266 | 267 | ||
267 | </LinearLayout> | 268 | </LinearLayout> |
268 | 269 | ||
269 | <LinearLayout | 270 | <LinearLayout |
270 | android:id="@+id/linel_myclass" | 271 | android:id="@+id/linel_myclass" |
271 | android:layout_width="match_parent" | 272 | android:layout_width="match_parent" |
272 | android:layout_height="wrap_content" | 273 | android:layout_height="wrap_content" |
273 | android:layout_marginTop="35dp" | 274 | android:layout_marginTop="35dp" |
274 | android:gravity="center_vertical" | 275 | android:gravity="center_vertical" |
275 | android:orientation="horizontal"> | 276 | android:orientation="horizontal"> |
276 | 277 | ||
277 | <ImageView | 278 | <ImageView |
278 | android:layout_width="0dp" | 279 | android:layout_width="0dp" |
279 | android:layout_height="wrap_content" | 280 | android:layout_height="wrap_content" |
280 | android:layout_weight="1" | 281 | android:layout_weight="1" |
281 | android:src="@mipmap/wodebanji" /> | 282 | android:src="@mipmap/wodebanji" /> |
282 | 283 | ||
283 | <TextView | 284 | <TextView |
284 | android:layout_width="0dp" | 285 | android:layout_width="0dp" |
285 | android:layout_height="wrap_content" | 286 | android:layout_height="wrap_content" |
286 | android:layout_weight="5" | 287 | android:layout_weight="5" |
287 | android:text="我的班级" | 288 | android:text="我的班级" |
288 | android:textSize="20sp" /> | 289 | android:textSize="20sp" /> |
289 | 290 | ||
290 | <ImageView | 291 | <ImageView |
291 | android:layout_width="0dp" | 292 | android:layout_width="0dp" |
292 | android:layout_height="wrap_content" | 293 | android:layout_height="wrap_content" |
293 | android:layout_weight="1" | 294 | android:layout_weight="1" |
294 | android:src="@mipmap/youjiantou" /> | 295 | android:src="@mipmap/youjiantou" /> |
295 | 296 | ||
296 | </LinearLayout> | 297 | </LinearLayout> |
297 | 298 | ||
298 | 299 | ||
299 | </LinearLayout> | 300 | </LinearLayout> |
300 | 301 | ||
301 | <LinearLayout | 302 | <LinearLayout |
302 | android:layout_width="match_parent" | 303 | android:layout_width="match_parent" |
303 | android:layout_height="match_parent" | 304 | android:layout_height="match_parent" |
304 | android:layout_marginTop="120dp" | 305 | android:layout_marginTop="120dp" |
305 | android:background="@mipmap/xiaoguanggao"> | 306 | android:background="@mipmap/xiaoguanggao"> |
306 | 307 | ||
307 | </LinearLayout> | 308 | </LinearLayout> |
308 | 309 | ||
309 | 310 | ||
310 | </LinearLayout> | 311 | </LinearLayout> |
311 | 312 | ||
312 | 313 | ||
313 | <View | 314 | <View |
314 | android:layout_width="0.7dp" | 315 | android:layout_width="0.7dp" |
315 | android:layout_height="match_parent" | 316 | android:layout_height="match_parent" |
316 | android:background="@color/cutoff_line"> | 317 | android:background="@color/cutoff_line"> |
317 | 318 | ||
318 | </View> | 319 | </View> |
319 | 320 | ||
320 | <LinearLayout | 321 | <LinearLayout |
321 | android:layout_width="0dp" | 322 | android:layout_width="0dp" |
322 | android:layout_height="match_parent" | 323 | android:layout_height="match_parent" |
323 | android:layout_weight="2.5" | 324 | android:layout_weight="2.5" |
324 | android:orientation="vertical"> | 325 | android:orientation="vertical"> |
325 | 326 | ||
326 | <LinearLayout | 327 | <LinearLayout |
327 | android:layout_width="match_parent" | 328 | android:layout_width="match_parent" |
328 | android:layout_height="wrap_content" | 329 | android:layout_height="wrap_content" |
329 | android:layout_margin="20dp" | 330 | android:layout_margin="20dp" |
330 | android:gravity="center_vertical" | 331 | android:gravity="center_vertical" |
331 | android:orientation="horizontal"> | 332 | android:orientation="horizontal"> |
332 | 333 | ||
333 | <View | 334 | <View |
334 | android:layout_width="5dp" | 335 | android:layout_width="5dp" |
335 | android:layout_height="20dp" | 336 | android:layout_height="20dp" |
336 | android:background="@color/login_text_blue"> | 337 | android:background="@color/login_text_blue"> |
337 | 338 | ||
338 | </View> | 339 | </View> |
339 | 340 | ||
340 | <TextView | 341 | <TextView |
341 | android:layout_width="wrap_content" | 342 | android:layout_width="wrap_content" |
342 | android:layout_height="wrap_content" | 343 | android:layout_height="wrap_content" |
343 | android:layout_marginLeft="5dp" | 344 | android:layout_marginLeft="5dp" |
344 | android:text="最近学习" | 345 | android:text="最近学习" |
345 | android:textSize="22sp" /> | 346 | android:textSize="22sp" /> |
346 | 347 | ||
347 | </LinearLayout> | 348 | </LinearLayout> |
348 | 349 | ||
349 | <LinearLayout | 350 | <LinearLayout |
350 | android:layout_width="match_parent" | 351 | android:layout_width="match_parent" |
351 | android:layout_height="wrap_content"> | 352 | android:layout_height="wrap_content"> |
352 | 353 | ||
353 | <android.support.v7.widget.RecyclerView | 354 | <android.support.v7.widget.RecyclerView |
354 | android:id="@+id/id_recyclerview_horizontal" | 355 | android:id="@+id/id_recyclerview_horizontal" |
355 | android:layout_width="match_parent" | 356 | android:layout_width="match_parent" |
356 | android:layout_height="match_parent" | 357 | android:layout_height="match_parent" |
357 | android:layout_centerVertical="true" | 358 | android:layout_centerVertical="true" |
358 | android:scrollbars="none" /> | 359 | android:scrollbars="none" /> |
359 | </LinearLayout> | 360 | </LinearLayout> |
360 | 361 | ||
361 | <View | 362 | <View |
362 | android:layout_width="match_parent" | 363 | android:layout_width="match_parent" |
363 | android:layout_height="0.7dp" | 364 | android:layout_height="0.7dp" |
364 | android:background="@color/cutoff_line"> | 365 | android:background="@color/cutoff_line"> |
365 | 366 | ||
366 | </View> | 367 | </View> |
367 | 368 | ||
368 | <LinearLayout | 369 | <LinearLayout |
369 | android:layout_width="match_parent" | 370 | android:layout_width="match_parent" |
370 | android:layout_height="wrap_content" | 371 | android:layout_height="wrap_content" |
371 | android:layout_margin="20dp" | 372 | android:layout_margin="20dp" |
372 | android:gravity="center_vertical" | 373 | android:gravity="center_vertical" |
373 | android:orientation="horizontal"> | 374 | android:orientation="horizontal"> |
374 | 375 | ||
375 | <View | 376 | <View |
376 | android:layout_width="5dp" | 377 | android:layout_width="5dp" |
377 | android:layout_height="20dp" | 378 | android:layout_height="20dp" |
378 | android:background="@color/login_text_blue"> | 379 | android:background="@color/login_text_blue"> |
379 | 380 | ||
380 | </View> | 381 | </View> |
381 | 382 | ||
382 | <TextView | 383 | <TextView |
383 | android:layout_width="0dp" | 384 | android:layout_width="0dp" |
384 | android:layout_height="wrap_content" | 385 | android:layout_height="wrap_content" |
385 | android:layout_marginLeft="5dp" | 386 | android:layout_marginLeft="5dp" |
386 | android:layout_weight="2" | 387 | android:layout_weight="5" |
387 | android:text="个人信息" | 388 | android:text="个人信息" |
388 | android:textSize="22sp" /> | 389 | android:textSize="22sp" /> |
389 | 390 | ||
390 | <TextView | 391 | <TextView |
391 | android:id="@+id/tv_edit_presoninfo" | 392 | android:id="@+id/tv_edit_presoninfo" |
392 | android:padding="5dp" | 393 | android:padding="5dp" |
393 | android:layout_width="0dp" | 394 | android:layout_width="0dp" |
394 | android:layout_height="wrap_content" | 395 | android:layout_height="wrap_content" |
395 | android:layout_marginLeft="10dp" | 396 | android:layout_marginLeft="10dp" |
396 | android:layout_weight="0.2" | 397 | android:layout_weight="0.4" |
397 | android:text="编辑" | 398 | android:text="编辑" |
398 | android:textSize="18sp" /> | 399 | android:textSize="18sp" /> |
399 | 400 | ||
400 | <ImageView | 401 | <ImageView |
401 | android:layout_width="0dp" | 402 | android:layout_width="0dp" |
402 | android:layout_height="wrap_content" | 403 | android:layout_height="wrap_content" |
403 | android:layout_weight="0.1" | 404 | android:layout_weight="0.1" |
404 | 405 | ||
405 | android:src="@mipmap/youjiantou" /> | 406 | android:src="@mipmap/youjiantou" /> |
406 | 407 | ||
407 | 408 | ||
408 | </LinearLayout> | 409 | </LinearLayout> |
409 | 410 | ||
410 | <LinearLayout | 411 | <LinearLayout |
411 | android:layout_width="match_parent" | 412 | android:layout_width="match_parent" |
412 | android:layout_height="wrap_content" | 413 | android:layout_height="wrap_content" |
413 | android:layout_marginLeft="50dp" | 414 | android:layout_marginLeft="50dp" |
414 | android:layout_marginTop="10dp" | 415 | android:layout_marginTop="10dp" |
415 | android:orientation="vertical"> | 416 | android:orientation="vertical"> |
416 | 417 | ||
417 | <LinearLayout | 418 | <LinearLayout |
418 | android:layout_width="match_parent" | 419 | android:layout_width="match_parent" |
419 | android:layout_height="wrap_content" | 420 | android:layout_height="wrap_content" |
420 | android:gravity="center_vertical" | 421 | android:gravity="center_vertical" |
421 | android:orientation="horizontal"> | 422 | android:orientation="horizontal"> |
422 | 423 | ||
423 | <TextView | 424 | <TextView |
424 | android:layout_width="0dp" | 425 | android:layout_width="0dp" |
425 | android:layout_height="wrap_content" | 426 | android:layout_height="wrap_content" |
426 | android:layout_weight="1" | 427 | android:layout_weight="1" |
427 | android:text="昵称" | 428 | android:text="昵称" |
428 | android:textSize="20sp" /> | 429 | android:textSize="20sp" /> |
429 | 430 | ||
430 | <TextView | 431 | <TextView |
431 | android:id="@+id/tv_username1" | 432 | android:id="@+id/tv_username1" |
432 | android:layout_width="0dp" | 433 | android:layout_width="0dp" |
433 | android:layout_height="wrap_content" | 434 | android:layout_height="wrap_content" |
434 | android:layout_weight="2" | 435 | android:layout_weight="2" |
435 | android:hint="未填写" | 436 | android:hint="未填写" |
436 | android:textSize="20sp" /> | 437 | android:textSize="20sp" /> |
437 | 438 | ||
438 | <TextView | 439 | <TextView |
439 | android:layout_width="1dp" | 440 | android:layout_width="1dp" |
440 | android:layout_height="wrap_content" | 441 | android:layout_height="wrap_content" |
441 | android:layout_weight="1" | 442 | android:layout_weight="1" |
442 | android:text="星座" | 443 | android:text="星座" |
443 | android:textSize="20sp" /> | 444 | android:textSize="20sp" /> |
444 | 445 | ||
445 | <TextView | 446 | <TextView |
446 | android:id="@+id/tv_mygad" | 447 | android:id="@+id/tv_mygad" |
447 | android:layout_width="0dp" | 448 | android:layout_width="0dp" |
448 | android:layout_height="wrap_content" | 449 | android:layout_height="wrap_content" |
449 | android:layout_weight="2" | 450 | android:layout_weight="2" |
450 | android:hint="未填写" | 451 | android:hint="未填写" |
451 | android:textSize="20sp" /> | 452 | android:textSize="20sp" /> |
452 | </LinearLayout> | 453 | </LinearLayout> |
453 | 454 | ||
454 | <LinearLayout | 455 | <LinearLayout |
455 | android:layout_width="match_parent" | 456 | android:layout_width="match_parent" |
456 | android:layout_height="wrap_content" | 457 | android:layout_height="wrap_content" |
457 | android:layout_marginTop="20dp" | 458 | android:layout_marginTop="20dp" |
458 | android:gravity="center_vertical" | 459 | android:gravity="center_vertical" |
459 | android:orientation="horizontal"> | 460 | android:orientation="horizontal"> |
460 | 461 | ||
461 | <TextView | 462 | <TextView |
462 | android:layout_width="0dp" | 463 | android:layout_width="0dp" |
463 | android:layout_height="wrap_content" | 464 | android:layout_height="wrap_content" |
464 | android:layout_weight="1" | 465 | android:layout_weight="1" |
465 | android:text="性别" | 466 | android:text="性别" |
466 | android:textSize="20sp" /> | 467 | android:textSize="20sp" /> |
467 | 468 | ||
468 | <TextView | 469 | <TextView |
469 | android:id="@+id/tv_sex" | 470 | android:id="@+id/tv_sex" |
470 | android:layout_width="0dp" | 471 | android:layout_width="0dp" |
471 | android:layout_height="wrap_content" | 472 | android:layout_height="wrap_content" |
472 | android:layout_weight="2" | 473 | android:layout_weight="2" |
473 | android:hint="未填写" | 474 | android:hint="未填写" |
474 | android:textSize="20sp" /> | 475 | android:textSize="20sp" /> |
475 | 476 | ||
476 | <TextView | 477 | <TextView |
477 | android:layout_width="1dp" | 478 | android:layout_width="1dp" |
478 | android:layout_height="wrap_content" | 479 | android:layout_height="wrap_content" |
479 | android:layout_weight="1" | 480 | android:layout_weight="1" |
480 | android:text="地区" | 481 | android:text="地区" |
481 | android:textSize="20sp" /> | 482 | android:textSize="20sp" /> |
482 | 483 | ||
483 | <TextView | 484 | <TextView |
484 | android:id="@+id/tv_useinfo_adress" | 485 | android:id="@+id/tv_useinfo_adress" |
485 | android:layout_width="0dp" | 486 | android:layout_width="0dp" |
486 | android:layout_height="wrap_content" | 487 | android:layout_height="wrap_content" |
487 | android:layout_weight="2" | 488 | android:layout_weight="2" |
488 | android:hint="未填写" | 489 | android:hint="未填写" |
489 | android:textSize="20sp" /> | 490 | android:textSize="20sp" /> |
490 | </LinearLayout> | 491 | </LinearLayout> |
491 | 492 | ||
492 | <LinearLayout | 493 | <LinearLayout |
493 | android:layout_width="match_parent" | 494 | android:layout_width="match_parent" |
494 | android:layout_height="wrap_content" | 495 | android:layout_height="wrap_content" |
495 | android:layout_marginTop="20dp" | 496 | android:layout_marginTop="20dp" |
496 | android:gravity="center_vertical" | 497 | android:gravity="center_vertical" |
497 | android:orientation="horizontal"> | 498 | android:orientation="horizontal"> |
498 | 499 | ||
499 | <TextView | 500 | <TextView |
500 | android:layout_width="0dp" | 501 | android:layout_width="0dp" |
501 | android:layout_height="wrap_content" | 502 | android:layout_height="wrap_content" |
502 | android:layout_weight="1" | 503 | android:layout_weight="1" |
503 | android:text="生日" | 504 | android:text="生日" |
504 | android:textSize="20sp" /> | 505 | android:textSize="20sp" /> |
505 | 506 | ||
506 | <TextView | 507 | <TextView |
507 | android:id="@+id/tv_useinfo_birthday" | 508 | android:id="@+id/tv_useinfo_birthday" |
508 | android:layout_width="0dp" | 509 | android:layout_width="0dp" |
509 | android:layout_height="wrap_content" | 510 | android:layout_height="wrap_content" |
510 | android:layout_weight="2" | 511 | android:layout_weight="2" |
511 | android:hint="未填写" | 512 | android:hint="未填写" |
512 | android:textSize="20sp" /> | 513 | android:textSize="20sp" /> |
513 | 514 | ||
514 | <TextView | 515 | <TextView |
515 | android:layout_width="1dp" | 516 | android:layout_width="1dp" |
516 | android:layout_height="wrap_content" | 517 | android:layout_height="wrap_content" |
517 | android:layout_weight="1" | 518 | android:layout_weight="1" |
518 | android:text="学校" | 519 | android:text="学校" |
519 | android:textSize="20sp" /> | 520 | android:textSize="20sp" /> |
520 | 521 | ||
521 | <TextView | 522 | <TextView |
522 | android:id="@+id/tv_useinfo_school" | 523 | android:id="@+id/tv_useinfo_school" |
523 | android:layout_width="0dp" | 524 | android:layout_width="0dp" |
524 | android:layout_height="wrap_content" | 525 | android:layout_height="wrap_content" |
525 | android:layout_weight="2" | 526 | android:layout_weight="2" |
526 | android:hint="未填写" | 527 | android:hint="未填写" |
527 | android:textSize="20sp" /> | 528 | android:textSize="20sp" /> |
528 | </LinearLayout> | 529 | </LinearLayout> |
529 | 530 | ||
530 | <LinearLayout | 531 | <LinearLayout |
531 | android:layout_width="match_parent" | 532 | android:layout_width="match_parent" |
532 | android:layout_height="wrap_content" | 533 | android:layout_height="wrap_content" |
533 | android:layout_marginTop="20dp" | 534 | android:layout_marginTop="20dp" |
534 | android:gravity="center_vertical" | 535 | android:gravity="center_vertical" |
535 | android:orientation="horizontal"> | 536 | android:orientation="horizontal"> |
536 | 537 | ||
537 | <TextView | 538 | <TextView |
538 | android:layout_width="0dp" | 539 | android:layout_width="0dp" |
539 | android:layout_height="wrap_content" | 540 | android:layout_height="wrap_content" |
540 | android:layout_weight="1" | 541 | android:layout_weight="1" |
541 | android:text="Q Q" | 542 | android:text=" Q Q" |
542 | android:textSize="20sp" /> | 543 | android:textSize="20sp" /> |
543 | 544 | ||
544 | <TextView | 545 | <TextView |
545 | android:id="@+id/tv_useinfo_qq" | 546 | android:id="@+id/tv_useinfo_qq" |
546 | android:layout_width="0dp" | 547 | android:layout_width="0dp" |
547 | android:layout_height="wrap_content" | 548 | android:layout_height="wrap_content" |
548 | android:layout_weight="2" | 549 | android:layout_weight="2" |
549 | android:hint="未填写" | 550 | android:hint="未填写" |
550 | android:textSize="20sp" /> | 551 | android:textSize="20sp" /> |
551 | 552 | ||
552 | <TextView | 553 | <TextView |
553 | android:layout_width="1dp" | 554 | android:layout_width="1dp" |
554 | android:layout_height="wrap_content" | 555 | android:layout_height="wrap_content" |
555 | android:layout_weight="1" | 556 | android:layout_weight="1" |
556 | android:text="年级" | 557 | android:text="年级" |
557 | android:textSize="20sp" /> | 558 | android:textSize="20sp" /> |
558 | 559 | ||
559 | <TextView | 560 | <TextView |
560 | android:id="@+id/tv_useinfo_gender" | 561 | android:id="@+id/tv_useinfo_gender" |
561 | android:layout_width="0dp" | 562 | android:layout_width="0dp" |
562 | android:layout_height="wrap_content" | 563 | android:layout_height="wrap_content" |
563 | android:layout_weight="2" | 564 | android:layout_weight="2" |
564 | android:hint="未填写" | 565 | android:hint="未填写" |
565 | android:textSize="20sp" /> | 566 | android:textSize="20sp" /> |
566 | </LinearLayout> | 567 | </LinearLayout> |
567 | 568 | ||
568 | 569 | ||
569 | </LinearLayout> | 570 | </LinearLayout> |
570 | <View | 571 | <View |
571 | android:layout_width="match_parent" | 572 | android:layout_width="match_parent" |
572 | android:layout_height="0.7dp" | 573 | android:layout_height="0.7dp" |
573 | android:layout_marginTop="20dp" | 574 | android:layout_marginTop="20dp" |
574 | android:background="@color/cutoff_line"> | 575 | android:background="@color/cutoff_line"> |
575 | 576 | ||
576 | </View> | 577 | </View> |
577 | <LinearLayout | 578 | <LinearLayout |
578 | android:layout_width="match_parent" | 579 | android:layout_width="match_parent" |
579 | android:layout_height="wrap_content" | 580 | android:layout_height="wrap_content" |
580 | android:layout_margin="20dp" | 581 | android:layout_margin="20dp" |
581 | android:gravity="center_vertical" | 582 | android:gravity="center_vertical" |
582 | android:orientation="horizontal"> | 583 | android:orientation="horizontal"> |
583 | 584 | ||
584 | <View | 585 | <View |
585 | android:layout_width="5dp" | 586 | android:layout_width="5dp" |
586 | android:layout_height="20dp" | 587 | android:layout_height="20dp" |
587 | android:background="@color/login_text_blue"> | 588 | android:background="@color/login_text_blue"> |
588 | 589 | ||
589 | </View> | 590 | </View> |
590 | 591 | ||
591 | <TextView | 592 | <TextView |
592 | android:layout_width="wrap_content" | 593 | android:layout_width="wrap_content" |
593 | android:layout_height="wrap_content" | 594 | android:layout_height="wrap_content" |
594 | android:layout_marginLeft="5dp" | 595 | android:layout_marginLeft="5dp" |
595 | android:text="版本信息" | 596 | android:text="版本信息" |
596 | android:textSize="22sp" /> | 597 | android:textSize="22sp" /> |
597 | 598 | ||
598 | </LinearLayout> | 599 | </LinearLayout> |
599 | 600 | ||
600 | <LinearLayout | 601 | <LinearLayout |
601 | android:layout_width="match_parent" | 602 | android:layout_width="match_parent" |
602 | android:layout_height="wrap_content" | 603 | android:layout_height="wrap_content" |
603 | android:layout_marginTop="20dp"> | 604 | android:layout_marginTop="20dp"> |
604 | 605 | ||
605 | <TextView | 606 | <TextView |
606 | android:layout_width="match_parent" | 607 | android:layout_width="match_parent" |
607 | android:layout_height="100dp" | 608 | android:layout_height="100dp" |
608 | android:layout_marginLeft="20dp" | 609 | android:layout_marginLeft="20dp" |
609 | android:layout_marginTop="10dp" | 610 | android:layout_marginTop="10dp" |
610 | android:gravity="center" | 611 | android:gravity="center" |
611 | android:text="这里需要显示水平滑动的" /> | 612 | android:text="这里需要显示水平滑动的" /> |
612 | </LinearLayout> | 613 | </LinearLayout> |
613 | 614 | ||
614 | 615 | ||
615 | </LinearLayout> | 616 | </LinearLayout> |
616 | 617 | ||
617 | 618 | ||
618 | </LinearLayout> | 619 | </LinearLayout> |
619 | 620 | ||
620 | 621 | ||
621 | </LinearLayout> | 622 | </LinearLayout> |
622 | 623 |
PersonalCenter/app/src/main/res/layout/fragment_changge_version_info_itmes.xml
1 | <?xml version="1.0" encoding="utf-8"?> | 1 | <?xml version="1.0" encoding="utf-8"?> |
2 | <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | 2 | <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" |
3 | xmlns:fresco="http://schemas.android.com/apk/res-auto" | ||
3 | android:orientation="vertical" | 4 | android:orientation="vertical" |
4 | android:layout_width="match_parent" | 5 | android:layout_width="match_parent" |
5 | android:layout_height="match_parent" | 6 | android:layout_height="match_parent" |
6 | android:gravity="center"> | 7 | android:gravity="center"> |
7 | 8 | ||
8 | 9 | ||
9 | <ImageView | 10 | <com.facebook.drawee.view.SimpleDraweeView |
10 | android:src="@mipmap/ic_launcher" | 11 | android:id="@+id/image_publish" |
11 | android:id="@+id/image" | ||
12 | android:layout_width="100dp" | 12 | android:layout_width="100dp" |
13 | android:background="@drawable/corcle_black_bg" | ||
14 | android:layout_height="150dp" | 13 | android:layout_height="150dp" |
14 | android:layout_gravity="center" | ||
15 | android:background="@drawable/corcle_black_bg" | ||
16 | fresco:placeholderImage="@mipmap/header_default" | ||
17 | fresco:roundAsCircle="true" | ||
18 | fresco:placeholderImageScaleType="fitCenter" /> | ||
15 | 19 | ||
16 | /> | ||
17 | <TextView | 20 | <TextView |
18 | android:id="@+id/text" | 21 | android:id="@+id/subject" |
19 | android:layout_marginTop="5dp" | 22 | android:layout_marginTop="5dp" |
20 | android:textSize="22sp" | 23 | android:textSize="22sp" |
21 | android:layout_width="wrap_content" | 24 | android:layout_width="wrap_content" |
22 | android:layout_height="wrap_content" | 25 | android:layout_height="wrap_content" |
23 | android:textColor="@color/login_text_black" | 26 | android:textColor="@color/login_text_black" |
24 | android:text="" | 27 | android:text="" |
25 | /> | 28 | /> |
26 | <TextView | 29 | <TextView |
27 | android:id="@+id/tv_publish" | 30 | android:id="@+id/tv_publish" |
28 | android:layout_marginTop="10dp" | 31 | android:layout_marginTop="10dp" |
29 | android:textSize="18sp" | 32 | android:textSize="18sp" |
30 | android:layout_width="wrap_content" | 33 | android:layout_width="wrap_content" |
31 | android:layout_height="wrap_content" | 34 | android:layout_height="wrap_content" |
32 | android:textColor="@color/login_text_black" | 35 | android:textColor="@color/login_text_black" |
33 | android:text="人民教育出版社" | 36 | android:text="" |
PersonalCenter/app/src/main/res/values/styles.xml
1 | <resources> | 1 | <resources> |
2 | 2 | ||
3 | <!-- Base application theme. --> | 3 | <!-- Base application theme. --> |
4 | <style name="AppTheme" parent="Theme.AppCompat"> | 4 | <style name="AppTheme" parent="Theme.AppCompat"> |
5 | <!-- Customize your theme here. --> | 5 | <!-- Customize your theme here. --> |
6 | <item name="colorPrimary">@color/colorPrimary</item> | 6 | <item name="colorPrimary">@color/colorPrimary</item> |
7 | <item name="colorPrimaryDark">@color/colorPrimaryDark</item> | 7 | <item name="colorPrimaryDark">@color/colorPrimaryDark</item> |
8 | <item name="colorAccent">@color/colorAccent</item> | 8 | <item name="colorAccent">@color/colorAccent</item> |
9 | </style> | 9 | </style> |
10 | 10 | ||
11 | <style name="login_register_edit_style"> | 11 | <style name="login_register_edit_style"> |
12 | <item name="android:textSize">19sp</item> | 12 | <item name="android:textSize">19sp</item> |
13 | <item name="android:singleLine">true</item> | 13 | <item name="android:singleLine">true</item> |
14 | <item name="android:background">@drawable/selector_edittext_bg</item> | 14 | <item name="android:background">@drawable/selector_edittext_bg</item> |
15 | <item name="android:layout_width">match_parent</item> | 15 | <item name="android:layout_width">match_parent</item> |
16 | <item name="android:layout_height">wrap_content</item> | 16 | <item name="android:layout_height">wrap_content</item> |
17 | <item name="android:textColorHint">@color/login_edittext_hint</item> | 17 | <item name="android:textColorHint">@color/login_edittext_hint</item> |
18 | <item name="android:padding">10dp</item> | 18 | <item name="android:padding">10dp</item> |
19 | </style> | 19 | </style> |
20 | 20 | ||
21 | <style name="login_register_edit_rect_style"> | 21 | <style name="login_register_edit_rect_style"> |
22 | <item name="android:textSize">19sp</item> | 22 | <item name="android:textSize">19sp</item> |
23 | <item name="android:singleLine">true</item> | 23 | <item name="android:singleLine">true</item> |
24 | <item name="android:background">@drawable/selector_edittext_rect_bg</item> | 24 | <item name="android:background">@drawable/selector_edittext_rect_bg</item> |
25 | <item name="android:layout_width">match_parent</item> | 25 | <item name="android:layout_width">match_parent</item> |
26 | <item name="android:layout_height">wrap_content</item> | 26 | <item name="android:layout_height">wrap_content</item> |
27 | <item name="android:textColorHint">@color/login_edittext_hint</item> | 27 | <item name="android:textColorHint">@color/login_edittext_hint</item> |
28 | <item name="android:padding">10dp</item> | 28 | <item name="android:padding">10dp</item> |
29 | </style> | 29 | </style> |
30 | 30 | ||
31 | <style name="login_register_btn_authcode_rect_style"> | 31 | <style name="login_register_btn_authcode_rect_style"> |
32 | <item name="android:textSize">19sp</item> | 32 | <item name="android:textSize">19sp</item> |
33 | <item name="android:singleLine">true</item> | 33 | <item name="android:singleLine">true</item> |
34 | <item name="android:background">@drawable/btn_rect_normal</item> | 34 | <item name="android:background">@drawable/btn_rect_normal</item> |
35 | <item name="android:layout_width">match_parent</item> | 35 | <item name="android:layout_width">match_parent</item> |
36 | <item name="android:layout_height">wrap_content</item> | 36 | <item name="android:layout_height">wrap_content</item> |
37 | <item name="android:textColorHint">@color/login_edittext_hint</item> | 37 | <item name="android:textColorHint">@color/login_edittext_hint</item> |
38 | <item name="android:padding">10dp</item> | 38 | <item name="android:padding">10dp</item> |
39 | </style> | 39 | </style> |
40 | <style name="text_login_register_style" > | 40 | <style name="text_login_register_style" > |
41 | <item name="android:layout_width">wrap_content</item> | 41 | <item name="android:layout_width">wrap_content</item> |
42 | <item name="android:layout_height">wrap_content</item> | 42 | <item name="android:layout_height">wrap_content</item> |
43 | <item name="android:textSize">22sp</item> | 43 | <item name="android:textSize">22sp</item> |
44 | <item name="android:gravity">center</item> | 44 | <item name="android:gravity">center</item> |
45 | <item name="android:padding">10dp</item> | 45 | <item name="android:padding">10dp</item> |
46 | </style> | 46 | </style> |
47 | <style name="button_login_register_style"> | 47 | <style name="button_login_register_style"> |
48 | <item name="android:layout_width">match_parent</item> | 48 | <item name="android:layout_width">match_parent</item> |
49 | <item name="android:layout_height">wrap_content</item> | 49 | <item name="android:layout_height">wrap_content</item> |
50 | <item name="android:background">@drawable/selector_blue_btn_bg</item> | 50 | <item name="android:background">@drawable/selector_blue_btn_bg</item> |
51 | <item name="android:textSize">23sp</item> | 51 | <item name="android:textSize">23sp</item> |
52 | |||
52 | <item name="android:gravity">center</item> | 53 | <item name="android:gravity">center</item> |
53 | <item name="android:padding">10dp</item> | 54 | <item name="android:padding">10dp</item> |
54 | <item name="android:textColor">@android:color/white</item> | 55 | <item name="android:textColor">@android:color/white</item> |
55 | </style> | 56 | </style> |
56 | <style name="text_forget_pwd_style" > | 57 | <style name="text_forget_pwd_style" > |
57 | <item name="android:layout_width">wrap_content</item> | 58 | <item name="android:layout_width">wrap_content</item> |
58 | <item name="android:layout_height">wrap_content</item> | 59 | <item name="android:layout_height">wrap_content</item> |
59 | <item name="android:textSize">18sp</item> | 60 | <item name="android:textSize">18sp</item> |
60 | <item name="android:gravity">center</item> | 61 | <item name="android:gravity">center</item> |
61 | <item name="android:padding">8dp</item> | 62 | <item name="android:padding">8dp</item> |
62 | </style> | 63 | </style> |
63 | <style name="registererrhint_style"> | 64 | <style name="registererrhint_style"> |
64 | <item name="android:textSize">14dip</item> | 65 | <item name="android:textSize">14dip</item> |
65 | <item name="android:layout_width">match_parent</item> | 66 | <item name="android:layout_width">match_parent</item> |
66 | <item name="android:layout_height">wrap_content</item> | 67 | <item name="android:layout_height">wrap_content</item> |
67 | <item name="android:textColor">@color/error_hint</item> | 68 | <item name="android:textColor">@color/error_hint</item> |
68 | <item name="android:layout_marginTop">5dip</item> | 69 | <item name="android:layout_marginTop">5dip</item> |
69 | </style> | 70 | </style> |
70 | <style name="iv_pwd_change_style"> | 71 | <style name="iv_pwd_change_style"> |
71 | <item name="android:layout_width">wrap_content</item> | 72 | <item name="android:layout_width">wrap_content</item> |
72 | <item name="android:layout_height">wrap_content</item> | 73 | <item name="android:layout_height">wrap_content</item> |
73 | <item name="android:background">@mipmap/pwd_hide</item> | 74 | <item name="android:background">@mipmap/pwd_hide</item> |
74 | <item name="android:layout_alignParentRight">true</item> | 75 | <item name="android:layout_alignParentRight">true</item> |
75 | <item name="android:layout_centerVertical">true</item> | 76 | <item name="android:layout_centerVertical">true</item> |
76 | <item name="android:layout_marginRight">15dp</item> | 77 | <item name="android:layout_marginRight">15dp</item> |
77 | </style> | 78 | </style> |
78 | <style name="dialogWindowAnim" parent="android:Animation" mce_bogus="1"> | 79 | <style name="dialogWindowAnim" parent="android:Animation" mce_bogus="1"> |
79 | <item name="android:windowEnterAnimation">@anim/dialog_enter_anim</item> | 80 | <item name="android:windowEnterAnimation">@anim/dialog_enter_anim</item> |
80 | <item name="android:windowExitAnimation">@anim/dialog_exit_anim</item> | 81 | <item name="android:windowExitAnimation">@anim/dialog_exit_anim</item> |
81 | </style> | 82 | </style> |
82 | 83 | ||
83 | 84 | ||
84 | 85 | ||
85 | 86 | ||
86 | </resources> | 87 | </resources> |
87 | 88 |
PersonalCenter/circledialog/src/main/java/com/mylhyl/circledialog/CircleDialog.java
1 | package com.mylhyl.circledialog; | 1 | package com.mylhyl.circledialog; |
2 | 2 | ||
3 | import android.support.annotation.ColorInt; | 3 | import android.support.annotation.ColorInt; |
4 | import android.support.annotation.DrawableRes; | 4 | import android.support.annotation.DrawableRes; |
5 | import android.support.annotation.FloatRange; | 5 | import android.support.annotation.FloatRange; |
6 | import android.support.annotation.NonNull; | 6 | import android.support.annotation.NonNull; |
7 | import android.support.v4.app.DialogFragment; | 7 | import android.support.v4.app.DialogFragment; |
8 | import android.support.v4.app.FragmentActivity; | 8 | import android.support.v4.app.FragmentActivity; |
9 | import android.view.Gravity; | 9 | import android.view.Gravity; |
10 | import android.view.View; | 10 | import android.view.View; |
11 | import android.widget.AdapterView; | 11 | import android.widget.AdapterView; |
12 | 12 | ||
13 | import com.mylhyl.circledialog.callback.ConfigButton; | 13 | import com.mylhyl.circledialog.callback.ConfigButton; |
14 | import com.mylhyl.circledialog.callback.ConfigDialog; | 14 | import com.mylhyl.circledialog.callback.ConfigDialog; |
15 | import com.mylhyl.circledialog.callback.ConfigInput; | 15 | import com.mylhyl.circledialog.callback.ConfigInput; |
16 | import com.mylhyl.circledialog.callback.ConfigItems; | 16 | import com.mylhyl.circledialog.callback.ConfigItems; |
17 | import com.mylhyl.circledialog.callback.ConfigProgress; | 17 | import com.mylhyl.circledialog.callback.ConfigProgress; |
18 | import com.mylhyl.circledialog.callback.ConfigText; | 18 | import com.mylhyl.circledialog.callback.ConfigText; |
19 | import com.mylhyl.circledialog.callback.ConfigTitle; | 19 | import com.mylhyl.circledialog.callback.ConfigTitle; |
20 | import com.mylhyl.circledialog.params.ButtonParams; | 20 | import com.mylhyl.circledialog.params.ButtonParams; |
21 | import com.mylhyl.circledialog.params.CircleParams; | 21 | import com.mylhyl.circledialog.params.CircleParams; |
22 | import com.mylhyl.circledialog.params.DialogParams; | 22 | import com.mylhyl.circledialog.params.DialogParams; |
23 | import com.mylhyl.circledialog.params.InputParams; | 23 | import com.mylhyl.circledialog.params.InputParams; |
24 | import com.mylhyl.circledialog.params.ItemsParams; | 24 | import com.mylhyl.circledialog.params.ItemsParams; |
25 | import com.mylhyl.circledialog.params.ProgressParams; | 25 | import com.mylhyl.circledialog.params.ProgressParams; |
26 | import com.mylhyl.circledialog.params.TextParams; | 26 | import com.mylhyl.circledialog.params.TextParams; |
27 | import com.mylhyl.circledialog.params.TitleParams; | 27 | import com.mylhyl.circledialog.params.TitleParams; |
28 | import com.mylhyl.circledialog.view.listener.OnInputClickListener; | 28 | import com.mylhyl.circledialog.view.listener.OnInputClickListener; |
29 | 29 | ||
30 | /** | 30 | /** |
31 | * Created by hupei on 2017/3/29. | 31 | * Created by hupei on 2017/3/29. |
32 | */ | 32 | */ |
33 | 33 | ||
34 | public final class CircleDialog { | 34 | public final class CircleDialog { |
35 | private AbsCircleDialog mDialog; | 35 | private AbsCircleDialog mDialog; |
36 | 36 | ||
37 | private CircleDialog() { | 37 | private CircleDialog() { |
38 | } | 38 | } |
39 | 39 | ||
40 | public DialogFragment create(CircleParams params) { | 40 | public DialogFragment create(CircleParams params) { |
41 | if (mDialog == null) | 41 | if (mDialog == null) |
42 | mDialog = AbsCircleDialog.newAbsCircleDialog(params); | 42 | mDialog = AbsCircleDialog.newAbsCircleDialog(params); |
43 | else { | 43 | else { |
44 | if (mDialog != null && mDialog.getDialog() != null && mDialog.getDialog().isShowing()) { | 44 | if (mDialog != null && mDialog.getDialog() != null && mDialog.getDialog().isShowing()) { |
45 | mDialog.refreshView(); | 45 | mDialog.refreshView(); |
46 | } | 46 | } |
47 | } | 47 | } |
48 | return mDialog; | 48 | return mDialog; |
49 | } | 49 | } |
50 | 50 | ||
51 | public void show(FragmentActivity activity) { | 51 | public void show(FragmentActivity activity) { |
52 | mDialog.show(activity.getSupportFragmentManager(), "circleDialog"); | 52 | mDialog.show(activity.getSupportFragmentManager(), "circleDialog"); |
53 | } | 53 | } |
54 | 54 | ||
55 | public static class Builder { | 55 | public static class Builder { |
56 | private FragmentActivity mActivity; | 56 | private FragmentActivity mActivity; |
57 | private CircleDialog mCircleDialog; | 57 | private CircleDialog mCircleDialog; |
58 | private CircleParams mCircleParams; | 58 | private CircleParams mCircleParams; |
59 | 59 | ||
60 | 60 | ||
61 | public Builder(@NonNull FragmentActivity activity) { | 61 | public Builder(@NonNull FragmentActivity activity) { |
62 | this.mActivity = activity; | 62 | this.mActivity = activity; |
63 | mCircleParams = new CircleParams(); | 63 | mCircleParams = new CircleParams(); |
64 | mCircleParams.dialogParams = new DialogParams(); | 64 | mCircleParams.dialogParams = new DialogParams(); |
65 | } | 65 | } |
66 | 66 | ||
67 | |||
68 | |||
67 | /** | 69 | /** |
68 | * 设置对话框位置 | 70 | * 设置对话框位置 |
69 | * | 71 | * |
70 | * @param gravity 位置 | 72 | * @param gravity 位置 |
71 | * @return builder | 73 | * @return builder |
72 | */ | 74 | */ |
73 | public Builder setGravity(int gravity) { | 75 | public Builder setGravity(int gravity) { |
74 | mCircleParams.dialogParams.gravity = gravity; | 76 | mCircleParams.dialogParams.gravity = gravity; |
75 | return this; | 77 | return this; |
76 | } | 78 | } |
77 | 79 | ||
78 | /** | 80 | /** |
79 | * 设置对话框点击外部关闭 | 81 | * 设置对话框点击外部关闭 |
80 | * | 82 | * |
81 | * @param cancel true允许 | 83 | * @param cancel true允许 |
82 | * @return Builder | 84 | * @return Builder |
83 | */ | 85 | */ |
84 | public Builder setCanceledOnTouchOutside(boolean cancel) { | 86 | public Builder setCanceledOnTouchOutside(boolean cancel) { |
85 | mCircleParams.dialogParams.canceledOnTouchOutside = cancel; | 87 | mCircleParams.dialogParams.canceledOnTouchOutside = cancel; |
86 | return this; | 88 | return this; |
87 | } | 89 | } |
88 | 90 | ||
89 | /** | 91 | /** |
90 | * 设置对话框返回键关闭 | 92 | * 设置对话框返回键关闭 |
91 | * | 93 | * |
92 | * @param cancel true允许 | 94 | * @param cancel true允许 |
93 | * @return Builder | 95 | * @return Builder |
94 | */ | 96 | */ |
95 | public Builder setCancelable(boolean cancel) { | 97 | public Builder setCancelable(boolean cancel) { |
96 | mCircleParams.dialogParams.cancelable = cancel; | 98 | mCircleParams.dialogParams.cancelable = cancel; |
97 | return this; | 99 | return this; |
98 | } | 100 | } |
99 | 101 | ||
100 | /** | 102 | /** |
101 | * 设置对话框宽度 | 103 | * 设置对话框宽度 |
102 | * | 104 | * |
103 | * @param width 0.0 - 1.0 | 105 | * @param width 0.0 - 1.0 |
104 | * @return Builder | 106 | * @return Builder |
105 | */ | 107 | */ |
106 | public Builder setWidth(@FloatRange(from = 0.0, to = 1.0) float width) { | 108 | public Builder setWidth(@FloatRange(from = 0.0, to = 1.0) float width) { |
107 | mCircleParams.dialogParams.width = width; | 109 | mCircleParams.dialogParams.width = width; |
108 | return this; | 110 | return this; |
109 | } | 111 | } |
110 | 112 | ||
111 | /** | 113 | /** |
112 | * 设置对话框圆角 | 114 | * 设置对话框圆角 |
113 | * | 115 | * |
114 | * @param radius 半径 | 116 | * @param radius 半径 |
115 | * @return Builder | 117 | * @return Builder |
116 | */ | 118 | */ |
117 | public Builder setRadius(int radius) { | 119 | public Builder setRadius(int radius) { |
118 | mCircleParams.dialogParams.radius = radius; | 120 | mCircleParams.dialogParams.radius = radius; |
119 | return this; | 121 | return this; |
120 | } | 122 | } |
121 | 123 | ||
122 | public Builder configDialog(@NonNull ConfigDialog configDialog) { | 124 | public Builder configDialog(@NonNull ConfigDialog configDialog) { |
123 | configDialog.onConfig(mCircleParams.dialogParams); | 125 | configDialog.onConfig(mCircleParams.dialogParams); |
124 | return this; | 126 | return this; |
125 | } | 127 | } |
126 | 128 | ||
127 | public Builder setTitle(@NonNull String text) { | 129 | public Builder setTitle(@NonNull String text) { |
128 | newTitleParams(); | 130 | newTitleParams(); |
129 | mCircleParams.titleParams.text = text; | 131 | mCircleParams.titleParams.text = text; |
130 | return this; | 132 | return this; |
131 | } | 133 | } |
132 | 134 | ||
133 | public Builder setTitleColor(@ColorInt int color) { | 135 | public Builder setTitleColor(@ColorInt int color) { |
134 | newTitleParams(); | 136 | newTitleParams(); |
135 | mCircleParams.titleParams.textColor = color; | 137 | mCircleParams.titleParams.textColor = color; |
136 | return this; | 138 | return this; |
137 | } | 139 | } |
138 | 140 | ||
139 | public Builder configTitle(@NonNull ConfigTitle configTitle) { | 141 | public Builder configTitle(@NonNull ConfigTitle configTitle) { |
140 | newTitleParams(); | 142 | newTitleParams(); |
141 | configTitle.onConfig(mCircleParams.titleParams); | 143 | configTitle.onConfig(mCircleParams.titleParams); |
142 | return this; | 144 | return this; |
143 | } | 145 | } |
144 | 146 | ||
145 | private void newTitleParams() { | 147 | private void newTitleParams() { |
146 | if (mCircleParams.titleParams == null) | 148 | if (mCircleParams.titleParams == null) |
147 | mCircleParams.titleParams = new TitleParams(); | 149 | mCircleParams.titleParams = new TitleParams(); |
148 | } | 150 | } |
149 | 151 | ||
150 | public Builder setText(@NonNull String text) { | 152 | public Builder setText(@NonNull String text) { |
151 | newTextParams(); | 153 | newTextParams(); |
152 | mCircleParams.textParams.text = text; | 154 | mCircleParams.textParams.text = text; |
153 | return this; | 155 | return this; |
154 | } | 156 | } |
155 | 157 | ||
156 | public Builder setTextColor(@ColorInt int color) { | 158 | public Builder setTextColor(@ColorInt int color) { |
157 | newTextParams(); | 159 | newTextParams(); |
158 | mCircleParams.textParams.textColor = color; | 160 | mCircleParams.textParams.textColor = color; |
159 | return this; | 161 | return this; |
160 | } | 162 | } |
161 | 163 | ||
162 | public Builder configText(@NonNull ConfigText configText) { | 164 | public Builder configText(@NonNull ConfigText configText) { |
163 | newTextParams(); | 165 | newTextParams(); |
164 | configText.onConfig(mCircleParams.textParams); | 166 | configText.onConfig(mCircleParams.textParams); |
165 | return this; | 167 | return this; |
166 | } | 168 | } |
167 | 169 | ||
168 | private void newTextParams() { | 170 | private void newTextParams() { |
169 | //判断是否已经设置过 | 171 | //判断是否已经设置过 |
170 | if (mCircleParams.dialogParams.gravity == Gravity.NO_GRAVITY) | 172 | if (mCircleParams.dialogParams.gravity == Gravity.NO_GRAVITY) |
171 | mCircleParams.dialogParams.gravity = Gravity.CENTER; | 173 | mCircleParams.dialogParams.gravity = Gravity.CENTER; |
172 | if (mCircleParams.textParams == null) | 174 | if (mCircleParams.textParams == null) |
173 | mCircleParams.textParams = new TextParams(); | 175 | mCircleParams.textParams = new TextParams(); |
174 | } | 176 | } |
175 | 177 | ||
176 | public Builder setItems(@NonNull Object items, AdapterView.OnItemClickListener listener) { | 178 | public Builder setItems(@NonNull Object items, AdapterView.OnItemClickListener listener) { |
177 | newItemsParams(); | 179 | newItemsParams(); |
178 | ItemsParams params = mCircleParams.itemsParams; | 180 | ItemsParams params = mCircleParams.itemsParams; |
179 | params.items = items; | 181 | params.items = items; |
180 | params.listener = listener; | 182 | params.listener = listener; |
181 | return this; | 183 | return this; |
182 | } | 184 | } |
183 | 185 | ||
184 | 186 | ||
185 | public Builder configItems(@NonNull ConfigItems configItems) { | 187 | public Builder configItems(@NonNull ConfigItems configItems) { |
186 | newItemsParams(); | 188 | newItemsParams(); |
187 | configItems.onConfig(mCircleParams.itemsParams); | 189 | configItems.onConfig(mCircleParams.itemsParams); |
188 | return this; | 190 | return this; |
189 | } | 191 | } |
190 | 192 | ||
191 | private void newItemsParams() { | 193 | private void newItemsParams() { |
192 | //设置列表特殊的参数 | 194 | //设置列表特殊的参数 |
193 | DialogParams dialogParams = mCircleParams.dialogParams; | 195 | DialogParams dialogParams = mCircleParams.dialogParams; |
194 | //判断是否已经设置过 | 196 | //判断是否已经设置过 |
195 | if (dialogParams.gravity == Gravity.NO_GRAVITY) | 197 | if (dialogParams.gravity == Gravity.NO_GRAVITY) |
196 | dialogParams.gravity = Gravity.BOTTOM;//默认底部显示 | 198 | dialogParams.gravity = Gravity.BOTTOM;//默认底部显示 |
197 | //判断是否已经设置过 | 199 | //判断是否已经设置过 |
198 | if (dialogParams.yOff == 0) | 200 | if (dialogParams.yOff == 0) |
199 | dialogParams.yOff = 20;//底部与屏幕的距离 | 201 | dialogParams.yOff = 20;//底部与屏幕的距离 |
200 | 202 | ||
201 | if (mCircleParams.itemsParams == null) | 203 | if (mCircleParams.itemsParams == null) |
202 | mCircleParams.itemsParams = new ItemsParams() { | 204 | mCircleParams.itemsParams = new ItemsParams() { |
203 | @Override | 205 | @Override |
204 | public void dismiss() { | 206 | public void dismiss() { |
205 | onDismiss(); | 207 | onDismiss(); |
206 | } | 208 | } |
207 | }; | 209 | }; |
208 | } | 210 | } |
209 | 211 | ||
210 | /** | 212 | /** |
211 | * 设置进度条文本 | 213 | * 设置进度条文本 |
212 | * | 214 | * |
213 | * @param text 进度条文本,style = 水平样式时,支持String.format() 例如:已经下载%s | 215 | * @param text 进度条文本,style = 水平样式时,支持String.format() 例如:已经下载%s |
214 | * @return | 216 | * @return |
215 | */ | 217 | */ |
216 | public Builder setProgressText(@NonNull String text) { | 218 | public Builder setProgressText(@NonNull String text) { |
217 | newProgressParams(); | 219 | newProgressParams(); |
218 | mCircleParams.progressParams.text = text; | 220 | mCircleParams.progressParams.text = text; |
219 | return this; | 221 | return this; |
220 | } | 222 | } |
221 | 223 | ||
222 | /** | 224 | /** |
223 | * 设置进度条样式 | 225 | * 设置进度条样式 |
224 | * | 226 | * |
225 | * @param style {@link ProgressParams#STYLE_HORIZONTAL 水平样式} or | 227 | * @param style {@link ProgressParams#STYLE_HORIZONTAL 水平样式} or |
226 | * {@link ProgressParams#STYLE_SPINNER} | 228 | * {@link ProgressParams#STYLE_SPINNER} |
227 | * @return | 229 | * @return |
228 | */ | 230 | */ |
229 | public Builder setProgressStyle(int style) { | 231 | public Builder setProgressStyle(int style) { |
230 | newProgressParams(); | 232 | newProgressParams(); |
231 | mCircleParams.progressParams.style = style; | 233 | mCircleParams.progressParams.style = style; |
232 | return this; | 234 | return this; |
233 | } | 235 | } |
234 | 236 | ||
235 | public Builder setProgress(int max, int progress) { | 237 | public Builder setProgress(int max, int progress) { |
236 | newProgressParams(); | 238 | newProgressParams(); |
237 | ProgressParams progressParams = mCircleParams.progressParams; | 239 | ProgressParams progressParams = mCircleParams.progressParams; |
238 | progressParams.max = max; | 240 | progressParams.max = max; |
239 | progressParams.progress = progress; | 241 | progressParams.progress = progress; |
240 | return this; | 242 | return this; |
241 | } | 243 | } |
242 | 244 | ||
243 | public Builder setProgressDrawable(@DrawableRes int progressDrawableId) { | 245 | public Builder setProgressDrawable(@DrawableRes int progressDrawableId) { |
244 | newProgressParams(); | 246 | newProgressParams(); |
245 | mCircleParams.progressParams.progressDrawableId = progressDrawableId; | 247 | mCircleParams.progressParams.progressDrawableId = progressDrawableId; |
246 | return this; | 248 | return this; |
247 | } | 249 | } |
248 | 250 | ||
249 | public Builder setProgressHeight(int height) { | 251 | public Builder setProgressHeight(int height) { |
250 | newProgressParams(); | 252 | newProgressParams(); |
251 | mCircleParams.progressParams.progressHeight = height; | 253 | mCircleParams.progressParams.progressHeight = height; |
252 | return this; | 254 | return this; |
253 | } | 255 | } |
254 | 256 | ||
255 | public Builder configProgress(@NonNull ConfigProgress configProgress) { | 257 | public Builder configProgress(@NonNull ConfigProgress configProgress) { |
256 | newProgressParams(); | 258 | newProgressParams(); |
257 | configProgress.onConfig(mCircleParams.progressParams); | 259 | configProgress.onConfig(mCircleParams.progressParams); |
258 | return this; | 260 | return this; |
259 | } | 261 | } |
260 | 262 | ||
261 | private void newProgressParams() { | 263 | private void newProgressParams() { |
262 | //判断是否已经设置过 | 264 | //判断是否已经设置过 |
263 | if (mCircleParams.dialogParams.gravity == Gravity.NO_GRAVITY) | 265 | if (mCircleParams.dialogParams.gravity == Gravity.NO_GRAVITY) |
264 | mCircleParams.dialogParams.gravity = Gravity.CENTER; | 266 | mCircleParams.dialogParams.gravity = Gravity.CENTER; |
265 | if (mCircleParams.progressParams == null) | 267 | if (mCircleParams.progressParams == null) |
266 | mCircleParams.progressParams = new ProgressParams(); | 268 | mCircleParams.progressParams = new ProgressParams(); |
267 | } | 269 | } |
268 | 270 | ||
269 | public Builder setInputHint(@NonNull String text) { | 271 | public Builder setInputHint(@NonNull String text) { |
270 | newInputParams(); | 272 | newInputParams(); |
271 | mCircleParams.inputParams.hintText = text; | 273 | mCircleParams.inputParams.hintText = text; |
272 | return this; | 274 | return this; |
273 | } | 275 | } |
274 | 276 | ||
275 | public Builder setInputHeight(int height) { | 277 | public Builder setInputHeight(int height) { |
276 | newInputParams(); | 278 | newInputParams(); |
277 | mCircleParams.inputParams.inputHeight = height; | 279 | mCircleParams.inputParams.inputHeight = height; |
278 | return this; | 280 | return this; |
279 | } | 281 | } |
280 | 282 | ||
281 | public Builder configInput(@NonNull ConfigInput configInput) { | 283 | public Builder configInput(@NonNull ConfigInput configInput) { |
282 | newInputParams(); | 284 | newInputParams(); |
283 | configInput.onConfig(mCircleParams.inputParams); | 285 | configInput.onConfig(mCircleParams.inputParams); |
284 | return this; | 286 | return this; |
285 | } | 287 | } |
286 | 288 | ||
287 | private void newInputParams() { | 289 | private void newInputParams() { |
288 | //判断是否已经设置过 | 290 | //判断是否已经设置过 |
289 | if (mCircleParams.dialogParams.gravity == Gravity.NO_GRAVITY) | 291 | if (mCircleParams.dialogParams.gravity == Gravity.NO_GRAVITY) |
290 | mCircleParams.dialogParams.gravity = Gravity.CENTER; | 292 | mCircleParams.dialogParams.gravity = Gravity.CENTER; |
291 | if (mCircleParams.inputParams == null) | 293 | if (mCircleParams.inputParams == null) |
292 | mCircleParams.inputParams = new InputParams(); | 294 | mCircleParams.inputParams = new InputParams(); |
293 | } | 295 | } |
294 | 296 | ||
295 | public Builder setPositive(@NonNull String text, View.OnClickListener listener) { | 297 | public Builder setPositive(@NonNull String text, View.OnClickListener listener) { |
296 | newPositiveParams(); | 298 | newPositiveParams(); |
297 | ButtonParams params = mCircleParams.positiveParams; | 299 | ButtonParams params = mCircleParams.positiveParams; |
298 | params.text = text; | 300 | params.text = text; |
299 | params.listener = listener; | 301 | params.listener = listener; |
300 | return this; | 302 | return this; |
301 | } | 303 | } |
302 | 304 | ||
303 | public Builder setPositiveInput(@NonNull String text, OnInputClickListener listener) { | 305 | public Builder setPositiveInput(@NonNull String text, OnInputClickListener listener) { |
304 | newPositiveParams(); | 306 | newPositiveParams(); |
305 | ButtonParams params = mCircleParams.positiveParams; | 307 | ButtonParams params = mCircleParams.positiveParams; |
306 | params.text = text; | 308 | params.text = text; |
307 | params.inputListener = listener; | 309 | params.inputListener = listener; |
308 | return this; | 310 | return this; |
309 | } | 311 | } |
310 | 312 | ||
311 | public Builder configPositive(@NonNull ConfigButton configButton) { | 313 | public Builder configPositive(@NonNull ConfigButton configButton) { |
312 | newPositiveParams(); | 314 | newPositiveParams(); |
313 | configButton.onConfig(mCircleParams.positiveParams); | 315 | configButton.onConfig(mCircleParams.positiveParams); |
314 | return this; | 316 | return this; |
315 | } | 317 | } |
316 | 318 | ||
317 | private void newPositiveParams() { | 319 | private void newPositiveParams() { |
318 | if (mCircleParams.positiveParams == null) | 320 | if (mCircleParams.positiveParams == null) |
319 | mCircleParams.positiveParams = new ButtonParams() { | 321 | mCircleParams.positiveParams = new ButtonParams() { |
320 | @Override | 322 | @Override |
321 | public void dismiss() { | 323 | public void dismiss() { |
322 | onDismiss(); | 324 | onDismiss(); |
323 | } | 325 | } |
324 | }; | 326 | }; |
325 | } | 327 | } |
326 | 328 | ||
327 | public Builder setNegative(@NonNull String text, View.OnClickListener listener) { | 329 | public Builder setNegative(@NonNull String text, View.OnClickListener listener) { |
328 | newNegativeParams(); | 330 | newNegativeParams(); |
329 | ButtonParams params = mCircleParams.negativeParams; | 331 | ButtonParams params = mCircleParams.negativeParams; |
330 | params.text = text; | 332 | params.text = text; |
331 | params.listener = listener; | 333 | params.listener = listener; |
332 | return this; | 334 | return this; |
333 | } | 335 | } |
334 | 336 | ||
335 | 337 | ||
336 | public Builder configNegative(@NonNull ConfigButton configButton) { | 338 | public Builder configNegative(@NonNull ConfigButton configButton) { |
337 | newNegativeParams(); | 339 | newNegativeParams(); |
338 | configButton.onConfig(mCircleParams.negativeParams); | 340 | configButton.onConfig(mCircleParams.negativeParams); |
339 | return this; | 341 | return this; |
340 | } | 342 | } |
341 | 343 | ||
342 | private void newNegativeParams() { | 344 | private void newNegativeParams() { |
343 | if (mCircleParams.negativeParams == null) | 345 | if (mCircleParams.negativeParams == null) |
344 | mCircleParams.negativeParams = new ButtonParams() { | 346 | mCircleParams.negativeParams = new ButtonParams() { |
345 | @Override | 347 | @Override |
346 | public void dismiss() { | 348 | public void dismiss() { |
347 | onDismiss(); | 349 | onDismiss(); |
348 | } | 350 | } |
349 | }; | 351 | }; |
350 | } | 352 | } |
351 | 353 | ||
352 | private void onDismiss() { | 354 | private void onDismiss() { |
353 | if (mCircleParams.dialogFragment != null) { | 355 | if (mCircleParams.dialogFragment != null) { |
354 | mCircleParams.dialogFragment.dismiss(); | 356 | mCircleParams.dialogFragment.dismiss(); |
355 | mActivity = null; | 357 | mActivity = null; |
356 | mCircleParams.dialogFragment = null; | 358 | mCircleParams.dialogFragment = null; |
357 | } | 359 | } |
358 | } | 360 | } |
359 | 361 | ||
360 | public DialogFragment create() { | 362 | public DialogFragment create() { |
361 | if (mCircleDialog == null) | 363 | if (mCircleDialog == null) |
362 | mCircleDialog = new CircleDialog(); | 364 | mCircleDialog = new CircleDialog(); |
363 | return mCircleDialog.create(mCircleParams); | 365 | return mCircleDialog.create(mCircleParams); |
364 | } | 366 | } |
365 | 367 | ||
366 | public DialogFragment show() { | 368 | public DialogFragment show() { |
367 | DialogFragment dialogFragment = create(); | 369 | DialogFragment dialogFragment = create(); |
368 | mCircleDialog.show(mActivity); | 370 | mCircleDialog.show(mActivity); |
369 | return dialogFragment; | 371 | return dialogFragment; |
370 | } | 372 | } |
371 | } | 373 | } |
372 | } | 374 | } |
373 | 375 |
PersonalCenter/mypresonallibrary/build.gradle
1 | apply plugin: 'com.android.library' | 1 | apply plugin: 'com.android.library' |
2 | 2 | ||
3 | android { | 3 | android { |
4 | compileSdkVersion 25 | 4 | compileSdkVersion 25 |
5 | buildToolsVersion "25.0.3" | 5 | buildToolsVersion "25.0.3" |
6 | 6 | ||
7 | defaultConfig { | 7 | defaultConfig { |
8 | minSdkVersion 15 | 8 | minSdkVersion 15 |
9 | targetSdkVersion 25 | 9 | targetSdkVersion 25 |
10 | versionCode 1 | 10 | versionCode 1 |
11 | versionName "1.0" | 11 | versionName "1.0" |
12 | 12 | ||
13 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" | 13 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" |
14 | 14 | ||
15 | } | 15 | } |
16 | buildTypes { | 16 | buildTypes { |
17 | release { | 17 | release { |
18 | minifyEnabled false | 18 | minifyEnabled false |
19 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' | 19 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' |
20 | } | 20 | } |
21 | } | 21 | } |
22 | } | 22 | } |
23 | 23 | ||
24 | dependencies { | 24 | dependencies { |
25 | compile fileTree(dir: 'libs', include: ['*.jar']) | 25 | compile fileTree(include: ['*.jar'], dir: 'libs') |
26 | androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { | 26 | androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { |
27 | exclude group: 'com.android.support', module: 'support-annotations' | 27 | exclude group: 'com.android.support', module: 'support-annotations' |
28 | }) | 28 | }) |
29 | compile 'com.android.support:appcompat-v7:25.3.1' | 29 | compile 'com.android.support:appcompat-v7:25.3.1' |
30 | testCompile 'junit:junit:4.12' | 30 | testCompile 'junit:junit:4.12' |
31 | } | 31 | } |
32 | 32 |
PersonalCenter/mypresonallibrary/src/main/aidl/com/hjx/personalcenter/service/IPresonalInterface.aidl
1 | // IPresonalInterface.aidl | 1 | // IPresonalInterface.aidl |
2 | package com.hjx.personalcenter.service; | 2 | package com.hjx.personalcenter.service; |
3 | 3 | ||
4 | // Declare any non-default types here with import statements | 4 | // Declare any non-default types here with import statements |
5 | 5 | ||
6 | interface IPresonalInterface { | 6 | interface IPresonalInterface { |
7 | //测试AIDL | 7 | //测试AIDL |
8 | String sayHello(); | 8 | String sayHello(); |
9 | //UI view 所有的页面 | 9 | //UI view 所有的页面 |
10 | String viewPage(String action); | 10 | String viewPage(String action); |
11 | //得到用户登录信息 | 11 | //得到用户登录信息 |
12 | String getSimpleUser(); | 12 | String getSimpleUser(); |
13 | //得到用户保卡信息 | 13 | //得到用户保卡信息 |
14 | String getcardUser(); | 14 | String getcardUser(); |
15 | //得到用户个人信息 | ||
16 | String getUserInfo(); | ||
17 | String logout();//注销 | ||
18 | String validateToken();//验证Token | ||
19 | String getDeviceID(); | ||
20 | //子账户信息 | ||
21 | String getChildsInfo(); | ||
15 | } | 22 | } |
16 | 23 |
PersonalCenter/mypresonallibrary/src/main/java/com/hjx/mypresonallibrary/ActionConfig.java
File was created | 1 | /** | |
2 | * HaoJiXing Teacher Q&A | ||
3 | * copyright(C)2013- Acorn International | ||
4 | * | ||
5 | * packeage:com.ozing.center.util.ActionConfig.java | ||
6 | * create:2013年10月29日下午3:32:01 | ||
7 | */ | ||
8 | package com.hjx.mypresonallibrary; | ||
9 | |||
10 | /** | ||
11 | * @author jixiaolong<jixiaolong@chinadrtv.com> | ||
12 | * @code: 015261 | ||
13 | */ | ||
14 | public class ActionConfig { | ||
15 | public static final String SERVICE_ACTION = "com.hjx.mypresonallibrary.ICenterService"; | ||
16 | public static final String PACKAGENAEM = "com.hjx.personalcenter"; | ||
17 | } | ||
18 |
PersonalCenter/mypresonallibrary/src/main/java/com/hjx/mypresonallibrary/PresonalCallBack.java
File was created | 1 | package com.hjx.mypresonallibrary; | |
2 | |||
3 | /** | ||
4 | * Created by h on 2017/9/13. | ||
5 | */ | ||
6 | |||
7 | public interface PresonalCallBack { | ||
8 | public void result(Object obj); | ||
9 | } | ||
10 |
PersonalCenter/mypresonallibrary/src/main/java/com/hjx/mypresonallibrary/PresonalHelper.java
File was created | 1 | package com.hjx.mypresonallibrary; | |
2 | |||
3 | import android.app.Service; | ||
4 | import android.content.ComponentName; | ||
5 | import android.content.Context; | ||
6 | import android.content.DialogInterface; | ||
7 | import android.content.Intent; | ||
8 | import android.content.ServiceConnection; | ||
9 | import android.os.IBinder; | ||
10 | import android.os.RemoteException; | ||
11 | |||
12 | import com.hjx.personalcenter.service.IPresonalInterface; | ||
13 | |||
14 | import java.util.concurrent.locks.ReentrantLock; | ||
15 | |||
16 | /** | ||
17 | * Created by h on 2017/9/13. | ||
18 | */ | ||
19 | |||
20 | public class PresonalHelper implements DialogInterface.OnDismissListener{ | ||
21 | private IPresonalInterface center; | ||
22 | private int STATUS_IDLE = 0; | ||
23 | private int STATUS_PENDDING = 1; | ||
24 | private int STATUS_FINISH = 2; | ||
25 | private int status = STATUS_IDLE; | ||
26 | private byte[] mx = new byte[0]; | ||
27 | private ReentrantLock lock = new ReentrantLock(); | ||
28 | private boolean isRun = false; | ||
29 | private boolean isShow = false; | ||
30 | |||
31 | public PresonalHelper() { | ||
32 | isRun = true; | ||
33 | } | ||
34 | private ServiceConnection serviceConnection = new ServiceConnection() { | ||
35 | |||
36 | @Override | ||
37 | public void onServiceDisconnected(ComponentName name) { | ||
38 | center = null; | ||
39 | } | ||
40 | |||
41 | @Override | ||
42 | public void onServiceConnected(ComponentName name, IBinder service) { | ||
43 | center = IPresonalInterface.Stub.asInterface(service); | ||
44 | synchronized (mx) { | ||
45 | status = STATUS_FINISH; | ||
46 | mx.notifyAll(); | ||
47 | } | ||
48 | } | ||
49 | }; | ||
50 | private void bind(Context context){ | ||
51 | status = STATUS_PENDDING; | ||
52 | Intent intent = new Intent(ActionConfig.SERVICE_ACTION); | ||
53 | intent.setPackage(ActionConfig.PACKAGENAEM); | ||
54 | context.getApplicationContext().bindService(intent, serviceConnection, Service.BIND_AUTO_CREATE); | ||
55 | } | ||
56 | |||
57 | |||
58 | @Override | ||
59 | public void onDismiss(DialogInterface dialog) { | ||
60 | isShow = false; | ||
61 | |||
62 | } | ||
63 | private void checkBind(Context context){ | ||
64 | if(!isRun)return; | ||
65 | if(status == STATUS_IDLE || (center == null && status!= STATUS_PENDDING)){ | ||
66 | bind(context); | ||
67 | } | ||
68 | |||
69 | if(status == STATUS_PENDDING || status == STATUS_IDLE){ | ||
70 | try { | ||
71 | synchronized (mx) { | ||
72 | if (center == null) | ||
73 | mx.wait(); | ||
74 | } | ||
75 | } catch (InterruptedException e) { | ||
76 | e.printStackTrace(); | ||
77 | } | ||
78 | } | ||
79 | } | ||
80 | private String buildNotInstallResult(){ | ||
81 | return "{\"resultCode\":301,\"message\":\"center not install.\"}"; | ||
82 | } | ||
83 | private String buildNotRun(){ | ||
84 | return "{\"resultCode\":302,\"message\":\"center is destoryed\"}"; | ||
85 | } | ||
86 | private String buildRemoteError(){ | ||
87 | return "{\"resultCode\":303,\"message\":\"remote service call failed\"}"; | ||
88 | } | ||
89 | public void getSimpleUser(final Context context, final PresonalCallBack callBack){ | ||
90 | if(callBack == null){ | ||
91 | throw new IllegalArgumentException("call back can not null"); | ||
92 | } | ||
93 | new Thread(new Runnable() { | ||
94 | |||
95 | @Override | ||
96 | public void run() { | ||
97 | String result = null; | ||
98 | try { | ||
99 | checkBind(context); | ||
100 | if(!isRun){ | ||
101 | result = buildNotRun(); | ||
102 | }else{ | ||
103 | result = center.getSimpleUser(); | ||
104 | } | ||
105 | } catch (RemoteException e) { | ||
106 | e.printStackTrace(); | ||
107 | result = buildRemoteError(); | ||
108 | } | ||
109 | callBack.result(result); | ||
110 | } | ||
111 | }).start(); | ||
112 | } | ||
113 | public void getcardUser(final Context context, final PresonalCallBack callBack){ | ||
114 | if(callBack == null){ | ||
115 | throw new IllegalArgumentException("call back can not null"); | ||
116 | } | ||
117 | new Thread(new Runnable() { | ||
118 | |||
119 | @Override | ||
120 | public void run() { | ||
121 | String result = null; | ||
122 | try { | ||
123 | checkBind(context); | ||
124 | if(!isRun){ | ||
125 | result = buildNotRun(); | ||
126 | }else{ | ||
127 | result = center.getcardUser(); | ||
128 | } | ||
129 | } catch (RemoteException e) { | ||
130 | e.printStackTrace(); | ||
131 | result = buildRemoteError(); | ||
132 | } | ||
133 | callBack.result(result); | ||
134 | } | ||
135 | }).start(); | ||
136 | } | ||
137 | } | ||
138 |