Commit 8b0669cf5812010aa9ef69e8f3f12cb11af571cc

Authored by YangShuai
1 parent 1dee521f

1 新增个人资料页

Showing 19 changed files with 1765 additions and 72 deletions
app/strike/src/main/java/com/cnlive/strike/LoginSuccessActivity.java
... ... @@ -14,6 +14,7 @@ import com.cnlive.moudle.pedometer.ui.activity.RunLineActivity;
14 14 import com.cnlive.strike.user.auth.UserService;
15 15 import com.cnlive.strike.user.model.LoginSuccessInfo;
16 16 import com.cnlive.strike.user.ui.activity.FirstLoginActivity;
  17 +import com.cnlive.strike.user.ui.activity.PersonalDataActivity;
17 18 import com.cnlive.strike.user.util.UserRouterHelper;
18 19  
19 20 @Route(path = "/cloud/user/LoginSuccessActivity")
... ... @@ -47,8 +48,9 @@ public class LoginSuccessActivity extends BaseActivity {
47 48 private void initAction() {
48 49 switch (eventType) {
49 50 case UserRouterHelper.SHOW_MAIN_VIEW://显示主界面
50   - CommonInfo.setUserInfo(this, UserService.getUid(this), UserService.getInstance(this).getAppAccount().getNickName(), UserService.getInstance(this).getAppAccount().getFaceUrl(), UserService.getInstance(this).getAppAccount().getMobile());
51   - RunLineActivity.newInstance(this, null, null, null, null);
  51 +// CommonInfo.setUserInfo(this, UserService.getUid(this), UserService.getInstance(this).getAppAccount().getNickName(), UserService.getInstance(this).getAppAccount().getFaceUrl(), UserService.getInstance(this).getAppAccount().getMobile());
  52 +// RunLineActivity.newInstance(this, null, null, null, null);
  53 + startActivity(new Intent(me, PersonalDataActivity.class));
52 54 finish();
53 55 break;
54 56  
... ...
app/strike/src/main/java/com/cnlive/strike/MainActivity.java
... ... @@ -20,6 +20,7 @@ import com.cnlive.strike.user.auth.UserService;
20 20 import com.cnlive.strike.user.ui.activity.FirstLoginActivity;
21 21 import com.cnlive.strike.user.ui.activity.LoginActivity;
22 22 import com.cnlive.strike.user.ui.activity.LoginDialogActivity;
  23 +import com.cnlive.strike.user.ui.activity.PersonalDataActivity;
23 24 import com.cnlive.strike.xiaojiaspeaker.ui.activity.AllDeviceActivity;
24 25  
25 26 import androidx.annotation.NonNull;
... ... @@ -36,12 +37,12 @@ public class MainActivity extends AppCompatActivity {
36 37 findViewById(R.id.go_to).setOnClickListener(new View.OnClickListener() {
37 38 @Override
38 39 public void onClick(View v) {
39   -// if (TextUtils.isEmpty(UserService.getUid(MainActivity.this))) {
  40 + if (TextUtils.isEmpty(UserService.getUid(MainActivity.this))) {
40 41 startActivity(new Intent(MainActivity.this, LoginActivity.class));
41 42 //// finish();
42   -// } else {
43   -// startActivity(new Intent(MainActivity.this, FirstLoginActivity.class));
44   -// }
  43 + } else {
  44 + startActivity(new Intent(MainActivity.this, PersonalDataActivity.class));
  45 + }
45 46 // Intent intent = new Intent(MainActivity.this, LoginDialogActivity.class);
46 47 // startActivity(intent);
47 48 // overridePendingTransition(R.anim.activity_in, R.anim.activity_out);
... ...
cloud/user/src/main/AndroidManifest.xml
... ... @@ -38,7 +38,31 @@
38 38 <meta-data
39 39 android:name="WEIBO_CHANNEL"
40 40 android:value="weibo" />
41   -
  41 + <!-- 个人签名-->
  42 + <activity
  43 + android:name=".ui.activity.SignatureActivity"
  44 + android:configChanges="keyboardHidden|screenSize|smallestScreenSize|screenLayout|orientation"
  45 + android:launchMode="singleTop"
  46 + android:screenOrientation="portrait"
  47 + android:windowSoftInputMode="stateVisible|adjustPan" />
  48 + <!-- 个人资料姓名-->
  49 + <activity
  50 + android:name=".ui.activity.UpdateContentActivity"
  51 + android:configChanges="keyboardHidden|screenSize|smallestScreenSize|screenLayout|orientation"
  52 + android:launchMode="singleTop"
  53 + android:screenOrientation="portrait" />
  54 + <!--预览头像-->
  55 + <activity
  56 + android:name=".ui.activity.PersonalImageActivity"
  57 + android:configChanges="screenSize|smallestScreenSize|screenLayout|orientation"
  58 + android:launchMode="singleTop"
  59 + android:screenOrientation="portrait" />
  60 + <!-- 个人资料页-->
  61 + <activity
  62 + android:name=".ui.activity.PersonalDataActivity"
  63 + android:configChanges="keyboardHidden|screenSize|smallestScreenSize|screenLayout|orientation"
  64 + android:launchMode="singleTop"
  65 + android:screenOrientation="portrait" />
42 66 <activity
43 67 android:name=".ui.activity.LoginDialogActivity"
44 68 android:configChanges="screenSize|smallestScreenSize|screenLayout|orientation"
... ... @@ -65,33 +89,6 @@
65 89 android:launchMode="singleTask"
66 90 android:screenOrientation="portrait"
67 91 android:windowSoftInputMode="adjustResize" />
68   - <!-- 个人资料页-->
69   - <activity
70   - android:name="com.cnlive.strike.moudle.user.ui.activity.PersonalDataActivity"
71   - android:configChanges="keyboardHidden|screenSize|smallestScreenSize|screenLayout|orientation"
72   - android:launchMode="singleTop"
73   - android:screenOrientation="portrait" />
74   - <!--预览头像-->
75   - <activity
76   - android:name="com.cnlive.strike.moudle.user.ui.activity.PersonalImageActivity"
77   - android:configChanges="screenSize|smallestScreenSize|screenLayout|orientation"
78   - android:launchMode="singleTop"
79   - android:screenOrientation="portrait" />
80   - <!-- 个人资料姓名-->
81   - <activity
82   - android:name="com.cnlive.strike.moudle.user.ui.activity.UpdateContentActivity"
83   - android:configChanges="keyboardHidden|screenSize|smallestScreenSize|screenLayout|orientation"
84   - android:launchMode="singleTop"
85   - android:screenOrientation="portrait"
86   - android:windowSoftInputMode="stateVisible|adjustPan" />
87   - <!-- 个人签名-->
88   - <activity
89   - android:name="com.cnlive.strike.moudle.user.ui.activity.SignatureActivity"
90   - android:configChanges="keyboardHidden|screenSize|smallestScreenSize|screenLayout|orientation"
91   - android:launchMode="singleTop"
92   - android:screenOrientation="portrait"
93   - android:windowSoftInputMode="stateVisible|adjustPan" />
94   -
95 92  
96 93 <service
97 94 android:name="com.cnlive.strike.user.auth.UserAccountService"
... ...
cloud/user/src/main/java/com/cnlive/strike/user/frame/presenter/PersonalDataPresenter.java 0 → 100644
  1 +package com.cnlive.strike.user.frame.presenter;
  2 +
  3 +import android.content.Context;
  4 +import android.text.InputFilter;
  5 +import android.text.InputType;
  6 +import android.text.TextUtils;
  7 +import android.widget.EditText;
  8 +import android.widget.Toast;
  9 +
  10 +import com.cnlive.core.libs.base.frame.presenter.BasePresenter;
  11 +import com.cnlive.core.libs.base.util.AlertUtil;
  12 +import com.cnlive.core.network.HttpConn;
  13 +import com.cnlive.core.network.NetCallBack;
  14 +import com.cnlive.core.network.model.BaseResult;
  15 +import com.cnlive.strike.user.UserUtilAction;
  16 +import com.cnlive.strike.user.auth.UserService;
  17 +import com.cnlive.strike.user.frame.view.PersonalDataView;
  18 +import com.cnlive.strike.user.model.CNLiveUserInfoExt;
  19 +import com.cnlive.strike.user.model.msg.UserEventMsg;
  20 +import com.cnlive.strike.user.ui.activity.PersonalDataActivity;
  21 +import com.cnlive.strike.user.util.UserRouterHelper;
  22 +import com.google.gson.Gson;
  23 +import com.hannesdorfmann.mosby3.mvp.MvpBasePresenter;
  24 +import com.qmuiteam.qmui.widget.dialog.QMUIDialog;
  25 +import com.qmuiteam.qmui.widget.dialog.QMUIDialogAction;
  26 +
  27 +import org.greenrobot.eventbus.EventBus;
  28 +
  29 +import io.reactivex.disposables.Disposable;
  30 +
  31 +//import com.cnlive.tcsdk.LoginManager;
  32 +
  33 +/**
  34 + * 创建:wukuiqing
  35 + * <p>
  36 + * 时间:2018/3/22
  37 + * <p>
  38 + * 描述:
  39 + */
  40 +
  41 +public class PersonalDataPresenter extends BasePresenter<PersonalDataView> {
  42 +
  43 + private Disposable updateUserExtInfoEvent;
  44 + private Disposable modifyUserInfoEvent;
  45 +
  46 + public void setData(UserService userService) {
  47 + ifViewAttached(view -> view.setView(userService));
  48 + }
  49 +
  50 + public void upLoadNickName(PersonalDataActivity personalDataActivity, UserService userService) {
  51 + QMUIDialog.EditTextDialogBuilder builderNickName = new QMUIDialog.EditTextDialogBuilder(personalDataActivity);
  52 + EditText name = builderNickName.getEditText();
  53 + name.setFilters(new InputFilter[]{new InputFilter.LengthFilter(15)});
  54 + name.setLines(1);
  55 + builderNickName.setTitle("修改昵称")
  56 + .setPlaceholder("昵称最多15个字")
  57 + .setInputType(InputType.TYPE_CLASS_TEXT)
  58 + .addAction("取消", new QMUIDialogAction.ActionListener() {
  59 + @Override
  60 + public void onClick(QMUIDialog dialog, int index) {
  61 + dialog.cancel();
  62 + }
  63 + })
  64 + .addAction("确定", new QMUIDialogAction.ActionListener() {
  65 + @Override
  66 + public void onClick(QMUIDialog dialog, int index) {
  67 + String name = builderNickName.getEditText().getText().toString();
  68 +
  69 + if (name != null && name.trim().length() > 0) {
  70 + if (name.length() > 15) {
  71 + AlertUtil.showDeftToast(personalDataActivity, "昵称最多十五个字");
  72 + } else {
  73 + dialog.dismiss();
  74 +
  75 + upLoadUserInfo(personalDataActivity, userService, "nickName", name);
  76 + }
  77 +
  78 +
  79 + } else {
  80 + AlertUtil.showDeftToast(personalDataActivity, "昵称不能为空");
  81 + }
  82 + }
  83 + }).show();
  84 + }
  85 +
  86 + public void upLoadUserInfo(Context context, UserService userService, String type, String value) {
  87 +
  88 +
  89 + /**
  90 + * @param uid 用户ID
  91 + * @param type nickName-昵称,gender-性别,email-邮箱, location-联系方式
  92 + * @param value 对应的信息,性别,m:男、f:女、n:未知
  93 + * @param callback 回调
  94 + *
  95 + *
  96 + */
  97 + if (modifyUserInfoEvent != null && !modifyUserInfoEvent.isDisposed()) {
  98 + modifyUserInfoEvent.dispose();
  99 + }
  100 + String uid = UserService.getUid(context);
  101 + String token = userService.getAppAccount().getToken();
  102 +
  103 + modifyUserInfoEvent = HttpConn.action(
  104 + UserUtilAction.modifyUserInfo(context, uid, type, value, token), new NetCallBack<BaseResult>() {
  105 + @Override
  106 + public void onRequestState(int state) {
  107 +
  108 + }
  109 +
  110 + @Override
  111 + public void onSuccess(BaseResult data) {
  112 + if (type.equals("nickName")) {
  113 + userService.setUserNickName(value);
  114 + ifViewAttached(view -> view.upDataNickName(value));
  115 + UserRouterHelper.modifyUserName(context, value);
  116 +// LoginManager.modifyUserName( UserService.getUid(context), value);
  117 + } else if (type.equals("gender")) {
  118 + userService.setUserSex(value);
  119 + ifViewAttached(view -> view.upDataSex(value));
  120 + } else if (type.equals("location")) {
  121 + userService.setUserLocation(value);
  122 + ifViewAttached(view -> view.upDataLocation(value));
  123 + }
  124 + }
  125 +
  126 + @Override
  127 + public void onFailure(String errCode, String errMsg) {
  128 + if (UserUtilAction.TOKEN_ERROR_CODE.equals(errCode)) {
  129 + ifViewAttached(view -> view.showTokenErrorDialog());
  130 + } else {
  131 + ifViewAttached(view -> view.showMessage(errMsg));
  132 + }
  133 + }
  134 + }
  135 + );
  136 +
  137 + }
  138 +
  139 +
  140 + public void upDataLocation(PersonalDataActivity personalDataActivity, UserService userService) {
  141 +
  142 + QMUIDialog.EditTextDialogBuilder builderNickName = new QMUIDialog.EditTextDialogBuilder(personalDataActivity);
  143 + EditText where = builderNickName.getEditText();
  144 + where.setFilters(new InputFilter[]{new InputFilter.LengthFilter(12)});
  145 + where.setLines(1);
  146 + builderNickName.setTitle("修改位置")
  147 + .setPlaceholder("在此输入您的位置")
  148 + .setInputType(InputType.TYPE_CLASS_TEXT)
  149 + .addAction("取消", new QMUIDialogAction.ActionListener() {
  150 + @Override
  151 + public void onClick(QMUIDialog dialog, int index) {
  152 + dialog.cancel();
  153 + }
  154 + })
  155 + .addAction("确定", new QMUIDialogAction.ActionListener() {
  156 + @Override
  157 + public void onClick(QMUIDialog dialog, int index) {
  158 + String location = builderNickName.getEditText().getText().toString();
  159 + if (location != null && location.length() > 0) {
  160 + dialog.dismiss();
  161 + upLoadUserInfo(personalDataActivity, userService, "location", location);
  162 + } else {
  163 +
  164 + AlertUtil.showDeftToast(personalDataActivity, "请填入您的位置");
  165 + }
  166 + }
  167 + }).show();
  168 + }
  169 +
  170 + /**
  171 + * 修改个人信息 名字 性别 地址
  172 + *
  173 + * @param personalDataActivity
  174 + * @param userService
  175 + */
  176 + public void upDataSignature(PersonalDataActivity personalDataActivity, UserService userService) {
  177 + QMUIDialog.EditTextDialogBuilder builderNickName = new QMUIDialog.EditTextDialogBuilder(personalDataActivity);
  178 + builderNickName.setTitle("修改个性签名")
  179 + .setPlaceholder("请输入您的个性签名")
  180 + .setInputType(InputType.TYPE_CLASS_TEXT)
  181 + .addAction("取消", new QMUIDialogAction.ActionListener() {
  182 + @Override
  183 + public void onClick(QMUIDialog dialog, int index) {
  184 + dialog.cancel();
  185 + }
  186 + })
  187 + .addAction("确定", new QMUIDialogAction.ActionListener() {
  188 + @Override
  189 + public void onClick(QMUIDialog dialog, int index) {
  190 + String location = builderNickName.getEditText().getText().toString();
  191 + if (!TextUtils.isEmpty(location)) {
  192 + if (location.length() > 15) {
  193 + AlertUtil.showDeftToast(personalDataActivity, "个性签名最多十五个字");
  194 + } else {
  195 + dialog.dismiss();
  196 + upLoadSignature(personalDataActivity, userService, location);
  197 + }
  198 +
  199 +
  200 + } else {
  201 + AlertUtil.showDeftToast(personalDataActivity, "请输入您的个性签名");
  202 + }
  203 + }
  204 + }).show();
  205 +
  206 + }
  207 +
  208 + /**
  209 + * 修改个人签名
  210 + *
  211 + * @param personalDataActivity
  212 + * @param userService
  213 + * @param value
  214 + */
  215 + public void upLoadSignature(PersonalDataActivity personalDataActivity, UserService userService, String value) {
  216 + if (updateUserExtInfoEvent != null && !updateUserExtInfoEvent.isDisposed()) {
  217 + updateUserExtInfoEvent.dispose();
  218 + }
  219 + String uid = UserService.getUid(personalDataActivity);
  220 + String token = userService.getAppAccount().getToken();
  221 +
  222 + CNLiveUserInfoExt info = new CNLiveUserInfoExt();
  223 + info.setUserSign(value);
  224 +
  225 + String signature = new Gson().toJson(info);
  226 + updateUserExtInfoEvent = HttpConn.action(
  227 + UserUtilAction.updateUserExtInfo(personalDataActivity, uid, signature, token), new NetCallBack<BaseResult>() {
  228 + @Override
  229 + public void onRequestState(int state) {
  230 +
  231 + }
  232 +
  233 + @Override
  234 + public void onSuccess(BaseResult data) {
  235 + userService.setUserSign(value);
  236 + ifViewAttached(view -> view.upSignature(value));
  237 + }
  238 +
  239 + @Override
  240 + public void onFailure(String errCode, String errMsg) {
  241 + if (UserUtilAction.TOKEN_ERROR_CODE.equals(errCode)) {
  242 + ifViewAttached(view -> view.showTokenErrorDialog());
  243 + } else {
  244 + AlertUtil.showDeftToast(personalDataActivity,errMsg);
  245 + }
  246 + }
  247 + }
  248 + );
  249 + }
  250 +}
... ...
cloud/user/src/main/java/com/cnlive/strike/user/frame/presenter/PersonalImagePresenter.java 0 → 100644
  1 +package com.cnlive.strike.user.frame.presenter;
  2 +
  3 +import android.content.SharedPreferences;
  4 +
  5 +import com.cnlive.core.libs.base.frame.presenter.BasePresenter;
  6 +import com.cnlive.core.libs.base.util.AlertUtil;
  7 +import com.cnlive.core.libs.base.util.SharedPreferencesHelper;
  8 +import com.cnlive.core.network.HttpConn;
  9 +import com.cnlive.core.network.NetCallBack;
  10 +import com.cnlive.core.network.model.BaseResult;
  11 +import com.cnlive.core.network.model.FaceData;
  12 +import com.cnlive.core.network.model.TokenData;
  13 +import com.cnlive.strike.user.UserUtilAction;
  14 +import com.cnlive.strike.user.auth.UserService;
  15 +import com.cnlive.strike.user.frame.view.PersonalImageView;
  16 +import com.cnlive.strike.user.ui.activity.PersonalImageActivity;
  17 +import com.cnlive.strike.user.util.UserRouterHelper;
  18 +
  19 +import java.io.File;
  20 +
  21 +import io.reactivex.ObservableSource;
  22 +import io.reactivex.disposables.Disposable;
  23 +import io.reactivex.functions.Function;
  24 +
  25 +import static android.content.Context.MODE_PRIVATE;
  26 +
  27 +/**
  28 + * 创建:wukuiqing
  29 + * <p>
  30 + * 时间:2018/3/22
  31 + * <p>
  32 + * 描述:
  33 + */
  34 +
  35 +
  36 +public class PersonalImagePresenter extends BasePresenter<PersonalImageView> {
  37 +
  38 + private Disposable updateFaceEvent;
  39 + private UserService userService;
  40 +
  41 + public void showBottomSheet() {
  42 + ifViewAttached(view -> view.showBottomSheet());
  43 +
  44 + }
  45 +
  46 + public void uploadUserIcon(PersonalImageActivity activity, String path) {
  47 +
  48 + if (updateFaceEvent != null && !updateFaceEvent.isDisposed()) {
  49 + updateFaceEvent.dispose();
  50 + }
  51 + userService = UserService.getInstance(activity);
  52 + String uid = UserService.getUid(activity);
  53 + String token = userService.getAppAccount().getToken();
  54 + /**
  55 + * @param uid 用户ID
  56 + * @param secret 获取access_token 凭证
  57 + * @param file 头像文件
  58 + * @param callback 回调
  59 + */
  60 + File file = new File(path);
  61 + updateFaceEvent = HttpConn.action(
  62 + UserUtilAction.accessToken(activity)
  63 + .concatMap(new Function<BaseResult<TokenData>, ObservableSource<BaseResult<FaceData>>>() {
  64 + @Override
  65 + public ObservableSource<BaseResult<FaceData>> apply(BaseResult<TokenData> tokenDataBaseResult) throws Exception {
  66 + if (tokenDataBaseResult.isSuccess()) {
  67 + return UserUtilAction.updateUserFace(activity, uid, file, token, tokenDataBaseResult.getData().getAccess_token());
  68 + }
  69 + return HttpConn.error(tokenDataBaseResult);
  70 + }
  71 + }), new NetCallBack<BaseResult<FaceData>>() {
  72 + @Override
  73 + public void onRequestState(int state) {
  74 +
  75 + }
  76 +
  77 + @Override
  78 + public void onSuccess(BaseResult<FaceData> data) {
  79 + userService.setUserFaceUrl(data.getData().getFaceUrl(), data.getData().getBigFaceUrl());
  80 + SharedPreferences preferences = activity.getSharedPreferences("updateface", MODE_PRIVATE);
  81 + boolean status = preferences.getBoolean(UserService.getUid(activity), false);
  82 + Boolean app_is_show_integral = SharedPreferencesHelper.getInstance(activity).getBoolValue("APP_IS_SHOW_INTEGRAL");
  83 + if (!status && app_is_show_integral) {
  84 + //todo
  85 + UserRouterHelper.goToCoinRainAction(activity, "update_face", "", "updateface", false);
  86 + }
  87 + ifViewAttached(view -> view.upDataUserIcon(data.getData().getBigFaceUrl()));
  88 + }
  89 +
  90 + @Override
  91 + public void onFailure(String errCode, String errMsg) {
  92 + ifViewAttached(view -> view.hideLoading());
  93 + if (UserUtilAction.TOKEN_ERROR_CODE.equals(errCode)) {
  94 + ifViewAttached(view -> view.showTokenErrorDialog());
  95 + } else {
  96 + AlertUtil.showDeftToast(activity, errMsg);
  97 + }
  98 + }
  99 + }
  100 + );
  101 +
  102 + }
  103 +}
... ...
cloud/user/src/main/java/com/cnlive/strike/user/frame/view/PersonalDataView.java 0 → 100644
  1 +package com.cnlive.strike.user.frame.view;
  2 +
  3 +import android.text.TextUtils;
  4 +
  5 +import com.bumptech.glide.Priority;
  6 +import com.bumptech.glide.load.resource.bitmap.RoundedCorners;
  7 +import com.bumptech.glide.request.RequestOptions;
  8 +import com.cnlive.core.libs.base.frame.view.BaseView;
  9 +import com.cnlive.core.libs.base.util.AlertUtil;
  10 +import com.cnlive.core.libs.base.util.GlideUtil;
  11 +import com.cnlive.strike.user.R;
  12 +import com.cnlive.strike.user.auth.UserService;
  13 +import com.cnlive.strike.user.model.CNLiveUserInfo;
  14 +import com.cnlive.strike.user.ui.activity.PersonalDataActivity;
  15 +import com.cnlive.strike.user.ui.widget.TokenErrorDialog;
  16 +
  17 +import static com.bumptech.glide.request.RequestOptions.bitmapTransform;
  18 +
  19 +/**
  20 + * 创建:wukuiqing
  21 + * <p>
  22 + * 时间:2018/3/22
  23 + * <p>
  24 + * 描述:
  25 + */
  26 +public class PersonalDataView extends BaseView {
  27 + PersonalDataActivity activity;
  28 +
  29 + public PersonalDataView(PersonalDataActivity activity) {
  30 + this.activity = activity;
  31 + }
  32 +
  33 + public void setView(UserService userService) {
  34 + CNLiveUserInfo info = userService == null ? null : userService.getAppAccount();
  35 + if (info == null) return;
  36 + activity.binding.tvName.setText(info.getNickName());
  37 + if ("m".equals(info.getGender())) {
  38 + activity.binding.tvSex.setText("男");
  39 + } else if ("f".equals(info.getGender())) {
  40 + activity.binding.tvSex.setText("女");
  41 + } else {
  42 + activity.binding.tvSex.setText("男");
  43 + }
  44 +
  45 + String location = info.getLocation();
  46 + activity.binding.tvWhere.setText(TextUtils.isEmpty(location) ? "中国" : location);
  47 +
  48 + RequestOptions options = bitmapTransform(new RoundedCorners(10))
  49 + .placeholder(R.drawable.touxiang_round)
  50 + .error(R.drawable.touxiang_round)
  51 + .priority(Priority.HIGH);
  52 + if (TextUtils.isEmpty(info.getFaceUrl())) {
  53 + GlideUtil.into(activity.binding.ivIcon, "http://wjj.ys1.cnliveimg.com/admin/test/head.png", options);
  54 + } else {
  55 + GlideUtil.into(activity.binding.ivIcon, info.getFaceUrl(), options);
  56 + }
  57 +
  58 + if (!TextUtils.isEmpty(info.getUserSign())) {
  59 + activity.binding.tvAutograph.setText(info.getUserSign());
  60 + }
  61 + }
  62 +
  63 + public void upDataSex(String value) {
  64 + if ("m".equals(value)) {
  65 + activity.binding.tvSex.setText("男");
  66 + } else if ("f".equals(value)) {
  67 + activity.binding.tvSex.setText("女");
  68 + } else {
  69 + activity.binding.tvSex.setText("其他");
  70 + }
  71 + }
  72 +
  73 + public void upDataNickName(String value) {
  74 + activity.binding.tvName.setText(value);
  75 + }
  76 +
  77 + public void upDataLocation(String value) {
  78 + activity.binding.tvWhere.setText(value);
  79 + }
  80 +
  81 + public void upSignature(String value) {
  82 + activity.binding.tvAutograph.setText(value);
  83 + }
  84 +
  85 + public void showMessage(String s) {
  86 + if (activity == null) return;
  87 + AlertUtil.showDeftToast(activity, s);
  88 + }
  89 +
  90 + public void showTokenErrorDialog() {
  91 + if (activity.tokenErrorDialog != null)
  92 + activity.tokenErrorDialog.dismiss();
  93 + activity.tokenErrorDialog = TokenErrorDialog.showTokenErrorDialog(activity);
  94 + }
  95 +
  96 +
  97 +}
... ...
cloud/user/src/main/java/com/cnlive/strike/user/frame/view/PersonalImageView.java 0 → 100644
  1 +package com.cnlive.strike.user.frame.view;
  2 +
  3 +import android.Manifest;
  4 +import android.app.Activity;
  5 +import android.content.Context;
  6 +import android.content.Intent;
  7 +import android.os.Environment;
  8 +import android.os.Handler;
  9 +import android.os.Message;
  10 +import android.util.Log;
  11 +import android.view.View;
  12 +import android.widget.Toast;
  13 +
  14 +import com.bumptech.glide.Priority;
  15 +import com.bumptech.glide.request.RequestOptions;
  16 +import com.cnlive.core.libs.base.frame.view.BaseView;
  17 +import com.cnlive.core.libs.base.interfaces.OnPermissionResponseListener;
  18 +import com.cnlive.core.libs.base.ui.widget.BottomMenuDialog;
  19 +import com.cnlive.core.libs.base.util.AlertUtil;
  20 +import com.cnlive.core.libs.base.util.GlideUtil;
  21 +import com.cnlive.media.picker.ImageCaptureManager;
  22 +import com.cnlive.media.picker.ImagePicker;
  23 +import com.cnlive.media.picker.PickerConfig;
  24 +import com.cnlive.media.picker.utils.FileUtils;
  25 +import com.cnlive.media.picker.utils.ImagePickerComUtils;
  26 +import com.cnlive.media.picker.utils.PermissionChecker;
  27 +import com.cnlive.strike.user.R;
  28 +import com.cnlive.strike.user.preview.ui.widget.DownLoadImageService;
  29 +import com.cnlive.strike.user.preview.ui.widget.ImageDownLoadCallBack;
  30 +import com.cnlive.strike.user.ui.activity.PersonalImageActivity;
  31 +import com.cnlive.strike.user.ui.widget.TokenErrorDialog;
  32 +import com.cnlive.strike.user.util.UserRouterHelper;
  33 +
  34 +import java.io.File;
  35 +import java.io.IOException;
  36 +
  37 +import static com.cnlive.media.picker.ui.PickerActivity.REQUEST_CODE_PERMISSION_CAMERA;
  38 +
  39 +
  40 +/**
  41 + * 创建:wukuiqing
  42 + * <p>
  43 + * 时间:2018/3/22
  44 + * <p>
  45 + * 描述:
  46 + */
  47 +
  48 +public class PersonalImageView extends BaseView {
  49 +
  50 + PersonalImageActivity activity;
  51 + private BottomMenuDialog bottomMenuDialog;
  52 + public static final int REQUEST_CODE_EDIT_PHOTO_CAMERA = 10008;
  53 + public Handler handler = new Handler() {
  54 + @Override
  55 + public void handleMessage(Message msg) {
  56 + super.handleMessage(msg);
  57 + if (msg.what == 1) {
  58 + AlertUtil.showSuccessToast(activity, "保存成功");
  59 +
  60 + } else if (msg.what == 2) {
  61 + AlertUtil.showSuccessToast(activity, "保存失败");
  62 + }
  63 +
  64 +
  65 + }
  66 + };
  67 +
  68 + public PersonalImageView(PersonalImageActivity activity) {
  69 + this.activity = activity;
  70 + bottomMenuDialog = new BottomMenuDialog.Builder(activity)
  71 +
  72 + .addMenu("从手机相册中选择", new View.OnClickListener() {
  73 + @Override
  74 + public void onClick(View v) {
  75 + bottomMenuDialog.dismiss();
  76 + showAlbum(activity);
  77 +
  78 + }
  79 +
  80 + }).addMenu("保存图片", new View.OnClickListener() {
  81 + @Override
  82 + public void onClick(View v) {
  83 + bottomMenuDialog.dismiss();
  84 + activity.requestPermission(REQUEST_CODE_EDIT_PHOTO_CAMERA,
  85 + com.cnlive.media.picker.R.string.dialog_imagepicker_permission_sdcard_message,
  86 + new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, new OnPermissionResponseListener() {
  87 + @Override
  88 + public void onSuccess(String[] permissions) {
  89 + savePicture(activity, activity.iconPath);
  90 + }
  91 +
  92 + @Override
  93 + public void onFail() {
  94 +
  95 + }
  96 + });
  97 + }
  98 + }).create(activity);
  99 + }
  100 +
  101 + public void showBottomSheet() {
  102 + bottomMenuDialog.show();
  103 + }
  104 +
  105 + private String[] showAlbumPermission = new String[]{Manifest.permission.CAMERA, Manifest.permission.WRITE_EXTERNAL_STORAGE};
  106 +
  107 + //相册选取
  108 + public void showAlbum(Context context) {
  109 + if (context == null) return;
  110 + activity.requestPermission(REQUEST_CODE_EDIT_PHOTO_CAMERA,
  111 + com.cnlive.media.picker.R.string.dialog_imagepicker_permission_sdcard_message,
  112 + showAlbumPermission, new OnPermissionResponseListener() {
  113 + @Override
  114 + public void onSuccess(String[] permissions) {
  115 + new ImagePicker
  116 + .Builder()
  117 + .setSelectGif(false)
  118 + //最大选择图片数目,默认40张
  119 + .maxNum(1)
  120 + //是否需要相机(默认false)
  121 + .needCamera(true)
  122 + //选择模式(默认PICKER_IMAGE_VIDEO) PICKER_IMAGE-->图片 PICKER_VIDEO-->视频 PICKER_IMAGE_VIDEO-->图片&视频
  123 + .selectMode(PickerConfig.PICKER_IMAGE)
  124 + //拍照或录像存储位置 默认Environment.getExternalStorageDirectory().getPath() + File.separator + "JCamera"
  125 + .cachePath(Environment.getExternalStorageDirectory() + "/strike/file/")
  126 + //是否为发朋友圈模式(默认false) true-->图片与视频不能同时选择
  127 + .isFriendCircle(true)
  128 + //裁剪 只有在单选模式下才可以使用
  129 + .doCrop(1, 1, 300, 300)
  130 + //是否开启单选模式(默认false)
  131 + .isSinglePick(true)
  132 + .maxImageSize(10 * 1024 * 1024)
  133 + .builder()
  134 + .start(activity, PickerConfig.PICKER_IMAGE, PickerConfig.DEFAULT_RESULT_CODE);
  135 + }
  136 +
  137 + @Override
  138 + public void onFail() {
  139 +
  140 + }
  141 + });
  142 +
  143 + }
  144 +
  145 + private String[] showCameraPermission = new String[]{Manifest.permission.CAMERA, Manifest.permission.WRITE_EXTERNAL_STORAGE};
  146 +
  147 + /**
  148 + * 拍照
  149 + */
  150 + public void showCamera(Context context, boolean checkOnly) {
  151 + if (context == null) return;
  152 + if (!ImagePickerComUtils.isSdExist()) {
  153 + Toast.makeText(context, "SD卡不存在", Toast.LENGTH_SHORT).show();
  154 + return;
  155 + }
  156 + activity.requestPermission(REQUEST_CODE_PERMISSION_CAMERA,
  157 + com.cnlive.media.picker.R.string.dialog_imagepicker_permission_camera_message,
  158 + showCameraPermission,
  159 + new OnPermissionResponseListener() {
  160 +
  161 + @Override
  162 + public void onSuccess(String[] permissions) {
  163 + takeCamre();
  164 + }
  165 +
  166 + @Override
  167 + public void onFail() {
  168 +
  169 + }
  170 + });
  171 + }
  172 +
  173 +
  174 + public ImageCaptureManager captureManager;
  175 +
  176 +
  177 + private void takeCamre() {
  178 + try {
  179 + captureManager = new ImageCaptureManager(activity);
  180 + Intent intent = captureManager.dispatchTakePictureIntent();
  181 + activity.startActivityForResult(intent, ImageCaptureManager.REQUEST_TAKE_PHOTO);
  182 + } catch (SecurityException e) {
  183 + Log.e("PersonalImageView", "Capture", e);
  184 + Toast.makeText(activity, com.cnlive.media.picker.R.string.msg_no_save_permission, Toast.LENGTH_SHORT).show();
  185 + } catch (Exception e) {
  186 + Log.e("PersonalImageView", "Capture", e);
  187 + Toast.makeText(activity, com.cnlive.media.picker.R.string.imagepicker_crop_decode_fail, Toast.LENGTH_SHORT).show();
  188 + }
  189 + }
  190 +
  191 +
  192 + /**
  193 + * 保存图片
  194 + *
  195 + * @param url
  196 + */
  197 + private void savePicture(Context context, String url) {
  198 +
  199 +
  200 + DownLoadImageService downLoadImageService = new DownLoadImageService(context, url, new ImageDownLoadCallBack() {
  201 + @Override
  202 + public void onDownLoadSuccess(File file) throws IOException {
  203 +
  204 + }
  205 +
  206 + @Override
  207 + public void onDownLoadSuccess(String bitmap) {
  208 + Message msg = Message.obtain();
  209 + msg.what = 1;
  210 + msg.obj = bitmap;
  211 + handler.sendMessage(msg);
  212 + }
  213 +
  214 + @Override
  215 + public void onDownLoadFailed() {
  216 + Message msg = Message.obtain();
  217 + msg.what = 2;
  218 + handler.sendMessage(msg);
  219 + }
  220 + });
  221 +
  222 + new Thread(downLoadImageService).start();
  223 +
  224 + }
  225 +
  226 + public void upDataUserIcon(String faceUrl) {
  227 + RequestOptions options = RequestOptions.circleCropTransform().dontAnimate().skipMemoryCache(false).placeholder(R.drawable.touxiang_circle).error(R.drawable.touxiang_circle).priority(Priority.HIGH);
  228 + GlideUtil.into(activity.binding.ivIcon, faceUrl, options);
  229 + activity.path = faceUrl;
  230 + hideLoading();
  231 + AlertUtil.showDeftToast(activity, "头像修改成功");
  232 +// LoginManager.modifyUserImage(UserService.getUid(activity), faceUrl);
  233 + UserRouterHelper.modifyUserName(activity, faceUrl);
  234 +
  235 + }
  236 +
  237 + public void showLoading() {
  238 + activity.tipDialog.show();
  239 + }
  240 +
  241 + public void hideLoading() {
  242 + activity.tipDialog.dismiss();
  243 + }
  244 +
  245 + public void showTokenErrorDialog() {
  246 + if (activity.tokenErrorDialog != null)
  247 + activity.tokenErrorDialog.dismiss();
  248 + activity.tokenErrorDialog = TokenErrorDialog.showTokenErrorDialog(activity);
  249 + }
  250 +
  251 + /**
  252 + * 移除Handler消息队列中的消息
  253 + */
  254 + public void onDestory() {
  255 + if (activity != null) handler.removeCallbacksAndMessages(null);
  256 + }
  257 +
  258 + /**
  259 + * 清理鲁班压缩后的图片
  260 + *
  261 + * @param luBanFile
  262 + */
  263 + public void clearLuban(File luBanFile) {
  264 + FileUtils.deleteFile(luBanFile);
  265 + }
  266 +}
... ...
cloud/user/src/main/java/com/cnlive/strike/user/model/LaunchPage.java 0 → 100644
  1 +package com.cnlive.strike.user.model;
  2 +
  3 +import android.view.View;
  4 +
  5 +import androidx.databinding.BaseObservable;
  6 +import androidx.databinding.Bindable;
  7 +
  8 +import com.cnlive.strike.user.BR;
  9 +
  10 +
  11 +public class LaunchPage extends BaseObservable {
  12 +
  13 + private int loading = View.GONE;
  14 +
  15 + @Bindable
  16 + public int getLoading() {
  17 + return loading;
  18 + }
  19 +
  20 + public void setLoading(int loading) {
  21 + this.loading = loading;
  22 + notifyPropertyChanged(com.cnlive.strike.user.BR.loading);
  23 + }
  24 +}
... ...
cloud/user/src/main/java/com/cnlive/strike/user/preview/ui/widget/DownLoadImageService.java 0 → 100644
  1 +package com.cnlive.strike.user.preview.ui.widget;
  2 +
  3 +import android.content.Context;
  4 +import android.content.Intent;
  5 +import android.net.Uri;
  6 +import android.os.Environment;
  7 +import android.text.TextUtils;
  8 +import android.util.Log;
  9 +
  10 +import com.bumptech.glide.Glide;
  11 +import com.bumptech.glide.request.target.Target;
  12 +import com.cnlive.core.libs.base.util.MD5Util;
  13 +import com.cnlive.media.picker.utils.FileTypeUtil;
  14 +
  15 +import java.io.File;
  16 +import java.io.FileInputStream;
  17 +import java.io.FileOutputStream;
  18 +import java.io.InputStream;
  19 +
  20 +/**
  21 + * 创建:wukuiqing
  22 + * <p>
  23 + * 时间:2018/3/17
  24 + * <p>
  25 + * 描述:图片下载的工具类
  26 + */
  27 +
  28 +public class DownLoadImageService implements Runnable {
  29 + private String url;
  30 + private Context context;
  31 + private ImageDownLoadCallBack callBack;
  32 + private File file;
  33 +
  34 + public DownLoadImageService(Context context, String url, ImageDownLoadCallBack callBack) {
  35 + this.url = url;
  36 + this.callBack = callBack;
  37 + this.context = context;
  38 + }
  39 +
  40 + @Override
  41 + public void run() {
  42 + try {
  43 + if (!TextUtils.isEmpty(url)) file = Glide.with(context).asFile()
  44 + .load(url)
  45 + .into(Target.SIZE_ORIGINAL, Target.SIZE_ORIGINAL)
  46 + .get();
  47 + if (file != null) saveImageToGallery(context, file);
  48 + } catch (Exception e) {
  49 + Log.e("DownLoadFile", "", e);
  50 + } finally {
  51 + if (file != null && file.exists()) callBack.onDownLoadSuccess(file.getAbsolutePath());
  52 + else callBack.onDownLoadFailed();
  53 + }
  54 + }
  55 +
  56 + public void saveImageToGallery(Context context, File file) {
  57 + try {
  58 + String md5 = MD5Util.getMD5(file);
  59 + InputStream inStream = new FileInputStream(file); //读入原文件
  60 + File appDir = new File(Environment.getExternalStorageDirectory(), "strike");
  61 + if (!appDir.exists()) appDir.mkdir();
  62 +
  63 + String type = FileTypeUtil.getFileType(file.getAbsolutePath());
  64 + String extension;//初始文件扩展名
  65 + if (TextUtils.isEmpty(type)) {
  66 + extension = ".jpg";
  67 + } else {
  68 + extension = "." + type;
  69 + }
  70 +
  71 + File newFile = new File(appDir, md5 + extension);
  72 + FileOutputStream outputStream = new FileOutputStream(newFile);
  73 +
  74 + int byteread = 0;
  75 + byte[] buffer2 = new byte[1444];
  76 + while ((byteread = inStream.read(buffer2)) != -1)
  77 + outputStream.write(buffer2, 0, byteread);
  78 + inStream.close();
  79 + outputStream.close();
  80 +
  81 + context.sendBroadcast(new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE, Uri.parse("file://" + newFile.getAbsolutePath())));
  82 + //TODO 文件缓存已经完成 待优化~!!
  83 + } catch (Exception e) {
  84 + Log.e("ImageDownloadService", "Exception ", e);
  85 + }
  86 + }
  87 +}
... ...
cloud/user/src/main/java/com/cnlive/strike/user/preview/ui/widget/ImageDownLoadCallBack.java 0 → 100644
  1 +package com.cnlive.strike.user.preview.ui.widget;
  2 +
  3 +import java.io.File;
  4 +import java.io.IOException;
  5 +
  6 +/**
  7 + * 创建:wukuiqing
  8 + * <p>
  9 + * 时间:2018/3/17
  10 + * <p>
  11 + * 描述:
  12 + */
  13 +
  14 +public interface ImageDownLoadCallBack {
  15 +
  16 + void onDownLoadSuccess(File file) throws IOException;
  17 + void onDownLoadSuccess(String path);
  18 +
  19 + void onDownLoadFailed();
  20 +}
... ...
cloud/user/src/main/java/com/cnlive/strike/user/ui/activity/PersonalDataActivity.java 0 → 100644
  1 +package com.cnlive.strike.user.ui.activity;
  2 +
  3 +import android.app.Dialog;
  4 +import android.content.Context;
  5 +import android.content.Intent;
  6 +import android.os.Bundle;
  7 +import android.text.TextUtils;
  8 +import android.view.View;
  9 +
  10 +import com.alibaba.android.arouter.facade.annotation.Route;
  11 +import com.alibaba.android.arouter.launcher.ARouter;
  12 +import com.bumptech.glide.load.engine.DiskCacheStrategy;
  13 +import com.bumptech.glide.request.RequestOptions;
  14 +import com.cnlive.core.libs.base.frame.activity.BaseActivity;
  15 +import com.cnlive.core.libs.base.ui.widget.BottomMenuDialog;
  16 +import com.cnlive.core.libs.base.util.GlideUtil;
  17 +import com.cnlive.core.libs.base.util.StatusBarConfig;
  18 +import com.cnlive.strike.user.R;
  19 +import com.cnlive.strike.user.auth.UserService;
  20 +import com.cnlive.strike.user.databinding.ActivityPersonalDataBinding;
  21 +import com.cnlive.strike.user.frame.presenter.PersonalDataPresenter;
  22 +import com.cnlive.strike.user.frame.view.PersonalDataView;
  23 +import com.cnlive.strike.user.model.LaunchPage;
  24 +import com.qmuiteam.qmui.widget.QMUITopBar;
  25 +
  26 +import java.util.ArrayList;
  27 +
  28 +
  29 +/**
  30 + * 创建:wukuiqing
  31 + * <p>
  32 + * 时间:2018/3/22
  33 + * <p>
  34 + * 描述: 编辑个人资料页面
  35 + */
  36 +@Route(path = "/cnuser/PersonalDataActivity")
  37 +public class PersonalDataActivity extends BaseActivity<PersonalDataView, PersonalDataPresenter> implements View.OnClickListener {
  38 + private UserService userService;
  39 + private BottomMenuDialog sex;
  40 + public Dialog tokenErrorDialog;
  41 +// public LaunchPage data;
  42 + public ActivityPersonalDataBinding binding;
  43 +
  44 + @Override
  45 + protected int getBindLayoutId() {
  46 + return R.layout.activity_personal_data;
  47 + }
  48 +
  49 + @Override
  50 + protected void initBindingData() {
  51 + super.initBindingData();
  52 + binding= (ActivityPersonalDataBinding) getBaseBinding();
  53 + }
  54 +
  55 + public static void startActivity(Context context) {
  56 + Intent intent = new Intent(context, PersonalDataActivity.class);
  57 + context.startActivity(intent);
  58 + }
  59 +
  60 +
  61 + @Override
  62 + protected void initData() {
  63 + super.initData();
  64 + userService = UserService.getInstance(this);
  65 + getPresenter().setData(userService);
  66 + }
  67 +
  68 + @Override
  69 + protected void initView() {
  70 + super.initView();
  71 + setStatusBarTextColor(StatusBarConfig.BLACK);
  72 + setStatusBarColor(R.color.color_fff,0);
  73 + QMUITopBar toolbar = (QMUITopBar) binding.titleBar;
  74 + toolbar.setTitle("个人资料");
  75 + toolbar.setBackgroundColor(getResources().getColor(R.color.white));
  76 + toolbar.addLeftImageButton(R.drawable.drd_fanhui, R.id.qmui_topbar_item_left_back).setOnClickListener(new View.OnClickListener() {
  77 + @Override
  78 + public void onClick(View v) {
  79 + finish();
  80 + }
  81 + });
  82 + binding.rlIcon.setOnClickListener(this);
  83 + binding.rlName.setOnClickListener(this);
  84 + binding.rlSex.setOnClickListener(this);
  85 + binding.rlQr.setOnClickListener(this);
  86 + binding.rlWhere.setOnClickListener(this);
  87 + binding.rlAutograph.setOnClickListener(this);
  88 + binding.rlAutograph.setOnClickListener(this);
  89 + sex = new BottomMenuDialog.Builder(this)
  90 + .addMenu("男", new View.OnClickListener() {
  91 + @Override
  92 + public void onClick(View v) {
  93 + sex.dismiss();
  94 + getPresenter().upLoadUserInfo(PersonalDataActivity.this, userService, "gender", "m");
  95 +
  96 + }
  97 + }).addMenu("女", new View.OnClickListener() {
  98 + @Override
  99 + public void onClick(View v) {
  100 + getPresenter().upLoadUserInfo(PersonalDataActivity.this, userService, "gender", "f");
  101 + sex.dismiss();
  102 +
  103 + }
  104 +
  105 + }).create(this);
  106 + }
  107 +
  108 + @Override
  109 + protected void onDestroy() {
  110 + super.onDestroy();
  111 + }
  112 +
  113 + @Override
  114 + protected void onPause() {
  115 + super.onPause();
  116 + if (tokenErrorDialog != null) tokenErrorDialog.dismiss();
  117 + }
  118 +
  119 + @Override
  120 + protected void onResume() {
  121 + super.onResume();
  122 + getMvpView().setView(UserService.getInstance(this));
  123 + }
  124 +
  125 + @Override
  126 + public void onClick(View v) {
  127 +
  128 + //头像
  129 + if ((v.getId() == R.id.rl_icon)) {
  130 + String faceBig = userService.getAppAccount().getBigFaceUrl();
  131 +
  132 + if (faceBig == null || TextUtils.isEmpty(faceBig)) {
  133 + faceBig = TextUtils.isEmpty(userService.getAppAccount().getFaceUrl()) ? "" : userService.getAppAccount().getFaceUrl();
  134 + }
  135 + PersonalImageActivity.startActivity(this, faceBig);
  136 + }
  137 + //名字
  138 + else if ((v.getId() == R.id.rl_name)) {
  139 + UpdateContentActivity.startActivity(this, "nickName");
  140 + }
  141 + //性别
  142 + else if ((v.getId() == R.id.rl_sex)) {
  143 + sex.show();
  144 + }
  145 + //二维码
  146 + else if ((v.getId() == R.id.rl_qr)) {
  147 + ArrayList urls = new ArrayList();
  148 + urls.add(userService.getAppAccount().getFaceUrl());
  149 + //todo
  150 +// GenerateQRActivity.startActivity(this, urls, userService.getAppAccount().getNickName(), userService.getAppAccount().getLocation(), "扫描二维码,加我好友", "user", "....");
  151 + ARouter.getInstance().build("/qr/GenerateQRActivity")
  152 + .withStringArrayList("userUrl", urls)
  153 + .withString("userName", userService.getAppAccount().getNickName())
  154 + .withString("address", userService.getAppAccount().getLocation())
  155 + .withString("bomHint", "扫描二维码,加我好友")
  156 + .withString("qrType", "user")
  157 + .withString("content", "....")
  158 + .navigation(this);
  159 +
  160 + }
  161 + //地区
  162 + else if ((v.getId() == R.id.rl_where)) {
  163 + UpdateContentActivity.startActivity(this, "location");
  164 + }
  165 + //个性签名
  166 + else if ((v.getId() == R.id.rl_autograph)) {
  167 + SignatureActivity.startActivity(this);
  168 + }
  169 +
  170 + }
  171 +
  172 +
  173 + @Override
  174 + protected void onActivityResult(int requestCode, int resultCode, Intent data) {
  175 + super.onActivityResult(requestCode, resultCode, data);
  176 +
  177 + if (requestCode == 10011 && resultCode == 10010) {
  178 + RequestOptions requestOptions = new RequestOptions().skipMemoryCache(true).diskCacheStrategy(DiskCacheStrategy.NONE);
  179 + GlideUtil.into(binding.ivIcon, userService.getAppAccount().getFaceUrl(), requestOptions);
  180 + }
  181 +
  182 +
  183 + }
  184 +}
... ...
cloud/user/src/main/java/com/cnlive/strike/user/ui/activity/PersonalImageActivity.java 0 → 100644
  1 +package com.cnlive.strike.user.ui.activity;
  2 +
  3 +import android.app.Dialog;
  4 +import android.content.Intent;
  5 +import android.os.Bundle;
  6 +import android.os.Environment;
  7 +import android.text.TextUtils;
  8 +import android.view.View;
  9 +
  10 +import com.cnlive.core.libs.base.frame.activity.BaseActivity;
  11 +import com.cnlive.core.libs.base.util.AlertUtil;
  12 +import com.cnlive.core.libs.base.util.GlideUtil;
  13 +import com.cnlive.core.libs.base.util.StatusBarConfig;
  14 +import com.cnlive.media.picker.PickerConfig;
  15 +import com.cnlive.media.picker.entity.Media;
  16 +import com.cnlive.strike.user.R;
  17 +import com.cnlive.strike.user.auth.UserService;
  18 +import com.cnlive.strike.user.databinding.ActivityPersonalImageBinding;
  19 +import com.cnlive.strike.user.frame.presenter.PersonalImagePresenter;
  20 +import com.cnlive.strike.user.frame.view.PersonalImageView;
  21 +import com.qmuiteam.qmui.widget.QMUITopBar;
  22 +import com.qmuiteam.qmui.widget.dialog.QMUITipDialog;
  23 +import com.top.zibin.luban.CompressionPredicate;
  24 +import com.top.zibin.luban.Luban;
  25 +import com.top.zibin.luban.OnCompressListener;
  26 +
  27 +import java.io.File;
  28 +import java.util.ArrayList;
  29 +
  30 +/**
  31 + * 创建:wukuiqing
  32 + * <p>
  33 + * 时间:2018/3/22
  34 + * <p>
  35 + * 描述: 更新头像
  36 + */
  37 +
  38 +public class PersonalImageActivity extends BaseActivity<PersonalImageView, PersonalImagePresenter > {
  39 +
  40 + public String iconPath;
  41 + public String path;
  42 + public QMUITipDialog tipDialog;
  43 + private File luBanFile;
  44 + public Dialog tokenErrorDialog;
  45 + public ActivityPersonalImageBinding binding;
  46 +
  47 + public static void startActivity(PersonalDataActivity context, String iconPath) {
  48 + Intent intent = new Intent(context, PersonalImageActivity.class);
  49 + intent.putExtra("iconPath", iconPath);
  50 + context.startActivityForResult(intent, 10011);
  51 + }
  52 +
  53 + @Override
  54 + protected int getBindLayoutId() {
  55 + return R.layout.activity_personal_image;
  56 + }
  57 +
  58 + @Override
  59 + protected void initBindingData() {
  60 + super.initBindingData();
  61 + binding = (ActivityPersonalImageBinding) getBaseBinding();
  62 + }
  63 +
  64 +
  65 +
  66 + @Override
  67 + protected void initView() {
  68 + super.initView();
  69 + setStatusBarTextColor(StatusBarConfig.BLACK);
  70 + setStatusBarColor(R.color.color_fff,0);
  71 + iconPath = UserService.getInstance(this).getAppAccount().getBigFaceUrl();
  72 + QMUITopBar toolbar = (QMUITopBar) binding.toolBar;
  73 + toolbar.setTitle("个人头像");
  74 + toolbar.setBackgroundColor(getResources().getColor(R.color.white));
  75 + toolbar.addRightImageButton(R.drawable.pyq_xiangxizilao_shezhi, R.id.topbar_right_change_button)
  76 + .setOnClickListener(new View.OnClickListener() {
  77 + @Override
  78 + public void onClick(View view) {
  79 + getPresenter().showBottomSheet();
  80 + }
  81 + });
  82 + toolbar.addLeftImageButton(R.drawable.drd_fanhui, R.id.qmui_topbar_item_left_back).setOnClickListener(new View.OnClickListener() {
  83 + @Override
  84 + public void onClick(View v) {
  85 + onBackPressed();
  86 + }
  87 + });
  88 + GlideUtil.into(binding.ivIcon, iconPath);
  89 + tipDialog = new QMUITipDialog.Builder(this)
  90 + .setIconType(QMUITipDialog.Builder.ICON_TYPE_LOADING)
  91 + .setTipWord("上传中")
  92 + .create();
  93 + }
  94 +
  95 + @Override
  96 + protected void onPause() {
  97 + super.onPause();
  98 + if (tokenErrorDialog != null) tokenErrorDialog.dismiss();
  99 + }
  100 +
  101 + @Override
  102 + protected void onDestroy() {
  103 + if (luBanFile != null && luBanFile.exists()) getMvpView().clearLuban(luBanFile);
  104 + if (getMvpView() != null) getMvpView().onDestory();
  105 + super.onDestroy();
  106 + if (tipDialog != null) tipDialog.dismiss();
  107 +
  108 + }
  109 +
  110 + @Override
  111 + protected void onActivityResult(int requestCode, int resultCode, Intent data) {
  112 + super.onActivityResult(requestCode, resultCode, data);
  113 +
  114 + if (resultCode == PickerConfig.DEFAULT_RESULT_CODE) {
  115 + ArrayList<Media> select = data.getParcelableArrayListExtra(PickerConfig.EXTRA_RESULT);
  116 + path = select.get(0).path;
  117 +
  118 + Luban.with(this)
  119 + .load(path)
  120 + .ignoreBy(400)
  121 + .putGear(1)
  122 + .setTargetDir(getPath())
  123 + .filter(new CompressionPredicate() {
  124 + @Override
  125 + public boolean apply(String path) {
  126 + return !(TextUtils.isEmpty(path) || path.toLowerCase().endsWith(".gif"));
  127 + }
  128 + })
  129 + .setCompressListener(new OnCompressListener() {
  130 + @Override
  131 + public void onStart() {
  132 + }
  133 +
  134 + @Override
  135 + public void onSuccess(File file) {
  136 + luBanFile = file;
  137 + getPresenter().uploadUserIcon(PersonalImageActivity.this, file.getPath());
  138 + }
  139 +
  140 + @Override
  141 + public void onError(Throwable e) {
  142 + AlertUtil.showDeftToast(PersonalImageActivity.this, "二维码压缩失败");
  143 + }
  144 + }).launch();
  145 +
  146 + if (getMvpView() != null)
  147 + getMvpView().showLoading();
  148 + }
  149 +
  150 +
  151 + }
  152 +
  153 +
  154 +
  155 + public String getPath() {
  156 + String path = Environment.getExternalStorageDirectory() + "/strike/image/";
  157 + File file = new File(path);
  158 + if (file.mkdirs()) {
  159 + return path;
  160 + }
  161 + return path;
  162 + }
  163 +
  164 + @Override
  165 + public void onBackPressed() {
  166 + Intent intent = new Intent();
  167 + setResult(10010, intent);
  168 + this.finish();
  169 +
  170 + }
  171 +}
... ...
cloud/user/src/main/java/com/cnlive/strike/user/ui/activity/SignatureActivity.java 0 → 100644
  1 +package com.cnlive.strike.user.ui.activity;
  2 +
  3 +import android.app.Activity;
  4 +import android.app.Dialog;
  5 +import android.content.Intent;
  6 +import android.text.Editable;
  7 +import android.text.InputFilter;
  8 +import android.text.TextUtils;
  9 +import android.text.TextWatcher;
  10 +import android.view.View;
  11 +import android.widget.Button;
  12 +import android.widget.Toast;
  13 +
  14 +import com.cnlive.core.libs.base.frame.activity.BaseActivity;
  15 +import com.cnlive.core.libs.base.util.AlertUtil;
  16 +import com.cnlive.core.libs.base.util.QMUITipDialogUtil;
  17 +import com.cnlive.core.libs.base.util.StatusBarConfig;
  18 +import com.cnlive.core.network.HttpConn;
  19 +import com.cnlive.core.network.NetCallBack;
  20 +import com.cnlive.core.network.model.BaseResult;
  21 +import com.cnlive.strike.user.R;
  22 +import com.cnlive.strike.user.UserUtilAction;
  23 +import com.cnlive.strike.user.auth.UserService;
  24 +import com.cnlive.strike.user.databinding.ActivitySignatureBinding;
  25 +import com.cnlive.strike.user.model.CNLiveUserInfoExt;
  26 +import com.cnlive.strike.user.ui.widget.TokenErrorDialog;
  27 +import com.google.gson.Gson;
  28 +import com.qmuiteam.qmui.widget.QMUITopBar;
  29 +import io.reactivex.disposables.Disposable;
  30 +
  31 +/**
  32 + * 作者: 吴奎庆
  33 + * <p>
  34 + * 时间: 2018/7/20
  35 + * <p>
  36 + * 简介:
  37 + */
  38 +
  39 +public class SignatureActivity extends BaseActivity implements View.OnClickListener {
  40 +
  41 + private Disposable updateUserExtInfoEvent;
  42 + private ActivitySignatureBinding binding;
  43 + private String userId;
  44 + private String token;
  45 + private Button right;
  46 + private Dialog tokenErrorDialog;
  47 +
  48 + public static void startActivity(Activity activity) {
  49 + Intent intent = new Intent(activity, SignatureActivity.class);
  50 + activity.startActivity(intent);
  51 + }
  52 +
  53 + @Override
  54 + protected int getBindLayoutId() {
  55 + return R.layout.activity_signature;
  56 + }
  57 +
  58 + @Override
  59 + protected void initBindingData() {
  60 + super.initBindingData();
  61 + binding = (ActivitySignatureBinding) getBaseBinding();
  62 + }
  63 +
  64 + @Override
  65 + protected void initView() {
  66 + super.initView();
  67 + setStatusBarColor(R.color.color_fff, 0);
  68 + setStatusBarTextColor(StatusBarConfig.BLACK);
  69 + userId = UserService.getUid(this);
  70 + token = UserService.getInstance(this).getAppAccount().getToken();
  71 + QMUITopBar toolbar = (QMUITopBar) binding.includeToolbar;
  72 + toolbar.setTitle("个性签名");
  73 + toolbar.setBackgroundColor(getResources().getColor(R.color.white));
  74 + right = toolbar.addRightTextButton("保存", R.id.rightBtn);
  75 + right.setTextColor(getResources().getColor(R.color.black));
  76 + right.setOnClickListener(this);
  77 + toolbar.addLeftImageButton(R.drawable.fl_fanhui, R.id.qmui_topbar_item_left_back).setOnClickListener(this);
  78 + InputFilter[] filters = {new InputFilter.LengthFilter(40)};
  79 + binding.edContent.setFilters(filters);
  80 + binding.edContent.addTextChangedListener(new TextWatcher() {
  81 + @Override
  82 + public void beforeTextChanged(CharSequence s, int start, int count, int after) {
  83 +
  84 + }
  85 +
  86 + @Override
  87 + public void onTextChanged(CharSequence s, int start, int before, int count) {
  88 + }
  89 +
  90 + @Override
  91 + public void afterTextChanged(Editable s) {
  92 + if (s != null) {
  93 + int length = s.length();
  94 + binding.tvCount.setText(length + "/40");
  95 + }
  96 + }
  97 + });
  98 + showSoftInput();
  99 + String sign = UserService.getInstance(this).getAppAccount().getUserSign();
  100 + if (!TextUtils.isEmpty(sign)) {
  101 + binding.edContent.setText(sign);
  102 + binding.tvCount.setText(sign.length() + "/40");
  103 + } else {
  104 + binding.tvCount.setText(0 + "/40");
  105 + }
  106 + }
  107 +
  108 + @Override
  109 + protected void onPause() {
  110 + super.onPause();
  111 + if (tokenErrorDialog != null) tokenErrorDialog.dismiss();
  112 + }
  113 +
  114 + @Override
  115 + public void onClick(View v) {
  116 + if (v.getId() == R.id.rightBtn) {
  117 + if (right.isClickable()) {
  118 + hideSoftInput();
  119 + uploadSignature(binding.edContent.getText().toString().trim());
  120 + }
  121 + } else if (v.getId() == R.id.qmui_topbar_item_left_back) {
  122 + hideSoftInput();
  123 + finish();
  124 + }
  125 + }
  126 +
  127 + private void uploadSignature(String content) {
  128 + if (content != null && content.trim().length() > 0) {
  129 + upLoadSignature(content);
  130 + } else {
  131 + AlertUtil.showDeftToast(this, "请输入您的签名,签名内容不能为空");
  132 + }
  133 + }
  134 +
  135 + /**
  136 + * 修改个人签名
  137 + *
  138 + * @param value
  139 + */
  140 + public void upLoadSignature(String value) {
  141 +
  142 + if (updateUserExtInfoEvent != null && !updateUserExtInfoEvent.isDisposed()) {
  143 + updateUserExtInfoEvent.dispose();
  144 + }
  145 + right.setClickable(false);
  146 + CNLiveUserInfoExt info = new CNLiveUserInfoExt();
  147 + info.setUserSign(value);
  148 + String signature = new Gson().toJson(info);
  149 +
  150 + updateUserExtInfoEvent = HttpConn.action(
  151 + UserUtilAction.updateUserExtInfo(this, userId, signature, token), new NetCallBack<BaseResult>() {
  152 + @Override
  153 + public void onRequestState(int state) {
  154 + if (state == HttpConn.ON_START) {
  155 + right.setClickable(false);
  156 + QMUITipDialogUtil.loadingDialog(me, "修改中", true);
  157 +
  158 + } else if (state == HttpConn.ON_END) {
  159 + right.setClickable(true);
  160 + QMUITipDialogUtil.dismessDialog();
  161 + }
  162 +
  163 + }
  164 +
  165 + @Override
  166 + public void onSuccess(BaseResult data) {
  167 + UserService.getInstance(SignatureActivity.this).setUserSign(value);
  168 + finish();
  169 + }
  170 +
  171 + @Override
  172 + public void onFailure(String errCode, String errMsg) {
  173 + right.setClickable(true);
  174 + if (UserUtilAction.TOKEN_ERROR_CODE.equals(errCode)) {
  175 + showTokenErrorDialog();
  176 + } else {
  177 + AlertUtil.showDeftToast(me,errMsg);
  178 + }
  179 + }
  180 + }
  181 + );
  182 + }
  183 +
  184 + private void showTokenErrorDialog() {
  185 + if (tokenErrorDialog != null)
  186 + tokenErrorDialog.dismiss();
  187 + tokenErrorDialog = TokenErrorDialog.showTokenErrorDialog(this);
  188 + }
  189 +}
... ...
cloud/user/src/main/java/com/cnlive/strike/user/ui/activity/UpdateContentActivity.java 0 → 100644
  1 +package com.cnlive.strike.user.ui.activity;
  2 +
  3 +import android.app.Activity;
  4 +import android.app.Dialog;
  5 +import android.content.Context;
  6 +import android.content.Intent;
  7 +import android.content.SharedPreferences;
  8 +import android.text.Editable;
  9 +import android.text.InputFilter;
  10 +import android.text.TextUtils;
  11 +import android.text.TextWatcher;
  12 +import android.util.Log;
  13 +import android.view.View;
  14 +import android.view.inputmethod.InputMethodManager;
  15 +import android.widget.Button;
  16 +
  17 +import com.cnlive.core.libs.base.frame.activity.BaseActivity;
  18 +import com.cnlive.core.libs.base.util.AlertUtil;
  19 +import com.cnlive.core.libs.base.util.QMUITipDialogUtil;
  20 +import com.cnlive.core.libs.base.util.SharedPreferencesHelper;
  21 +import com.cnlive.core.libs.base.util.StatusBarConfig;
  22 +import com.cnlive.core.network.HttpConn;
  23 +import com.cnlive.core.network.NetCallBack;
  24 +import com.cnlive.core.network.model.BaseResult;
  25 +import com.cnlive.strike.user.R;
  26 +import com.cnlive.strike.user.UserUtilAction;
  27 +import com.cnlive.strike.user.auth.UserService;
  28 +import com.cnlive.strike.user.databinding.ActivityUpdateContentBinding;
  29 +import com.cnlive.strike.user.ui.widget.TokenErrorDialog;
  30 +import com.cnlive.strike.user.util.UserRouterHelper;
  31 +import com.qmuiteam.qmui.widget.QMUITopBar;
  32 +
  33 +import java.util.regex.Matcher;
  34 +import java.util.regex.Pattern;
  35 +import java.util.regex.PatternSyntaxException;
  36 +
  37 +import io.reactivex.disposables.Disposable;
  38 +
  39 +/**
  40 + * 作者: 吴奎庆
  41 + * <p>
  42 + * 时间: 2018/7/20
  43 + * <p>
  44 + * 简介: 内容更新页面(名字 地区的更改)
  45 + */
  46 +
  47 +public class UpdateContentActivity extends BaseActivity implements View.OnClickListener {
  48 +
  49 + private Disposable modifyUserInfoEvent;
  50 + private ActivityUpdateContentBinding binding;
  51 + private Button right;
  52 + private String type;
  53 + private Dialog tokenErrorDialog;
  54 +
  55 + public static void startActivity(Activity activity, String type) {
  56 + Intent intent = new Intent(activity, UpdateContentActivity.class);
  57 + intent.putExtra("type", type);
  58 + activity.startActivity(intent);
  59 + }
  60 +
  61 + @Override
  62 + protected int getBindLayoutId() {
  63 + return R.layout.activity_update_content;
  64 + }
  65 +
  66 + @Override
  67 + protected void initBindingData() {
  68 + super.initBindingData();
  69 + binding = (ActivityUpdateContentBinding) getBaseBinding();
  70 + }
  71 +
  72 + @Override
  73 + protected void initParam() {
  74 + super.initParam();
  75 + type = getIntent().getStringExtra("type");
  76 + }
  77 +
  78 + @Override
  79 + protected void initView() {
  80 + super.initView();
  81 + setStatusBarTextColor(StatusBarConfig.BLACK);
  82 + setStatusBarColor(R.color.color_fff, 0);
  83 + showSoftInput(binding.edContent);
  84 + switch (type) {
  85 + case "nickName":
  86 + initNameView();
  87 + break;
  88 + case "location":
  89 + initLocationView();
  90 + break;
  91 + }
  92 + }
  93 +
  94 + @Override
  95 + protected void onPause() {
  96 + super.onPause();
  97 + if (tokenErrorDialog != null) tokenErrorDialog.dismiss();
  98 + }
  99 +
  100 + private void initLocationView() {
  101 + QMUITopBar toolbar = (QMUITopBar) binding.includeToolbar;
  102 + toolbar.setTitle("修改地区");
  103 + toolbar.setBackgroundColor(getResources().getColor(R.color.white));
  104 + right = toolbar.addRightTextButton("保存", R.id.rightBtn);
  105 + right.setTextColor(getResources().getColor(R.color.black));
  106 + right.setOnClickListener(this);
  107 + toolbar.addLeftImageButton(R.drawable.fl_fanhui, R.id.qmui_topbar_item_left_back).setOnClickListener(this);
  108 + InputFilter[] filters = {new InputFilter.LengthFilter(12)};
  109 + String location = UserService.getInstance(this).getAppAccount().getLocation();
  110 + if (TextUtils.isEmpty(location)) location = "中国";
  111 + if (location == null) location = "请输入您的地区";
  112 + binding.edContent.setFilters(filters);
  113 + binding.edContent.setHint(location);
  114 + binding.edContent.addTextChangedListener(new TextWatcher() {
  115 + @Override
  116 + public void beforeTextChanged(CharSequence s, int start, int count, int after) {
  117 + Log.e(",", "");
  118 + }
  119 +
  120 + @Override
  121 + public void onTextChanged(CharSequence s, int start, int before, int count) {
  122 + }
  123 +
  124 + @Override
  125 + public void afterTextChanged(Editable s) {
  126 + if (s != null) {
  127 + int length = s.length();
  128 + if (length == 0) {
  129 + binding.edContent.setHint("请输入您的地区");
  130 + }
  131 + binding.tvCount.setText(length + "/12");
  132 + }
  133 + }
  134 + });
  135 + binding.tvCount.setText(location.length() + "/12");
  136 + }
  137 +
  138 + private void initNameView() {
  139 + QMUITopBar toolbar = (QMUITopBar) binding.includeToolbar;
  140 + toolbar.setTitle("修改昵称");
  141 + toolbar.setBackgroundColor(getResources().getColor(R.color.white));
  142 + right = toolbar.addRightTextButton("保存", R.id.rightBtn);
  143 + right.setTextColor(getResources().getColor(R.color.black));
  144 + right.setOnClickListener(this);
  145 + toolbar.addLeftImageButton(R.drawable.fl_fanhui, R.id.qmui_topbar_item_left_back).setOnClickListener(this);
  146 + InputFilter[] filters = {new InputFilter.LengthFilter(15)};
  147 + String nickName = UserService.getInstance(this).getAppAccount().getNickName();
  148 + if (nickName == null) nickName = "请输入您的昵称";
  149 + binding.edContent.setFilters(filters);
  150 + binding.edContent.setText(nickName);
  151 + binding.tvAlert.setText(getString(R.string.user_hint_edit_nickname));
  152 + binding.tvCount.setText(nickName.length() + "/15");
  153 + binding.edContent.addTextChangedListener(new TextWatcher() {
  154 + @Override
  155 + public void beforeTextChanged(CharSequence s, int start, int count, int after) {
  156 +
  157 + }
  158 +
  159 + @Override
  160 + public void onTextChanged(CharSequence s, int start, int before, int count) {
  161 + String editable = binding.edContent.getText().toString();
  162 + String str = stringFilter(editable.toString());
  163 + if (!editable.equals(str)) {
  164 + binding.edContent.setText(str);
  165 + //设置新的光标所在位置
  166 + binding.edContent.setSelection(str.length());
  167 + }
  168 + }
  169 +
  170 + @Override
  171 + public void afterTextChanged(Editable s) {
  172 + if (s != null) {
  173 + String str = stringFilter(s.toString());
  174 + int length = str.length();
  175 + if (length == 0) {
  176 + binding.edContent.setHint("请输入您的昵称");
  177 + }
  178 +
  179 +
  180 + binding.tvCount.setText(length + "/15");
  181 + }
  182 + }
  183 + });
  184 + }
  185 +
  186 +
  187 + @Override
  188 + public void onClick(View v) {
  189 +
  190 + if (v.getId() == R.id.rightBtn) {
  191 + if (right.isClickable()) {
  192 + hideSoftInput();
  193 + if ("nickName".equals(type)) {
  194 + String nickName = UserService.getInstance(this).getAppAccount().getNickName();
  195 + String newnickname = binding.edContent.getText().toString().trim().replaceAll("[\r\n]", "");
  196 + if (nickName != null && !nickName.equals(newnickname)) {
  197 + uploadContent("nickName", binding.edContent.getText().toString().trim().replaceAll("[\r\n]", ""));
  198 + } else {
  199 + showMessage("修改成功");
  200 + finish();
  201 + }
  202 + } else if ("location".equals(type)) {
  203 + uploadContent("location", binding.edContent.getText().toString().replaceAll("[\r\n]", ""));
  204 + }
  205 + }
  206 + } else if (v.getId() == R.id.qmui_topbar_item_left_back) {
  207 + hideSoftInput();
  208 + finish();
  209 + }
  210 + }
  211 +
  212 +
  213 + /**
  214 + * 修改个人信息
  215 + *
  216 + * @param type
  217 + * @param content
  218 + */
  219 + private void uploadContent(String type, String content) {
  220 + if (modifyUserInfoEvent != null && !modifyUserInfoEvent.isDisposed()) {
  221 + modifyUserInfoEvent.dispose();
  222 + }
  223 + if (!TextUtils.isEmpty(content) && content.trim().length() > 0) {
  224 + //TODO 昵称临时增加内容限制
  225 +// if (type.equals("nickName") && !content.matches("^[a-zA-Z0-9\u2E80-\u9fa5+\\-_]{1,15}$")) {
  226 +// showMessage(getString(R.string.user_toast_edit_nickname_error));
  227 +// return;
  228 +// }
  229 + /**
  230 + * @param uid 用户ID
  231 + * @param type nickName-昵称,gender-性别,email-邮箱, location-联系方式
  232 + * @param value 对应的信息,性别,m:男、f:女、n:未知
  233 + * @param callback 回调
  234 + *
  235 + *
  236 + */
  237 +
  238 + UserService userService = UserService.getInstance(this);
  239 + String uid = userService.getUid(this);
  240 + String token = userService.getAppAccount().getToken();
  241 +
  242 + modifyUserInfoEvent = HttpConn.action(
  243 + UserUtilAction.modifyUserInfo(this, uid, type, content.trim(), token), new NetCallBack<BaseResult>() {
  244 + @Override
  245 + public void onRequestState(int state) {
  246 + if (state == HttpConn.ON_START) {
  247 + QMUITipDialogUtil.loadingDialog(me, "修改中", true);
  248 + } else if (state == HttpConn.ON_END) {
  249 + QMUITipDialogUtil.dismessDialog();
  250 + }
  251 + }
  252 +
  253 + @Override
  254 + public void onSuccess(BaseResult data) {
  255 + if (type.equals("nickName")) {
  256 + userService.setUserNickName(content.trim());
  257 + showMessage("修改成功");
  258 + SharedPreferences preferences = me.getSharedPreferences("updatenick", MODE_PRIVATE);
  259 + boolean status = preferences.getBoolean(UserService.getUid(me), false);
  260 + Boolean app_is_show_integral = SharedPreferencesHelper.getInstance(me).getBoolValue("APP_IS_SHOW_INTEGRAL");
  261 + if (!status && app_is_show_integral) {
  262 + //todo
  263 + UserRouterHelper.goToCoinRainAction(me, "update_nick", "", "updatenick", false);
  264 +// CoinRainAction.code(this, UserService.getUid(this), "update_nick", "", "updatenick", false);
  265 + }
  266 + //todo
  267 + UserRouterHelper.modifyUserName(me, content.trim());
  268 +// LoginManager.modifyUserName(UserService.getUid(this), content.trim());
  269 + finish();
  270 + } else if (type.equals("location")) {
  271 + userService.setUserLocation(content.trim());
  272 + showMessage("修改成功");
  273 + finish();
  274 + }
  275 + }
  276 +
  277 + @Override
  278 + public void onFailure(String errCode, String errMsg) {
  279 + if (UserUtilAction.TOKEN_ERROR_CODE.equals(errCode)) {
  280 + showTokenErrorDialog();
  281 + } else {
  282 + showMessage(errMsg);
  283 + }
  284 + }
  285 + }
  286 + );
  287 + } else {
  288 + showMessage("您输入的内容不能为空");
  289 + }
  290 + }
  291 +
  292 + public void showMessage(String content) {
  293 + if (TextUtils.isEmpty(content)) return;
  294 + AlertUtil.showDeftToast(this, content);
  295 + }
  296 +
  297 + /**
  298 + * 禁止EditText输入特殊字符
  299 + *
  300 + * @param str
  301 + */
  302 + public static String stringFilter(String str) throws PatternSyntaxException {
  303 + // 只允许字母、数字和汉字
  304 + String regEx = "[^a-zA-Z0-9\u4E00-\u9FA5++_―_ ̄ˉ— \\\n]";//正则表达式
  305 + Pattern p = Pattern.compile(regEx);
  306 + Matcher m = p.matcher(str);
  307 + return m.replaceAll("").trim();
  308 + }
  309 +
  310 + private void showTokenErrorDialog() {
  311 + if (tokenErrorDialog != null)
  312 + tokenErrorDialog.dismiss();
  313 + tokenErrorDialog = TokenErrorDialog.showTokenErrorDialog(this);
  314 + }
  315 +}
... ...
cloud/user/src/main/java/com/cnlive/strike/user/util/UserRouterHelper.java
... ... @@ -53,16 +53,6 @@ public class UserRouterHelper {
53 53 if (null == context) {
54 54 return;
55 55 }
56   -// try {
57   -// Class clz = Class.forName(activityClassName);
58   -// Intent intent = new Intent(context, clz);
59   -// intent.putExtra("eventType", MODIFY_USER_IMAGE);
60   -// context.startActivity(intent);
61   -// } catch (ClassNotFoundException e) {
62   -// e.printStackTrace();
63   -// Log.d("error", e.toString());
64   -// }
65   -
66 56 ARouter.getInstance().build(LoginActivity.LOGIN_SUCCESS_PATH)
67 57 .withInt("eventType", MODIFY_USER_IMAGE)
68 58 .withString("faceUrl", faceUrl)
... ... @@ -78,15 +68,6 @@ public class UserRouterHelper {
78 68 if (null == context) {
79 69 return;
80 70 }
81   -// try {
82   -// Class clz = Class.forName(activityClassName);
83   -// Intent intent = new Intent(context, clz);
84   -// intent.putExtra("eventType", USER_INVALID);
85   -// context.startActivity(intent);
86   -// } catch (ClassNotFoundException e) {
87   -// e.printStackTrace();
88   -// Log.d("error", e.toString());
89   -// }
90 71 ARouter.getInstance().build(LoginActivity.LOGIN_SUCCESS_PATH)
91 72 .withInt("eventType", USER_INVALID)
92 73 .navigation(context);
... ... @@ -101,18 +82,6 @@ public class UserRouterHelper {
101 82 if (null == context) {
102 83 return;
103 84 }
104   -// try {
105   -// Class clz = Class.forName(activityClassName);
106   -// Intent intent = new Intent(context, clz);
107   -// intent.putExtra("eventType", MODIFY_USER_NAME);
108   -// intent.putExtra("nickName", nickName);
109   -//
110   -// context.startActivity(intent);
111   -// } catch (ClassNotFoundException e) {
112   -// e.printStackTrace();
113   -// Log.d("error", e.toString());
114   -// }
115   -
116 85 ARouter.getInstance().build(LoginActivity.LOGIN_SUCCESS_PATH)
117 86 .withInt("eventType", MODIFY_USER_NAME)
118 87 .withString("nickName", nickName)
... ...
cloud/user/src/main/res/layout/activity_signature.xml
... ... @@ -25,7 +25,7 @@
25 25 <com.cnlive.libs.emoj.widget.SimpleEditText
26 26 android:id="@+id/ed_content"
27 27 android:layout_width="match_parent"
28   - android:layout_height="wrap_content"
  28 + android:layout_height="match_parent"
29 29 android:background="@null"
30 30 android:gravity="start"
31 31 android:hint="请输入您的签名"
... ...
cloud/user/src/main/res/layout/activity_update_content.xml
... ... @@ -25,16 +25,17 @@
25 25 <com.cnlive.libs.emoj.widget.ExpressionEditText
26 26 android:id="@+id/ed_content"
27 27 android:layout_width="match_parent"
28   - android:layout_height="wrap_content"
  28 + android:layout_height="match_parent"
29 29 android:background="@null"
  30 + android:focusable="true"
30 31 android:focusableInTouchMode="true"
31 32 android:gravity="start"
32 33 android:imeOptions="actionDone|flagNoFullscreen|flagNoExtractUi"
33 34 android:maxLength="10"
34   - android:paddingBottom="@dimen/dp_10"
35 35 android:paddingLeft="@dimen/dp_10"
36   - android:paddingRight="@dimen/dp_10"
37 36 android:paddingTop="@dimen/dp_10"
  37 + android:paddingRight="@dimen/dp_10"
  38 + android:paddingBottom="@dimen/dp_10"
38 39 android:textColor="@color/text_input_color"
39 40 android:textCursorDrawable="@drawable/edit_cursor" />
40 41  
... ... @@ -42,8 +43,8 @@
42 43 android:id="@+id/tv_count"
43 44 android:layout_width="wrap_content"
44 45 android:layout_height="wrap_content"
45   - android:layout_alignParentBottom="true"
46 46 android:layout_alignParentRight="true"
  47 + android:layout_alignParentBottom="true"
47 48 android:padding="@dimen/dp_10"
48 49 android:textColor="@color/black" />
49 50  
... ...
core/app_qr/src/main/java/com/cnlive/strike/moudle/qr/ui/activity/GenerateQRActivity.java
... ... @@ -142,7 +142,6 @@ public class GenerateQRActivity extends BaseActivity&lt;GenerateQRView, GenerateQRP
142 142 userName = getIntent().getStringExtra("userName");
143 143 address = getIntent().getStringExtra("address");
144 144 bomHint = getIntent().getStringExtra("bomHint");
145   - qrType = getIntent().getStringExtra("qrType");
146 145 content = getIntent().getStringExtra("content");
147 146  
148 147 if (qrType != null && qrType.equals("user")) {
... ...
core/base/src/main/java/com/cnlive/core/libs/base/frame/activity/BaseActivity.java
... ... @@ -673,6 +673,7 @@ public abstract class BaseActivity&lt;V extends BaseView, P extends BasePresenter&lt;V
673 673 public void requestPermission(String[] permissions, OnPermissionResponseListener
674 674 onPermissionResponseListener) {
675 675 this.onPermissionResponseListener = onPermissionResponseListener;
  676 + this.userSetPermission=permissions;
676 677 if (checkPermissions(permissions)) {
677 678 if (onPermissionResponseListener != null) {
678 679 onPermissionResponseListener.onSuccess(permissions);
... ... @@ -687,6 +688,7 @@ public abstract class BaseActivity&lt;V extends BaseView, P extends BasePresenter&lt;V
687 688 onPermissionResponseListener) {
688 689 this.onPermissionResponseListener = onPermissionResponseListener;
689 690 this.isShowRefuseDialog = isShowRefuseDialog;
  691 + this.userSetPermission=permissions;
690 692 if (checkPermissions(permissions)) {
691 693 if (onPermissionResponseListener != null) {
692 694 onPermissionResponseListener.onSuccess(permissions);
... ... @@ -710,7 +712,8 @@ public abstract class BaseActivity&lt;V extends BaseView, P extends BasePresenter&lt;V
710 712 public void requestPermission(boolean isDefineActivity, String[] permissions, OnPermissionResponseListener
711 713 onPermissionResponseListener) {
712 714 this.onPermissionResponseListener = onPermissionResponseListener;
713   - isDefinePermissionCloseActivity = isDefineActivity;
  715 + this.isDefinePermissionCloseActivity = isDefineActivity;
  716 + this.userSetPermission=permissions;
714 717 if (checkPermissions(permissions)) {
715 718 if (onPermissionResponseListener != null) {
716 719 onPermissionResponseListener.onSuccess(permissions);
... ... @@ -726,6 +729,7 @@ public abstract class BaseActivity&lt;V extends BaseView, P extends BasePresenter&lt;V
726 729 this.onPermissionResponseListener = onPermissionResponseListener;
727 730 this.isDefinePermissionCloseActivity = isDefineActivity;
728 731 this.isShowRefuseDialog = isShowRefuseDialog;
  732 + this.userSetPermission=permissions;
729 733 if (checkPermissions(permissions)) {
730 734 if (onPermissionResponseListener != null) {
731 735 onPermissionResponseListener.onSuccess(permissions);
... ... @@ -792,6 +796,7 @@ public abstract class BaseActivity&lt;V extends BaseView, P extends BasePresenter&lt;V
792 796 onPermissionResponseListener) {
793 797 this.userSetDefinePermissionTip = defineTip;
794 798 this.onPermissionResponseListener = onPermissionResponseListener;
  799 + this.userSetPermission=permissions;
795 800 if (checkPermissions(permissions)) {
796 801 if (onPermissionResponseListener != null) {
797 802 onPermissionResponseListener.onSuccess(permissions);
... ... @@ -807,6 +812,7 @@ public abstract class BaseActivity&lt;V extends BaseView, P extends BasePresenter&lt;V
807 812 this.userSetDefinePermissionTip = defineTip;
808 813 this.onPermissionResponseListener = onPermissionResponseListener;
809 814 this.isShowRefuseDialog = isShowRefuseDialog;
  815 + this.userSetPermission=permissions;
810 816 if (checkPermissions(permissions)) {
811 817 if (onPermissionResponseListener != null) {
812 818 onPermissionResponseListener.onSuccess(permissions);
... ... @@ -829,6 +835,7 @@ public abstract class BaseActivity&lt;V extends BaseView, P extends BasePresenter&lt;V
829 835 this.onPermissionResponseListener = onPermissionResponseListener;
830 836 this.USER_SET_REQUEST_CODE_PERMISSION = requestCode;
831 837 this.isDefinePermissionCloseActivity = isDefineActivity;
  838 + this.userSetPermission=permissions;
832 839 if (checkPermissions(permissions)) {
833 840 if (onPermissionResponseListener != null) {
834 841 onPermissionResponseListener.onSuccess(permissions);
... ... @@ -845,6 +852,7 @@ public abstract class BaseActivity&lt;V extends BaseView, P extends BasePresenter&lt;V
845 852 this.USER_SET_REQUEST_CODE_PERMISSION = requestCode;
846 853 this.isDefinePermissionCloseActivity = isDefineActivity;
847 854 this.isShowRefuseDialog = isShowRefuseDialog;
  855 + this.userSetPermission=permissions;
848 856 if (checkPermissions(permissions)) {
849 857 if (onPermissionResponseListener != null) {
850 858 onPermissionResponseListener.onSuccess(permissions);
... ... @@ -866,6 +874,7 @@ public abstract class BaseActivity&lt;V extends BaseView, P extends BasePresenter&lt;V
866 874 permissions, OnPermissionResponseListener onPermissionResponseListener) {
867 875 this.onPermissionResponseListener = onPermissionResponseListener;
868 876 this.USER_SET_REQUEST_CODE_PERMISSION = requestCode;
  877 + this.userSetPermission=permissions;
869 878 if (checkPermissions(permissions)) {
870 879 if (onPermissionResponseListener != null) {
871 880 onPermissionResponseListener.onSuccess(permissions);
... ... @@ -881,6 +890,7 @@ public abstract class BaseActivity&lt;V extends BaseView, P extends BasePresenter&lt;V
881 890 this.onPermissionResponseListener = onPermissionResponseListener;
882 891 this.USER_SET_REQUEST_CODE_PERMISSION = requestCode;
883 892 this.isShowRefuseDialog = isShowRefuseDialog;
  893 + this.userSetPermission=permissions;
884 894 if (checkPermissions(permissions)) {
885 895 if (onPermissionResponseListener != null) {
886 896 onPermissionResponseListener.onSuccess(permissions);
... ... @@ -904,6 +914,7 @@ public abstract class BaseActivity&lt;V extends BaseView, P extends BasePresenter&lt;V
904 914 this.USER_SET_REQUEST_CODE_PERMISSION = requestCode;
905 915 this.isDefinePermissionCloseActivity = isDefineActivity;
906 916 this.userSetDefinePermissionTip = defineTip;
  917 + this.userSetPermission=permissions;
907 918 if (checkPermissions(permissions)) {
908 919 if (onPermissionResponseListener != null) {
909 920 onPermissionResponseListener.onSuccess(permissions);
... ... @@ -921,6 +932,7 @@ public abstract class BaseActivity&lt;V extends BaseView, P extends BasePresenter&lt;V
921 932 this.isDefinePermissionCloseActivity = isDefineActivity;
922 933 this.userSetDefinePermissionTip = defineTip;
923 934 this.isShowRefuseDialog = isShowRefuseDialog;
  935 + this.userSetPermission=permissions;
924 936 if (checkPermissions(permissions)) {
925 937 if (onPermissionResponseListener != null) {
926 938 onPermissionResponseListener.onSuccess(permissions);
... ... @@ -943,6 +955,7 @@ public abstract class BaseActivity&lt;V extends BaseView, P extends BasePresenter&lt;V
943 955 this.onPermissionResponseListener = onPermissionResponseListener;
944 956 this.USER_SET_REQUEST_CODE_PERMISSION = requestCode;
945 957 this.userSetDefinePermissionTip = defineTip;
  958 + this.userSetPermission=permissions;
946 959 if (checkPermissions(permissions)) {
947 960 if (onPermissionResponseListener != null) {
948 961 onPermissionResponseListener.onSuccess(permissions);
... ... @@ -959,6 +972,7 @@ public abstract class BaseActivity&lt;V extends BaseView, P extends BasePresenter&lt;V
959 972 this.USER_SET_REQUEST_CODE_PERMISSION = requestCode;
960 973 this.userSetDefinePermissionTip = defineTip;
961 974 this.isShowRefuseDialog = isShowRefuseDialog;
  975 + this.userSetPermission=permissions;
962 976 if (checkPermissions(permissions)) {
963 977 if (onPermissionResponseListener != null) {
964 978 onPermissionResponseListener.onSuccess(permissions);
... ... @@ -983,6 +997,7 @@ public abstract class BaseActivity&lt;V extends BaseView, P extends BasePresenter&lt;V
983 997 this.USER_SET_REQUEST_CODE_PERMISSION = requestCode;
984 998 this.userSetDefinePermissionTip = getResources().getString(defineTip);
985 999 this.isDefinePermissionCloseActivity = isDefineActivity;
  1000 + this.userSetPermission=permissions;
986 1001 if (checkPermissions(permissions)) {
987 1002 if (onPermissionResponseListener != null) {
988 1003 onPermissionResponseListener.onSuccess(permissions);
... ... @@ -1000,6 +1015,7 @@ public abstract class BaseActivity&lt;V extends BaseView, P extends BasePresenter&lt;V
1000 1015 this.userSetDefinePermissionTip = getResources().getString(defineTip);
1001 1016 this.isDefinePermissionCloseActivity = isDefineActivity;
1002 1017 this.isShowRefuseDialog = isShowRefuseDialog;
  1018 + this.userSetPermission=permissions;
1003 1019 if (checkPermissions(permissions)) {
1004 1020 if (onPermissionResponseListener != null) {
1005 1021 onPermissionResponseListener.onSuccess(permissions);
... ... @@ -1023,6 +1039,7 @@ public abstract class BaseActivity&lt;V extends BaseView, P extends BasePresenter&lt;V
1023 1039 this.onPermissionResponseListener = onPermissionResponseListener;
1024 1040 this.USER_SET_REQUEST_CODE_PERMISSION = requestCode;
1025 1041 this.userSetDefinePermissionTip = getResources().getString(defineTip);
  1042 + this.userSetPermission=permissions;
1026 1043 if (checkPermissions(permissions)) {
1027 1044 if (onPermissionResponseListener != null) {
1028 1045 onPermissionResponseListener.onSuccess(permissions);
... ... @@ -1039,6 +1056,7 @@ public abstract class BaseActivity&lt;V extends BaseView, P extends BasePresenter&lt;V
1039 1056 this.USER_SET_REQUEST_CODE_PERMISSION = requestCode;
1040 1057 this.userSetDefinePermissionTip = getResources().getString(defineTip);
1041 1058 this.isShowRefuseDialog = isShowRefuseDialog;
  1059 + this.userSetPermission=permissions;
1042 1060 if (checkPermissions(permissions)) {
1043 1061 if (onPermissionResponseListener != null) {
1044 1062 onPermissionResponseListener.onSuccess(permissions);
... ...