Commit 2c99dc96b1261fcb885e753855843d31dd1954fd
1 parent
80c9782036
Exists in
master
适配N979S主页面,隐藏切换桌面按钮
Showing
4 changed files
with
6 additions
and
2 deletions
Show diff stats
PersonalCenter/app/PresonalCenter.apk
No preview for this file type
PersonalCenter/app/PresonalCenter_2020_0706.apk
No preview for this file type
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 23 | 9 | targetSdkVersion 23 |
| 10 | versionCode 17 | 10 | versionCode 18 |
| 11 | versionName "1.2.8" | 11 | versionName "1.2.9" |
| 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.3.1' | 47 | compile 'com.android.support:recyclerview-v7:25.3.1' |
| 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.app.Dialog; | 3 | import android.app.Dialog; |
| 4 | import android.content.Context; | 4 | import android.content.Context; |
| 5 | import android.content.Intent; | 5 | import android.content.Intent; |
| 6 | import android.content.pm.PackageManager; | 6 | import android.content.pm.PackageManager; |
| 7 | import android.net.Uri; | 7 | import android.net.Uri; |
| 8 | import android.os.Build; | 8 | import android.os.Build; |
| 9 | import android.os.Bundle; | 9 | import android.os.Bundle; |
| 10 | import android.os.Handler; | 10 | import android.os.Handler; |
| 11 | import android.os.Message; | 11 | import android.os.Message; |
| 12 | import android.provider.MediaStore; | 12 | import android.provider.MediaStore; |
| 13 | import android.support.annotation.NonNull; | 13 | import android.support.annotation.NonNull; |
| 14 | import android.support.v4.app.FragmentActivity; | 14 | import android.support.v4.app.FragmentActivity; |
| 15 | import android.support.v4.content.FileProvider; | 15 | import android.support.v4.content.FileProvider; |
| 16 | import android.support.v7.widget.LinearLayoutManager; | 16 | import android.support.v7.widget.LinearLayoutManager; |
| 17 | import android.support.v7.widget.RecyclerView; | 17 | import android.support.v7.widget.RecyclerView; |
| 18 | import android.util.Log; | 18 | import android.util.Log; |
| 19 | import android.view.KeyEvent; | 19 | import android.view.KeyEvent; |
| 20 | import android.view.LayoutInflater; | 20 | import android.view.LayoutInflater; |
| 21 | import android.view.View; | 21 | import android.view.View; |
| 22 | import android.view.ViewGroup; | 22 | import android.view.ViewGroup; |
| 23 | import android.widget.Button; | 23 | import android.widget.Button; |
| 24 | import android.widget.GridView; | 24 | import android.widget.GridView; |
| 25 | import android.widget.ImageView; | 25 | import android.widget.ImageView; |
| 26 | import android.widget.LinearLayout; | 26 | import android.widget.LinearLayout; |
| 27 | import android.widget.TextView; | 27 | import android.widget.TextView; |
| 28 | import android.widget.Toast; | 28 | import android.widget.Toast; |
| 29 | 29 | ||
| 30 | import com.google.gson.Gson; | 30 | import com.google.gson.Gson; |
| 31 | import com.hjx.personalcenter.R; | 31 | import com.hjx.personalcenter.R; |
| 32 | import com.hjx.personalcenter.adapter.MianGridAdapter; | 32 | import com.hjx.personalcenter.adapter.MianGridAdapter; |
| 33 | import com.hjx.personalcenter.adapter.VideoAdapter; | 33 | import com.hjx.personalcenter.adapter.VideoAdapter; |
| 34 | import com.hjx.personalcenter.customdialog.HeadDialog; | 34 | import com.hjx.personalcenter.customdialog.HeadDialog; |
| 35 | import com.hjx.personalcenter.customdialog.RecyclerViewSpaceItem; | 35 | import com.hjx.personalcenter.customdialog.RecyclerViewSpaceItem; |
| 36 | import com.hjx.personalcenter.db.Content; | 36 | import com.hjx.personalcenter.db.Content; |
| 37 | import com.hjx.personalcenter.db.SaveParam; | 37 | import com.hjx.personalcenter.db.SaveParam; |
| 38 | import com.hjx.personalcenter.http.HttpCode; | 38 | import com.hjx.personalcenter.http.HttpCode; |
| 39 | import com.hjx.personalcenter.http.HttpManager; | 39 | import com.hjx.personalcenter.http.HttpManager; |
| 40 | import com.hjx.personalcenter.interfaces.DialogCallBack; | 40 | import com.hjx.personalcenter.interfaces.DialogCallBack; |
| 41 | import com.hjx.personalcenter.model.DefautPublishInfo; | 41 | import com.hjx.personalcenter.model.DefautPublishInfo; |
| 42 | import com.hjx.personalcenter.model.DeviceInfo; | ||
| 42 | import com.hjx.personalcenter.model.PesonalInfo; | 43 | import com.hjx.personalcenter.model.PesonalInfo; |
| 43 | import com.hjx.personalcenter.model.SignInfo; | 44 | import com.hjx.personalcenter.model.SignInfo; |
| 44 | import com.hjx.personalcenter.model.VideoInfo; | 45 | import com.hjx.personalcenter.model.VideoInfo; |
| 45 | import com.hjx.personalcenter.update.UpdateChecker; | 46 | import com.hjx.personalcenter.update.UpdateChecker; |
| 46 | import com.hjx.personalcenter.util.AlertUtils; | 47 | import com.hjx.personalcenter.util.AlertUtils; |
| 47 | import com.hjx.personalcenter.util.BrithdayStar; | 48 | import com.hjx.personalcenter.util.BrithdayStar; |
| 48 | import com.hjx.personalcenter.util.CropUtils; | 49 | import com.hjx.personalcenter.util.CropUtils; |
| 49 | import com.hjx.personalcenter.util.DialogPermission; | 50 | import com.hjx.personalcenter.util.DialogPermission; |
| 50 | import com.hjx.personalcenter.util.FileUtil; | 51 | import com.hjx.personalcenter.util.FileUtil; |
| 51 | import com.hjx.personalcenter.util.GetDevicesUtil; | 52 | import com.hjx.personalcenter.util.GetDevicesUtil; |
| 52 | import com.hjx.personalcenter.util.PermissionUtil; | 53 | import com.hjx.personalcenter.util.PermissionUtil; |
| 53 | import com.hjx.personalcenter.util.SharedPreferenceMark; | 54 | import com.hjx.personalcenter.util.SharedPreferenceMark; |
| 54 | import com.mylhyl.circledialog.CircleDialog; | 55 | import com.mylhyl.circledialog.CircleDialog; |
| 55 | import com.mylhyl.circledialog.callback.ConfigInput; | 56 | import com.mylhyl.circledialog.callback.ConfigInput; |
| 56 | import com.mylhyl.circledialog.params.InputParams; | 57 | import com.mylhyl.circledialog.params.InputParams; |
| 57 | import com.mylhyl.circledialog.view.listener.OnInputClickListener; | 58 | import com.mylhyl.circledialog.view.listener.OnInputClickListener; |
| 58 | import com.squareup.picasso.Picasso; | 59 | import com.squareup.picasso.Picasso; |
| 59 | import com.zaaach.toprightmenu.MenuItem; | 60 | import com.zaaach.toprightmenu.MenuItem; |
| 60 | import com.zaaach.toprightmenu.TopRightMenu; | 61 | import com.zaaach.toprightmenu.TopRightMenu; |
| 61 | 62 | ||
| 62 | import org.json.JSONException; | 63 | import org.json.JSONException; |
| 63 | import org.json.JSONObject; | 64 | import org.json.JSONObject; |
| 64 | 65 | ||
| 65 | import java.io.File; | 66 | import java.io.File; |
| 66 | import java.io.UnsupportedEncodingException; | 67 | import java.io.UnsupportedEncodingException; |
| 67 | import java.util.ArrayList; | 68 | import java.util.ArrayList; |
| 68 | import java.util.List; | 69 | import java.util.List; |
| 69 | 70 | ||
| 70 | public class MainActivity extends FragmentActivity implements View.OnClickListener, DialogCallBack.CallBackView { | 71 | public class MainActivity extends FragmentActivity implements View.OnClickListener, DialogCallBack.CallBackView { |
| 71 | private ImageView iv_imformatioan, iv_setting, iv_sign, iv_sex,iv_switch, tv_edit_presoninfo; | 72 | private ImageView iv_imformatioan, iv_setting, iv_sign, iv_sex,iv_switch, tv_edit_presoninfo; |
| 72 | private TextView tv_sign, | 73 | private TextView tv_sign, |
| 73 | tv_username, tv_username1, tv_mygad, tv_sex, tv_useinfo_adress, tv_useinfo_birthday, | 74 | tv_username, tv_username1, tv_mygad, tv_sex, tv_useinfo_adress, tv_useinfo_birthday, |
| 74 | tv_useinfo_qq, tv_useinfo_school, tv_useinfo_gender, tv_yangji; | 75 | tv_useinfo_qq, tv_useinfo_school, tv_useinfo_gender, tv_yangji; |
| 75 | private TextView linel_mycuoti, linel_mynote, linel_mycollege, linel_myclass, iv_look_card; | 76 | private TextView linel_mycuoti, linel_mynote, linel_mycollege, linel_myclass, iv_look_card; |
| 76 | private TopRightMenu mTopRightMenu; | 77 | private TopRightMenu mTopRightMenu; |
| 77 | private LinearLayout view_novedeo; | 78 | private LinearLayout view_novedeo; |
| 78 | private View sssssssss; | 79 | private View sssssssss; |
| 79 | //水平滑动 | 80 | //水平滑动 |
| 80 | private RecyclerView mRecyclerView; | 81 | private RecyclerView mRecyclerView; |
| 81 | private GridView mRecyclerViewpublish; | 82 | private GridView mRecyclerViewpublish; |
| 82 | private VideoAdapter RecyclerViewadapter; | 83 | private VideoAdapter RecyclerViewadapter; |
| 83 | private MianGridAdapter RecyclerViewadapterpublish; | 84 | private MianGridAdapter RecyclerViewadapterpublish; |
| 84 | private ArrayList<DefautPublishInfo.DataBean> defautPublishInfos = new ArrayList<>(); | 85 | private ArrayList<DefautPublishInfo.DataBean> defautPublishInfos = new ArrayList<>(); |
| 85 | 86 | ||
| 86 | private ArrayList<VideoInfo.DataBean> videoinfo = new ArrayList<>(); | 87 | private ArrayList<VideoInfo.DataBean> videoinfo = new ArrayList<>(); |
| 87 | private boolean showIcon = false; | 88 | private boolean showIcon = false; |
| 88 | private boolean dimBg = false; | 89 | private boolean dimBg = false; |
| 89 | private boolean needAnim = true; | 90 | private boolean needAnim = true; |
| 90 | private static final int REQUEST_CODE_TAKE_PHOTO = 1; | 91 | private static final int REQUEST_CODE_TAKE_PHOTO = 1; |
| 91 | private static final int REQUEST_CODE_ALBUM = 2; | 92 | private static final int REQUEST_CODE_ALBUM = 2; |
| 92 | private static final int REQUEST_CODE_CROUP_PHOTO = 3; | 93 | private static final int REQUEST_CODE_CROUP_PHOTO = 3; |
| 93 | private ImageView mSimpleDraweeView; | 94 | private ImageView mSimpleDraweeView; |
| 94 | private File file; | 95 | private File file; |
| 95 | private Uri uri; | 96 | private Uri uri; |
| 96 | String portrait; | 97 | String portrait; |
| 97 | private Button middle_btn,primary_btn; | 98 | private Button middle_btn,primary_btn; |
| 98 | private Dialog hintDialog; | 99 | private Dialog hintDialog; |
| 99 | 100 | ||
| 100 | Handler handler = new Handler() { | 101 | Handler handler = new Handler() { |
| 101 | @Override | 102 | @Override |
| 102 | public void handleMessage(Message msg) { | 103 | public void handleMessage(Message msg) { |
| 103 | super.handleMessage(msg); | 104 | super.handleMessage(msg); |
| 104 | switch (msg.what) { | 105 | switch (msg.what) { |
| 105 | case HttpCode.GETINFO: | 106 | case HttpCode.GETINFO: |
| 106 | PesonalInfo.DataBean cardinfoBean = (PesonalInfo.DataBean) msg.obj; | 107 | PesonalInfo.DataBean cardinfoBean = (PesonalInfo.DataBean) msg.obj; |
| 107 | tv_username.setText(cardinfoBean.getNickName()); | 108 | tv_username.setText(cardinfoBean.getNickName()); |
| 108 | tv_username1.setText(cardinfoBean.getNickName()); | 109 | tv_username1.setText(cardinfoBean.getNickName()); |
| 109 | tv_useinfo_adress.setText(cardinfoBean.getRegion().getRegionName()); | 110 | tv_useinfo_adress.setText(cardinfoBean.getRegion().getRegionName()); |
| 110 | tv_useinfo_birthday.setText(cardinfoBean.getBirthday()); | 111 | tv_useinfo_birthday.setText(cardinfoBean.getBirthday()); |
| 111 | tv_useinfo_qq.setText(cardinfoBean.getQq()); | 112 | tv_useinfo_qq.setText(cardinfoBean.getQq()); |
| 112 | tv_useinfo_school.setText(cardinfoBean.getSchool().getSchoolName()); | 113 | tv_useinfo_school.setText(cardinfoBean.getSchool().getSchoolName()); |
| 113 | tv_useinfo_gender.setText(cardinfoBean.getGrade().getGradeName()); | 114 | tv_useinfo_gender.setText(cardinfoBean.getGrade().getGradeName()); |
| 114 | String sex = cardinfoBean.getGender(); | 115 | String sex = cardinfoBean.getGender(); |
| 115 | if ("0".equals(sex)) { | 116 | if ("0".equals(sex)) { |
| 116 | tv_sex.setText("男"); | 117 | tv_sex.setText("男"); |
| 117 | iv_sex.setImageResource(R.mipmap.men); | 118 | iv_sex.setImageResource(R.mipmap.men); |
| 118 | } else { | 119 | } else { |
| 119 | tv_sex.setText("女"); | 120 | tv_sex.setText("女"); |
| 120 | iv_sex.setImageResource(R.mipmap.women); | 121 | iv_sex.setImageResource(R.mipmap.women); |
| 121 | } | 122 | } |
| 122 | portrait = cardinfoBean.getPortrait(); | 123 | portrait = cardinfoBean.getPortrait(); |
| 123 | //mSimpleDraweeView.setImageURI(cardinfoBean.getPortrait()); | 124 | //mSimpleDraweeView.setImageURI(cardinfoBean.getPortrait()); |
| 124 | if (portrait!=null&&!portrait.isEmpty()) { | 125 | if (portrait!=null&&!portrait.isEmpty()) { |
| 125 | Picasso.with(MainActivity.this).load(portrait).into(mSimpleDraweeView); | 126 | Picasso.with(MainActivity.this).load(portrait).into(mSimpleDraweeView); |
| 126 | } | 127 | } |
| 127 | //加载星座 | 128 | //加载星座 |
| 128 | BrithdayStar brithdayStar = new BrithdayStar(); | 129 | BrithdayStar brithdayStar = new BrithdayStar(); |
| 129 | if (cardinfoBean.getBirthday() == null || "".equals(cardinfoBean.getBirthday())) { | 130 | if (cardinfoBean.getBirthday() == null || "".equals(cardinfoBean.getBirthday())) { |
| 130 | tv_mygad.setText(""); | 131 | tv_mygad.setText(""); |
| 131 | } else { | 132 | } else { |
| 132 | String xiongzuo = brithdayStar.getConstellations(cardinfoBean.getBirthday()); | 133 | String xiongzuo = brithdayStar.getConstellations(cardinfoBean.getBirthday()); |
| 133 | tv_mygad.setText(xiongzuo); | 134 | tv_mygad.setText(xiongzuo); |
| 134 | } | 135 | } |
| 135 | //保存个人信息 | 136 | //保存个人信息 |
| 136 | SaveParam.getInstance().saveLoginParam(MainActivity.this, SaveParam.ACCOUNTUSERNAME, cardinfoBean.getNickName()); | 137 | SaveParam.getInstance().saveLoginParam(MainActivity.this, SaveParam.ACCOUNTUSERNAME, cardinfoBean.getNickName()); |
| 137 | SaveParam.getInstance().saveLoginParam(MainActivity.this, SaveParam.ACCOUNTGRADES, cardinfoBean.getGrade().getGradeName()); | 138 | SaveParam.getInstance().saveLoginParam(MainActivity.this, SaveParam.ACCOUNTGRADES, cardinfoBean.getGrade().getGradeName()); |
| 138 | SaveParam.getInstance().saveLoginParam(MainActivity.this, SaveParam.ACCOUNTSCHOOL, cardinfoBean.getSchool().getSchoolName()); | 139 | SaveParam.getInstance().saveLoginParam(MainActivity.this, SaveParam.ACCOUNTSCHOOL, cardinfoBean.getSchool().getSchoolName()); |
| 139 | SaveParam.getInstance().saveLoginParam(MainActivity.this, SaveParam.ACCOUNTCONSTELLATION, cardinfoBean.getBirthday()); | 140 | SaveParam.getInstance().saveLoginParam(MainActivity.this, SaveParam.ACCOUNTCONSTELLATION, cardinfoBean.getBirthday()); |
| 140 | SaveParam.getInstance().saveLoginParam(MainActivity.this, SaveParam.ACCOUNTSEX, tv_sex.getText().toString()); | 141 | SaveParam.getInstance().saveLoginParam(MainActivity.this, SaveParam.ACCOUNTSEX, tv_sex.getText().toString()); |
| 141 | SaveParam.getInstance().saveLoginParam(MainActivity.this, SaveParam.ACCOUNTQQ, cardinfoBean.getQq()); | 142 | SaveParam.getInstance().saveLoginParam(MainActivity.this, SaveParam.ACCOUNTQQ, cardinfoBean.getQq()); |
| 142 | SaveParam.getInstance().saveLoginParam(MainActivity.this, SaveParam.ACCOUNTADRESS, cardinfoBean.getRegion().getRegionName()); | 143 | SaveParam.getInstance().saveLoginParam(MainActivity.this, SaveParam.ACCOUNTADRESS, cardinfoBean.getRegion().getRegionName()); |
| 143 | SaveParam.getInstance().saveLoginParam(MainActivity.this, SaveParam.ACCOUNTXINGZUO, cardinfoBean.getAddress()); | 144 | SaveParam.getInstance().saveLoginParam(MainActivity.this, SaveParam.ACCOUNTXINGZUO, cardinfoBean.getAddress()); |
| 144 | SaveParam.getInstance().saveLoginParam(MainActivity.this, SaveParam.ADRESSID, cardinfoBean.getRegion().getRegionId()); | 145 | SaveParam.getInstance().saveLoginParam(MainActivity.this, SaveParam.ADRESSID, cardinfoBean.getRegion().getRegionId()); |
| 145 | SaveParam.getInstance().saveLoginParam(MainActivity.this, SaveParam.PORTAIT, cardinfoBean.getPortrait()); | 146 | SaveParam.getInstance().saveLoginParam(MainActivity.this, SaveParam.PORTAIT, cardinfoBean.getPortrait()); |
| 146 | SaveParam.getInstance().saveLoginParam(MainActivity.this, SaveParam.MAINSHOOLID, cardinfoBean.getSchool().getSchoolId()); | 147 | SaveParam.getInstance().saveLoginParam(MainActivity.this, SaveParam.MAINSHOOLID, cardinfoBean.getSchool().getSchoolId()); |
| 147 | String graderID = cardinfoBean.getGrade().getGradeId(); | 148 | String graderID = cardinfoBean.getGrade().getGradeId(); |
| 148 | Log.e("test", "nianji" + graderID); | 149 | Log.e("test", "nianji" + graderID); |
| 149 | try { | 150 | try { |
| 150 | long auserID = Long.parseLong(graderID); | 151 | long auserID = Long.parseLong(graderID); |
| 151 | String ss = SaveParam.getInstance().getLoginParam(MainActivity.this, SaveParam.GRADENS); | 152 | String ss = SaveParam.getInstance().getLoginParam(MainActivity.this, SaveParam.GRADENS); |
| 152 | // if ((auserID < 8) && (ss == null)) { | 153 | // if ((auserID < 8) && (ss == null)) { |
| 153 | // Intent intentbroad = new Intent(); | 154 | // Intent intentbroad = new Intent(); |
| 154 | // intentbroad.putExtra("info", "小学"); | 155 | // intentbroad.putExtra("info", "小学"); |
| 155 | // //4、定义广播发送的action | 156 | // //4、定义广播发送的action |
| 156 | // intentbroad.setAction("com.ozing.launcher.SWITCH_GRADE"); | 157 | // intentbroad.setAction("com.ozing.launcher.SWITCH_GRADE"); |
| 157 | // //5、发送广播 | 158 | // //5、发送广播 |
| 158 | // sendBroadcast(intentbroad); | 159 | // sendBroadcast(intentbroad); |
| 159 | // Log.i("---", "发送完了"); | 160 | // Log.i("---", "发送完了"); |
| 160 | // } | 161 | // } |
| 161 | } catch (NumberFormatException e) { | 162 | } catch (NumberFormatException e) { |
| 162 | e.printStackTrace(); | 163 | e.printStackTrace(); |
| 163 | } | 164 | } |
| 164 | 165 | ||
| 165 | 166 | ||
| 166 | SaveParam.getInstance().saveLoginParam(MainActivity.this, SaveParam.GRADENS, graderID); | 167 | SaveParam.getInstance().saveLoginParam(MainActivity.this, SaveParam.GRADENS, graderID); |
| 167 | String userID = SaveParam.getInstance().getLoginParam(MainActivity.this, "userId"); | 168 | String userID = SaveParam.getInstance().getLoginParam(MainActivity.this, "userId"); |
| 168 | //账户类型 | 169 | //账户类型 |
| 169 | String accounts = SaveParam.getInstance().getCustomizeParam(MainActivity.this, SaveParam.ACCOUNT); | 170 | String accounts = SaveParam.getInstance().getCustomizeParam(MainActivity.this, SaveParam.ACCOUNT); |
| 170 | String childID = SaveParam.getInstance().getCustomizeParam(MainActivity.this, SaveParam.CHILDSID); | 171 | String childID = SaveParam.getInstance().getCustomizeParam(MainActivity.this, SaveParam.CHILDSID); |
| 171 | 172 | ||
| 172 | try { | 173 | try { |
| 173 | Object auserID; | 174 | Object auserID; |
| 174 | int type; | 175 | int type; |
| 175 | int graderIDs = Integer.parseInt(graderID); | 176 | int graderIDs = Integer.parseInt(graderID); |
| 176 | if ("2".equals(accounts)) { | 177 | if ("2".equals(accounts)) { |
| 177 | type = Integer.parseInt(accounts); | 178 | type = Integer.parseInt(accounts); |
| 178 | auserID = childID; | 179 | auserID = childID; |
| 179 | } else { | 180 | } else { |
| 180 | type = Integer.parseInt(accounts); | 181 | type = Integer.parseInt(accounts); |
| 181 | auserID = Long.parseLong(userID); | 182 | auserID = Long.parseLong(userID); |
| 182 | } | 183 | } |
| 183 | //获取版本信息 | 184 | //获取版本信息 |
| 184 | //Log.e("test","nianji"+graderID+auserID+"sssss"+type); | 185 | //Log.e("test","nianji"+graderID+auserID+"sssss"+type); |
| 185 | HttpManager.getInstance().getpublishinfo(MainActivity.this, auserID, graderIDs, type, handler); | 186 | HttpManager.getInstance().getpublishinfo(MainActivity.this, auserID, graderIDs, type, handler); |
| 186 | 187 | ||
| 187 | } catch (NumberFormatException e) { | 188 | } catch (NumberFormatException e) { |
| 188 | e.printStackTrace(); | 189 | e.printStackTrace(); |
| 189 | } | 190 | } |
| 190 | 191 | ||
| 191 | break; | 192 | break; |
| 192 | case HttpCode.SIGN: | 193 | case HttpCode.SIGN: |
| 193 | SignInfo.DataBean dataBean = (SignInfo.DataBean) msg.obj; | 194 | SignInfo.DataBean dataBean = (SignInfo.DataBean) msg.obj; |
| 194 | if (dataBean.getSignature() == null) { | 195 | if (dataBean.getSignature() == null) { |
| 195 | tv_sign.setText("你还未设置个性签名"); | 196 | tv_sign.setText("你还未设置个性签名"); |
| 196 | } else { | 197 | } else { |
| 197 | tv_sign.setText(dataBean.getSignature()); | 198 | tv_sign.setText(dataBean.getSignature()); |
| 198 | } | 199 | } |
| 199 | 200 | ||
| 200 | break; | 201 | break; |
| 201 | case HttpCode.PUBLISH_SUCESS: | 202 | case HttpCode.PUBLISH_SUCESS: |
| 202 | defautPublishInfos.clear(); | 203 | defautPublishInfos.clear(); |
| 203 | defautPublishInfos.addAll((List<DefautPublishInfo.DataBean>) msg.obj); | 204 | defautPublishInfos.addAll((List<DefautPublishInfo.DataBean>) msg.obj); |
| 204 | RecyclerViewadapterpublish.notifyDataSetChanged(); | 205 | RecyclerViewadapterpublish.notifyDataSetChanged(); |
| 205 | Gson gson = new Gson(); | 206 | Gson gson = new Gson(); |
| 206 | Log.e("test", "(List<DefautPublishInfo.DataBean>) msg.obj" + gson.toJson(msg.obj)); | 207 | Log.e("test", "(List<DefautPublishInfo.DataBean>) msg.obj" + gson.toJson(msg.obj)); |
| 207 | SaveParam.getInstance().saveLoginParam(MainActivity.this, SaveParam.VERSIONINTEFACE, gson.toJson(msg.obj)); | 208 | SaveParam.getInstance().saveLoginParam(MainActivity.this, SaveParam.VERSIONINTEFACE, gson.toJson(msg.obj)); |
| 208 | break; | 209 | break; |
| 209 | case HttpCode.GETVIDIO_SUCESS: | 210 | case HttpCode.GETVIDIO_SUCESS: |
| 210 | videoinfo.clear(); | 211 | videoinfo.clear(); |
| 211 | view_novedeo.setVisibility(View.GONE); | 212 | view_novedeo.setVisibility(View.GONE); |
| 212 | videoinfo.addAll((List<VideoInfo.DataBean>) msg.obj); | 213 | videoinfo.addAll((List<VideoInfo.DataBean>) msg.obj); |
| 213 | RecyclerViewadapter.notifyDataSetChanged(); | 214 | RecyclerViewadapter.notifyDataSetChanged(); |
| 214 | break; | 215 | break; |
| 215 | case HttpCode.SUCHCARDINFOONE: | 216 | case HttpCode.SUCHCARDINFOONE: |
| 216 | JSONObject jsonObject; | 217 | JSONObject jsonObject; |
| 217 | String status; | 218 | String status; |
| 218 | try { | 219 | try { |
| 219 | jsonObject = new JSONObject((String) msg.obj); | 220 | jsonObject = new JSONObject((String) msg.obj); |
| 220 | status = jsonObject.getString("status"); | 221 | status = jsonObject.getString("status"); |
| 221 | if (status.equals("1")) { | 222 | if (status.equals("1")) { |
| 222 | //sssssssss.setVisibility(View.VISIBLE); | 223 | //sssssssss.setVisibility(View.VISIBLE); |
| 223 | tv_yangji.setVisibility(View.GONE); | 224 | tv_yangji.setVisibility(View.GONE); |
| 224 | iv_look_card.setVisibility(View.VISIBLE); | 225 | iv_look_card.setVisibility(View.VISIBLE); |
| 225 | //客机没有保卡 | 226 | //客机没有保卡 |
| 226 | } else if (status.equals("2001")) { | 227 | } else if (status.equals("2001")) { |
| 227 | //sssssssss.setVisibility(View.VISIBLE); | 228 | //sssssssss.setVisibility(View.VISIBLE); |
| 228 | tv_yangji.setVisibility(View.GONE); | 229 | tv_yangji.setVisibility(View.GONE); |
| 229 | iv_look_card.setVisibility(View.VISIBLE); | 230 | iv_look_card.setVisibility(View.VISIBLE); |
| 230 | AlertUtils.showToast(MainActivity.this, "您的机器还没有保卡信息或该机器已置为样机,请重新登录"); | 231 | AlertUtils.showToast(MainActivity.this, "您的机器还没有保卡信息或该机器已置为样机,请重新登录"); |
| 231 | SaveParam.getInstance().clearData(MainActivity.this); | 232 | SaveParam.getInstance().clearData(MainActivity.this); |
| 232 | Intent settingintent = new Intent(); | 233 | Intent settingintent = new Intent(); |
| 233 | settingintent.setClass(MainActivity.this, LoginAndRegisterActivity.class); | 234 | settingintent.setClass(MainActivity.this, LoginAndRegisterActivity.class); |
| 234 | startActivity(settingintent); | 235 | startActivity(settingintent); |
| 235 | MainActivity.this.finish(); | 236 | MainActivity.this.finish(); |
| 236 | overridePendingTransition(R.anim.rightin, R.anim.rightout); | 237 | overridePendingTransition(R.anim.rightin, R.anim.rightout); |
| 237 | } else if (status.equals("2002")) {//样机 | 238 | } else if (status.equals("2002")) {//样机 |
| 238 | //sssssssss.setVisibility(View.INVISIBLE); | 239 | //sssssssss.setVisibility(View.INVISIBLE); |
| 239 | iv_look_card.setVisibility(View.INVISIBLE); | 240 | iv_look_card.setVisibility(View.INVISIBLE); |
| 240 | tv_yangji.setVisibility(View.VISIBLE); | 241 | tv_yangji.setVisibility(View.VISIBLE); |
| 241 | 242 | ||
| 242 | } else { | 243 | } else { |
| 243 | AlertUtils.showToast(MainActivity.this, "服务器连接失败"); | 244 | AlertUtils.showToast(MainActivity.this, "服务器连接失败"); |
| 244 | } | 245 | } |
| 245 | } catch (JSONException e) { | 246 | } catch (JSONException e) { |
| 246 | e.printStackTrace(); | 247 | e.printStackTrace(); |
| 247 | } | 248 | } |
| 248 | case HttpCode.TOUXIANG: | 249 | case HttpCode.TOUXIANG: |
| 249 | if (msg.obj.equals("1")){ | 250 | if (msg.obj.equals("1")){ |
| 250 | String s = SaveParam.getInstance().getLoginParam(MainActivity.this,SaveParam.PORTAIT); | 251 | String s = SaveParam.getInstance().getLoginParam(MainActivity.this,SaveParam.PORTAIT); |
| 251 | if (portrait!=null&&!portrait.isEmpty()){ | 252 | if (portrait!=null&&!portrait.isEmpty()){ |
| 252 | Picasso.with(MainActivity.this).load(s).into(mSimpleDraweeView); | 253 | Picasso.with(MainActivity.this).load(s).into(mSimpleDraweeView); |
| 253 | } | 254 | } |
| 254 | 255 | ||
| 255 | } | 256 | } |
| 256 | break; | 257 | break; |
| 257 | case HttpCode.RELOGIN: | 258 | case HttpCode.RELOGIN: |
| 258 | //清除数据 | 259 | //清除数据 |
| 259 | SaveParam.getInstance().saveCustomizeParam(MainActivity.this, SaveParam.ACCOUNT, "1"); | 260 | SaveParam.getInstance().saveCustomizeParam(MainActivity.this, SaveParam.ACCOUNT, "1"); |
| 260 | SaveParam.getInstance().clearData(MainActivity.this); | 261 | SaveParam.getInstance().clearData(MainActivity.this); |
| 261 | Intent settingintent = new Intent(); | 262 | Intent settingintent = new Intent(); |
| 262 | settingintent.setClass(MainActivity.this, LoginAndRegisterActivity.class); | 263 | settingintent.setClass(MainActivity.this, LoginAndRegisterActivity.class); |
| 263 | startActivity(settingintent); | 264 | startActivity(settingintent); |
| 264 | overridePendingTransition(R.anim.rightin, R.anim.rightout); | 265 | overridePendingTransition(R.anim.rightin, R.anim.rightout); |
| 265 | finish(); | 266 | finish(); |
| 266 | break; | 267 | break; |
| 267 | 268 | ||
| 268 | 269 | ||
| 269 | } | 270 | } |
| 270 | } | 271 | } |
| 271 | }; | 272 | }; |
| 272 | 273 | ||
| 273 | @Override | 274 | @Override |
| 274 | protected void onCreate(Bundle savedInstanceState) { | 275 | protected void onCreate(Bundle savedInstanceState) { |
| 275 | super.onCreate(savedInstanceState); | 276 | super.onCreate(savedInstanceState); |
| 276 | setContentView(R.layout.activity_main); | 277 | setContentView(R.layout.activity_main); |
| 277 | SysApplication.getInstance().addActivity(this); | 278 | SysApplication.getInstance().addActivity(this); |
| 278 | initView(); | 279 | initView(); |
| 279 | initData(); | 280 | initData(); |
| 280 | initLister(); | 281 | initLister(); |
| 281 | updateVersion(); | 282 | updateVersion(); |
| 282 | GetDevicesUtil.getMacAddress(this); | 283 | GetDevicesUtil.getMacAddress(this); |
| 283 | } | 284 | } |
| 284 | 285 | ||
| 285 | //////版本更新 | 286 | //////版本更新 |
| 286 | private void updateVersion() { | 287 | private void updateVersion() { |
| 287 | if (PermissionUtil.hasReadExternalStoragePermission(this)) { | 288 | if (PermissionUtil.hasReadExternalStoragePermission(this)) { |
| 288 | UpdateChecker updateChecker = new UpdateChecker(this); | 289 | UpdateChecker updateChecker = new UpdateChecker(this); |
| 289 | updateChecker.checkForUpdates(); | 290 | updateChecker.checkForUpdates(); |
| 290 | } | 291 | } |
| 291 | } | 292 | } |
| 292 | 293 | ||
| 293 | private void initView() { | 294 | private void initView() { |
| 294 | iv_imformatioan = (ImageView) findViewById(R.id.iv_imformatioan); | 295 | iv_imformatioan = (ImageView) findViewById(R.id.iv_imformatioan); |
| 295 | iv_look_card = (TextView) findViewById(R.id.iv_look_card); | 296 | iv_look_card = (TextView) findViewById(R.id.iv_look_card); |
| 296 | tv_edit_presoninfo = (ImageView) findViewById(R.id.tv_edit_presoninfo); | 297 | tv_edit_presoninfo = (ImageView) findViewById(R.id.tv_edit_presoninfo); |
| 297 | iv_setting = (ImageView) findViewById(R.id.iv_setting); | 298 | iv_setting = (ImageView) findViewById(R.id.iv_setting); |
| 298 | iv_sign = (ImageView) findViewById(R.id.iv_sign); | 299 | iv_sign = (ImageView) findViewById(R.id.iv_sign); |
| 299 | tv_sign = (TextView) findViewById(R.id.tv_sign); | 300 | tv_sign = (TextView) findViewById(R.id.tv_sign); |
| 300 | //头像 | 301 | //头像 |
| 301 | mSimpleDraweeView = (ImageView) findViewById(R.id.iv_head); | 302 | mSimpleDraweeView = (ImageView) findViewById(R.id.iv_head); |
| 302 | //初始化个人信息 | 303 | //初始化个人信息 |
| 303 | iv_sex = (ImageView) findViewById(R.id.iv_sex); | 304 | iv_sex = (ImageView) findViewById(R.id.iv_sex); |
| 304 | iv_switch = (ImageView) findViewById(R.id.iv_switch); | 305 | iv_switch = (ImageView) findViewById(R.id.iv_switch); |
| 305 | tv_username = (TextView) findViewById(R.id.tv_username); | 306 | tv_username = (TextView) findViewById(R.id.tv_username); |
| 306 | tv_username1 = (TextView) findViewById(R.id.tv_username1); | 307 | tv_username1 = (TextView) findViewById(R.id.tv_username1); |
| 307 | tv_mygad = (TextView) findViewById(R.id.tv_mygad); | 308 | tv_mygad = (TextView) findViewById(R.id.tv_mygad); |
| 308 | tv_sex = (TextView) findViewById(R.id.tv_sex); | 309 | tv_sex = (TextView) findViewById(R.id.tv_sex); |
| 309 | tv_useinfo_adress = (TextView) findViewById(R.id.tv_useinfo_adress); | 310 | tv_useinfo_adress = (TextView) findViewById(R.id.tv_useinfo_adress); |
| 310 | tv_useinfo_birthday = (TextView) findViewById(R.id.tv_useinfo_birthday); | 311 | tv_useinfo_birthday = (TextView) findViewById(R.id.tv_useinfo_birthday); |
| 311 | tv_useinfo_qq = (TextView) findViewById(R.id.tv_useinfo_qq); | 312 | tv_useinfo_qq = (TextView) findViewById(R.id.tv_useinfo_qq); |
| 312 | tv_useinfo_school = (TextView) findViewById(R.id.tv_useinfo_school); | 313 | tv_useinfo_school = (TextView) findViewById(R.id.tv_useinfo_school); |
| 313 | tv_useinfo_gender = (TextView) findViewById(R.id.tv_useinfo_gender); | 314 | tv_useinfo_gender = (TextView) findViewById(R.id.tv_useinfo_gender); |
| 314 | tv_yangji = (TextView) findViewById(R.id.tv_yangji); | 315 | tv_yangji = (TextView) findViewById(R.id.tv_yangji); |
| 315 | //跳转其他应用 | 316 | //跳转其他应用 |
| 316 | linel_mycuoti = (TextView) findViewById(R.id.linel_mycuoti); | 317 | linel_mycuoti = (TextView) findViewById(R.id.linel_mycuoti); |
| 317 | linel_mynote = (TextView) findViewById(R.id.linel_mynote); | 318 | linel_mynote = (TextView) findViewById(R.id.linel_mynote); |
| 318 | linel_mycollege = (TextView) findViewById(R.id.linel_mycollege); | 319 | linel_mycollege = (TextView) findViewById(R.id.linel_mycollege); |
| 319 | linel_myclass = (TextView) findViewById(R.id.linel_myclass); | 320 | linel_myclass = (TextView) findViewById(R.id.linel_myclass); |
| 320 | // | 321 | // |
| 321 | mRecyclerView = (RecyclerView) findViewById(R.id.id_recyclerview_horizontal); | 322 | mRecyclerView = (RecyclerView) findViewById(R.id.id_recyclerview_horizontal); |
| 322 | mRecyclerViewpublish = (GridView) findViewById(R.id.id_recyclerview_pubish); | 323 | mRecyclerViewpublish = (GridView) findViewById(R.id.id_recyclerview_pubish); |
| 323 | view_novedeo = (LinearLayout) findViewById(R.id.view_novedeo); | 324 | view_novedeo = (LinearLayout) findViewById(R.id.view_novedeo); |
| 324 | 325 | ||
| 325 | //sssssssss = findViewById(R.id.sssssssss); | 326 | //sssssssss = findViewById(R.id.sssssssss); |
| 327 | if(android.os.Build.MODEL.equals("N979S")){ | ||
| 328 | iv_switch.setVisibility(View.GONE); | ||
| 329 | } | ||
| 326 | 330 | ||
| 327 | } | 331 | } |
| 328 | 332 | ||
| 329 | 333 | ||
| 330 | private void initData() { | 334 | private void initData() { |
| 331 | file = new File(FileUtil.getCachePath(this), "user-avatar.jpg"); | 335 | file = new File(FileUtil.getCachePath(this), "user-avatar.jpg"); |
| 332 | if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N) { | 336 | if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N) { |
| 333 | uri = Uri.fromFile(file); | 337 | uri = Uri.fromFile(file); |
| 334 | } else { | 338 | } else { |
| 335 | //通过FileProvider创建一个content类型的Uri(android 7.0需要这样的方法跨应用访问) | 339 | //通过FileProvider创建一个content类型的Uri(android 7.0需要这样的方法跨应用访问) |
| 336 | uri = FileProvider.getUriForFile(MyApplication.getContext(), "com.hjx.personalcenter.fileprovider", file); | 340 | uri = FileProvider.getUriForFile(MyApplication.getContext(), "com.hjx.personalcenter.fileprovider", file); |
| 337 | } | 341 | } |
| 338 | //设置布局管理器 | 342 | //设置布局管理器 |
| 339 | LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this); | 343 | LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this); |
| 340 | linearLayoutManager.setOrientation(LinearLayoutManager.VERTICAL); | 344 | linearLayoutManager.setOrientation(LinearLayoutManager.VERTICAL); |
| 341 | 345 | ||
| 342 | // LinearLayoutManager linearLayoutManagerpublish = new LinearLayoutManager(this); | 346 | // LinearLayoutManager linearLayoutManagerpublish = new LinearLayoutManager(this); |
| 343 | // linearLayoutManagerpublish.setOrientation(LinearLayoutManager.HORIZONTAL); | 347 | // linearLayoutManagerpublish.setOrientation(LinearLayoutManager.HORIZONTAL); |
| 344 | 348 | ||
| 345 | mRecyclerView.setLayoutManager(linearLayoutManager); | 349 | mRecyclerView.setLayoutManager(linearLayoutManager); |
| 346 | mRecyclerView.addItemDecoration(new RecyclerViewSpaceItem(10)); | 350 | mRecyclerView.addItemDecoration(new RecyclerViewSpaceItem(10)); |
| 347 | 351 | ||
| 348 | // mRecyclerViewpublish.setLayoutManager(linearLayoutManagerpublish); | 352 | // mRecyclerViewpublish.setLayoutManager(linearLayoutManagerpublish); |
| 349 | // mRecyclerViewpublish.addItemDecoration(new RecyclerViewSpaceItem(10)); | 353 | // mRecyclerViewpublish.addItemDecoration(new RecyclerViewSpaceItem(10)); |
| 350 | 354 | ||
| 351 | //设置视频适配器 | 355 | //设置视频适配器 |
| 352 | RecyclerViewadapter = new VideoAdapter(this, videoinfo); | 356 | RecyclerViewadapter = new VideoAdapter(this, videoinfo); |
| 353 | RecyclerViewadapterpublish = new MianGridAdapter(defautPublishInfos, this); | 357 | RecyclerViewadapterpublish = new MianGridAdapter(defautPublishInfos, this); |
| 354 | 358 | ||
| 355 | //版本信息适配器 | 359 | //版本信息适配器 |
| 356 | mRecyclerView.setAdapter(RecyclerViewadapter); | 360 | mRecyclerView.setAdapter(RecyclerViewadapter); |
| 357 | mRecyclerViewpublish.setAdapter(RecyclerViewadapterpublish); | 361 | mRecyclerViewpublish.setAdapter(RecyclerViewadapterpublish); |
| 358 | 362 | ||
| 359 | //判断保卡信息是否为样机 | 363 | //判断保卡信息是否为样机 |
| 360 | String yangji = SaveParam.getInstance().getLoginParam(this, SaveParam.YANGJI); | 364 | String yangji = SaveParam.getInstance().getLoginParam(this, SaveParam.YANGJI); |
| 361 | String deviceNumber = GetDevicesUtil.getDevicesInfo(MainActivity.this).getDeviceNumber(); | 365 | String deviceNumber = GetDevicesUtil.getDevicesInfo(MainActivity.this).getDeviceNumber(); |
| 362 | Log.d("test", "yangji" + yangji); | 366 | Log.d("test", "yangji" + yangji); |
| 363 | if ("1".equals(yangji)) { | 367 | if ("1".equals(yangji)) { |
| 364 | //sssssssss.setVisibility(View.INVISIBLE); | 368 | //sssssssss.setVisibility(View.INVISIBLE); |
| 365 | iv_look_card.setVisibility(View.INVISIBLE); | 369 | iv_look_card.setVisibility(View.INVISIBLE); |
| 366 | tv_yangji.setVisibility(View.VISIBLE); | 370 | tv_yangji.setVisibility(View.VISIBLE); |
| 367 | } else { | 371 | } else { |
| 368 | SaveParam.getInstance().saveLoginParam(MainActivity.this, SaveParam.YANGJI, "0"); | 372 | SaveParam.getInstance().saveLoginParam(MainActivity.this, SaveParam.YANGJI, "0"); |
| 369 | HttpManager.getInstance().getcardinfo1(this, deviceNumber, handler); | 373 | HttpManager.getInstance().getcardinfo1(this, deviceNumber, handler); |
| 370 | 374 | ||
| 371 | } | 375 | } |
| 372 | 376 | ||
| 373 | 377 | ||
| 374 | } | 378 | } |
| 375 | 379 | ||
| 376 | private void initLister() { | 380 | private void initLister() { |
| 377 | iv_imformatioan.setOnClickListener(this); | 381 | iv_imformatioan.setOnClickListener(this); |
| 378 | iv_look_card.setOnClickListener(this); | 382 | iv_look_card.setOnClickListener(this); |
| 379 | tv_edit_presoninfo.setOnClickListener(this); | 383 | tv_edit_presoninfo.setOnClickListener(this); |
| 380 | iv_setting.setOnClickListener(this); | 384 | iv_setting.setOnClickListener(this); |
| 381 | iv_sign.setOnClickListener(this); | 385 | iv_sign.setOnClickListener(this); |
| 382 | tv_sign.setOnClickListener(this); | 386 | tv_sign.setOnClickListener(this); |
| 383 | mSimpleDraweeView.setOnClickListener(this); | 387 | mSimpleDraweeView.setOnClickListener(this); |
| 384 | linel_mycuoti.setOnClickListener(this); | 388 | linel_mycuoti.setOnClickListener(this); |
| 385 | linel_mynote.setOnClickListener(this); | 389 | linel_mynote.setOnClickListener(this); |
| 386 | linel_mycollege.setOnClickListener(this); | 390 | linel_mycollege.setOnClickListener(this); |
| 387 | linel_myclass.setOnClickListener(this); | 391 | linel_myclass.setOnClickListener(this); |
| 388 | iv_switch.setOnClickListener(this); | 392 | iv_switch.setOnClickListener(this); |
| 389 | 393 | ||
| 390 | } | 394 | } |
| 391 | 395 | ||
| 392 | @Override | 396 | @Override |
| 393 | public void onClick(View v) { | 397 | public void onClick(View v) { |
| 394 | switch (v.getId()) { | 398 | switch (v.getId()) { |
| 395 | case R.id.iv_imformatioan: | 399 | case R.id.iv_imformatioan: |
| 396 | Intent intent = new Intent(); | 400 | Intent intent = new Intent(); |
| 397 | intent.setClass(MainActivity.this, FeedBackActivity.class); | 401 | intent.setClass(MainActivity.this, FeedBackActivity.class); |
| 398 | startActivity(intent); | 402 | startActivity(intent); |
| 399 | overridePendingTransition(R.anim.rightin, R.anim.rightout); | 403 | overridePendingTransition(R.anim.rightin, R.anim.rightout); |
| 400 | break; | 404 | break; |
| 401 | case R.id.iv_look_card: | 405 | case R.id.iv_look_card: |
| 402 | Intent lookintent = new Intent(); | 406 | Intent lookintent = new Intent(); |
| 403 | lookintent.setClass(MainActivity.this, ElectronicCardLookInfoActivity.class); | 407 | lookintent.setClass(MainActivity.this, ElectronicCardLookInfoActivity.class); |
| 404 | startActivity(lookintent); | 408 | startActivity(lookintent); |
| 405 | overridePendingTransition(R.anim.rightin, R.anim.rightout); | 409 | overridePendingTransition(R.anim.rightin, R.anim.rightout); |
| 406 | break; | 410 | break; |
| 407 | case R.id.tv_edit_presoninfo: | 411 | case R.id.tv_edit_presoninfo: |
| 408 | Intent editintent = new Intent(); | 412 | Intent editintent = new Intent(); |
| 409 | editintent.setClass(MainActivity.this, ChangePresonalInfoActivity.class); | 413 | editintent.setClass(MainActivity.this, ChangePresonalInfoActivity.class); |
| 410 | startActivity(editintent); | 414 | startActivity(editintent); |
| 411 | overridePendingTransition(R.anim.rightin, R.anim.rightout); | 415 | overridePendingTransition(R.anim.rightin, R.anim.rightout); |
| 412 | break; | 416 | break; |
| 413 | case R.id.iv_head: | 417 | case R.id.iv_head: |
| 414 | HeadDialog.getInstance(this).show(getSupportFragmentManager(), "HeadDialog"); | 418 | HeadDialog.getInstance(this).show(getSupportFragmentManager(), "HeadDialog"); |
| 415 | break; | 419 | break; |
| 416 | case R.id.iv_setting: | 420 | case R.id.iv_setting: |
| 417 | mTopRightMenu = new TopRightMenu(MainActivity.this); | 421 | mTopRightMenu = new TopRightMenu(MainActivity.this); |
| 418 | List<MenuItem> menuItems = new ArrayList<>(); | 422 | List<MenuItem> menuItems = new ArrayList<>(); |
| 419 | menuItems.add(new MenuItem(R.mipmap.blank, " 切换账户")); | 423 | menuItems.add(new MenuItem(R.mipmap.blank, " 切换账户")); |
| 420 | menuItems.add(new MenuItem(R.mipmap.blank, " 账户管理")); | 424 | menuItems.add(new MenuItem(R.mipmap.blank, " 账户管理")); |
| 421 | mTopRightMenu | 425 | mTopRightMenu |
| 422 | .setHeight(CropUtils.dp2px(this,100)) //默认高度480 | 426 | .setHeight(CropUtils.dp2px(this,100)) //默认高度480 |
| 423 | .setWidth(CropUtils.dp2px(this,110)) //默认宽度wrap_content | 427 | .setWidth(CropUtils.dp2px(this,110)) //默认宽度wrap_content |
| 424 | .showIcon(showIcon) //显示菜单图标,默认为true | 428 | .showIcon(showIcon) //显示菜单图标,默认为true |
| 425 | .dimBackground(dimBg) //背景变暗,默认为true | 429 | .dimBackground(dimBg) //背景变暗,默认为true |
| 426 | .needAnimationStyle(needAnim) //显示动画,默认为true | 430 | .needAnimationStyle(needAnim) //显示动画,默认为true |
| 427 | .setAnimationStyle(R.style.TRM_ANIM_STYLE) //默认为R.style.TRM_ANIM_STYLE | 431 | .setAnimationStyle(R.style.TRM_ANIM_STYLE) //默认为R.style.TRM_ANIM_STYLE |
| 428 | .setOnMenuItemClickListener(new TopRightMenu.OnMenuItemClickListener() { | 432 | .setOnMenuItemClickListener(new TopRightMenu.OnMenuItemClickListener() { |
| 429 | @Override | 433 | @Override |
| 430 | public void onMenuItemClick(int position) { | 434 | public void onMenuItemClick(int position) { |
| 431 | switch (position) { | 435 | switch (position) { |
| 432 | case 0: | 436 | case 0: |
| 433 | new CircleDialog.Builder(MainActivity.this) | 437 | new CircleDialog.Builder(MainActivity.this) |
| 434 | .setCanceledOnTouchOutside(false) | 438 | .setCanceledOnTouchOutside(false) |
| 435 | .setWidth(0.4f) | 439 | .setWidth(0.4f) |
| 436 | .setCancelable(false) | 440 | .setCancelable(false) |
| 437 | .setText("您确定要退出,更换其他账号登录吗?") | 441 | .setText("您确定要退出,更换其他账号登录吗?") |
| 438 | .setNegative("取消", null) | 442 | .setNegative("取消", null) |
| 439 | .setPositive("确定", new View.OnClickListener() { | 443 | .setPositive("确定", new View.OnClickListener() { |
| 440 | @Override | 444 | @Override |
| 441 | public void onClick(View v) { | 445 | public void onClick(View v) { |
| 442 | //String graderID = SaveParam.getInstance().getLoginParam(MainActivity.this, SaveParam.GRADENS); | 446 | //String graderID = SaveParam.getInstance().getLoginParam(MainActivity.this, SaveParam.GRADENS); |
| 443 | //int graderIDs = Integer.parseInt(graderID); | 447 | //int graderIDs = Integer.parseInt(graderID); |
| 444 | // if (graderIDs < 8) { | 448 | // if (graderIDs < 8) { |
| 445 | // Intent intentbroad = new Intent(); | 449 | // Intent intentbroad = new Intent(); |
| 446 | // intentbroad.putExtra("info", "小学"); | 450 | // intentbroad.putExtra("info", "小学"); |
| 447 | // //4、定义广播发送的action | 451 | // //4、定义广播发送的action |
| 448 | // intentbroad.setAction("com.ozing.launcher.SWITCH_GRADE"); | 452 | // intentbroad.setAction("com.ozing.launcher.SWITCH_GRADE"); |
| 449 | // //5、发送广播 | 453 | // //5、发送广播 |
| 450 | // sendBroadcast(intentbroad); | 454 | // sendBroadcast(intentbroad); |
| 451 | // Log.i("---", "发送完了"); | 455 | // Log.i("---", "发送完了"); |
| 452 | // } | 456 | // } |
| 453 | //清除数据 | 457 | //清除数据 |
| 454 | SaveParam.getInstance().saveCustomizeParam(MainActivity.this, SaveParam.ACCOUNT, "1"); | 458 | SaveParam.getInstance().saveCustomizeParam(MainActivity.this, SaveParam.ACCOUNT, "1"); |
| 455 | SaveParam.getInstance().clearData(MainActivity.this); | 459 | SaveParam.getInstance().clearData(MainActivity.this); |
| 456 | Intent settingintent = new Intent(); | 460 | Intent settingintent = new Intent(); |
| 457 | settingintent.setClass(MainActivity.this, LoginAndRegisterActivity.class); | 461 | settingintent.setClass(MainActivity.this, LoginAndRegisterActivity.class); |
| 458 | startActivity(settingintent); | 462 | startActivity(settingintent); |
| 459 | overridePendingTransition(R.anim.rightin, R.anim.rightout); | 463 | overridePendingTransition(R.anim.rightin, R.anim.rightout); |
| 460 | finish(); | 464 | finish(); |
| 461 | } | 465 | } |
| 462 | }) | 466 | }) |
| 463 | .show(); | 467 | .show(); |
| 464 | break; | 468 | break; |
| 465 | case 1: | 469 | case 1: |
| 466 | Intent accontMintent = new Intent(); | 470 | Intent accontMintent = new Intent(); |
| 467 | accontMintent.setClass(MainActivity.this, AccountManagementActivity.class); | 471 | accontMintent.setClass(MainActivity.this, AccountManagementActivity.class); |
| 468 | startActivity(accontMintent); | 472 | startActivity(accontMintent); |
| 469 | overridePendingTransition(R.anim.rightin, R.anim.rightout); | 473 | overridePendingTransition(R.anim.rightin, R.anim.rightout); |
| 470 | break; | 474 | break; |
| 471 | } | 475 | } |
| 472 | } | 476 | } |
| 473 | }) | 477 | }) |
| 474 | .addMenuList(menuItems) | 478 | .addMenuList(menuItems) |
| 475 | .showAsDropDown(iv_setting, -120, 0); | 479 | .showAsDropDown(iv_setting, -120, 0); |
| 476 | break; | 480 | break; |
| 477 | case R.id.iv_sign: | 481 | case R.id.iv_sign: |
| 478 | case R.id.tv_sign: | 482 | case R.id.tv_sign: |
| 479 | new CircleDialog.Builder(this) | 483 | new CircleDialog.Builder(this) |
| 480 | .setCanceledOnTouchOutside(false) | 484 | .setCanceledOnTouchOutside(false) |
| 481 | .setCancelable(true) | 485 | .setCancelable(true) |
| 482 | .setTitle("个性签名") | 486 | .setTitle("个性签名") |
| 483 | .setInputHint("请输入个性签名") | 487 | .setInputHint("请输入个性签名") |
| 484 | .setWidth(0.4f) | 488 | .setWidth(0.4f) |
| 485 | .setInputHeight(80) | 489 | .setInputHeight(80) |
| 486 | .configInput(new ConfigInput() { | 490 | .configInput(new ConfigInput() { |
| 487 | @Override | 491 | @Override |
| 488 | public void onConfig(InputParams params) { | 492 | public void onConfig(InputParams params) { |
| 489 | // params.inputBackgroundResourceId = R.drawable.bg_input; | 493 | // params.inputBackgroundResourceId = R.drawable.bg_input; |
| 490 | } | 494 | } |
| 491 | }) | 495 | }) |
| 492 | .setNegative("取消", new View.OnClickListener() { | 496 | .setNegative("取消", new View.OnClickListener() { |
| 493 | @Override | 497 | @Override |
| 494 | public void onClick(View v) { | 498 | public void onClick(View v) { |
| 495 | RecyclerViewadapterpublish.notifyDataSetChanged(); | 499 | RecyclerViewadapterpublish.notifyDataSetChanged(); |
| 496 | } | 500 | } |
| 497 | }) | 501 | }) |
| 498 | .setPositiveInput("确定", new OnInputClickListener() { | 502 | .setPositiveInput("确定", new OnInputClickListener() { |
| 499 | @Override | 503 | @Override |
| 500 | public void onClick(String text, View v) { | 504 | public void onClick(String text, View v) { |
| 501 | if (text.equals("")) { | 505 | if (text.equals("")) { |
| 502 | AlertUtils.showToast(MainActivity.this, "请输入个性签名"); | 506 | AlertUtils.showToast(MainActivity.this, "请输入个性签名"); |
| 503 | } else { | 507 | } else { |
| 504 | try { | 508 | try { |
| 505 | String typeaccount = SaveParam.getInstance().getCustomizeParam(MainActivity.this, SaveParam.ACCOUNT); | 509 | String typeaccount = SaveParam.getInstance().getCustomizeParam(MainActivity.this, SaveParam.ACCOUNT); |
| 506 | String userID = SaveParam.getInstance().getLoginParam(MainActivity.this, "userId"); | 510 | String userID = SaveParam.getInstance().getLoginParam(MainActivity.this, "userId"); |
| 507 | String childsID = SaveParam.getInstance().getCustomizeParam(MainActivity.this, SaveParam.CHILDSID); | 511 | String childsID = SaveParam.getInstance().getCustomizeParam(MainActivity.this, SaveParam.CHILDSID); |
| 508 | Object id = null; | 512 | Object id = null; |
| 509 | long auserID = Long.parseLong(userID); | 513 | long auserID = Long.parseLong(userID); |
| 510 | int typeaccount1 = Integer.parseInt(typeaccount); | 514 | int typeaccount1 = Integer.parseInt(typeaccount); |
| 511 | if (typeaccount1 == 2) { | 515 | if (typeaccount1 == 2) { |
| 512 | id = childsID; | 516 | id = childsID; |
| 513 | } else { | 517 | } else { |
| 514 | id = auserID; | 518 | id = auserID; |
| 515 | } | 519 | } |
| 516 | HttpManager.getInstance().changsignature(MainActivity.this, id, typeaccount1, text); | 520 | HttpManager.getInstance().changsignature(MainActivity.this, id, typeaccount1, text); |
| 517 | RecyclerViewadapterpublish.notifyDataSetChanged(); | 521 | RecyclerViewadapterpublish.notifyDataSetChanged(); |
| 518 | } catch (NumberFormatException e) { | 522 | } catch (NumberFormatException e) { |
| 519 | e.printStackTrace(); | 523 | e.printStackTrace(); |
| 520 | } | 524 | } |
| 521 | 525 | ||
| 522 | tv_sign.setText(text); | 526 | tv_sign.setText(text); |
| 523 | } | 527 | } |
| 524 | 528 | ||
| 525 | } | 529 | } |
| 526 | }) | 530 | }) |
| 527 | .show(); | 531 | .show(); |
| 528 | break; | 532 | break; |
| 529 | case R.id.iv_switch: | 533 | case R.id.iv_switch: |
| 530 | showSwitchDialog(); | 534 | showSwitchDialog(); |
| 531 | break; | 535 | break; |
| 532 | case R.id.middle_btn: | 536 | case R.id.middle_btn: |
| 533 | SaveParam.getInstance().saveLoginParam(MainActivity.this, SaveParam.GRADENS, "9"); | 537 | SaveParam.getInstance().saveLoginParam(MainActivity.this, SaveParam.GRADENS, "9"); |
| 534 | hintDialog.cancel(); | 538 | hintDialog.cancel(); |
| 535 | SysApplication.getInstance().exit(); | 539 | SysApplication.getInstance().exit(); |
| 536 | break; | 540 | break; |
| 537 | case R.id.primary_btn: | 541 | case R.id.primary_btn: |
| 538 | SaveParam.getInstance().saveLoginParam(MainActivity.this, SaveParam.GRADENS, "3"); | 542 | SaveParam.getInstance().saveLoginParam(MainActivity.this, SaveParam.GRADENS, "3"); |
| 539 | hintDialog.cancel(); | 543 | hintDialog.cancel(); |
| 540 | SysApplication.getInstance().exit(); | 544 | SysApplication.getInstance().exit(); |
| 541 | break; | 545 | break; |
| 542 | case R.id.linel_mycuoti: | 546 | case R.id.linel_mycuoti: |
| 543 | AlertUtils.showToast(this, "未安装该应用 "); | 547 | AlertUtils.showToast(this, "未安装该应用 "); |
| 544 | break; | 548 | break; |
| 545 | case R.id.linel_mynote: | 549 | case R.id.linel_mynote: |
| 546 | AlertUtils.showToast(this, "未安装该应用 "); | 550 | AlertUtils.showToast(this, "未安装该应用 "); |
| 547 | break; | 551 | break; |
| 548 | case R.id.linel_mycollege: | 552 | case R.id.linel_mycollege: |
| 549 | AlertUtils.showToast(this, "未安装该应用 "); | 553 | AlertUtils.showToast(this, "未安装该应用 "); |
| 550 | break; | 554 | break; |
| 551 | case R.id.linel_myclass: | 555 | case R.id.linel_myclass: |
| 552 | AlertUtils.showToast(this, "未安装该应用 "); | 556 | AlertUtils.showToast(this, "未安装该应用 "); |
| 553 | break; | 557 | break; |
| 554 | } | 558 | } |
| 555 | 559 | ||
| 556 | } | 560 | } |
| 557 | 561 | ||
| 558 | @Override | 562 | @Override |
| 559 | protected void onPause() { | 563 | protected void onPause() { |
| 560 | super.onPause(); | 564 | super.onPause(); |
| 561 | } | 565 | } |
| 562 | 566 | ||
| 563 | @Override | 567 | @Override |
| 564 | protected void onResume() { | 568 | protected void onResume() { |
| 565 | super.onResume(); | 569 | super.onResume(); |
| 566 | Content.changegradeinfoflag = 0; | 570 | Content.changegradeinfoflag = 0; |
| 567 | Content.changeadressinfoflag = 0; | 571 | Content.changeadressinfoflag = 0; |
| 568 | String userID = SaveParam.getInstance().getLoginParam(this, "userId"); | 572 | String userID = SaveParam.getInstance().getLoginParam(this, "userId"); |
| 569 | //获取个性签名 | 573 | //获取个性签名 |
| 570 | String typeaccount = SaveParam.getInstance().getCustomizeParam(this, SaveParam.ACCOUNT); | 574 | String typeaccount = SaveParam.getInstance().getCustomizeParam(this, SaveParam.ACCOUNT); |
| 571 | String childsID = SaveParam.getInstance().getCustomizeParam(this, SaveParam.CHILDSID); | 575 | String childsID = SaveParam.getInstance().getCustomizeParam(this, SaveParam.CHILDSID); |
| 572 | 576 | ||
| 573 | try { | 577 | try { |
| 574 | Object auserID = 1; | 578 | Object auserID = 1; |
| 575 | long id = Long.parseLong(userID); | 579 | long id = Long.parseLong(userID); |
| 576 | int typeaccount1 = Integer.parseInt(typeaccount); | 580 | int typeaccount1 = Integer.parseInt(typeaccount); |
| 577 | //获取个人信息 | 581 | //获取个人信息 |
| 578 | HttpManager.getInstance().getpresonalinfo(MainActivity.this, id, typeaccount1, handler); | 582 | HttpManager.getInstance().getpresonalinfo(MainActivity.this, id, typeaccount1, handler); |
| 579 | if (typeaccount1 == 2) { | 583 | if (typeaccount1 == 2) { |
| 580 | auserID = childsID; | 584 | auserID = childsID; |
| 581 | } else { | 585 | } else { |
| 582 | auserID = id; | 586 | auserID = id; |
| 583 | } | 587 | } |
| 584 | Log.e("test", "个性签名的ID" + auserID); | 588 | Log.e("test", "个性签名的ID" + auserID); |
| 585 | HttpManager.getInstance().getsignatures(MainActivity.this, auserID, typeaccount1, handler); | 589 | HttpManager.getInstance().getsignatures(MainActivity.this, auserID, typeaccount1, handler); |
| 586 | //获取最近播放视频 | 590 | //获取最近播放视频 |
| 587 | HttpManager.getInstance().getstuyvidioinfo(this, auserID, handler); | 591 | HttpManager.getInstance().getstuyvidioinfo(this, auserID, handler); |
| 588 | 592 | ||
| 589 | } catch (NumberFormatException e) { | 593 | } catch (NumberFormatException e) { |
| 590 | e.printStackTrace(); | 594 | e.printStackTrace(); |
| 591 | } | 595 | } |
| 592 | 596 | ||
| 593 | } | 597 | } |
| 594 | 598 | ||
| 595 | //回调头像监听 | 599 | //回调头像监听 |
| 596 | @Override | 600 | @Override |
| 597 | public void heard(Context context, View v, int headpitiaon) { | 601 | public void heard(Context context, View v, int headpitiaon) { |
| 598 | String picUrl = ""; | 602 | String picUrl = ""; |
| 599 | String userID; | 603 | String userID; |
| 600 | String typeaccount = SaveParam.getInstance().getCustomizeParam(this, SaveParam.ACCOUNT); | 604 | String typeaccount = SaveParam.getInstance().getCustomizeParam(this, SaveParam.ACCOUNT); |
| 601 | if ("2".equals(typeaccount)) { | 605 | if ("2".equals(typeaccount)) { |
| 602 | userID = SaveParam.getInstance().getCustomizeParam(this, SaveParam.CHILDSID); | 606 | userID = SaveParam.getInstance().getCustomizeParam(this, SaveParam.CHILDSID); |
| 603 | } else { | 607 | } else { |
| 604 | userID = SaveParam.getInstance().getLoginParam(this, "userId"); | 608 | userID = SaveParam.getInstance().getLoginParam(this, "userId"); |
| 605 | } | 609 | } |
| 606 | switch (v.getId()) { | 610 | switch (v.getId()) { |
| 607 | //选择默认图片 | 611 | //选择默认图片 |
| 608 | case R.id.oktakephone: | 612 | case R.id.oktakephone: |
| 609 | if (headpitiaon == 1) { | 613 | if (headpitiaon == 1) { |
| 610 | mSimpleDraweeView.setImageDrawable(null); | 614 | mSimpleDraweeView.setImageDrawable(null); |
| 611 | mSimpleDraweeView.setImageResource(R.mipmap.default_avatar1); | 615 | mSimpleDraweeView.setImageResource(R.mipmap.default_avatar1); |
| 612 | picUrl = "http://hjxprodbucket.oss.aliyuncs.com/static/upload/boss_api/announcement/2018-01-25/75f05c02-3dbc-44e3-aec9-a73eca60ca8b.png"; | 616 | picUrl = "http://hjxprodbucket.oss.aliyuncs.com/static/upload/boss_api/announcement/2018-01-25/75f05c02-3dbc-44e3-aec9-a73eca60ca8b.png"; |
| 613 | try { | 617 | try { |
| 614 | HttpManager.getInstance().headerdeft(this, userID, typeaccount, picUrl); | 618 | HttpManager.getInstance().headerdeft(this, userID, typeaccount, picUrl); |
| 615 | } catch (UnsupportedEncodingException e) { | 619 | } catch (UnsupportedEncodingException e) { |
| 616 | e.printStackTrace(); | 620 | e.printStackTrace(); |
| 617 | } | 621 | } |
| 618 | } else if (headpitiaon == 2) { | 622 | } else if (headpitiaon == 2) { |
| 619 | mSimpleDraweeView.setImageDrawable(null); | 623 | mSimpleDraweeView.setImageDrawable(null); |
| 620 | mSimpleDraweeView.setImageResource(R.mipmap.default_avatar2); | 624 | mSimpleDraweeView.setImageResource(R.mipmap.default_avatar2); |
| 621 | picUrl = "http://hjxprodbucket.oss.aliyuncs.com/static/upload/boss_api/announcement/2018-01-25/d102b0d8-435f-45a5-908f-ea43e02176d4.png"; | 625 | picUrl = "http://hjxprodbucket.oss.aliyuncs.com/static/upload/boss_api/announcement/2018-01-25/d102b0d8-435f-45a5-908f-ea43e02176d4.png"; |
| 622 | try { | 626 | try { |
| 623 | HttpManager.getInstance().headerdeft(this, userID, typeaccount, picUrl); | 627 | HttpManager.getInstance().headerdeft(this, userID, typeaccount, picUrl); |
| 624 | } catch (UnsupportedEncodingException e) { | 628 | } catch (UnsupportedEncodingException e) { |
| 625 | e.printStackTrace(); | 629 | e.printStackTrace(); |
| 626 | } | 630 | } |
| 627 | } else if (headpitiaon == 3) { | 631 | } else if (headpitiaon == 3) { |
| 628 | mSimpleDraweeView.setImageDrawable(null); | 632 | mSimpleDraweeView.setImageDrawable(null); |
| 629 | mSimpleDraweeView.setImageResource(R.mipmap.default_avatar3); | 633 | mSimpleDraweeView.setImageResource(R.mipmap.default_avatar3); |
| 630 | picUrl = "http://hjxprodbucket.oss.aliyuncs.com/static/upload/boss_api/announcement/2018-01-25/a623a8ba-5e56-4827-95d1-ffeb0d6874d5.png"; | 634 | picUrl = "http://hjxprodbucket.oss.aliyuncs.com/static/upload/boss_api/announcement/2018-01-25/a623a8ba-5e56-4827-95d1-ffeb0d6874d5.png"; |
| 631 | try { | 635 | try { |
| 632 | HttpManager.getInstance().headerdeft(this, userID, typeaccount, picUrl); | 636 | HttpManager.getInstance().headerdeft(this, userID, typeaccount, picUrl); |
| 633 | } catch (UnsupportedEncodingException e) { | 637 | } catch (UnsupportedEncodingException e) { |
| 634 | e.printStackTrace(); | 638 | e.printStackTrace(); |
| 635 | } | 639 | } |
| 636 | } else if (headpitiaon == 4) { | 640 | } else if (headpitiaon == 4) { |
| 637 | mSimpleDraweeView.setImageDrawable(null); | 641 | mSimpleDraweeView.setImageDrawable(null); |
| 638 | mSimpleDraweeView.setImageResource(R.mipmap.default_avatar4); | 642 | mSimpleDraweeView.setImageResource(R.mipmap.default_avatar4); |
| 639 | picUrl = "http://hjxprodbucket.oss.aliyuncs.com/static/upload/boss_api/announcement/2018-01-25/3d822736-a18d-47ae-b0b1-67752e027375.png"; | 643 | picUrl = "http://hjxprodbucket.oss.aliyuncs.com/static/upload/boss_api/announcement/2018-01-25/3d822736-a18d-47ae-b0b1-67752e027375.png"; |
| 640 | try { | 644 | try { |
| 641 | HttpManager.getInstance().headerdeft(this, userID, typeaccount, picUrl); | 645 | HttpManager.getInstance().headerdeft(this, userID, typeaccount, picUrl); |
| 642 | } catch (UnsupportedEncodingException e) { | 646 | } catch (UnsupportedEncodingException e) { |
| 643 | e.printStackTrace(); | 647 | e.printStackTrace(); |
| 644 | } | 648 | } |
| 645 | } else { | 649 | } else { |
| 646 | mSimpleDraweeView.setImageDrawable(null); | 650 | mSimpleDraweeView.setImageDrawable(null); |
| 647 | mSimpleDraweeView.setImageResource(R.mipmap.header_default); | 651 | mSimpleDraweeView.setImageResource(R.mipmap.header_default); |
| 648 | ; | 652 | ; |
| 649 | } | 653 | } |
| 650 | 654 | ||
| 651 | break; | 655 | break; |
| 652 | case R.id.canceltakephone: | 656 | case R.id.canceltakephone: |
| 653 | 657 | ||
| 654 | break; | 658 | break; |
| 655 | //拍摄和相册 | 659 | //拍摄和相册 |
| 656 | case R.id.take_pic: | 660 | case R.id.take_pic: |
| 657 | if (PermissionUtil.hasCameraPermission(MainActivity.this)) { | 661 | if (PermissionUtil.hasCameraPermission(MainActivity.this)) { |
| 658 | uploadAvatarFromPhotoRequest(); | 662 | uploadAvatarFromPhotoRequest(); |
| 659 | } | 663 | } |
| 660 | break; | 664 | break; |
| 661 | case R.id.xiangce: | 665 | case R.id.xiangce: |
| 662 | uploadAvatarFromAlbumRequest(); | 666 | uploadAvatarFromAlbumRequest(); |
| 663 | break; | 667 | break; |
| 664 | 668 | ||
| 665 | } | 669 | } |
| 666 | 670 | ||
| 667 | } | 671 | } |
| 668 | 672 | ||
| 669 | //照相 | 673 | //照相 |
| 670 | private void uploadAvatarFromPhotoRequest() { | 674 | private void uploadAvatarFromPhotoRequest() { |
| 671 | Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); | 675 | Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); |
| 672 | intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); | 676 | intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); |
| 673 | intent.putExtra(MediaStore.Images.Media.ORIENTATION, 0); | 677 | intent.putExtra(MediaStore.Images.Media.ORIENTATION, 0); |
| 674 | intent.putExtra(MediaStore.EXTRA_OUTPUT, uri); | 678 | intent.putExtra(MediaStore.EXTRA_OUTPUT, uri); |
| 675 | startActivityForResult(intent, REQUEST_CODE_TAKE_PHOTO); | 679 | startActivityForResult(intent, REQUEST_CODE_TAKE_PHOTO); |
| 676 | } | 680 | } |
| 677 | 681 | ||
| 678 | //选择图库 | 682 | //选择图库 |
| 679 | private void uploadAvatarFromAlbumRequest() { | 683 | private void uploadAvatarFromAlbumRequest() { |
| 680 | Intent photoPickerIntent = new Intent(Intent.ACTION_PICK); | 684 | Intent photoPickerIntent = new Intent(Intent.ACTION_PICK); |
| 681 | photoPickerIntent.setType("image/*"); | 685 | photoPickerIntent.setType("image/*"); |
| 682 | startActivityForResult(photoPickerIntent, REQUEST_CODE_ALBUM); | 686 | startActivityForResult(photoPickerIntent, REQUEST_CODE_ALBUM); |
| 683 | } | 687 | } |
| 684 | 688 | ||
| 685 | //回掉 | 689 | //回掉 |
| 686 | @Override | 690 | @Override |
| 687 | protected void onActivityResult(int requestCode, int resultCode, Intent data) { | 691 | protected void onActivityResult(int requestCode, int resultCode, Intent data) { |
| 688 | super.onActivityResult(requestCode, resultCode, data); | 692 | super.onActivityResult(requestCode, resultCode, data); |
| 689 | if (resultCode != -1) { | 693 | if (resultCode != -1) { |
| 690 | return; | 694 | return; |
| 691 | } | 695 | } |
| 692 | if (requestCode == REQUEST_CODE_ALBUM && data != null) { | 696 | if (requestCode == REQUEST_CODE_ALBUM && data != null) { |
| 693 | Uri newUri; | 697 | Uri newUri; |
| 694 | if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N) { | 698 | if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N) { |
| 695 | newUri = Uri.parse("file:///" + CropUtils.getPath(this, data.getData())); | 699 | newUri = Uri.parse("file:///" + CropUtils.getPath(this, data.getData())); |
| 696 | } else { | 700 | } else { |
| 697 | newUri = data.getData(); | 701 | newUri = data.getData(); |
| 698 | } | 702 | } |
| 699 | if (newUri != null) { | 703 | if (newUri != null) { |
| 700 | startPhotoZoom(newUri); | 704 | startPhotoZoom(newUri); |
| 701 | } else { | 705 | } else { |
| 702 | Toast.makeText(this, "没有得到相册图片", Toast.LENGTH_LONG).show(); | 706 | Toast.makeText(this, "没有得到相册图片", Toast.LENGTH_LONG).show(); |
| 703 | } | 707 | } |
| 704 | } else if (requestCode == REQUEST_CODE_TAKE_PHOTO) { | 708 | } else if (requestCode == REQUEST_CODE_TAKE_PHOTO) { |
| 705 | //startPhotoZoom(uri); | 709 | //startPhotoZoom(uri); |
| 706 | uploadAvatarFromPhoto(); | 710 | uploadAvatarFromPhoto(); |
| 707 | } else if (requestCode == REQUEST_CODE_CROUP_PHOTO) { | 711 | } else if (requestCode == REQUEST_CODE_CROUP_PHOTO) { |
| 708 | uploadAvatarFromPhoto(); | 712 | uploadAvatarFromPhoto(); |
| 709 | } | 713 | } |
| 710 | } | 714 | } |
| 711 | 715 | ||
| 712 | private void uploadAvatarFromPhoto() { | 716 | private void uploadAvatarFromPhoto() { |
| 713 | compressAndUploadAvatar(file.getPath()); | 717 | compressAndUploadAvatar(file.getPath()); |
| 714 | 718 | ||
| 715 | } | 719 | } |
| 716 | 720 | ||
| 717 | private void compressAndUploadAvatar(String fileSrc) { | 721 | private void compressAndUploadAvatar(String fileSrc) { |
| 718 | 722 | ||
| 719 | 723 | ||
| 720 | //上传到服务器 | 724 | //上传到服务器 |
| 721 | 725 | ||
| 722 | final File cover = FileUtil.getSmallBitmap(this, fileSrc); | 726 | final File cover = FileUtil.getSmallBitmap(this, fileSrc); |
| 723 | String mimeType = "image/*"; | 727 | String mimeType = "image/*"; |
| 724 | //requestBody = RequestBody.create(MediaType.parse(mimeType), file); | 728 | //requestBody = RequestBody.create(MediaType.parse(mimeType), file); |
| 725 | //String fileName = cover.getName(); | 729 | //String fileName = cover.getName(); |
| 726 | String userID; | 730 | String userID; |
| 727 | String typeaccount = SaveParam.getInstance().getCustomizeParam(this, SaveParam.ACCOUNT); | 731 | String typeaccount = SaveParam.getInstance().getCustomizeParam(this, SaveParam.ACCOUNT); |
| 728 | if ("2".equals(typeaccount)) { | 732 | if ("2".equals(typeaccount)) { |
| 729 | userID = SaveParam.getInstance().getCustomizeParam(this, SaveParam.CHILDSID); | 733 | userID = SaveParam.getInstance().getCustomizeParam(this, SaveParam.CHILDSID); |
| 730 | } else { | 734 | } else { |
| 731 | userID = SaveParam.getInstance().getLoginParam(this, "userId"); | 735 | userID = SaveParam.getInstance().getLoginParam(this, "userId"); |
| 732 | } | 736 | } |
| 733 | 737 | ||
| 734 | //上传头像 | 738 | //上传头像 |
| 735 | 739 | ||
| 736 | try { | 740 | try { |
| 737 | HttpManager.getInstance().header(this, userID, typeaccount, fileSrc,handler); | 741 | HttpManager.getInstance().header(this, userID, typeaccount, fileSrc,handler); |
| 738 | } catch (UnsupportedEncodingException e) { | 742 | } catch (UnsupportedEncodingException e) { |
| 739 | e.printStackTrace(); | 743 | e.printStackTrace(); |
| 740 | } | 744 | } |
| 741 | //mSimpleDraweeView.setImageURI(Uri.fromFile(new File(fileSrc))); | 745 | //mSimpleDraweeView.setImageURI(Uri.fromFile(new File(fileSrc))); |
| 742 | 746 | ||
| 743 | // GenericDraweeHierarchyBuilder builder = new GenericDraweeHierarchyBuilder(getResources()); | 747 | // GenericDraweeHierarchyBuilder builder = new GenericDraweeHierarchyBuilder(getResources()); |
| 744 | // GenericDraweeHierarchy hierarchy = builder | 748 | // GenericDraweeHierarchy hierarchy = builder |
| 745 | // .setDesiredAspectRatio(1f) | 749 | // .setDesiredAspectRatio(1f) |
| 746 | // .setFailureImage(R.mipmap.header_default) | 750 | // .setFailureImage(R.mipmap.header_default) |
| 747 | // //圆形头像 | 751 | // //圆形头像 |
| 748 | // .setRoundingParams(RoundingParams.asCircle()) | 752 | // .setRoundingParams(RoundingParams.asCircle()) |
| 749 | // .build(); | 753 | // .build(); |
| 750 | // //OOM | 754 | // //OOM |
| 751 | // ImageRequest request = ImageRequestBuilder.newBuilderWithSource(uri) | 755 | // ImageRequest request = ImageRequestBuilder.newBuilderWithSource(uri) |
| 752 | // //根据View的尺寸放缩图片 | 756 | // //根据View的尺寸放缩图片 |
| 753 | // .setResizeOptions(new ResizeOptions(mSimpleDraweeView.getWidth(), mSimpleDraweeView.getHeight())) | 757 | // .setResizeOptions(new ResizeOptions(mSimpleDraweeView.getWidth(), mSimpleDraweeView.getHeight())) |
| 754 | // .build(); | 758 | // .build(); |
| 755 | // | 759 | // |
| 756 | // | 760 | // |
| 757 | // //加载本地图片 | 761 | // //加载本地图片 |
| 758 | // Uri uri = Uri.fromFile(cover); | 762 | // Uri uri = Uri.fromFile(cover); |
| 759 | //Picasso.with(MainActivity.this).load(uri).placeholder(R.mipmap.header_default).error(R.mipmap.header_default).transform(new RoundTransform(1000)).into(mSimpleDraweeView); | 763 | //Picasso.with(MainActivity.this).load(uri).placeholder(R.mipmap.header_default).error(R.mipmap.header_default).transform(new RoundTransform(1000)).into(mSimpleDraweeView); |
| 760 | // DraweeController controller = Fresco.newDraweeControllerBuilder() | 764 | // DraweeController controller = Fresco.newDraweeControllerBuilder() |
| 761 | // .setOldController(mSimpleDraweeView.getController()) | 765 | // .setOldController(mSimpleDraweeView.getController()) |
| 762 | // .setImageRequest(request) | 766 | // .setImageRequest(request) |
| 763 | // .setUri(uri) | 767 | // .setUri(uri) |
| 764 | // .build(); | 768 | // .build(); |
| 765 | // mSimpleDraweeView.setHierarchy(hierarchy); | 769 | // mSimpleDraweeView.setHierarchy(hierarchy); |
| 766 | // mSimpleDraweeView.setController(controller); | 770 | // mSimpleDraweeView.setController(controller); |
| 767 | 771 | ||
| 768 | } | 772 | } |
| 769 | 773 | ||
| 770 | public void startPhotoZoom(Uri uri) { | 774 | public void startPhotoZoom(Uri uri) { |
| 771 | Intent intent = new Intent("com.android.camera.action.CROP"); | 775 | Intent intent = new Intent("com.android.camera.action.CROP"); |
| 772 | intent.setDataAndType(uri, "image/*"); | 776 | intent.setDataAndType(uri, "image/*"); |
| 773 | intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); | 777 | intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); |
| 774 | intent.putExtra("crop", "true");// crop=true 有这句才能出来最后的裁剪页面. | 778 | intent.putExtra("crop", "true");// crop=true 有这句才能出来最后的裁剪页面. |
| 775 | intent.putExtra("aspectX", 1);// 这两项为裁剪框的比例. | 779 | intent.putExtra("aspectX", 1);// 这两项为裁剪框的比例. |
| 776 | intent.putExtra("aspectY", 1);// x:y=1:1 | 780 | intent.putExtra("aspectY", 1);// x:y=1:1 |
| 777 | // intent.putExtra("outputX", 400);//图片输出大小 | 781 | // intent.putExtra("outputX", 400);//图片输出大小 |
| 778 | // intent.putExtra("outputY", 400); | 782 | // intent.putExtra("outputY", 400); |
| 779 | intent.putExtra("output", Uri.fromFile(file)); | 783 | intent.putExtra("output", Uri.fromFile(file)); |
| 780 | intent.putExtra("outputFormat", "JPEG");// 返回格式 | 784 | intent.putExtra("outputFormat", "JPEG");// 返回格式 |
| 781 | startActivityForResult(intent, REQUEST_CODE_CROUP_PHOTO); | 785 | startActivityForResult(intent, REQUEST_CODE_CROUP_PHOTO); |
| 782 | } | 786 | } |
| 783 | 787 | ||
| 784 | @Override | 788 | @Override |
| 785 | public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) { | 789 | public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) { |
| 786 | switch (requestCode) { | 790 | switch (requestCode) { |
| 787 | 791 | ||
| 788 | case PermissionUtil.REQUEST_SHOWCAMERA: | 792 | case PermissionUtil.REQUEST_SHOWCAMERA: |
| 789 | if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) { | 793 | if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) { |
| 790 | // Permission Granted | 794 | // Permission Granted |
| 791 | uploadAvatarFromPhotoRequest(); | 795 | uploadAvatarFromPhotoRequest(); |
| 792 | 796 | ||
| 793 | } else { | 797 | } else { |
| 794 | if (!SharedPreferenceMark.getHasShowCamera()) { | 798 | if (!SharedPreferenceMark.getHasShowCamera()) { |
| 795 | SharedPreferenceMark.setHasShowCamera(true); | 799 | SharedPreferenceMark.setHasShowCamera(true); |
| 796 | new DialogPermission(this, "关闭摄像头权限影响扫描功能"); | 800 | new DialogPermission(this, "关闭摄像头权限影响扫描功能"); |
| 797 | 801 | ||
| 798 | } else { | 802 | } else { |
| 799 | Toast.makeText(this, "未获取摄像头权限", Toast.LENGTH_SHORT) | 803 | Toast.makeText(this, "未获取摄像头权限", Toast.LENGTH_SHORT) |
| 800 | .show(); | 804 | .show(); |
| 801 | } | 805 | } |
| 802 | } | 806 | } |
| 803 | break; | 807 | break; |
| 804 | case PermissionUtil.WRITE_EXTERNAL_STORAGE: | 808 | case PermissionUtil.WRITE_EXTERNAL_STORAGE: |
| 805 | if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) { | 809 | if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) { |
| 806 | // Permission Granted | 810 | // Permission Granted |
| 807 | UpdateChecker updateChecker = new UpdateChecker(this); | 811 | UpdateChecker updateChecker = new UpdateChecker(this); |
| 808 | updateChecker.checkForUpdates(); | 812 | updateChecker.checkForUpdates(); |
| 809 | 813 | ||
| 810 | } else { | 814 | } else { |
| 811 | if (!SharedPreferenceMark.getHasShowCamera()) { | 815 | if (!SharedPreferenceMark.getHasShowCamera()) { |
| 812 | new DialogPermission(this, "没有存储权限将导致应用无法更新"); | 816 | new DialogPermission(this, "没有存储权限将导致应用无法更新"); |
| 813 | 817 | ||
| 814 | } else { | 818 | } else { |
| 815 | Toast.makeText(this, "未获取存储权限,将导致应用无法更新", Toast.LENGTH_SHORT) | 819 | Toast.makeText(this, "未获取存储权限,将导致应用无法更新", Toast.LENGTH_SHORT) |
| 816 | .show(); | 820 | .show(); |
| 817 | } | 821 | } |
| 818 | } | 822 | } |
| 819 | break; | 823 | break; |
| 820 | default: | 824 | default: |
| 821 | super.onRequestPermissionsResult(requestCode, permissions, grantResults); | 825 | super.onRequestPermissionsResult(requestCode, permissions, grantResults); |
| 822 | } | 826 | } |
| 823 | } | 827 | } |
| 824 | 828 | ||
| 825 | 829 | ||
| 826 | private void showSwitchDialog() { | 830 | private void showSwitchDialog() { |
| 827 | //自定义部分 | 831 | //自定义部分 |
| 828 | LayoutInflater mInflater = LayoutInflater.from(this); | 832 | LayoutInflater mInflater = LayoutInflater.from(this); |
| 829 | View dialogView = mInflater.inflate(R.layout.dialog_layout, | 833 | View dialogView = mInflater.inflate(R.layout.dialog_layout, |
| 830 | null); | 834 | null); |
| 831 | hintDialog = new Dialog(this, R.style.CustomHintDialog); | 835 | hintDialog = new Dialog(this, R.style.CustomHintDialog); |
| 832 | middle_btn = (Button) dialogView.findViewById(R.id.middle_btn); | 836 | middle_btn = (Button) dialogView.findViewById(R.id.middle_btn); |
| 833 | primary_btn = (Button) dialogView.findViewById(R.id.primary_btn); | 837 | primary_btn = (Button) dialogView.findViewById(R.id.primary_btn); |
| 834 | hintDialog.addContentView(dialogView, new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT)); | 838 | hintDialog.addContentView(dialogView, new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT)); |
| 835 | hintDialog.setCanceledOnTouchOutside(true); | 839 | hintDialog.setCanceledOnTouchOutside(true); |
| 836 | hintDialog.show(); | 840 | hintDialog.show(); |
| 837 | middle_btn.setOnClickListener(this); | 841 | middle_btn.setOnClickListener(this); |
| 838 | primary_btn.setOnClickListener(this); | 842 | primary_btn.setOnClickListener(this); |
| 839 | } | 843 | } |
| 840 | 844 | ||
| 841 | private long exitTime = 0; | 845 | private long exitTime = 0; |
| 842 | 846 | ||
| 843 | @Override | 847 | @Override |
| 844 | public boolean onKeyDown(int keyCode, KeyEvent event) { | 848 | public boolean onKeyDown(int keyCode, KeyEvent event) { |
| 845 | if (keyCode == KeyEvent.KEYCODE_BACK) { | 849 | if (keyCode == KeyEvent.KEYCODE_BACK) { |
| 846 | if ((System.currentTimeMillis() - exitTime) > 2000) { | 850 | if ((System.currentTimeMillis() - exitTime) > 2000) { |
| 847 | Toast.makeText(getApplicationContext(), "再按一次退出程序", | 851 | Toast.makeText(getApplicationContext(), "再按一次退出程序", |
| 848 | Toast.LENGTH_SHORT).show(); | 852 | Toast.LENGTH_SHORT).show(); |
| 849 | exitTime = System.currentTimeMillis(); | 853 | exitTime = System.currentTimeMillis(); |
| 850 | } else { | 854 | } else { |
| 851 | //SysApplication.getInstance().finishActivity(MainActivity.this); | 855 | //SysApplication.getInstance().finishActivity(MainActivity.this); |
| 852 | SysApplication.getInstance().exit(); | 856 | SysApplication.getInstance().exit(); |
| 853 | } | 857 | } |
| 854 | return false; | 858 | return false; |
| 855 | } | 859 | } |
| 856 | return super.onKeyDown(keyCode, event); | 860 | return super.onKeyDown(keyCode, event); |
| 857 | } | 861 | } |
| 858 | } | 862 | } |
| 859 | 863 |