Commit 03b99a4c5f8451b9dc99604dd5c0d71c9c277d77
1 parent
66c44ff220
Exists in
master
最新版个人中心
Showing
8 changed files
with
54 additions
and
28 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 3 | 10 | versionCode 4 |
11 | versionName "1.0.3" | 11 | versionName "1.0.4" |
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 | lintOptions{ | 21 | lintOptions{ |
22 | checkReleaseBuilds false | 22 | checkReleaseBuilds false |
23 | abortOnError false | 23 | abortOnError false |
24 | } | 24 | } |
25 | sourceSets { | 25 | sourceSets { |
26 | main { | 26 | main { |
27 | jniLibs.srcDirs = ['libs'] | 27 | jniLibs.srcDirs = ['libs'] |
28 | } | 28 | } |
29 | } | 29 | } |
30 | } | 30 | } |
31 | 31 | ||
32 | dependencies { | 32 | dependencies { |
33 | compile fileTree(include: ['*.jar'], dir: 'libs') | 33 | compile fileTree(include: ['*.jar'], dir: 'libs') |
34 | androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { | 34 | androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { |
35 | exclude group: 'com.android.support', module: 'support-annotations' | 35 | exclude group: 'com.android.support', module: 'support-annotations' |
36 | }) | 36 | }) |
37 | compile 'com.tencent.bugly:crashreport:latest.release' | 37 | compile 'com.tencent.bugly:crashreport:latest.release' |
38 | compile 'org.apache.httpcomponents:httpcore:4.4.1' | 38 | compile 'org.apache.httpcomponents:httpcore:4.4.1' |
39 | compile 'org.apache.httpcomponents:httpclient:4.5' | 39 | compile 'org.apache.httpcomponents:httpclient:4.5' |
40 | compile 'com.android.support:appcompat-v7:25.3.1' | 40 | compile 'com.android.support:appcompat-v7:25.3.1' |
41 | testCompile 'junit:junit:4.12' | 41 | testCompile 'junit:junit:4.12' |
42 | compile project(':circledialog') | 42 | compile project(':circledialog') |
43 | compile project(':pickerview') | 43 | compile project(':pickerview') |
44 | compile files('libs/android-async-http-1.4.8.jar') | 44 | compile files('libs/android-async-http-1.4.8.jar') |
45 | compile 'com.google.code.gson:gson:2.7' | 45 | compile 'com.google.code.gson:gson:2.7' |
46 | compile 'com.zaaach:toprightmenu:1.0' | 46 | compile 'com.zaaach:toprightmenu:1.0' |
47 | compile 'com.android.support:recyclerview-v7:25.+' | 47 | compile 'com.android.support:recyclerview-v7:25.+' |
48 | debugCompile 'com.squareup.leakcanary:leakcanary-android:1.3' | 48 | debugCompile 'com.squareup.leakcanary:leakcanary-android:1.3' |
49 | releaseCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.3' | 49 | releaseCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.3' |
50 | compile 'com.google.zxing:core:3.3.0' | 50 | compile 'com.google.zxing:core:3.3.0' |
51 | compile 'com.google.zxing:android-core:3.3.0' | 51 | compile 'com.google.zxing:android-core:3.3.0' |
52 | compile project(path: ':mypresonallibrary') | 52 | compile project(path: ':mypresonallibrary') |
53 | compile files('libs/picasso-2.5.2.jar') | 53 | compile files('libs/picasso-2.5.2.jar') |
54 | } | 54 | } |
55 | 55 |
PersonalCenter/app/src/main/java/com/hjx/personalcenter/activity/MainActivity.java
1 | package com.hjx.personalcenter.activity; | 1 | package com.hjx.personalcenter.activity; |
2 | 2 | ||
3 | import android.content.Context; | 3 | import android.content.Context; |
4 | import android.content.Intent; | 4 | import android.content.Intent; |
5 | import android.content.pm.PackageManager; | 5 | import android.content.pm.PackageManager; |
6 | import android.net.Uri; | 6 | import android.net.Uri; |
7 | import android.os.Build; | 7 | import android.os.Build; |
8 | import android.os.Bundle; | 8 | import android.os.Bundle; |
9 | import android.os.Handler; | 9 | import android.os.Handler; |
10 | import android.os.Message; | 10 | import android.os.Message; |
11 | import android.provider.MediaStore; | 11 | import android.provider.MediaStore; |
12 | import android.support.annotation.NonNull; | 12 | import android.support.annotation.NonNull; |
13 | import android.support.v4.app.FragmentActivity; | 13 | import android.support.v4.app.FragmentActivity; |
14 | import android.support.v4.content.FileProvider; | 14 | import android.support.v4.content.FileProvider; |
15 | import android.support.v7.widget.LinearLayoutManager; | 15 | import android.support.v7.widget.LinearLayoutManager; |
16 | import android.support.v7.widget.RecyclerView; | 16 | import android.support.v7.widget.RecyclerView; |
17 | import android.util.Log; | 17 | import android.util.Log; |
18 | import android.view.KeyEvent; | 18 | import android.view.KeyEvent; |
19 | import android.view.View; | 19 | import android.view.View; |
20 | import android.widget.GridView; | 20 | import android.widget.GridView; |
21 | import android.widget.ImageView; | 21 | import android.widget.ImageView; |
22 | import android.widget.LinearLayout; | 22 | import android.widget.LinearLayout; |
23 | import android.widget.TextView; | 23 | import android.widget.TextView; |
24 | import android.widget.Toast; | 24 | import android.widget.Toast; |
25 | 25 | ||
26 | import com.google.gson.Gson; | 26 | import com.google.gson.Gson; |
27 | import com.hjx.personalcenter.R; | 27 | import com.hjx.personalcenter.R; |
28 | import com.hjx.personalcenter.adapter.MianGridAdapter; | 28 | import com.hjx.personalcenter.adapter.MianGridAdapter; |
29 | import com.hjx.personalcenter.adapter.VideoAdapter; | 29 | import com.hjx.personalcenter.adapter.VideoAdapter; |
30 | import com.hjx.personalcenter.customdialog.HeadDialog; | 30 | import com.hjx.personalcenter.customdialog.HeadDialog; |
31 | import com.hjx.personalcenter.customdialog.RecyclerViewSpaceItem; | 31 | import com.hjx.personalcenter.customdialog.RecyclerViewSpaceItem; |
32 | import com.hjx.personalcenter.db.Content; | 32 | import com.hjx.personalcenter.db.Content; |
33 | import com.hjx.personalcenter.db.SaveParam; | 33 | import com.hjx.personalcenter.db.SaveParam; |
34 | import com.hjx.personalcenter.http.HttpCode; | 34 | import com.hjx.personalcenter.http.HttpCode; |
35 | import com.hjx.personalcenter.http.HttpManager; | 35 | import com.hjx.personalcenter.http.HttpManager; |
36 | import com.hjx.personalcenter.interfaces.DialogCallBack; | 36 | import com.hjx.personalcenter.interfaces.DialogCallBack; |
37 | import com.hjx.personalcenter.model.DefautPublishInfo; | 37 | import com.hjx.personalcenter.model.DefautPublishInfo; |
38 | import com.hjx.personalcenter.model.PesonalInfo; | 38 | import com.hjx.personalcenter.model.PesonalInfo; |
39 | import com.hjx.personalcenter.model.SignInfo; | 39 | import com.hjx.personalcenter.model.SignInfo; |
40 | import com.hjx.personalcenter.model.VideoInfo; | 40 | import com.hjx.personalcenter.model.VideoInfo; |
41 | import com.hjx.personalcenter.update.UpdateChecker; | 41 | import com.hjx.personalcenter.update.UpdateChecker; |
42 | import com.hjx.personalcenter.util.AlertUtils; | 42 | import com.hjx.personalcenter.util.AlertUtils; |
43 | import com.hjx.personalcenter.util.BrithdayStar; | 43 | import com.hjx.personalcenter.util.BrithdayStar; |
44 | import com.hjx.personalcenter.util.CropUtils; | 44 | import com.hjx.personalcenter.util.CropUtils; |
45 | import com.hjx.personalcenter.util.DialogPermission; | 45 | import com.hjx.personalcenter.util.DialogPermission; |
46 | import com.hjx.personalcenter.util.FileUtil; | 46 | import com.hjx.personalcenter.util.FileUtil; |
47 | import com.hjx.personalcenter.util.GetDevicesUtil; | 47 | import com.hjx.personalcenter.util.GetDevicesUtil; |
48 | import com.hjx.personalcenter.util.PermissionUtil; | 48 | import com.hjx.personalcenter.util.PermissionUtil; |
49 | import com.hjx.personalcenter.util.SharedPreferenceMark; | 49 | import com.hjx.personalcenter.util.SharedPreferenceMark; |
50 | import com.mylhyl.circledialog.CircleDialog; | 50 | import com.mylhyl.circledialog.CircleDialog; |
51 | import com.mylhyl.circledialog.callback.ConfigInput; | 51 | import com.mylhyl.circledialog.callback.ConfigInput; |
52 | import com.mylhyl.circledialog.params.InputParams; | 52 | import com.mylhyl.circledialog.params.InputParams; |
53 | import com.mylhyl.circledialog.view.listener.OnInputClickListener; | 53 | import com.mylhyl.circledialog.view.listener.OnInputClickListener; |
54 | import com.squareup.picasso.Picasso; | 54 | import com.squareup.picasso.Picasso; |
55 | import com.zaaach.toprightmenu.MenuItem; | 55 | import com.zaaach.toprightmenu.MenuItem; |
56 | import com.zaaach.toprightmenu.TopRightMenu; | 56 | import com.zaaach.toprightmenu.TopRightMenu; |
57 | 57 | ||
58 | import org.json.JSONException; | 58 | import org.json.JSONException; |
59 | import org.json.JSONObject; | 59 | import org.json.JSONObject; |
60 | 60 | ||
61 | import java.io.File; | 61 | import java.io.File; |
62 | import java.io.UnsupportedEncodingException; | 62 | import java.io.UnsupportedEncodingException; |
63 | import java.util.ArrayList; | 63 | import java.util.ArrayList; |
64 | import java.util.List; | 64 | import java.util.List; |
65 | 65 | ||
66 | public class MainActivity extends FragmentActivity implements View.OnClickListener, DialogCallBack.CallBackView { | 66 | public class MainActivity extends FragmentActivity implements View.OnClickListener, DialogCallBack.CallBackView { |
67 | private ImageView iv_imformatioan, iv_setting, iv_sign, iv_sex, tv_edit_presoninfo; | 67 | private ImageView iv_imformatioan, iv_setting, iv_sign, iv_sex, tv_edit_presoninfo; |
68 | private TextView tv_sign, | 68 | private TextView tv_sign, |
69 | tv_username, tv_username1, tv_mygad, tv_sex, tv_useinfo_adress, tv_useinfo_birthday, | 69 | tv_username, tv_username1, tv_mygad, tv_sex, tv_useinfo_adress, tv_useinfo_birthday, |
70 | tv_useinfo_qq, tv_useinfo_school, tv_useinfo_gender, tv_yangji; | 70 | tv_useinfo_qq, tv_useinfo_school, tv_useinfo_gender, tv_yangji; |
71 | private TextView linel_mycuoti, linel_mynote, linel_mycollege, linel_myclass, iv_look_card; | 71 | private TextView linel_mycuoti, linel_mynote, linel_mycollege, linel_myclass, iv_look_card; |
72 | private TopRightMenu mTopRightMenu; | 72 | private TopRightMenu mTopRightMenu; |
73 | private LinearLayout view_novedeo; | 73 | private LinearLayout view_novedeo; |
74 | private View sssssssss; | 74 | private View sssssssss; |
75 | //水平滑动 | 75 | //水平滑动 |
76 | private RecyclerView mRecyclerView; | 76 | private RecyclerView mRecyclerView; |
77 | private GridView mRecyclerViewpublish; | 77 | private GridView mRecyclerViewpublish; |
78 | private VideoAdapter RecyclerViewadapter; | 78 | private VideoAdapter RecyclerViewadapter; |
79 | private MianGridAdapter RecyclerViewadapterpublish; | 79 | private MianGridAdapter RecyclerViewadapterpublish; |
80 | private ArrayList<DefautPublishInfo.DataBean> defautPublishInfos = new ArrayList<>(); | 80 | private ArrayList<DefautPublishInfo.DataBean> defautPublishInfos = new ArrayList<>(); |
81 | 81 | ||
82 | private ArrayList<VideoInfo.DataBean> videoinfo = new ArrayList<>(); | 82 | private ArrayList<VideoInfo.DataBean> videoinfo = new ArrayList<>(); |
83 | private boolean showIcon = false; | 83 | private boolean showIcon = false; |
84 | private boolean dimBg = false; | 84 | private boolean dimBg = false; |
85 | private boolean needAnim = true; | 85 | private boolean needAnim = true; |
86 | private static final int REQUEST_CODE_TAKE_PHOTO = 1; | 86 | private static final int REQUEST_CODE_TAKE_PHOTO = 1; |
87 | private static final int REQUEST_CODE_ALBUM = 2; | 87 | private static final int REQUEST_CODE_ALBUM = 2; |
88 | private static final int REQUEST_CODE_CROUP_PHOTO = 3; | 88 | private static final int REQUEST_CODE_CROUP_PHOTO = 3; |
89 | private ImageView mSimpleDraweeView; | 89 | private ImageView mSimpleDraweeView; |
90 | private File file; | 90 | private File file; |
91 | private Uri uri; | 91 | private Uri uri; |
92 | String portrait; | 92 | String portrait; |
93 | Handler handler = new Handler() { | 93 | Handler handler = new Handler() { |
94 | @Override | 94 | @Override |
95 | public void handleMessage(Message msg) { | 95 | public void handleMessage(Message msg) { |
96 | super.handleMessage(msg); | 96 | super.handleMessage(msg); |
97 | switch (msg.what) { | 97 | switch (msg.what) { |
98 | case HttpCode.GETINFO: | 98 | case HttpCode.GETINFO: |
99 | PesonalInfo.DataBean cardinfoBean = (PesonalInfo.DataBean) msg.obj; | 99 | PesonalInfo.DataBean cardinfoBean = (PesonalInfo.DataBean) msg.obj; |
100 | tv_username.setText(cardinfoBean.getNickName()); | 100 | tv_username.setText(cardinfoBean.getNickName()); |
101 | tv_username1.setText(cardinfoBean.getNickName()); | 101 | tv_username1.setText(cardinfoBean.getNickName()); |
102 | tv_useinfo_adress.setText(cardinfoBean.getRegion().getRegionName()); | 102 | tv_useinfo_adress.setText(cardinfoBean.getRegion().getRegionName()); |
103 | tv_useinfo_birthday.setText(cardinfoBean.getBirthday()); | 103 | tv_useinfo_birthday.setText(cardinfoBean.getBirthday()); |
104 | tv_useinfo_qq.setText(cardinfoBean.getQq()); | 104 | tv_useinfo_qq.setText(cardinfoBean.getQq()); |
105 | tv_useinfo_school.setText(cardinfoBean.getSchool().getSchoolName()); | 105 | tv_useinfo_school.setText(cardinfoBean.getSchool().getSchoolName()); |
106 | tv_useinfo_gender.setText(cardinfoBean.getGrade().getGradeName()); | 106 | tv_useinfo_gender.setText(cardinfoBean.getGrade().getGradeName()); |
107 | String sex = cardinfoBean.getGender(); | 107 | String sex = cardinfoBean.getGender(); |
108 | if ("0".equals(sex)) { | 108 | if ("0".equals(sex)) { |
109 | tv_sex.setText("男"); | 109 | tv_sex.setText("男"); |
110 | iv_sex.setImageResource(R.mipmap.men); | 110 | iv_sex.setImageResource(R.mipmap.men); |
111 | } else { | 111 | } else { |
112 | tv_sex.setText("女"); | 112 | tv_sex.setText("女"); |
113 | iv_sex.setImageResource(R.mipmap.women); | 113 | iv_sex.setImageResource(R.mipmap.women); |
114 | } | 114 | } |
115 | portrait = cardinfoBean.getPortrait(); | 115 | portrait = cardinfoBean.getPortrait(); |
116 | //mSimpleDraweeView.setImageURI(cardinfoBean.getPortrait()); | 116 | //mSimpleDraweeView.setImageURI(cardinfoBean.getPortrait()); |
117 | if (portrait!=null&&!portrait.isEmpty()) { | 117 | if (portrait!=null&&!portrait.isEmpty()) { |
118 | Picasso.with(MainActivity.this).load(portrait).into(mSimpleDraweeView); | 118 | Picasso.with(MainActivity.this).load(portrait).into(mSimpleDraweeView); |
119 | } | 119 | } |
120 | //加载星座 | 120 | //加载星座 |
121 | BrithdayStar brithdayStar = new BrithdayStar(); | 121 | BrithdayStar brithdayStar = new BrithdayStar(); |
122 | if (cardinfoBean.getBirthday() == null || "".equals(cardinfoBean.getBirthday())) { | 122 | if (cardinfoBean.getBirthday() == null || "".equals(cardinfoBean.getBirthday())) { |
123 | tv_mygad.setText(""); | 123 | tv_mygad.setText(""); |
124 | } else { | 124 | } else { |
125 | String xiongzuo = brithdayStar.getConstellations(cardinfoBean.getBirthday()); | 125 | String xiongzuo = brithdayStar.getConstellations(cardinfoBean.getBirthday()); |
126 | tv_mygad.setText(xiongzuo); | 126 | tv_mygad.setText(xiongzuo); |
127 | } | 127 | } |
128 | //保存个人信息 | 128 | //保存个人信息 |
129 | SaveParam.getInstance().saveLoginParam(MainActivity.this, SaveParam.ACCOUNTUSERNAME, cardinfoBean.getNickName()); | 129 | SaveParam.getInstance().saveLoginParam(MainActivity.this, SaveParam.ACCOUNTUSERNAME, cardinfoBean.getNickName()); |
130 | SaveParam.getInstance().saveLoginParam(MainActivity.this, SaveParam.ACCOUNTGRADES, cardinfoBean.getGrade().getGradeName()); | 130 | SaveParam.getInstance().saveLoginParam(MainActivity.this, SaveParam.ACCOUNTGRADES, cardinfoBean.getGrade().getGradeName()); |
131 | SaveParam.getInstance().saveLoginParam(MainActivity.this, SaveParam.ACCOUNTSCHOOL, cardinfoBean.getSchool().getSchoolName()); | 131 | SaveParam.getInstance().saveLoginParam(MainActivity.this, SaveParam.ACCOUNTSCHOOL, cardinfoBean.getSchool().getSchoolName()); |
132 | SaveParam.getInstance().saveLoginParam(MainActivity.this, SaveParam.ACCOUNTCONSTELLATION, cardinfoBean.getBirthday()); | 132 | SaveParam.getInstance().saveLoginParam(MainActivity.this, SaveParam.ACCOUNTCONSTELLATION, cardinfoBean.getBirthday()); |
133 | SaveParam.getInstance().saveLoginParam(MainActivity.this, SaveParam.ACCOUNTSEX, tv_sex.getText().toString()); | 133 | SaveParam.getInstance().saveLoginParam(MainActivity.this, SaveParam.ACCOUNTSEX, tv_sex.getText().toString()); |
134 | SaveParam.getInstance().saveLoginParam(MainActivity.this, SaveParam.ACCOUNTQQ, cardinfoBean.getQq()); | 134 | SaveParam.getInstance().saveLoginParam(MainActivity.this, SaveParam.ACCOUNTQQ, cardinfoBean.getQq()); |
135 | SaveParam.getInstance().saveLoginParam(MainActivity.this, SaveParam.ACCOUNTADRESS, cardinfoBean.getRegion().getRegionName()); | 135 | SaveParam.getInstance().saveLoginParam(MainActivity.this, SaveParam.ACCOUNTADRESS, cardinfoBean.getRegion().getRegionName()); |
136 | SaveParam.getInstance().saveLoginParam(MainActivity.this, SaveParam.ACCOUNTXINGZUO, cardinfoBean.getAddress()); | 136 | SaveParam.getInstance().saveLoginParam(MainActivity.this, SaveParam.ACCOUNTXINGZUO, cardinfoBean.getAddress()); |
137 | SaveParam.getInstance().saveLoginParam(MainActivity.this, SaveParam.ADRESSID, cardinfoBean.getRegion().getRegionId()); | 137 | SaveParam.getInstance().saveLoginParam(MainActivity.this, SaveParam.ADRESSID, cardinfoBean.getRegion().getRegionId()); |
138 | SaveParam.getInstance().saveLoginParam(MainActivity.this, SaveParam.PORTAIT, cardinfoBean.getPortrait()); | 138 | SaveParam.getInstance().saveLoginParam(MainActivity.this, SaveParam.PORTAIT, cardinfoBean.getPortrait()); |
139 | SaveParam.getInstance().saveLoginParam(MainActivity.this, SaveParam.MAINSHOOLID, cardinfoBean.getSchool().getSchoolId()); | 139 | SaveParam.getInstance().saveLoginParam(MainActivity.this, SaveParam.MAINSHOOLID, cardinfoBean.getSchool().getSchoolId()); |
140 | String graderID = cardinfoBean.getGrade().getGradeId(); | 140 | String graderID = cardinfoBean.getGrade().getGradeId(); |
141 | Log.e("test", "nianji" + graderID); | 141 | Log.e("test", "nianji" + graderID); |
142 | try { | 142 | try { |
143 | long auserID = Long.parseLong(graderID); | 143 | long auserID = Long.parseLong(graderID); |
144 | String ss = SaveParam.getInstance().getLoginParam(MainActivity.this, SaveParam.GRADENS); | 144 | String ss = SaveParam.getInstance().getLoginParam(MainActivity.this, SaveParam.GRADENS); |
145 | // if ((auserID < 8) && (ss == null)) { | 145 | // if ((auserID < 8) && (ss == null)) { |
146 | // Intent intentbroad = new Intent(); | 146 | // Intent intentbroad = new Intent(); |
147 | // intentbroad.putExtra("info", "小学"); | 147 | // intentbroad.putExtra("info", "小学"); |
148 | // //4、定义广播发送的action | 148 | // //4、定义广播发送的action |
149 | // intentbroad.setAction("com.ozing.launcher.SWITCH_GRADE"); | 149 | // intentbroad.setAction("com.ozing.launcher.SWITCH_GRADE"); |
150 | // //5、发送广播 | 150 | // //5、发送广播 |
151 | // sendBroadcast(intentbroad); | 151 | // sendBroadcast(intentbroad); |
152 | // Log.i("---", "发送完了"); | 152 | // Log.i("---", "发送完了"); |
153 | // } | 153 | // } |
154 | } catch (NumberFormatException e) { | 154 | } catch (NumberFormatException e) { |
155 | e.printStackTrace(); | 155 | e.printStackTrace(); |
156 | } | 156 | } |
157 | 157 | ||
158 | 158 | ||
159 | SaveParam.getInstance().saveLoginParam(MainActivity.this, SaveParam.GRADENS, graderID); | 159 | SaveParam.getInstance().saveLoginParam(MainActivity.this, SaveParam.GRADENS, graderID); |
160 | String userID = SaveParam.getInstance().getLoginParam(MainActivity.this, "userId"); | 160 | String userID = SaveParam.getInstance().getLoginParam(MainActivity.this, "userId"); |
161 | //账户类型 | 161 | //账户类型 |
162 | String accounts = SaveParam.getInstance().getCustomizeParam(MainActivity.this, SaveParam.ACCOUNT); | 162 | String accounts = SaveParam.getInstance().getCustomizeParam(MainActivity.this, SaveParam.ACCOUNT); |
163 | String childID = SaveParam.getInstance().getCustomizeParam(MainActivity.this, SaveParam.CHILDSID); | 163 | String childID = SaveParam.getInstance().getCustomizeParam(MainActivity.this, SaveParam.CHILDSID); |
164 | 164 | ||
165 | try { | 165 | try { |
166 | Object auserID; | 166 | Object auserID; |
167 | int type; | 167 | int type; |
168 | int graderIDs = Integer.parseInt(graderID); | 168 | int graderIDs = Integer.parseInt(graderID); |
169 | if ("2".equals(accounts)) { | 169 | if ("2".equals(accounts)) { |
170 | type = Integer.parseInt(accounts); | 170 | type = Integer.parseInt(accounts); |
171 | auserID = childID; | 171 | auserID = childID; |
172 | } else { | 172 | } else { |
173 | type = Integer.parseInt(accounts); | 173 | type = Integer.parseInt(accounts); |
174 | auserID = Long.parseLong(userID); | 174 | auserID = Long.parseLong(userID); |
175 | } | 175 | } |
176 | //获取版本信息 | 176 | //获取版本信息 |
177 | //Log.e("test","nianji"+graderID+auserID+"sssss"+type); | 177 | //Log.e("test","nianji"+graderID+auserID+"sssss"+type); |
178 | HttpManager.getInstance().getpublishinfo(MainActivity.this, auserID, graderIDs, type, handler); | 178 | HttpManager.getInstance().getpublishinfo(MainActivity.this, auserID, graderIDs, type, handler); |
179 | 179 | ||
180 | } catch (NumberFormatException e) { | 180 | } catch (NumberFormatException e) { |
181 | e.printStackTrace(); | 181 | e.printStackTrace(); |
182 | } | 182 | } |
183 | 183 | ||
184 | break; | 184 | break; |
185 | case HttpCode.SIGN: | 185 | case HttpCode.SIGN: |
186 | SignInfo.DataBean dataBean = (SignInfo.DataBean) msg.obj; | 186 | SignInfo.DataBean dataBean = (SignInfo.DataBean) msg.obj; |
187 | if (dataBean.getSignature() == null) { | 187 | if (dataBean.getSignature() == null) { |
188 | tv_sign.setText("你还未设置个性签名"); | 188 | tv_sign.setText("你还未设置个性签名"); |
189 | } else { | 189 | } else { |
190 | tv_sign.setText(dataBean.getSignature()); | 190 | tv_sign.setText(dataBean.getSignature()); |
191 | } | 191 | } |
192 | 192 | ||
193 | break; | 193 | break; |
194 | case HttpCode.PUBLISH_SUCESS: | 194 | case HttpCode.PUBLISH_SUCESS: |
195 | defautPublishInfos.clear(); | 195 | defautPublishInfos.clear(); |
196 | defautPublishInfos.addAll((List<DefautPublishInfo.DataBean>) msg.obj); | 196 | defautPublishInfos.addAll((List<DefautPublishInfo.DataBean>) msg.obj); |
197 | RecyclerViewadapterpublish.notifyDataSetChanged(); | 197 | RecyclerViewadapterpublish.notifyDataSetChanged(); |
198 | Gson gson = new Gson(); | 198 | Gson gson = new Gson(); |
199 | Log.e("test", "(List<DefautPublishInfo.DataBean>) msg.obj" + gson.toJson(msg.obj)); | 199 | Log.e("test", "(List<DefautPublishInfo.DataBean>) msg.obj" + gson.toJson(msg.obj)); |
200 | SaveParam.getInstance().saveLoginParam(MainActivity.this, SaveParam.VERSIONINTEFACE, gson.toJson(msg.obj)); | 200 | SaveParam.getInstance().saveLoginParam(MainActivity.this, SaveParam.VERSIONINTEFACE, gson.toJson(msg.obj)); |
201 | break; | 201 | break; |
202 | case HttpCode.GETVIDIO_SUCESS: | 202 | case HttpCode.GETVIDIO_SUCESS: |
203 | videoinfo.clear(); | 203 | videoinfo.clear(); |
204 | view_novedeo.setVisibility(View.GONE); | 204 | view_novedeo.setVisibility(View.GONE); |
205 | videoinfo.addAll((List<VideoInfo.DataBean>) msg.obj); | 205 | videoinfo.addAll((List<VideoInfo.DataBean>) msg.obj); |
206 | RecyclerViewadapter.notifyDataSetChanged(); | 206 | RecyclerViewadapter.notifyDataSetChanged(); |
207 | break; | 207 | break; |
208 | case HttpCode.SUCHCARDINFOONE: | 208 | case HttpCode.SUCHCARDINFOONE: |
209 | JSONObject jsonObject; | 209 | JSONObject jsonObject; |
210 | String status; | 210 | String status; |
211 | try { | 211 | try { |
212 | jsonObject = new JSONObject((String) msg.obj); | 212 | jsonObject = new JSONObject((String) msg.obj); |
213 | status = jsonObject.getString("status"); | 213 | status = jsonObject.getString("status"); |
214 | if (status.equals("1")) { | 214 | if (status.equals("1")) { |
215 | //sssssssss.setVisibility(View.VISIBLE); | 215 | //sssssssss.setVisibility(View.VISIBLE); |
216 | tv_yangji.setVisibility(View.GONE); | 216 | tv_yangji.setVisibility(View.GONE); |
217 | iv_look_card.setVisibility(View.VISIBLE); | 217 | iv_look_card.setVisibility(View.VISIBLE); |
218 | //客机没有保卡 | 218 | //客机没有保卡 |
219 | } else if (status.equals("2001")) { | 219 | } else if (status.equals("2001")) { |
220 | //sssssssss.setVisibility(View.VISIBLE); | 220 | //sssssssss.setVisibility(View.VISIBLE); |
221 | tv_yangji.setVisibility(View.GONE); | 221 | tv_yangji.setVisibility(View.GONE); |
222 | iv_look_card.setVisibility(View.VISIBLE); | 222 | iv_look_card.setVisibility(View.VISIBLE); |
223 | AlertUtils.showToast(MainActivity.this, "您的机器还没有保卡信息或该机器已置为样机,请重新登录"); | 223 | AlertUtils.showToast(MainActivity.this, "您的机器还没有保卡信息或该机器已置为样机,请重新登录"); |
224 | SaveParam.getInstance().clearData(MainActivity.this); | ||
224 | Intent settingintent = new Intent(); | 225 | Intent settingintent = new Intent(); |
225 | settingintent.setClass(MainActivity.this, LoginAndRegisterActivity.class); | 226 | settingintent.setClass(MainActivity.this, LoginAndRegisterActivity.class); |
226 | startActivity(settingintent); | 227 | startActivity(settingintent); |
227 | overridePendingTransition(R.anim.rightin, R.anim.rightout); | 228 | overridePendingTransition(R.anim.rightin, R.anim.rightout); |
228 | } else if (status.equals("2002")) {//样机 | 229 | } else if (status.equals("2002")) {//样机 |
229 | //sssssssss.setVisibility(View.INVISIBLE); | 230 | //sssssssss.setVisibility(View.INVISIBLE); |
230 | iv_look_card.setVisibility(View.INVISIBLE); | 231 | iv_look_card.setVisibility(View.INVISIBLE); |
231 | tv_yangji.setVisibility(View.VISIBLE); | 232 | tv_yangji.setVisibility(View.VISIBLE); |
232 | 233 | ||
233 | } else { | 234 | } else { |
234 | AlertUtils.showToast(MainActivity.this, "服务器连接失败"); | 235 | AlertUtils.showToast(MainActivity.this, "服务器连接失败"); |
235 | } | 236 | } |
236 | } catch (JSONException e) { | 237 | } catch (JSONException e) { |
237 | e.printStackTrace(); | 238 | e.printStackTrace(); |
238 | } | 239 | } |
239 | case HttpCode.TOUXIANG: | 240 | case HttpCode.TOUXIANG: |
240 | if (msg.obj.equals("1")){ | 241 | if (msg.obj.equals("1")){ |
241 | String s = SaveParam.getInstance().getLoginParam(MainActivity.this,SaveParam.PORTAIT); | 242 | String s = SaveParam.getInstance().getLoginParam(MainActivity.this,SaveParam.PORTAIT); |
242 | if (portrait!=null&&!portrait.isEmpty()){ | 243 | if (portrait!=null&&!portrait.isEmpty()){ |
243 | Picasso.with(MainActivity.this).load(s).into(mSimpleDraweeView); | 244 | Picasso.with(MainActivity.this).load(s).into(mSimpleDraweeView); |
244 | } | 245 | } |
245 | 246 | ||
246 | } | 247 | } |
247 | break; | 248 | break; |
248 | 249 | ||
249 | 250 | ||
250 | } | 251 | } |
251 | } | 252 | } |
252 | }; | 253 | }; |
253 | 254 | ||
254 | @Override | 255 | @Override |
255 | protected void onCreate(Bundle savedInstanceState) { | 256 | protected void onCreate(Bundle savedInstanceState) { |
256 | super.onCreate(savedInstanceState); | 257 | super.onCreate(savedInstanceState); |
257 | setContentView(R.layout.activity_main); | 258 | setContentView(R.layout.activity_main); |
258 | SysApplication.getInstance().addActivity(this); | 259 | SysApplication.getInstance().addActivity(this); |
259 | initView(); | 260 | initView(); |
260 | initData(); | 261 | initData(); |
261 | initLister(); | 262 | initLister(); |
262 | updateVersion(); | 263 | updateVersion(); |
263 | } | 264 | } |
264 | 265 | ||
265 | //////版本更新 | 266 | //////版本更新 |
266 | private void updateVersion() { | 267 | private void updateVersion() { |
267 | UpdateChecker updateChecker = new UpdateChecker(this); | 268 | UpdateChecker updateChecker = new UpdateChecker(this); |
268 | updateChecker.checkForUpdates(); | 269 | updateChecker.checkForUpdates(); |
269 | 270 | ||
270 | 271 | ||
271 | } | 272 | } |
272 | 273 | ||
273 | private void initView() { | 274 | private void initView() { |
274 | iv_imformatioan = (ImageView) findViewById(R.id.iv_imformatioan); | 275 | iv_imformatioan = (ImageView) findViewById(R.id.iv_imformatioan); |
275 | iv_look_card = (TextView) findViewById(R.id.iv_look_card); | 276 | iv_look_card = (TextView) findViewById(R.id.iv_look_card); |
276 | tv_edit_presoninfo = (ImageView) findViewById(R.id.tv_edit_presoninfo); | 277 | tv_edit_presoninfo = (ImageView) findViewById(R.id.tv_edit_presoninfo); |
277 | iv_setting = (ImageView) findViewById(R.id.iv_setting); | 278 | iv_setting = (ImageView) findViewById(R.id.iv_setting); |
278 | iv_sign = (ImageView) findViewById(R.id.iv_sign); | 279 | iv_sign = (ImageView) findViewById(R.id.iv_sign); |
279 | tv_sign = (TextView) findViewById(R.id.tv_sign); | 280 | tv_sign = (TextView) findViewById(R.id.tv_sign); |
280 | //头像 | 281 | //头像 |
281 | mSimpleDraweeView = (ImageView) findViewById(R.id.iv_head); | 282 | mSimpleDraweeView = (ImageView) findViewById(R.id.iv_head); |
282 | //初始化个人信息 | 283 | //初始化个人信息 |
283 | iv_sex = (ImageView) findViewById(R.id.iv_sex); | 284 | iv_sex = (ImageView) findViewById(R.id.iv_sex); |
284 | tv_username = (TextView) findViewById(R.id.tv_username); | 285 | tv_username = (TextView) findViewById(R.id.tv_username); |
285 | tv_username1 = (TextView) findViewById(R.id.tv_username1); | 286 | tv_username1 = (TextView) findViewById(R.id.tv_username1); |
286 | tv_mygad = (TextView) findViewById(R.id.tv_mygad); | 287 | tv_mygad = (TextView) findViewById(R.id.tv_mygad); |
287 | tv_sex = (TextView) findViewById(R.id.tv_sex); | 288 | tv_sex = (TextView) findViewById(R.id.tv_sex); |
288 | tv_useinfo_adress = (TextView) findViewById(R.id.tv_useinfo_adress); | 289 | tv_useinfo_adress = (TextView) findViewById(R.id.tv_useinfo_adress); |
289 | tv_useinfo_birthday = (TextView) findViewById(R.id.tv_useinfo_birthday); | 290 | tv_useinfo_birthday = (TextView) findViewById(R.id.tv_useinfo_birthday); |
290 | tv_useinfo_qq = (TextView) findViewById(R.id.tv_useinfo_qq); | 291 | tv_useinfo_qq = (TextView) findViewById(R.id.tv_useinfo_qq); |
291 | tv_useinfo_school = (TextView) findViewById(R.id.tv_useinfo_school); | 292 | tv_useinfo_school = (TextView) findViewById(R.id.tv_useinfo_school); |
292 | tv_useinfo_gender = (TextView) findViewById(R.id.tv_useinfo_gender); | 293 | tv_useinfo_gender = (TextView) findViewById(R.id.tv_useinfo_gender); |
293 | tv_yangji = (TextView) findViewById(R.id.tv_yangji); | 294 | tv_yangji = (TextView) findViewById(R.id.tv_yangji); |
294 | //跳转其他应用 | 295 | //跳转其他应用 |
295 | linel_mycuoti = (TextView) findViewById(R.id.linel_mycuoti); | 296 | linel_mycuoti = (TextView) findViewById(R.id.linel_mycuoti); |
296 | linel_mynote = (TextView) findViewById(R.id.linel_mynote); | 297 | linel_mynote = (TextView) findViewById(R.id.linel_mynote); |
297 | linel_mycollege = (TextView) findViewById(R.id.linel_mycollege); | 298 | linel_mycollege = (TextView) findViewById(R.id.linel_mycollege); |
298 | linel_myclass = (TextView) findViewById(R.id.linel_myclass); | 299 | linel_myclass = (TextView) findViewById(R.id.linel_myclass); |
299 | // | 300 | // |
300 | mRecyclerView = (RecyclerView) findViewById(R.id.id_recyclerview_horizontal); | 301 | mRecyclerView = (RecyclerView) findViewById(R.id.id_recyclerview_horizontal); |
301 | mRecyclerViewpublish = (GridView) findViewById(R.id.id_recyclerview_pubish); | 302 | mRecyclerViewpublish = (GridView) findViewById(R.id.id_recyclerview_pubish); |
302 | view_novedeo = (LinearLayout) findViewById(R.id.view_novedeo); | 303 | view_novedeo = (LinearLayout) findViewById(R.id.view_novedeo); |
303 | 304 | ||
304 | //sssssssss = findViewById(R.id.sssssssss); | 305 | //sssssssss = findViewById(R.id.sssssssss); |
305 | 306 | ||
306 | } | 307 | } |
307 | 308 | ||
308 | 309 | ||
309 | private void initData() { | 310 | private void initData() { |
310 | file = new File(FileUtil.getCachePath(this), "user-avatar.jpg"); | 311 | file = new File(FileUtil.getCachePath(this), "user-avatar.jpg"); |
311 | if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N) { | 312 | if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N) { |
312 | uri = Uri.fromFile(file); | 313 | uri = Uri.fromFile(file); |
313 | } else { | 314 | } else { |
314 | //通过FileProvider创建一个content类型的Uri(android 7.0需要这样的方法跨应用访问) | 315 | //通过FileProvider创建一个content类型的Uri(android 7.0需要这样的方法跨应用访问) |
315 | uri = FileProvider.getUriForFile(MyApplication.getContext(), "com.hjx.personalcenter", file); | 316 | uri = FileProvider.getUriForFile(MyApplication.getContext(), "com.hjx.personalcenter", file); |
316 | } | 317 | } |
317 | //设置布局管理器 | 318 | //设置布局管理器 |
318 | LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this); | 319 | LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this); |
319 | linearLayoutManager.setOrientation(LinearLayoutManager.VERTICAL); | 320 | linearLayoutManager.setOrientation(LinearLayoutManager.VERTICAL); |
320 | 321 | ||
321 | // LinearLayoutManager linearLayoutManagerpublish = new LinearLayoutManager(this); | 322 | // LinearLayoutManager linearLayoutManagerpublish = new LinearLayoutManager(this); |
322 | // linearLayoutManagerpublish.setOrientation(LinearLayoutManager.HORIZONTAL); | 323 | // linearLayoutManagerpublish.setOrientation(LinearLayoutManager.HORIZONTAL); |
323 | 324 | ||
324 | mRecyclerView.setLayoutManager(linearLayoutManager); | 325 | mRecyclerView.setLayoutManager(linearLayoutManager); |
325 | mRecyclerView.addItemDecoration(new RecyclerViewSpaceItem(10)); | 326 | mRecyclerView.addItemDecoration(new RecyclerViewSpaceItem(10)); |
326 | 327 | ||
327 | // mRecyclerViewpublish.setLayoutManager(linearLayoutManagerpublish); | 328 | // mRecyclerViewpublish.setLayoutManager(linearLayoutManagerpublish); |
328 | // mRecyclerViewpublish.addItemDecoration(new RecyclerViewSpaceItem(10)); | 329 | // mRecyclerViewpublish.addItemDecoration(new RecyclerViewSpaceItem(10)); |
329 | 330 | ||
330 | //设置视频适配器 | 331 | //设置视频适配器 |
331 | RecyclerViewadapter = new VideoAdapter(this, videoinfo); | 332 | RecyclerViewadapter = new VideoAdapter(this, videoinfo); |
332 | RecyclerViewadapterpublish = new MianGridAdapter(defautPublishInfos, this); | 333 | RecyclerViewadapterpublish = new MianGridAdapter(defautPublishInfos, this); |
333 | 334 | ||
334 | //版本信息适配器 | 335 | //版本信息适配器 |
335 | mRecyclerView.setAdapter(RecyclerViewadapter); | 336 | mRecyclerView.setAdapter(RecyclerViewadapter); |
336 | mRecyclerViewpublish.setAdapter(RecyclerViewadapterpublish); | 337 | mRecyclerViewpublish.setAdapter(RecyclerViewadapterpublish); |
337 | 338 | ||
338 | //判断保卡信息是否为样机 | 339 | //判断保卡信息是否为样机 |
339 | String yangji = SaveParam.getInstance().getLoginParam(this, SaveParam.YANGJI); | 340 | String yangji = SaveParam.getInstance().getLoginParam(this, SaveParam.YANGJI); |
340 | String deviceNumber = GetDevicesUtil.getDevicesInfo(MainActivity.this).getDeviceNumber(); | 341 | String deviceNumber = GetDevicesUtil.getDevicesInfo(MainActivity.this).getDeviceNumber(); |
341 | Log.d("test", "yangji" + yangji); | 342 | Log.d("test", "yangji" + yangji); |
342 | if ("1".equals(yangji)) { | 343 | if ("1".equals(yangji)) { |
343 | //sssssssss.setVisibility(View.INVISIBLE); | 344 | //sssssssss.setVisibility(View.INVISIBLE); |
344 | iv_look_card.setVisibility(View.INVISIBLE); | 345 | iv_look_card.setVisibility(View.INVISIBLE); |
345 | tv_yangji.setVisibility(View.VISIBLE); | 346 | tv_yangji.setVisibility(View.VISIBLE); |
346 | } else { | 347 | } else { |
347 | SaveParam.getInstance().saveLoginParam(MainActivity.this, SaveParam.YANGJI, "0"); | 348 | SaveParam.getInstance().saveLoginParam(MainActivity.this, SaveParam.YANGJI, "0"); |
348 | HttpManager.getInstance().getcardinfo1(this, deviceNumber, handler); | 349 | HttpManager.getInstance().getcardinfo1(this, deviceNumber, handler); |
349 | 350 | ||
350 | } | 351 | } |
351 | 352 | ||
352 | 353 | ||
353 | } | 354 | } |
354 | 355 | ||
355 | private void initLister() { | 356 | private void initLister() { |
356 | iv_imformatioan.setOnClickListener(this); | 357 | iv_imformatioan.setOnClickListener(this); |
357 | iv_look_card.setOnClickListener(this); | 358 | iv_look_card.setOnClickListener(this); |
358 | tv_edit_presoninfo.setOnClickListener(this); | 359 | tv_edit_presoninfo.setOnClickListener(this); |
359 | iv_setting.setOnClickListener(this); | 360 | iv_setting.setOnClickListener(this); |
360 | iv_sign.setOnClickListener(this); | 361 | iv_sign.setOnClickListener(this); |
361 | tv_sign.setOnClickListener(this); | 362 | tv_sign.setOnClickListener(this); |
362 | mSimpleDraweeView.setOnClickListener(this); | 363 | mSimpleDraweeView.setOnClickListener(this); |
363 | linel_mycuoti.setOnClickListener(this); | 364 | linel_mycuoti.setOnClickListener(this); |
364 | linel_mynote.setOnClickListener(this); | 365 | linel_mynote.setOnClickListener(this); |
365 | linel_mycollege.setOnClickListener(this); | 366 | linel_mycollege.setOnClickListener(this); |
366 | linel_myclass.setOnClickListener(this); | 367 | linel_myclass.setOnClickListener(this); |
367 | 368 | ||
368 | } | 369 | } |
369 | 370 | ||
370 | @Override | 371 | @Override |
371 | public void onClick(View v) { | 372 | public void onClick(View v) { |
372 | switch (v.getId()) { | 373 | switch (v.getId()) { |
373 | case R.id.iv_imformatioan: | 374 | case R.id.iv_imformatioan: |
374 | Intent intent = new Intent(); | 375 | Intent intent = new Intent(); |
375 | intent.setClass(MainActivity.this, FeedBackActivity.class); | 376 | intent.setClass(MainActivity.this, FeedBackActivity.class); |
376 | startActivity(intent); | 377 | startActivity(intent); |
377 | overridePendingTransition(R.anim.rightin, R.anim.rightout); | 378 | overridePendingTransition(R.anim.rightin, R.anim.rightout); |
378 | break; | 379 | break; |
379 | case R.id.iv_look_card: | 380 | case R.id.iv_look_card: |
380 | Intent lookintent = new Intent(); | 381 | Intent lookintent = new Intent(); |
381 | lookintent.setClass(MainActivity.this, ElectronicCardLookInfoActivity.class); | 382 | lookintent.setClass(MainActivity.this, ElectronicCardLookInfoActivity.class); |
382 | startActivity(lookintent); | 383 | startActivity(lookintent); |
383 | overridePendingTransition(R.anim.rightin, R.anim.rightout); | 384 | overridePendingTransition(R.anim.rightin, R.anim.rightout); |
384 | break; | 385 | break; |
385 | case R.id.tv_edit_presoninfo: | 386 | case R.id.tv_edit_presoninfo: |
386 | Intent editintent = new Intent(); | 387 | Intent editintent = new Intent(); |
387 | editintent.setClass(MainActivity.this, ChangePresonalInfoActivity.class); | 388 | editintent.setClass(MainActivity.this, ChangePresonalInfoActivity.class); |
388 | startActivity(editintent); | 389 | startActivity(editintent); |
389 | overridePendingTransition(R.anim.rightin, R.anim.rightout); | 390 | overridePendingTransition(R.anim.rightin, R.anim.rightout); |
390 | break; | 391 | break; |
391 | case R.id.iv_head: | 392 | case R.id.iv_head: |
392 | HeadDialog.getInstance(this).show(getSupportFragmentManager(), "HeadDialog"); | 393 | HeadDialog.getInstance(this).show(getSupportFragmentManager(), "HeadDialog"); |
393 | break; | 394 | break; |
394 | case R.id.iv_setting: | 395 | case R.id.iv_setting: |
395 | mTopRightMenu = new TopRightMenu(MainActivity.this); | 396 | mTopRightMenu = new TopRightMenu(MainActivity.this); |
396 | List<MenuItem> menuItems = new ArrayList<>(); | 397 | List<MenuItem> menuItems = new ArrayList<>(); |
397 | menuItems.add(new MenuItem(R.mipmap.blank, " 切换账户")); | 398 | menuItems.add(new MenuItem(R.mipmap.blank, " 切换账户")); |
398 | menuItems.add(new MenuItem(R.mipmap.blank, " 账户管理")); | 399 | menuItems.add(new MenuItem(R.mipmap.blank, " 账户管理")); |
399 | mTopRightMenu | 400 | mTopRightMenu |
400 | .setHeight(150) //默认高度480 | 401 | .setHeight(150) //默认高度480 |
401 | .setWidth(180) //默认宽度wrap_content | 402 | .setWidth(180) //默认宽度wrap_content |
402 | .showIcon(showIcon) //显示菜单图标,默认为true | 403 | .showIcon(showIcon) //显示菜单图标,默认为true |
403 | .dimBackground(dimBg) //背景变暗,默认为true | 404 | .dimBackground(dimBg) //背景变暗,默认为true |
404 | .needAnimationStyle(needAnim) //显示动画,默认为true | 405 | .needAnimationStyle(needAnim) //显示动画,默认为true |
405 | .setAnimationStyle(R.style.TRM_ANIM_STYLE) //默认为R.style.TRM_ANIM_STYLE | 406 | .setAnimationStyle(R.style.TRM_ANIM_STYLE) //默认为R.style.TRM_ANIM_STYLE |
406 | .setOnMenuItemClickListener(new TopRightMenu.OnMenuItemClickListener() { | 407 | .setOnMenuItemClickListener(new TopRightMenu.OnMenuItemClickListener() { |
407 | @Override | 408 | @Override |
408 | public void onMenuItemClick(int position) { | 409 | public void onMenuItemClick(int position) { |
409 | switch (position) { | 410 | switch (position) { |
410 | case 0: | 411 | case 0: |
411 | new CircleDialog.Builder(MainActivity.this) | 412 | new CircleDialog.Builder(MainActivity.this) |
412 | .setCanceledOnTouchOutside(false) | 413 | .setCanceledOnTouchOutside(false) |
413 | .setWidth(0.4f) | 414 | .setWidth(0.4f) |
414 | .setCancelable(false) | 415 | .setCancelable(false) |
415 | .setText("您确定要退出,更换其他账号登录吗?") | 416 | .setText("您确定要退出,更换其他账号登录吗?") |
416 | .setNegative("取消", null) | 417 | .setNegative("取消", null) |
417 | .setPositive("确定", new View.OnClickListener() { | 418 | .setPositive("确定", new View.OnClickListener() { |
418 | @Override | 419 | @Override |
419 | public void onClick(View v) { | 420 | public void onClick(View v) { |
420 | //String graderID = SaveParam.getInstance().getLoginParam(MainActivity.this, SaveParam.GRADENS); | 421 | //String graderID = SaveParam.getInstance().getLoginParam(MainActivity.this, SaveParam.GRADENS); |
421 | //int graderIDs = Integer.parseInt(graderID); | 422 | //int graderIDs = Integer.parseInt(graderID); |
422 | // if (graderIDs < 8) { | 423 | // if (graderIDs < 8) { |
423 | // Intent intentbroad = new Intent(); | 424 | // Intent intentbroad = new Intent(); |
424 | // intentbroad.putExtra("info", "小学"); | 425 | // intentbroad.putExtra("info", "小学"); |
425 | // //4、定义广播发送的action | 426 | // //4、定义广播发送的action |
426 | // intentbroad.setAction("com.ozing.launcher.SWITCH_GRADE"); | 427 | // intentbroad.setAction("com.ozing.launcher.SWITCH_GRADE"); |
427 | // //5、发送广播 | 428 | // //5、发送广播 |
428 | // sendBroadcast(intentbroad); | 429 | // sendBroadcast(intentbroad); |
429 | // Log.i("---", "发送完了"); | 430 | // Log.i("---", "发送完了"); |
430 | // } | 431 | // } |
431 | //清除数据 | 432 | //清除数据 |
432 | SaveParam.getInstance().saveCustomizeParam(MainActivity.this, SaveParam.ACCOUNT, "1"); | 433 | SaveParam.getInstance().saveCustomizeParam(MainActivity.this, SaveParam.ACCOUNT, "1"); |
433 | SaveParam.getInstance().clearData(MainActivity.this); | 434 | SaveParam.getInstance().clearData(MainActivity.this); |
434 | Intent settingintent = new Intent(); | 435 | Intent settingintent = new Intent(); |
435 | settingintent.setClass(MainActivity.this, LoginAndRegisterActivity.class); | 436 | settingintent.setClass(MainActivity.this, LoginAndRegisterActivity.class); |
436 | startActivity(settingintent); | 437 | startActivity(settingintent); |
437 | overridePendingTransition(R.anim.rightin, R.anim.rightout); | 438 | overridePendingTransition(R.anim.rightin, R.anim.rightout); |
438 | finish(); | 439 | finish(); |
439 | } | 440 | } |
440 | }) | 441 | }) |
441 | .show(); | 442 | .show(); |
442 | break; | 443 | break; |
443 | case 1: | 444 | case 1: |
444 | Intent accontMintent = new Intent(); | 445 | Intent accontMintent = new Intent(); |
445 | accontMintent.setClass(MainActivity.this, AccountManagementActivity.class); | 446 | accontMintent.setClass(MainActivity.this, AccountManagementActivity.class); |
446 | startActivity(accontMintent); | 447 | startActivity(accontMintent); |
447 | overridePendingTransition(R.anim.rightin, R.anim.rightout); | 448 | overridePendingTransition(R.anim.rightin, R.anim.rightout); |
448 | break; | 449 | break; |
449 | } | 450 | } |
450 | } | 451 | } |
451 | }) | 452 | }) |
452 | .addMenuList(menuItems) | 453 | .addMenuList(menuItems) |
453 | .showAsDropDown(iv_setting, -120, 0); | 454 | .showAsDropDown(iv_setting, -120, 0); |
454 | break; | 455 | break; |
455 | case R.id.iv_sign: | 456 | case R.id.iv_sign: |
456 | case R.id.tv_sign: | 457 | case R.id.tv_sign: |
457 | new CircleDialog.Builder(this) | 458 | new CircleDialog.Builder(this) |
458 | .setCanceledOnTouchOutside(false) | 459 | .setCanceledOnTouchOutside(false) |
459 | .setCancelable(true) | 460 | .setCancelable(true) |
460 | .setTitle("个性签名") | 461 | .setTitle("个性签名") |
461 | .setInputHint("请输入个性签名") | 462 | .setInputHint("请输入个性签名") |
462 | .setWidth(0.4f) | 463 | .setWidth(0.4f) |
463 | .setInputHeight(80) | 464 | .setInputHeight(80) |
464 | .configInput(new ConfigInput() { | 465 | .configInput(new ConfigInput() { |
465 | @Override | 466 | @Override |
466 | public void onConfig(InputParams params) { | 467 | public void onConfig(InputParams params) { |
467 | // params.inputBackgroundResourceId = R.drawable.bg_input; | 468 | // params.inputBackgroundResourceId = R.drawable.bg_input; |
468 | } | 469 | } |
469 | }) | 470 | }) |
470 | .setNegative("取消", new View.OnClickListener() { | 471 | .setNegative("取消", new View.OnClickListener() { |
471 | @Override | 472 | @Override |
472 | public void onClick(View v) { | 473 | public void onClick(View v) { |
473 | RecyclerViewadapterpublish.notifyDataSetChanged(); | 474 | RecyclerViewadapterpublish.notifyDataSetChanged(); |
474 | } | 475 | } |
475 | }) | 476 | }) |
476 | .setPositiveInput("确定", new OnInputClickListener() { | 477 | .setPositiveInput("确定", new OnInputClickListener() { |
477 | @Override | 478 | @Override |
478 | public void onClick(String text, View v) { | 479 | public void onClick(String text, View v) { |
479 | if (text.equals("")) { | 480 | if (text.equals("")) { |
480 | AlertUtils.showToast(MainActivity.this, "请输入个性签名"); | 481 | AlertUtils.showToast(MainActivity.this, "请输入个性签名"); |
481 | } else { | 482 | } else { |
482 | try { | 483 | try { |
483 | String typeaccount = SaveParam.getInstance().getCustomizeParam(MainActivity.this, SaveParam.ACCOUNT); | 484 | String typeaccount = SaveParam.getInstance().getCustomizeParam(MainActivity.this, SaveParam.ACCOUNT); |
484 | String userID = SaveParam.getInstance().getLoginParam(MainActivity.this, "userId"); | 485 | String userID = SaveParam.getInstance().getLoginParam(MainActivity.this, "userId"); |
485 | String childsID = SaveParam.getInstance().getCustomizeParam(MainActivity.this, SaveParam.CHILDSID); | 486 | String childsID = SaveParam.getInstance().getCustomizeParam(MainActivity.this, SaveParam.CHILDSID); |
486 | Object id = null; | 487 | Object id = null; |
487 | long auserID = Long.parseLong(userID); | 488 | long auserID = Long.parseLong(userID); |
488 | int typeaccount1 = Integer.parseInt(typeaccount); | 489 | int typeaccount1 = Integer.parseInt(typeaccount); |
489 | if (typeaccount1 == 2) { | 490 | if (typeaccount1 == 2) { |
490 | id = childsID; | 491 | id = childsID; |
491 | } else { | 492 | } else { |
492 | id = auserID; | 493 | id = auserID; |
493 | } | 494 | } |
494 | HttpManager.getInstance().changsignature(MainActivity.this, id, typeaccount1, text); | 495 | HttpManager.getInstance().changsignature(MainActivity.this, id, typeaccount1, text); |
495 | RecyclerViewadapterpublish.notifyDataSetChanged(); | 496 | RecyclerViewadapterpublish.notifyDataSetChanged(); |
496 | } catch (NumberFormatException e) { | 497 | } catch (NumberFormatException e) { |
497 | e.printStackTrace(); | 498 | e.printStackTrace(); |
498 | } | 499 | } |
499 | 500 | ||
500 | tv_sign.setText(text); | 501 | tv_sign.setText(text); |
501 | } | 502 | } |
502 | 503 | ||
503 | } | 504 | } |
504 | }) | 505 | }) |
505 | .show(); | 506 | .show(); |
506 | break; | 507 | break; |
507 | case R.id.linel_mycuoti: | 508 | case R.id.linel_mycuoti: |
508 | AlertUtils.showToast(this, "未安装该应用 "); | 509 | AlertUtils.showToast(this, "未安装该应用 "); |
509 | break; | 510 | break; |
510 | case R.id.linel_mynote: | 511 | case R.id.linel_mynote: |
511 | AlertUtils.showToast(this, "未安装该应用 "); | 512 | AlertUtils.showToast(this, "未安装该应用 "); |
512 | break; | 513 | break; |
513 | case R.id.linel_mycollege: | 514 | case R.id.linel_mycollege: |
514 | AlertUtils.showToast(this, "未安装该应用 "); | 515 | AlertUtils.showToast(this, "未安装该应用 "); |
515 | break; | 516 | break; |
516 | case R.id.linel_myclass: | 517 | case R.id.linel_myclass: |
517 | AlertUtils.showToast(this, "未安装该应用 "); | 518 | AlertUtils.showToast(this, "未安装该应用 "); |
518 | break; | 519 | break; |
519 | } | 520 | } |
520 | 521 | ||
521 | } | 522 | } |
522 | 523 | ||
523 | @Override | 524 | @Override |
524 | protected void onPause() { | 525 | protected void onPause() { |
525 | super.onPause(); | 526 | super.onPause(); |
526 | } | 527 | } |
527 | 528 | ||
528 | @Override | 529 | @Override |
529 | protected void onResume() { | 530 | protected void onResume() { |
530 | super.onResume(); | 531 | super.onResume(); |
531 | Content.changegradeinfoflag = 0; | 532 | Content.changegradeinfoflag = 0; |
532 | Content.changeadressinfoflag = 0; | 533 | Content.changeadressinfoflag = 0; |
533 | String userID = SaveParam.getInstance().getLoginParam(this, "userId"); | 534 | String userID = SaveParam.getInstance().getLoginParam(this, "userId"); |
534 | //获取个性签名 | 535 | //获取个性签名 |
535 | String typeaccount = SaveParam.getInstance().getCustomizeParam(this, SaveParam.ACCOUNT); | 536 | String typeaccount = SaveParam.getInstance().getCustomizeParam(this, SaveParam.ACCOUNT); |
536 | String childsID = SaveParam.getInstance().getCustomizeParam(this, SaveParam.CHILDSID); | 537 | String childsID = SaveParam.getInstance().getCustomizeParam(this, SaveParam.CHILDSID); |
537 | 538 | ||
538 | try { | 539 | try { |
539 | Object auserID = 1; | 540 | Object auserID = 1; |
540 | long id = Long.parseLong(userID); | 541 | long id = Long.parseLong(userID); |
541 | int typeaccount1 = Integer.parseInt(typeaccount); | 542 | int typeaccount1 = Integer.parseInt(typeaccount); |
542 | //获取个人信息 | 543 | //获取个人信息 |
543 | HttpManager.getInstance().getpresonalinfo(MainActivity.this, id, typeaccount1, handler); | 544 | HttpManager.getInstance().getpresonalinfo(MainActivity.this, id, typeaccount1, handler); |
544 | if (typeaccount1 == 2) { | 545 | if (typeaccount1 == 2) { |
545 | auserID = childsID; | 546 | auserID = childsID; |
546 | } else { | 547 | } else { |
547 | auserID = id; | 548 | auserID = id; |
548 | } | 549 | } |
549 | Log.e("test", "个性签名的ID" + auserID); | 550 | Log.e("test", "个性签名的ID" + auserID); |
550 | HttpManager.getInstance().getsignatures(MainActivity.this, auserID, typeaccount1, handler); | 551 | HttpManager.getInstance().getsignatures(MainActivity.this, auserID, typeaccount1, handler); |
551 | //获取最近播放视频 | 552 | //获取最近播放视频 |
552 | HttpManager.getInstance().getstuyvidioinfo(this, auserID, handler); | 553 | HttpManager.getInstance().getstuyvidioinfo(this, auserID, handler); |
553 | 554 | ||
554 | } catch (NumberFormatException e) { | 555 | } catch (NumberFormatException e) { |
555 | e.printStackTrace(); | 556 | e.printStackTrace(); |
556 | } | 557 | } |
557 | 558 | ||
558 | } | 559 | } |
559 | 560 | ||
560 | //回调头像监听 | 561 | //回调头像监听 |
561 | @Override | 562 | @Override |
562 | public void heard(Context context, View v, int headpitiaon) { | 563 | public void heard(Context context, View v, int headpitiaon) { |
563 | String picUrl = ""; | 564 | String picUrl = ""; |
564 | String userID; | 565 | String userID; |
565 | String typeaccount = SaveParam.getInstance().getCustomizeParam(this, SaveParam.ACCOUNT); | 566 | String typeaccount = SaveParam.getInstance().getCustomizeParam(this, SaveParam.ACCOUNT); |
566 | if ("2".equals(typeaccount)) { | 567 | if ("2".equals(typeaccount)) { |
567 | userID = SaveParam.getInstance().getCustomizeParam(this, SaveParam.CHILDSID); | 568 | userID = SaveParam.getInstance().getCustomizeParam(this, SaveParam.CHILDSID); |
568 | } else { | 569 | } else { |
569 | userID = SaveParam.getInstance().getLoginParam(this, "userId"); | 570 | userID = SaveParam.getInstance().getLoginParam(this, "userId"); |
570 | } | 571 | } |
571 | switch (v.getId()) { | 572 | switch (v.getId()) { |
572 | //选择默认图片 | 573 | //选择默认图片 |
573 | case R.id.oktakephone: | 574 | case R.id.oktakephone: |
574 | if (headpitiaon == 1) { | 575 | if (headpitiaon == 1) { |
575 | mSimpleDraweeView.setImageDrawable(null); | 576 | mSimpleDraweeView.setImageDrawable(null); |
576 | mSimpleDraweeView.setImageResource(R.mipmap.default_avatar1); | 577 | mSimpleDraweeView.setImageResource(R.mipmap.default_avatar1); |
577 | picUrl = "http://hjxprodbucket.oss.aliyuncs.com/static/upload/boss_api/announcement/2018-01-25/75f05c02-3dbc-44e3-aec9-a73eca60ca8b.png"; | 578 | picUrl = "http://hjxprodbucket.oss.aliyuncs.com/static/upload/boss_api/announcement/2018-01-25/75f05c02-3dbc-44e3-aec9-a73eca60ca8b.png"; |
578 | try { | 579 | try { |
579 | HttpManager.getInstance().headerdeft(this, userID, typeaccount, picUrl); | 580 | HttpManager.getInstance().headerdeft(this, userID, typeaccount, picUrl); |
580 | } catch (UnsupportedEncodingException e) { | 581 | } catch (UnsupportedEncodingException e) { |
581 | e.printStackTrace(); | 582 | e.printStackTrace(); |
582 | } | 583 | } |
583 | } else if (headpitiaon == 2) { | 584 | } else if (headpitiaon == 2) { |
584 | mSimpleDraweeView.setImageDrawable(null); | 585 | mSimpleDraweeView.setImageDrawable(null); |
585 | mSimpleDraweeView.setImageResource(R.mipmap.default_avatar2); | 586 | mSimpleDraweeView.setImageResource(R.mipmap.default_avatar2); |
586 | picUrl = "http://hjxprodbucket.oss.aliyuncs.com/static/upload/boss_api/announcement/2018-01-25/d102b0d8-435f-45a5-908f-ea43e02176d4.png"; | 587 | picUrl = "http://hjxprodbucket.oss.aliyuncs.com/static/upload/boss_api/announcement/2018-01-25/d102b0d8-435f-45a5-908f-ea43e02176d4.png"; |
587 | try { | 588 | try { |
588 | HttpManager.getInstance().headerdeft(this, userID, typeaccount, picUrl); | 589 | HttpManager.getInstance().headerdeft(this, userID, typeaccount, picUrl); |
589 | } catch (UnsupportedEncodingException e) { | 590 | } catch (UnsupportedEncodingException e) { |
590 | e.printStackTrace(); | 591 | e.printStackTrace(); |
591 | } | 592 | } |
592 | } else if (headpitiaon == 3) { | 593 | } else if (headpitiaon == 3) { |
593 | mSimpleDraweeView.setImageDrawable(null); | 594 | mSimpleDraweeView.setImageDrawable(null); |
594 | mSimpleDraweeView.setImageResource(R.mipmap.default_avatar3); | 595 | mSimpleDraweeView.setImageResource(R.mipmap.default_avatar3); |
595 | picUrl = "http://hjxprodbucket.oss.aliyuncs.com/static/upload/boss_api/announcement/2018-01-25/a623a8ba-5e56-4827-95d1-ffeb0d6874d5.png"; | 596 | picUrl = "http://hjxprodbucket.oss.aliyuncs.com/static/upload/boss_api/announcement/2018-01-25/a623a8ba-5e56-4827-95d1-ffeb0d6874d5.png"; |
596 | try { | 597 | try { |
597 | HttpManager.getInstance().headerdeft(this, userID, typeaccount, picUrl); | 598 | HttpManager.getInstance().headerdeft(this, userID, typeaccount, picUrl); |
598 | } catch (UnsupportedEncodingException e) { | 599 | } catch (UnsupportedEncodingException e) { |
599 | e.printStackTrace(); | 600 | e.printStackTrace(); |
600 | } | 601 | } |
601 | } else if (headpitiaon == 4) { | 602 | } else if (headpitiaon == 4) { |
602 | mSimpleDraweeView.setImageDrawable(null); | 603 | mSimpleDraweeView.setImageDrawable(null); |
603 | mSimpleDraweeView.setImageResource(R.mipmap.default_avatar4); | 604 | mSimpleDraweeView.setImageResource(R.mipmap.default_avatar4); |
604 | picUrl = "http://hjxprodbucket.oss.aliyuncs.com/static/upload/boss_api/announcement/2018-01-25/3d822736-a18d-47ae-b0b1-67752e027375.png"; | 605 | picUrl = "http://hjxprodbucket.oss.aliyuncs.com/static/upload/boss_api/announcement/2018-01-25/3d822736-a18d-47ae-b0b1-67752e027375.png"; |
605 | try { | 606 | try { |
606 | HttpManager.getInstance().headerdeft(this, userID, typeaccount, picUrl); | 607 | HttpManager.getInstance().headerdeft(this, userID, typeaccount, picUrl); |
607 | } catch (UnsupportedEncodingException e) { | 608 | } catch (UnsupportedEncodingException e) { |
608 | e.printStackTrace(); | 609 | e.printStackTrace(); |
609 | } | 610 | } |
610 | } else { | 611 | } else { |
611 | mSimpleDraweeView.setImageDrawable(null); | 612 | mSimpleDraweeView.setImageDrawable(null); |
612 | mSimpleDraweeView.setImageResource(R.mipmap.header_default); | 613 | mSimpleDraweeView.setImageResource(R.mipmap.header_default); |
613 | ; | 614 | ; |
614 | } | 615 | } |
615 | 616 | ||
616 | break; | 617 | break; |
617 | case R.id.canceltakephone: | 618 | case R.id.canceltakephone: |
618 | 619 | ||
619 | break; | 620 | break; |
620 | //拍摄和相册 | 621 | //拍摄和相册 |
621 | case R.id.take_pic: | 622 | case R.id.take_pic: |
622 | if (PermissionUtil.hasCameraPermission(MainActivity.this)) { | 623 | if (PermissionUtil.hasCameraPermission(MainActivity.this)) { |
623 | uploadAvatarFromPhotoRequest(); | 624 | uploadAvatarFromPhotoRequest(); |
624 | } | 625 | } |
625 | break; | 626 | break; |
626 | case R.id.xiangce: | 627 | case R.id.xiangce: |
627 | uploadAvatarFromAlbumRequest(); | 628 | uploadAvatarFromAlbumRequest(); |
628 | break; | 629 | break; |
629 | 630 | ||
630 | } | 631 | } |
631 | 632 | ||
632 | } | 633 | } |
633 | 634 | ||
634 | //照相 | 635 | //照相 |
635 | private void uploadAvatarFromPhotoRequest() { | 636 | private void uploadAvatarFromPhotoRequest() { |
636 | Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); | 637 | Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); |
637 | intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); | 638 | intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); |
638 | intent.putExtra(MediaStore.Images.Media.ORIENTATION, 0); | 639 | intent.putExtra(MediaStore.Images.Media.ORIENTATION, 0); |
639 | intent.putExtra(MediaStore.EXTRA_OUTPUT, uri); | 640 | intent.putExtra(MediaStore.EXTRA_OUTPUT, uri); |
640 | startActivityForResult(intent, REQUEST_CODE_TAKE_PHOTO); | 641 | startActivityForResult(intent, REQUEST_CODE_TAKE_PHOTO); |
641 | } | 642 | } |
642 | 643 | ||
643 | //选择图库 | 644 | //选择图库 |
644 | private void uploadAvatarFromAlbumRequest() { | 645 | private void uploadAvatarFromAlbumRequest() { |
645 | Intent photoPickerIntent = new Intent(Intent.ACTION_PICK); | 646 | Intent photoPickerIntent = new Intent(Intent.ACTION_PICK); |
646 | photoPickerIntent.setType("image/*"); | 647 | photoPickerIntent.setType("image/*"); |
647 | startActivityForResult(photoPickerIntent, REQUEST_CODE_ALBUM); | 648 | startActivityForResult(photoPickerIntent, REQUEST_CODE_ALBUM); |
648 | } | 649 | } |
649 | 650 | ||
650 | //回掉 | 651 | //回掉 |
651 | @Override | 652 | @Override |
652 | protected void onActivityResult(int requestCode, int resultCode, Intent data) { | 653 | protected void onActivityResult(int requestCode, int resultCode, Intent data) { |
653 | super.onActivityResult(requestCode, resultCode, data); | 654 | super.onActivityResult(requestCode, resultCode, data); |
654 | if (resultCode != -1) { | 655 | if (resultCode != -1) { |
655 | return; | 656 | return; |
656 | } | 657 | } |
657 | if (requestCode == REQUEST_CODE_ALBUM && data != null) { | 658 | if (requestCode == REQUEST_CODE_ALBUM && data != null) { |
658 | Uri newUri; | 659 | Uri newUri; |
659 | if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N) { | 660 | if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N) { |
660 | newUri = Uri.parse("file:///" + CropUtils.getPath(this, data.getData())); | 661 | newUri = Uri.parse("file:///" + CropUtils.getPath(this, data.getData())); |
661 | } else { | 662 | } else { |
662 | newUri = data.getData(); | 663 | newUri = data.getData(); |
663 | } | 664 | } |
664 | if (newUri != null) { | 665 | if (newUri != null) { |
665 | startPhotoZoom(newUri); | 666 | startPhotoZoom(newUri); |
666 | } else { | 667 | } else { |
667 | Toast.makeText(this, "没有得到相册图片", Toast.LENGTH_LONG).show(); | 668 | Toast.makeText(this, "没有得到相册图片", Toast.LENGTH_LONG).show(); |
668 | } | 669 | } |
669 | } else if (requestCode == REQUEST_CODE_TAKE_PHOTO) { | 670 | } else if (requestCode == REQUEST_CODE_TAKE_PHOTO) { |
670 | //startPhotoZoom(uri); | 671 | //startPhotoZoom(uri); |
671 | uploadAvatarFromPhoto(); | 672 | uploadAvatarFromPhoto(); |
672 | } else if (requestCode == REQUEST_CODE_CROUP_PHOTO) { | 673 | } else if (requestCode == REQUEST_CODE_CROUP_PHOTO) { |
673 | uploadAvatarFromPhoto(); | 674 | uploadAvatarFromPhoto(); |
674 | } | 675 | } |
675 | } | 676 | } |
676 | 677 | ||
677 | private void uploadAvatarFromPhoto() { | 678 | private void uploadAvatarFromPhoto() { |
678 | compressAndUploadAvatar(file.getPath()); | 679 | compressAndUploadAvatar(file.getPath()); |
679 | 680 | ||
680 | } | 681 | } |
681 | 682 | ||
682 | private void compressAndUploadAvatar(String fileSrc) { | 683 | private void compressAndUploadAvatar(String fileSrc) { |
683 | 684 | ||
684 | 685 | ||
685 | //上传到服务器 | 686 | //上传到服务器 |
686 | 687 | ||
687 | final File cover = FileUtil.getSmallBitmap(this, fileSrc); | 688 | final File cover = FileUtil.getSmallBitmap(this, fileSrc); |
688 | String mimeType = "image/*"; | 689 | String mimeType = "image/*"; |
689 | //requestBody = RequestBody.create(MediaType.parse(mimeType), file); | 690 | //requestBody = RequestBody.create(MediaType.parse(mimeType), file); |
690 | //String fileName = cover.getName(); | 691 | //String fileName = cover.getName(); |
691 | String userID; | 692 | String userID; |
692 | String typeaccount = SaveParam.getInstance().getCustomizeParam(this, SaveParam.ACCOUNT); | 693 | String typeaccount = SaveParam.getInstance().getCustomizeParam(this, SaveParam.ACCOUNT); |
693 | if ("2".equals(typeaccount)) { | 694 | if ("2".equals(typeaccount)) { |
694 | userID = SaveParam.getInstance().getCustomizeParam(this, SaveParam.CHILDSID); | 695 | userID = SaveParam.getInstance().getCustomizeParam(this, SaveParam.CHILDSID); |
695 | } else { | 696 | } else { |
696 | userID = SaveParam.getInstance().getLoginParam(this, "userId"); | 697 | userID = SaveParam.getInstance().getLoginParam(this, "userId"); |
697 | } | 698 | } |
698 | 699 | ||
699 | //上传头像 | 700 | //上传头像 |
700 | 701 | ||
701 | try { | 702 | try { |
702 | HttpManager.getInstance().header(this, userID, typeaccount, fileSrc,handler); | 703 | HttpManager.getInstance().header(this, userID, typeaccount, fileSrc,handler); |
703 | } catch (UnsupportedEncodingException e) { | 704 | } catch (UnsupportedEncodingException e) { |
704 | e.printStackTrace(); | 705 | e.printStackTrace(); |
705 | } | 706 | } |
706 | //mSimpleDraweeView.setImageURI(Uri.fromFile(new File(fileSrc))); | 707 | //mSimpleDraweeView.setImageURI(Uri.fromFile(new File(fileSrc))); |
707 | 708 | ||
708 | // GenericDraweeHierarchyBuilder builder = new GenericDraweeHierarchyBuilder(getResources()); | 709 | // GenericDraweeHierarchyBuilder builder = new GenericDraweeHierarchyBuilder(getResources()); |
709 | // GenericDraweeHierarchy hierarchy = builder | 710 | // GenericDraweeHierarchy hierarchy = builder |
710 | // .setDesiredAspectRatio(1f) | 711 | // .setDesiredAspectRatio(1f) |
711 | // .setFailureImage(R.mipmap.header_default) | 712 | // .setFailureImage(R.mipmap.header_default) |
712 | // //圆形头像 | 713 | // //圆形头像 |
713 | // .setRoundingParams(RoundingParams.asCircle()) | 714 | // .setRoundingParams(RoundingParams.asCircle()) |
714 | // .build(); | 715 | // .build(); |
715 | // //OOM | 716 | // //OOM |
716 | // ImageRequest request = ImageRequestBuilder.newBuilderWithSource(uri) | 717 | // ImageRequest request = ImageRequestBuilder.newBuilderWithSource(uri) |
717 | // //根据View的尺寸放缩图片 | 718 | // //根据View的尺寸放缩图片 |
718 | // .setResizeOptions(new ResizeOptions(mSimpleDraweeView.getWidth(), mSimpleDraweeView.getHeight())) | 719 | // .setResizeOptions(new ResizeOptions(mSimpleDraweeView.getWidth(), mSimpleDraweeView.getHeight())) |
719 | // .build(); | 720 | // .build(); |
720 | // | 721 | // |
721 | // | 722 | // |
722 | // //加载本地图片 | 723 | // //加载本地图片 |
723 | // Uri uri = Uri.fromFile(cover); | 724 | // Uri uri = Uri.fromFile(cover); |
724 | //Picasso.with(MainActivity.this).load(uri).placeholder(R.mipmap.header_default).error(R.mipmap.header_default).transform(new RoundTransform(1000)).into(mSimpleDraweeView); | 725 | //Picasso.with(MainActivity.this).load(uri).placeholder(R.mipmap.header_default).error(R.mipmap.header_default).transform(new RoundTransform(1000)).into(mSimpleDraweeView); |
725 | // DraweeController controller = Fresco.newDraweeControllerBuilder() | 726 | // DraweeController controller = Fresco.newDraweeControllerBuilder() |
726 | // .setOldController(mSimpleDraweeView.getController()) | 727 | // .setOldController(mSimpleDraweeView.getController()) |
727 | // .setImageRequest(request) | 728 | // .setImageRequest(request) |
728 | // .setUri(uri) | 729 | // .setUri(uri) |
729 | // .build(); | 730 | // .build(); |
730 | // mSimpleDraweeView.setHierarchy(hierarchy); | 731 | // mSimpleDraweeView.setHierarchy(hierarchy); |
731 | // mSimpleDraweeView.setController(controller); | 732 | // mSimpleDraweeView.setController(controller); |
732 | 733 | ||
733 | } | 734 | } |
734 | 735 | ||
735 | public void startPhotoZoom(Uri uri) { | 736 | public void startPhotoZoom(Uri uri) { |
736 | Intent intent = new Intent("com.android.camera.action.CROP"); | 737 | Intent intent = new Intent("com.android.camera.action.CROP"); |
737 | intent.setDataAndType(uri, "image/*"); | 738 | intent.setDataAndType(uri, "image/*"); |
738 | intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); | 739 | intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); |
739 | intent.putExtra("crop", "true");// crop=true 有这句才能出来最后的裁剪页面. | 740 | intent.putExtra("crop", "true");// crop=true 有这句才能出来最后的裁剪页面. |
740 | intent.putExtra("aspectX", 1);// 这两项为裁剪框的比例. | 741 | intent.putExtra("aspectX", 1);// 这两项为裁剪框的比例. |
741 | intent.putExtra("aspectY", 1);// x:y=1:1 | 742 | intent.putExtra("aspectY", 1);// x:y=1:1 |
742 | // intent.putExtra("outputX", 400);//图片输出大小 | 743 | // intent.putExtra("outputX", 400);//图片输出大小 |
743 | // intent.putExtra("outputY", 400); | 744 | // intent.putExtra("outputY", 400); |
744 | intent.putExtra("output", Uri.fromFile(file)); | 745 | intent.putExtra("output", Uri.fromFile(file)); |
745 | intent.putExtra("outputFormat", "JPEG");// 返回格式 | 746 | intent.putExtra("outputFormat", "JPEG");// 返回格式 |
746 | startActivityForResult(intent, REQUEST_CODE_CROUP_PHOTO); | 747 | startActivityForResult(intent, REQUEST_CODE_CROUP_PHOTO); |
747 | } | 748 | } |
748 | 749 | ||
749 | @Override | 750 | @Override |
750 | public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) { | 751 | public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) { |
751 | switch (requestCode) { | 752 | switch (requestCode) { |
752 | 753 | ||
753 | case PermissionUtil.REQUEST_SHOWCAMERA: | 754 | case PermissionUtil.REQUEST_SHOWCAMERA: |
754 | if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) { | 755 | if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) { |
755 | // Permission Granted | 756 | // Permission Granted |
756 | uploadAvatarFromPhotoRequest(); | 757 | uploadAvatarFromPhotoRequest(); |
757 | 758 | ||
758 | } else { | 759 | } else { |
759 | if (!SharedPreferenceMark.getHasShowCamera()) { | 760 | if (!SharedPreferenceMark.getHasShowCamera()) { |
760 | SharedPreferenceMark.setHasShowCamera(true); | 761 | SharedPreferenceMark.setHasShowCamera(true); |
761 | new DialogPermission(this, "关闭摄像头权限影响扫描功能"); | 762 | new DialogPermission(this, "关闭摄像头权限影响扫描功能"); |
762 | 763 | ||
763 | } else { | 764 | } else { |
764 | Toast.makeText(this, "未获取摄像头权限", Toast.LENGTH_SHORT) | 765 | Toast.makeText(this, "未获取摄像头权限", Toast.LENGTH_SHORT) |
765 | .show(); | 766 | .show(); |
766 | } | 767 | } |
767 | } | 768 | } |
768 | break; | 769 | break; |
769 | default: | 770 | default: |
770 | super.onRequestPermissionsResult(requestCode, permissions, grantResults); | 771 | super.onRequestPermissionsResult(requestCode, permissions, grantResults); |
771 | } | 772 | } |
772 | } | 773 | } |
773 | 774 | ||
774 | 775 | ||
775 | private long exitTime = 0; | 776 | private long exitTime = 0; |
776 | 777 | ||
777 | @Override | 778 | @Override |
778 | public boolean onKeyDown(int keyCode, KeyEvent event) { | 779 | public boolean onKeyDown(int keyCode, KeyEvent event) { |
779 | if (keyCode == KeyEvent.KEYCODE_BACK) { | 780 | if (keyCode == KeyEvent.KEYCODE_BACK) { |
780 | if ((System.currentTimeMillis() - exitTime) > 2000) { | 781 | if ((System.currentTimeMillis() - exitTime) > 2000) { |
781 | Toast.makeText(getApplicationContext(), "再按一次退出程序", | 782 | Toast.makeText(getApplicationContext(), "再按一次退出程序", |
782 | Toast.LENGTH_SHORT).show(); | 783 | Toast.LENGTH_SHORT).show(); |
783 | exitTime = System.currentTimeMillis(); | 784 | exitTime = System.currentTimeMillis(); |
784 | } else { | 785 | } else { |
785 | //SysApplication.getInstance().finishActivity(MainActivity.this); | 786 | //SysApplication.getInstance().finishActivity(MainActivity.this); |
786 | SysApplication.getInstance().exit(); | 787 | SysApplication.getInstance().exit(); |
787 | } | 788 | } |
788 | return false; | 789 | return false; |
789 | } | 790 | } |
790 | return super.onKeyDown(keyCode, event); | 791 | return super.onKeyDown(keyCode, event); |
791 | } | 792 | } |
792 | } | 793 | } |
793 | 794 |
PersonalCenter/app/src/main/java/com/hjx/personalcenter/activity/MyApplication.java
1 | package com.hjx.personalcenter.activity; | 1 | package com.hjx.personalcenter.activity; |
2 | 2 | ||
3 | import android.app.Application; | 3 | import android.app.Application; |
4 | import android.content.Context; | 4 | import android.content.Context; |
5 | import android.graphics.drawable.Drawable; | 5 | import android.graphics.drawable.Drawable; |
6 | import android.os.Looper; | 6 | import android.os.Looper; |
7 | import android.view.Gravity; | 7 | import android.view.Gravity; |
8 | import android.widget.TextView; | 8 | import android.widget.TextView; |
9 | import android.widget.Toast; | 9 | import android.widget.Toast; |
10 | 10 | ||
11 | import com.hjx.personalcenter.R; | 11 | import com.hjx.personalcenter.R; |
12 | import com.hjx.personalcenter.crash.CrashHandler; | 12 | import com.hjx.personalcenter.crash.CrashHandler; |
13 | import com.hjx.personalcenter.util.ImageCache; | 13 | import com.hjx.personalcenter.util.ImageCache; |
14 | import com.tencent.bugly.crashreport.CrashReport; | 14 | import com.tencent.bugly.crashreport.CrashReport; |
15 | 15 | ||
16 | /** | 16 | /** |
17 | * Created by ${yf} on 2017/2/16. | 17 | * Created by ${yf} on 2017/2/16. |
18 | */ | 18 | */ |
19 | 19 | ||
20 | public class MyApplication extends Application { | 20 | public class MyApplication extends Application { |
21 | 21 | ||
22 | private ImageCache mImageCache; | 22 | private ImageCache mImageCache; |
23 | private static Context context; | 23 | private static Context context; |
24 | private static MyApplication instance; | 24 | private static MyApplication instance; |
25 | @Override | 25 | @Override |
26 | public void onCreate() { | 26 | public void onCreate() { |
27 | context = getApplicationContext(); | 27 | context = getApplicationContext(); |
28 | //c初始化内存检测 | 28 | //c初始化内存检测 |
29 | // LeakCanary.install(this); | 29 | // LeakCanary.install(this); |
30 | //初始化Fresco | 30 | //初始化Fresco |
31 | mImageCache = new ImageCache(); | 31 | mImageCache = new ImageCache(); |
32 | instance = this; | 32 | instance = this; |
33 | CrashReport.initCrashReport(getApplicationContext(), "c2170557a0", false); | 33 | CrashReport.initCrashReport(getApplicationContext(), "c2170557a0", false); |
34 | CrashHandler crashHandler = CrashHandler.getInstance(); | 34 | CrashHandler crashHandler = CrashHandler.getInstance(); |
35 | //生成错误日志,上线的时候得放开 | 35 | //生成错误日志,上线的时候得放开 |
36 | //crashHandler.init(getApplicationContext()); | 36 | crashHandler.init(getApplicationContext()); |
37 | crashHandler.registerHandler(new CrashHandler.ExceptionHandler() { | 37 | crashHandler.registerHandler(new CrashHandler.ExceptionHandler() { |
38 | 38 | ||
39 | @Override | 39 | @Override |
40 | public boolean handleCrash(final Context context, final Throwable ex) { | 40 | public boolean handleCrash(final Context context, final Throwable ex) { |
41 | new Thread(new Runnable() { | 41 | new Thread(new Runnable() { |
42 | 42 | ||
43 | @Override | 43 | @Override |
44 | public void run() { | 44 | public void run() { |
45 | Looper.prepare(); | 45 | Looper.prepare(); |
46 | System.out.println("bcz = " + ex.toString()); | 46 | System.out.println("bcz = " + ex.toString()); |
47 | Toast toast = new Toast(context); | 47 | Toast toast = new Toast(context); |
48 | TextView tv = new TextView(context); | 48 | TextView tv = new TextView(context); |
49 | tv.setText(" 很抱歉,"+context.getString(R.string.app_name)+"崩溃了,我们会尽快修复."); | 49 | tv.setText(" 很抱歉,"+context.getString(R.string.app_name)+"崩溃了,我们会尽快修复."); |
50 | tv.setPadding(10, 10, 10, 10); | 50 | tv.setPadding(10, 10, 10, 10); |
51 | tv.setTextSize(20); | 51 | tv.setTextSize(20); |
52 | tv.setBackgroundResource(R.drawable.black_btn_default); | 52 | tv.setBackgroundResource(R.drawable.black_btn_default); |
53 | tv.setTextColor(context.getResources().getColor(android.R.color.white)); | 53 | tv.setTextColor(context.getResources().getColor(android.R.color.white)); |
54 | Drawable drawable= context.getResources().getDrawable(R.drawable.sorry); | 54 | Drawable drawable= context.getResources().getDrawable(R.drawable.sorry); |
55 | drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight()); | 55 | drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight()); |
56 | tv.setCompoundDrawables(drawable,null,null,null); | 56 | tv.setCompoundDrawables(drawable,null,null,null); |
57 | toast.setView(tv); | 57 | toast.setView(tv); |
58 | toast.setGravity(Gravity.CENTER, 0, 0); | 58 | toast.setGravity(Gravity.CENTER, 0, 0); |
59 | toast.setDuration(Toast.LENGTH_LONG); | 59 | toast.setDuration(Toast.LENGTH_LONG); |
60 | toast.show(); | 60 | toast.show(); |
61 | Looper.loop(); | 61 | Looper.loop(); |
62 | } | 62 | } |
63 | }).start(); | 63 | }).start(); |
64 | try { | 64 | try { |
65 | Thread.sleep(1000); | 65 | Thread.sleep(1000); |
66 | } catch (InterruptedException e) { | 66 | } catch (InterruptedException e) { |
67 | // TODO Auto-generated catch block | 67 | // TODO Auto-generated catch block |
68 | e.printStackTrace(); | 68 | e.printStackTrace(); |
69 | } | 69 | } |
70 | return false; | 70 | return false; |
71 | } | 71 | } |
72 | }); | 72 | }); |
73 | super.onCreate(); | 73 | super.onCreate(); |
74 | } | 74 | } |
75 | public ImageCache getImageCache() { | 75 | public ImageCache getImageCache() { |
76 | return mImageCache; | 76 | return mImageCache; |
77 | } | 77 | } |
78 | 78 | ||
79 | public static Context getContext() { | 79 | public static Context getContext() { |
80 | return context; | 80 | return context; |
81 | } | 81 | } |
82 | public static MyApplication getInstance() { | 82 | public static MyApplication getInstance() { |
83 | return instance; | 83 | return instance; |
84 | } | 84 | } |
85 | 85 | ||
86 | } | 86 | } |
87 | 87 |
PersonalCenter/app/src/main/java/com/hjx/personalcenter/adapter/GridAdapter.java
1 | package com.hjx.personalcenter.adapter; | 1 | package com.hjx.personalcenter.adapter; |
2 | 2 | ||
3 | import android.content.Context; | 3 | import android.content.Context; |
4 | import android.view.View; | 4 | import android.view.View; |
5 | import android.view.ViewGroup; | 5 | import android.view.ViewGroup; |
6 | import android.widget.BaseAdapter; | 6 | import android.widget.BaseAdapter; |
7 | import android.widget.ImageView; | 7 | import android.widget.ImageView; |
8 | import android.widget.TextView; | 8 | import android.widget.TextView; |
9 | 9 | ||
10 | import com.hjx.personalcenter.R; | 10 | import com.hjx.personalcenter.R; |
11 | import com.hjx.personalcenter.model.DefautPublishInfo; | 11 | import com.hjx.personalcenter.model.DefautPublishInfo; |
12 | 12 | ||
13 | import java.util.ArrayList; | 13 | import java.util.ArrayList; |
14 | 14 | ||
15 | /** | 15 | /** |
16 | * Created by h on 2017/9/12. | 16 | * Created by h on 2017/9/12. |
17 | */ | 17 | */ |
18 | 18 | ||
19 | public class GridAdapter extends BaseAdapter { | 19 | public class GridAdapter extends BaseAdapter { |
20 | private ArrayList<DefautPublishInfo.DataBean> defautPublishInfo; | 20 | private ArrayList<DefautPublishInfo.DataBean> defautPublishInfo; |
21 | private int imageid[] = {R.mipmap.xiaoxueyuwen,R.mipmap.xiaoxueshuxue,R.mipmap.xiaoxueyinyu}; | 21 | private int imageid[] = {R.mipmap.xiaoxueyuwen,R.mipmap.xiaoxueshuxue,R.mipmap.xiaoxueyinyu}; |
22 | private int imageids[] = {R.mipmap.gaozhongyuwen,R.mipmap.gaozhongshuxue,R.mipmap.gaozhongyinyu | 22 | private int imageids[] = {R.mipmap.gaozhongyuwen,R.mipmap.gaozhongshuxue,R.mipmap.gaozhongyinyu |
23 | ,R.mipmap.gaozhongwuli,R.mipmap.gaozhonghuaxue | 23 | ,R.mipmap.gaozhongwuli,R.mipmap.gaozhonghuaxue |
24 | ,R.mipmap.gaozhongshengwu,R.mipmap.gaozhongzhengzhi,R.mipmap.gaozhonglishi | 24 | ,R.mipmap.gaozhongshengwu,R.mipmap.gaozhongzhengzhi,R.mipmap.gaozhonglishi |
25 | ,R.mipmap.gaozhongdili,R.mipmap.gaozhongkexue}; | 25 | ,R.mipmap.gaozhongdili,R.mipmap.gaozhongkexue}; |
26 | private Context context; | 26 | private Context context; |
27 | 27 | ||
28 | public GridAdapter(ArrayList<DefautPublishInfo.DataBean> defautPublishInfo, Context context) { | 28 | public GridAdapter(ArrayList<DefautPublishInfo.DataBean> defautPublishInfo, Context context) { |
29 | this.defautPublishInfo = defautPublishInfo; | 29 | this.defautPublishInfo = defautPublishInfo; |
30 | this.context = context; | 30 | this.context = context; |
31 | } | 31 | } |
32 | 32 | ||
33 | @Override | 33 | @Override |
34 | public int getCount() { | 34 | public int getCount() { |
35 | return defautPublishInfo.size(); | 35 | return defautPublishInfo.size(); |
36 | } | 36 | } |
37 | 37 | ||
38 | @Override | 38 | @Override |
39 | public Object getItem(int position) { | 39 | public Object getItem(int position) { |
40 | return position; | 40 | return position; |
41 | } | 41 | } |
42 | 42 | ||
43 | @Override | 43 | @Override |
44 | public long getItemId(int position) { | 44 | public long getItemId(int position) { |
45 | return position; | 45 | return position; |
46 | } | 46 | } |
47 | 47 | ||
48 | @Override | 48 | @Override |
49 | public View getView(int position, View convertView, ViewGroup parent) { | 49 | public View getView(int position, View convertView, ViewGroup parent) { |
50 | ViewHolder viewHolder = new ViewHolder(); | 50 | ViewHolder viewHolder = new ViewHolder(); |
51 | if (convertView == null) { | 51 | if (convertView == null) { |
52 | convertView = View.inflate(context, R.layout.fragment_changge_version_info_itmes3, null); | 52 | convertView = View.inflate(context, R.layout.fragment_changge_version_info_itmes3, null); |
53 | viewHolder.simpleDraweeView = (ImageView) convertView.findViewById(R.id.image_publish); | 53 | viewHolder.simpleDraweeView = (ImageView) convertView.findViewById(R.id.image_publish); |
54 | viewHolder.subject = (TextView) convertView.findViewById(R.id.subject); | 54 | viewHolder.subject = (TextView) convertView.findViewById(R.id.subject); |
55 | viewHolder.publish = (TextView) convertView.findViewById(R.id.tv_publish); | 55 | viewHolder.publish = (TextView) convertView.findViewById(R.id.tv_publish); |
56 | convertView.setTag(viewHolder); | 56 | convertView.setTag(viewHolder); |
57 | } else { | 57 | } else { |
58 | viewHolder = (ViewHolder) convertView.getTag(); | 58 | viewHolder = (ViewHolder) convertView.getTag(); |
59 | } | 59 | } |
60 | if (position==2){ | 60 | if (position==2){ |
61 | viewHolder.simpleDraweeView.setBackgroundResource(imageid[position]); | 61 | viewHolder.simpleDraweeView.setBackgroundResource(imageid[position]); |
62 | }else { | 62 | }else { |
63 | viewHolder.simpleDraweeView.setBackgroundResource(imageids[position]); | 63 | if (defautPublishInfo.get(position).getSubject().contains("语文")){ |
64 | viewHolder.simpleDraweeView.setBackgroundResource(imageids[0]); | ||
65 | }else if (defautPublishInfo.get(position).getSubject().contains("数学")) { | ||
66 | viewHolder.simpleDraweeView.setBackgroundResource(imageids[1]); | ||
67 | }else if (defautPublishInfo.get(position).getSubject().contains("英语")) { | ||
68 | viewHolder.simpleDraweeView.setBackgroundResource(imageids[2]); | ||
69 | }else if (defautPublishInfo.get(position).getSubject().contains("物理")) { | ||
70 | viewHolder.simpleDraweeView.setBackgroundResource(imageids[3]); | ||
71 | }else if (defautPublishInfo.get(position).getSubject().contains("化学")) { | ||
72 | viewHolder.simpleDraweeView.setBackgroundResource(imageids[4]); | ||
73 | }else if (defautPublishInfo.get(position).getSubject().contains("生物")) { | ||
74 | viewHolder.simpleDraweeView.setBackgroundResource(imageids[5]); | ||
75 | }else if (defautPublishInfo.get(position).getSubject().contains("政治")) { | ||
76 | viewHolder.simpleDraweeView.setBackgroundResource(imageids[6]); | ||
77 | }else if (defautPublishInfo.get(position).getSubject().contains("历史")) { | ||
78 | viewHolder.simpleDraweeView.setBackgroundResource(imageids[7]); | ||
79 | }else if (defautPublishInfo.get(position).getSubject().contains("地理")) { | ||
80 | viewHolder.simpleDraweeView.setBackgroundResource(imageids[8]); | ||
81 | } | ||
82 | |||
83 | |||
84 | |||
85 | |||
86 | |||
87 | |||
88 | |||
64 | } | 89 | } |
65 | viewHolder.subject.setText(defautPublishInfo.get(position).getSubject()); | 90 | viewHolder.subject.setText(defautPublishInfo.get(position).getSubject()); |
66 | viewHolder.publish.setText(defautPublishInfo.get(position).getPress()); | 91 | viewHolder.publish.setText(defautPublishInfo.get(position).getPress()); |
67 | return convertView; | 92 | return convertView; |
68 | } | 93 | } |
69 | 94 | ||
70 | static class ViewHolder { | 95 | static class ViewHolder { |
71 | ImageView simpleDraweeView; | 96 | ImageView simpleDraweeView; |
72 | TextView subject; | 97 | TextView subject; |
73 | TextView publish; | 98 | TextView publish; |
74 | } | 99 | } |
75 | } | 100 | } |
76 | 101 |
PersonalCenter/app/src/main/java/com/hjx/personalcenter/fragment/VersionsInfoFragment.java
1 | package com.hjx.personalcenter.fragment; | 1 | package com.hjx.personalcenter.fragment; |
2 | 2 | ||
3 | import android.os.Bundle; | 3 | import android.os.Bundle; |
4 | import android.os.Handler; | 4 | import android.os.Handler; |
5 | import android.os.Message; | 5 | import android.os.Message; |
6 | import android.support.annotation.Nullable; | 6 | import android.support.annotation.Nullable; |
7 | import android.support.v4.app.Fragment; | 7 | import android.support.v4.app.Fragment; |
8 | import android.support.v4.view.ViewPager; | 8 | import android.support.v4.view.ViewPager; |
9 | import android.util.Log; | 9 | import android.util.Log; |
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.AdapterView; | 13 | import android.widget.AdapterView; |
14 | import android.widget.GridView; | 14 | import android.widget.GridView; |
15 | import android.widget.ImageView; | 15 | import android.widget.ImageView; |
16 | import android.widget.LinearLayout; | 16 | import android.widget.LinearLayout; |
17 | import android.widget.TextView; | 17 | import android.widget.TextView; |
18 | 18 | ||
19 | import com.hjx.personalcenter.R; | 19 | import com.hjx.personalcenter.R; |
20 | import com.hjx.personalcenter.activity.ChangePresonalInfoActivity; | 20 | import com.hjx.personalcenter.activity.ChangePresonalInfoActivity; |
21 | import com.hjx.personalcenter.adapter.GridAdapter; | 21 | import com.hjx.personalcenter.adapter.GridAdapter; |
22 | import com.hjx.personalcenter.customdialog.VerSionDialog; | 22 | import com.hjx.personalcenter.customdialog.VerSionDialog; |
23 | import com.hjx.personalcenter.db.SaveParam; | 23 | import com.hjx.personalcenter.db.SaveParam; |
24 | import com.hjx.personalcenter.http.HttpCode; | 24 | import com.hjx.personalcenter.http.HttpCode; |
25 | import com.hjx.personalcenter.http.HttpManager; | 25 | import com.hjx.personalcenter.http.HttpManager; |
26 | import com.hjx.personalcenter.interfaces.DialogCallBack; | 26 | import com.hjx.personalcenter.interfaces.DialogCallBack; |
27 | import com.hjx.personalcenter.model.DefautPublishInfo; | 27 | import com.hjx.personalcenter.model.DefautPublishInfo; |
28 | import com.hjx.personalcenter.model.VersionInfo; | 28 | import com.hjx.personalcenter.model.VersionInfo; |
29 | import com.squareup.picasso.Picasso; | 29 | import com.squareup.picasso.Picasso; |
30 | 30 | ||
31 | import java.util.ArrayList; | 31 | import java.util.ArrayList; |
32 | import java.util.List; | 32 | import java.util.List; |
33 | 33 | ||
34 | /** | 34 | /** |
35 | * Created by h on 2017/8/12. | 35 | * Created by h on 2017/8/12. |
36 | */ | 36 | */ |
37 | 37 | ||
38 | public class VersionsInfoFragment extends Fragment implements AdapterView.OnItemClickListener, View.OnClickListener, DialogCallBack.VersionCallBack { | 38 | public class VersionsInfoFragment extends Fragment implements AdapterView.OnItemClickListener, View.OnClickListener, DialogCallBack.VersionCallBack { |
39 | private GridView gridView; | 39 | private GridView gridView; |
40 | private ArrayList<DefautPublishInfo.DataBean> defautPublishInfos = new ArrayList<>(); | 40 | private ArrayList<DefautPublishInfo.DataBean> defautPublishInfos = new ArrayList<>(); |
41 | private GridAdapter sim_adapter; | 41 | private GridAdapter sim_adapter; |
42 | private View mView; | 42 | private View mView; |
43 | private int type; | 43 | private int type; |
44 | private ImageView cances; | 44 | private ImageView cances; |
45 | private LinearLayout tv_presons; | 45 | private LinearLayout tv_presons; |
46 | private TextView publish, sub; | 46 | private TextView publish, sub; |
47 | private ImageView simpleDraweeView; | 47 | private ImageView simpleDraweeView; |
48 | public static String TABLAYOUT_FRAGMENT = "versionfragment"; | 48 | public static String TABLAYOUT_FRAGMENT = "versionfragment"; |
49 | 49 | ||
50 | private String chinese, math,english,physics,chemistry,history,geography,political,biology,science; | 50 | private String chinese, math,english,physics,chemistry,history,geography,political,biology,science; |
51 | public static VersionsInfoFragment newInstance(int type) { | 51 | public static VersionsInfoFragment newInstance(int type) { |
52 | VersionsInfoFragment fragment = new VersionsInfoFragment(); | 52 | VersionsInfoFragment fragment = new VersionsInfoFragment(); |
53 | Bundle bundle = new Bundle(); | 53 | Bundle bundle = new Bundle(); |
54 | bundle.putSerializable(TABLAYOUT_FRAGMENT, type); | 54 | bundle.putSerializable(TABLAYOUT_FRAGMENT, type); |
55 | fragment.setArguments(bundle); | 55 | fragment.setArguments(bundle); |
56 | return fragment; | 56 | return fragment; |
57 | 57 | ||
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 | switch (msg.what) { | 64 | switch (msg.what) { |
65 | case HttpCode.PUBLISH_SUCESS: | 65 | case HttpCode.PUBLISH_SUCESS: |
66 | defautPublishInfos.clear(); | 66 | defautPublishInfos.clear(); |
67 | defautPublishInfos.addAll((List<DefautPublishInfo.DataBean>) msg.obj); | 67 | defautPublishInfos.addAll((List<DefautPublishInfo.DataBean>) msg.obj); |
68 | sim_adapter.notifyDataSetChanged(); | 68 | sim_adapter.notifyDataSetChanged(); |
69 | for (int i = 0; i < defautPublishInfos.size(); i++) { | 69 | for (int i = 0; i < defautPublishInfos.size(); i++) { |
70 | String subject = defautPublishInfos.get(i).getSubject(); | 70 | String subject = defautPublishInfos.get(i).getSubject(); |
71 | if (subject.equals("语文")) { | 71 | if (subject.equals("语文")) { |
72 | chinese = defautPublishInfos.get(i).getPress(); | 72 | chinese = defautPublishInfos.get(i).getPress(); |
73 | } else if (subject.equals("数学")) { | 73 | } else if (subject.equals("数学")) { |
74 | math = defautPublishInfos.get(i).getPress(); | 74 | math = defautPublishInfos.get(i).getPress(); |
75 | } else if (subject.equals("英语")) { | 75 | } else if (subject.equals("英语")) { |
76 | english = defautPublishInfos.get(i).getPress(); | 76 | english = defautPublishInfos.get(i).getPress(); |
77 | } else if (subject.equals("物理")) { | 77 | } else if (subject.equals("物理")) { |
78 | physics = defautPublishInfos.get(i).getPress(); | 78 | physics = defautPublishInfos.get(i).getPress(); |
79 | } else if (subject.equals("化学")) { | 79 | } else if (subject.equals("化学")) { |
80 | chemistry = defautPublishInfos.get(i).getPress(); | 80 | chemistry = defautPublishInfos.get(i).getPress(); |
81 | } else if (subject.equals("历史")) { | 81 | } else if (subject.equals("历史")) { |
82 | history = defautPublishInfos.get(i).getPress(); | 82 | history = defautPublishInfos.get(i).getPress(); |
83 | } else if (subject.equals("地理")) { | 83 | } else if (subject.equals("地理")) { |
84 | geography = defautPublishInfos.get(i).getPress(); | 84 | geography = defautPublishInfos.get(i).getPress(); |
85 | } else if (subject.equals("政治")) { | 85 | } else if (subject.equals("政治")) { |
86 | political = defautPublishInfos.get(i).getPress(); | 86 | political = defautPublishInfos.get(i).getPress(); |
87 | }else if (subject.equals("生物")) { | 87 | }else if (subject.equals("生物")) { |
88 | biology = defautPublishInfos.get(i).getPress(); | 88 | biology = defautPublishInfos.get(i).getPress(); |
89 | }else if (subject.equals("科学")) { | 89 | }else if (subject.equals("科学")) { |
90 | science = defautPublishInfos.get(i).getPress(); | 90 | science = defautPublishInfos.get(i).getPress(); |
91 | } | 91 | } |
92 | } | 92 | } |
93 | break; | 93 | break; |
94 | } | 94 | } |
95 | } | 95 | } |
96 | }; | 96 | }; |
97 | 97 | ||
98 | @Override | 98 | @Override |
99 | public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { | 99 | public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { |
100 | if (mView == null) { | 100 | if (mView == null) { |
101 | mView = inflater.inflate(R.layout.fragment_changge_version_info, container, false); | 101 | mView = inflater.inflate(R.layout.fragment_changge_version_info, container, false); |
102 | String userID = SaveParam.getInstance().getLoginParam(getActivity(), "userId"); | 102 | String userID = SaveParam.getInstance().getLoginParam(getActivity(), "userId"); |
103 | String graderid = SaveParam.getInstance().getLoginParam(getActivity(), SaveParam.GRADENS); | 103 | String graderid = SaveParam.getInstance().getLoginParam(getActivity(), SaveParam.GRADENS); |
104 | // //子账户年级id | 104 | // //子账户年级id |
105 | // String graderidchilds = SaveParam.getInstance().getCustomizeParam(getActivity(), SaveParam.CHILDSGRADENS); | 105 | // String graderidchilds = SaveParam.getInstance().getCustomizeParam(getActivity(), SaveParam.CHILDSGRADENS); |
106 | //账户类型 | 106 | //账户类型 |
107 | String accounts = SaveParam.getInstance().getCustomizeParam(getActivity(), SaveParam.ACCOUNT); | 107 | String accounts = SaveParam.getInstance().getCustomizeParam(getActivity(), SaveParam.ACCOUNT); |
108 | String childID = SaveParam.getInstance().getCustomizeParam(getActivity(),SaveParam.CHILDSID); | 108 | String childID = SaveParam.getInstance().getCustomizeParam(getActivity(),SaveParam.CHILDSID); |
109 | try { | 109 | try { |
110 | Object auserID; | 110 | Object auserID; |
111 | int type; | 111 | int type; |
112 | int graderIDs =Integer.parseInt(graderid); | 112 | int graderIDs =Integer.parseInt(graderid); |
113 | if ("2".equals(accounts)){ | 113 | if ("2".equals(accounts)){ |
114 | type=Integer.parseInt(accounts); | 114 | type=Integer.parseInt(accounts); |
115 | auserID =childID; | 115 | auserID =childID; |
116 | }else { | 116 | }else { |
117 | type =Integer.parseInt(accounts); | 117 | type =Integer.parseInt(accounts); |
118 | auserID =Long.parseLong(userID); | 118 | auserID =Long.parseLong(userID); |
119 | } | 119 | } |
120 | //获取版本信息 | 120 | //获取版本信息 |
121 | HttpManager.getInstance().getpublishinfo(getActivity(),auserID,graderIDs,type,handler); | 121 | HttpManager.getInstance().getpublishinfo(getActivity(),auserID,graderIDs,type,handler); |
122 | 122 | ||
123 | } catch (NumberFormatException e) { | 123 | } catch (NumberFormatException e) { |
124 | e.printStackTrace(); | 124 | e.printStackTrace(); |
125 | } | 125 | } |
126 | 126 | ||
127 | initView(mView); | 127 | initView(mView); |
128 | initData(); | 128 | initData(); |
129 | setLister(); | 129 | setLister(); |
130 | 130 | ||
131 | 131 | ||
132 | } | 132 | } |
133 | return mView; | 133 | return mView; |
134 | } | 134 | } |
135 | 135 | ||
136 | //初始化 | 136 | //初始化 |
137 | private void initView(View mView) { | 137 | private void initView(View mView) { |
138 | gridView = (GridView) mView.findViewById(R.id.grideview); | 138 | gridView = (GridView) mView.findViewById(R.id.grideview); |
139 | cances = (ImageView) mView.findViewById(R.id.cancel); | 139 | cances = (ImageView) mView.findViewById(R.id.cancel); |
140 | sub = (TextView) mView.findViewById(R.id.version_sub); | 140 | sub = (TextView) mView.findViewById(R.id.version_sub); |
141 | tv_presons = (LinearLayout) mView.findViewById(R.id.tv_presons); | 141 | tv_presons = (LinearLayout) mView.findViewById(R.id.tv_presons); |
142 | 142 | ||
143 | } | 143 | } |
144 | 144 | ||
145 | private void initData() { | 145 | private void initData() { |
146 | sim_adapter = new GridAdapter(defautPublishInfos, getActivity()); | 146 | sim_adapter = new GridAdapter(defautPublishInfos, getActivity()); |
147 | //配置适配器 | 147 | //配置适配器 |
148 | gridView.setAdapter(sim_adapter); | 148 | gridView.setAdapter(sim_adapter); |
149 | } | 149 | } |
150 | 150 | ||
151 | private void setLister() { | 151 | private void setLister() { |
152 | gridView.setOnItemClickListener(this); | 152 | gridView.setOnItemClickListener(this); |
153 | sub.setOnClickListener(this); | 153 | sub.setOnClickListener(this); |
154 | tv_presons.setOnClickListener(this); | 154 | tv_presons.setOnClickListener(this); |
155 | cances.setOnClickListener(this); | 155 | cances.setOnClickListener(this); |
156 | } | 156 | } |
157 | 157 | ||
158 | @Override | 158 | @Override |
159 | public void onItemClick(AdapterView<?> parent, View view, int position, long id) { | 159 | public void onItemClick(AdapterView<?> parent, View view, int position, long id) { |
160 | SaveParam.getInstance().saveLoginParam(getActivity(), SaveParam.SUBJECT, defautPublishInfos.get(position).getSubject()); | 160 | SaveParam.getInstance().saveLoginParam(getActivity(), SaveParam.SUBJECT, defautPublishInfos.get(position).getSubject()); |
161 | VerSionDialog.getInstance(this).show(getChildFragmentManager(), "VerSionDialog"); | 161 | VerSionDialog.getInstance(this).show(getChildFragmentManager(), "VerSionDialog"); |
162 | simpleDraweeView = (ImageView) view.findViewById(R.id.image_publish); | 162 | simpleDraweeView = (ImageView) view.findViewById(R.id.image_publish); |
163 | publish = (TextView) view.findViewById(R.id.tv_publish); | 163 | publish = (TextView) view.findViewById(R.id.tv_publish); |
164 | 164 | ||
165 | } | 165 | } |
166 | 166 | ||
167 | @Override | 167 | @Override |
168 | public void setUserVisibleHint(boolean isVisibleToUser) { | 168 | public void setUserVisibleHint(boolean isVisibleToUser) { |
169 | super.setUserVisibleHint(isVisibleToUser); | 169 | super.setUserVisibleHint(isVisibleToUser); |
170 | if (isVisibleToUser){ | 170 | if (isVisibleToUser){ |
171 | String userID = SaveParam.getInstance().getLoginParam(getActivity(), "userId"); | 171 | String userID = SaveParam.getInstance().getLoginParam(getActivity(), "userId"); |
172 | //String graderid = SaveParam.getInstance().getLoginParam(getActivity(), SaveParam.GRADENS); | 172 | //String graderid = SaveParam.getInstance().getLoginParam(getActivity(), SaveParam.GRADENS); |
173 | String graderid = SaveParam.getInstance().getLoginParam(getActivity(), SaveParam.VIEGREADE); | 173 | String graderid = SaveParam.getInstance().getLoginParam(getActivity(), SaveParam.VIEGREADE); |
174 | // //子账户年级id | 174 | // //子账户年级id |
175 | // String graderidchilds = SaveParam.getInstance().getCustomizeParam(getActivity(), SaveParam.CHILDSGRADENS); | 175 | // String graderidchilds = SaveParam.getInstance().getCustomizeParam(getActivity(), SaveParam.CHILDSGRADENS); |
176 | //账户类型 | 176 | //账户类型 |
177 | String accounts = SaveParam.getInstance().getCustomizeParam(getActivity(), SaveParam.ACCOUNT); | 177 | String accounts = SaveParam.getInstance().getCustomizeParam(getActivity(), SaveParam.ACCOUNT); |
178 | String childID = SaveParam.getInstance().getCustomizeParam(getActivity(),SaveParam.CHILDSID); | 178 | String childID = SaveParam.getInstance().getCustomizeParam(getActivity(),SaveParam.CHILDSID); |
179 | try { | 179 | try { |
180 | Object auserID; | 180 | Object auserID; |
181 | int type; | 181 | int type; |
182 | int graderIDs =Integer.parseInt(graderid); | 182 | int graderIDs =Integer.parseInt(graderid); |
183 | if ("2".equals(accounts)){ | 183 | if ("2".equals(accounts)){ |
184 | type=Integer.parseInt(accounts); | 184 | type=Integer.parseInt(accounts); |
185 | auserID =childID; | 185 | auserID =childID; |
186 | }else { | 186 | }else { |
187 | type =Integer.parseInt(accounts); | 187 | type =Integer.parseInt(accounts); |
188 | auserID =Long.parseLong(userID); | 188 | auserID =Long.parseLong(userID); |
189 | } | 189 | } |
190 | //获取版本信息 | 190 | //获取版本信息 |
191 | HttpManager.getInstance().getpublishinfo(getActivity(),auserID,graderIDs,type,handler); | 191 | HttpManager.getInstance().getpublishinfo(getActivity(),auserID,graderIDs,type,handler); |
192 | 192 | ||
193 | } catch (NumberFormatException e) { | 193 | } catch (NumberFormatException e) { |
194 | e.printStackTrace(); | 194 | e.printStackTrace(); |
195 | } | 195 | } |
196 | 196 | ||
197 | } | 197 | } |
198 | } | 198 | } |
199 | 199 | ||
200 | @Override | 200 | @Override |
201 | public void onResume() { | 201 | public void onResume() { |
202 | String userID = SaveParam.getInstance().getLoginParam(getActivity(), "userId"); | 202 | // String userID = SaveParam.getInstance().getLoginParam(getActivity(), "userId"); |
203 | String graderid = SaveParam.getInstance().getLoginParam(getActivity(), SaveParam.GRADENS); | 203 | // String graderid = SaveParam.getInstance().getLoginParam(getActivity(), SaveParam.GRADENS); |
204 | // //子账户年级id | 204 | //// //子账户年级id |
205 | // String graderidchilds = SaveParam.getInstance().getCustomizeParam(getActivity(), SaveParam.CHILDSGRADENS); | 205 | //// String graderidchilds = SaveParam.getInstance().getCustomizeParam(getActivity(), SaveParam.CHILDSGRADENS); |
206 | //账户类型 | 206 | // //账户类型 |
207 | String accounts = SaveParam.getInstance().getCustomizeParam(getActivity(), SaveParam.ACCOUNT); | 207 | // String accounts = SaveParam.getInstance().getCustomizeParam(getActivity(), SaveParam.ACCOUNT); |
208 | String childID = SaveParam.getInstance().getCustomizeParam(getActivity(),SaveParam.CHILDSID); | 208 | // String childID = SaveParam.getInstance().getCustomizeParam(getActivity(),SaveParam.CHILDSID); |
209 | try { | 209 | // try { |
210 | Object auserID; | 210 | // Object auserID; |
211 | int type; | 211 | // int type; |
212 | int graderIDs =Integer.parseInt(graderid); | 212 | // int graderIDs =Integer.parseInt(graderid); |
213 | if ("2".equals(accounts)){ | 213 | // if ("2".equals(accounts)){ |
214 | type=Integer.parseInt(accounts); | 214 | // type=Integer.parseInt(accounts); |
215 | auserID =childID; | 215 | // auserID =childID; |
216 | }else { | 216 | // }else { |
217 | type =Integer.parseInt(accounts); | 217 | // type =Integer.parseInt(accounts); |
218 | auserID =Long.parseLong(userID); | 218 | // auserID =Long.parseLong(userID); |
219 | } | 219 | // } |
220 | //获取版本信息 | 220 | // //获取版本信息 |
221 | HttpManager.getInstance().getpublishinfo(getActivity(),auserID,graderIDs,type,handler); | 221 | // HttpManager.getInstance().getpublishinfo(getActivity(),auserID,graderIDs,type,handler); |
222 | 222 | // | |
223 | } catch (NumberFormatException e) { | 223 | // } catch (NumberFormatException e) { |
224 | e.printStackTrace(); | 224 | // e.printStackTrace(); |
225 | } | 225 | // } |
226 | super.onResume(); | 226 | super.onResume(); |
227 | 227 | ||
228 | } | 228 | } |
229 | 229 | ||
230 | @Override | 230 | @Override |
231 | public void onClick(View v) { | 231 | public void onClick(View v) { |
232 | switch (v.getId()) { | 232 | switch (v.getId()) { |
233 | case R.id.version_sub: | 233 | case R.id.version_sub: |
234 | Log.e("test", "你提交版本信息"); | 234 | Log.e("test", "你提交版本信息"); |
235 | String userID = SaveParam.getInstance().getLoginParam(getActivity(), "userId"); | 235 | String userID = SaveParam.getInstance().getLoginParam(getActivity(), "userId"); |
236 | //子账户id | 236 | //子账户id |
237 | String childsidid = SaveParam.getInstance().getCustomizeParam(getActivity(), SaveParam.CHILDSID); | 237 | String childsidid = SaveParam.getInstance().getCustomizeParam(getActivity(), SaveParam.CHILDSID); |
238 | //账户类型 | 238 | //账户类型 |
239 | String accounts = SaveParam.getInstance().getCustomizeParam(getActivity(), SaveParam.ACCOUNT); | 239 | String accounts = SaveParam.getInstance().getCustomizeParam(getActivity(), SaveParam.ACCOUNT); |
240 | try { | 240 | try { |
241 | String id = null; | 241 | String id = null; |
242 | //String piblish = "清华大学出版社"; | 242 | //String piblish = "清华大学出版社"; |
243 | if ("2".equals(accounts)) { | 243 | if ("2".equals(accounts)) { |
244 | id = childsidid; | 244 | id = childsidid; |
245 | } else { | 245 | } else { |
246 | id = userID; | 246 | id = userID; |
247 | } | 247 | } |
248 | //修改版本信息 | 248 | //修改版本信息 |
249 | HttpManager.getInstance().changepublishinfo(getActivity(), id,chinese,math,english,physics,chemistry,history,geography,political,biology,science); | 249 | HttpManager.getInstance().changepublishinfo(getActivity(), id,chinese,math,english,physics,chemistry,history,geography,political,biology,science); |
250 | 250 | ||
251 | } catch (NumberFormatException e) { | 251 | } catch (NumberFormatException e) { |
252 | e.printStackTrace(); | 252 | e.printStackTrace(); |
253 | } | 253 | } |
254 | 254 | ||
255 | 255 | ||
256 | break; | 256 | break; |
257 | case R.id.tv_presons: | 257 | case R.id.tv_presons: |
258 | final ChangePresonalInfoActivity mainActivity = (ChangePresonalInfoActivity) getActivity(); | 258 | final ChangePresonalInfoActivity mainActivity = (ChangePresonalInfoActivity) getActivity(); |
259 | mainActivity.setFragment2Fragment(new ChangePresonalInfoActivity.Fragment2Fragment() { | 259 | mainActivity.setFragment2Fragment(new ChangePresonalInfoActivity.Fragment2Fragment() { |
260 | @Override | 260 | @Override |
261 | public void gotoFragment(ViewPager viewPager) { | 261 | public void gotoFragment(ViewPager viewPager) { |
262 | //fragment传递数据 | 262 | //fragment传递数据 |
263 | viewPager.setCurrentItem(0); | 263 | viewPager.setCurrentItem(0); |
264 | } | 264 | } |
265 | }); | 265 | }); |
266 | mainActivity.forSkip(); | 266 | mainActivity.forSkip(); |
267 | break; | 267 | break; |
268 | 268 | ||
269 | case R.id.cancel: | 269 | case R.id.cancel: |
270 | getActivity().finish(); | 270 | getActivity().finish(); |
271 | break; | 271 | break; |
272 | } | 272 | } |
273 | 273 | ||
274 | } | 274 | } |
275 | 275 | ||
276 | @Override | 276 | @Override |
277 | public void versionOnItemClick(ArrayList<VersionInfo.DataBean> data, int position, int type) { | 277 | public void versionOnItemClick(ArrayList<VersionInfo.DataBean> data, int position, int type) { |
278 | String imageurl = data.get(position).getPressCover(); | 278 | String imageurl = data.get(position).getPressCover(); |
279 | String publishs = data.get(position).getPressName(); | 279 | String publishs = data.get(position).getPressName(); |
280 | 280 | ||
281 | if (imageurl!=null&&!imageurl.isEmpty()) { | 281 | if (imageurl!=null&&!imageurl.isEmpty()) { |
282 | Picasso.with(getActivity()).load(imageurl).into(simpleDraweeView); | 282 | Picasso.with(getActivity()).load(imageurl).into(simpleDraweeView); |
283 | } | 283 | } |
284 | publish.setText(publishs); | 284 | publish.setText(publishs); |
285 | String subject = SaveParam.getInstance().getLoginParam(getActivity(), SaveParam.SUBJECT); | 285 | String subject = SaveParam.getInstance().getLoginParam(getActivity(), SaveParam.SUBJECT); |
286 | Log.e("test", "选择的科目" + subject); | 286 | Log.e("test", "选择的科目" + subject); |
287 | if ("语文".equals(subject)) { | 287 | if ("语文".equals(subject)) { |
288 | chinese = publishs; | 288 | chinese = publishs; |
289 | } else if ("数学".equals(subject)) { | 289 | } else if ("数学".equals(subject)) { |
290 | math = publishs; | 290 | math = publishs; |
291 | }else if ("英语".equals(subject)) { | 291 | }else if ("英语".equals(subject)) { |
292 | english = publishs; | 292 | english = publishs; |
293 | }else if ("物理".equals(subject)) { | 293 | }else if ("物理".equals(subject)) { |
294 | physics = publishs; | 294 | physics = publishs; |
295 | }else if ("化学".equals(subject)) { | 295 | }else if ("化学".equals(subject)) { |
296 | chemistry = publishs; | 296 | chemistry = publishs; |
297 | }else if ("历史".equals(subject)) { | 297 | }else if ("历史".equals(subject)) { |
298 | history = publishs; | 298 | history = publishs; |
299 | }else if ("地理".equals(subject)) { | 299 | }else if ("地理".equals(subject)) { |
300 | geography = publishs; | 300 | geography = publishs; |
301 | }else if ("政治".equals(subject)) { | 301 | }else if ("政治".equals(subject)) { |
302 | political = publishs; | 302 | political = publishs; |
303 | }else if ("生物".equals(subject)) { | 303 | }else if ("生物".equals(subject)) { |
304 | biology = publishs; | 304 | biology = publishs; |
305 | }else if ("科学".equals(subject)) { | 305 | }else if ("科学".equals(subject)) { |
306 | science = publishs; | 306 | science = publishs; |
307 | } | 307 | } |
308 | 308 | ||
309 | } | 309 | } |
310 | } | 310 | } |
311 | 311 |
PersonalCenter/app/src/main/res/mipmap-hdpi/head_default.png
5.72 KB
PersonalCenter/app/src/main/res/mipmap-xhdpi/head_default.png
5.72 KB
PersonalCenter/app/src/main/res/mipmap-xhdpi/header_default.png