diff --git a/model_zoo/official/lite/MindSpore_inhand/app/src/main/java/com/mindspore/himindspore/ui/me/AccountInfoActivity.java b/model_zoo/official/lite/MindSpore_inhand/app/src/main/java/com/mindspore/himindspore/ui/me/AccountInfoActivity.java index c6f7d70885e519f579d0f7514061b948bd6ae6ee..c28e738ae5c08dff58a16e7bc6b72b6b551f3682 100644 --- a/model_zoo/official/lite/MindSpore_inhand/app/src/main/java/com/mindspore/himindspore/ui/me/AccountInfoActivity.java +++ b/model_zoo/official/lite/MindSpore_inhand/app/src/main/java/com/mindspore/himindspore/ui/me/AccountInfoActivity.java @@ -17,6 +17,7 @@ package com.mindspore.himindspore.ui.me; import android.app.DatePickerDialog; import android.content.Intent; +import android.text.TextUtils; import android.util.Log; import android.widget.ImageView; @@ -31,6 +32,7 @@ import com.bumptech.glide.request.RequestOptions; import com.mindspore.common.base.mvp.BaseActivity; import com.mindspore.common.netbean.response.AccountBean; import com.mindspore.customview.ui.AccountViewBean; +import com.mindspore.customview.ui.MyToast; import com.mindspore.himindspore.R; import com.mindspore.himindspore.ui.me.adapter.UserInfoAdapter; import com.mindspore.himindspore.ui.me.event.AccountChangedEvent; @@ -42,6 +44,7 @@ import org.greenrobot.eventbus.Subscribe; import org.greenrobot.eventbus.ThreadMode; import java.util.ArrayList; +import java.util.Calendar; import io.reactivex.annotations.NonNull; @@ -70,9 +73,6 @@ public class AccountInfoActivity extends BaseActivity @Subscribe(threadMode = ThreadMode.MAIN) public void onEventMainThread(AccountChangedEvent event) { - if (presenter == null) { - presenter = AccountInfoPresenter.getInstance(this); - } presenter.getAccount(); } @@ -102,7 +102,7 @@ public class AccountInfoActivity extends BaseActivity @Override public void init() { EventBus.getDefault().register(this); - presenter = AccountInfoPresenter.getInstance(this); + presenter = new AccountInfoPresenter(this); presenter.getAccount(); nicknameViewBean = new AccountViewBean(getResources().getString(R.string.user_nick_name), ""); sexViewBean = new AccountViewBean(getResources().getString(R.string.user_sexes), ""); @@ -121,16 +121,7 @@ public class AccountInfoActivity extends BaseActivity sexViewBean.setOnClickListener(v -> { if (accountBean != null) { - AlertDialog ad = new AlertDialog.Builder(this, R.style.RadioDialogTheme) - .setTitle(getString(R.string.update_sexes)) - .setSingleChoiceItems(sexOption, accountBean.getGender() - 1, - (dialog, which) -> { - accountBean.setGender(which + 1); - presenter.updateAccount(accountBean); - dialog.dismiss(); - }) - .create(); - ad.show(); + setSexDialog(); } else { Log.e(TAG, "accountBean is null. can`t modify account."); } @@ -138,21 +129,7 @@ public class AccountInfoActivity extends BaseActivity birthdayViewBean.setOnClickListener(v -> { if (accountBean != null) { - String oldBirth = accountBean.getDateBirth(); - String[] oldBirthNum = oldBirth.split("-"); - int year = Integer.parseInt(oldBirthNum[0]); - int month = Integer.parseInt(oldBirthNum[1]) - 1; - int day = Integer.parseInt(oldBirthNum[2]); - DatePickerDialog datePickerDialog = new DatePickerDialog(this, - DatePickerDialog.THEME_DEVICE_DEFAULT_LIGHT, - (view, year1, month1, dayOfMonth) -> { - String dateStr = year1 + "-" + (month1 + 1) + "-" + dayOfMonth; - Log.d(TAG, "onDateSet:" + dateStr); - accountBean.setDateBirth(dateStr); - presenter.updateAccount(accountBean); - }, year, month, day); - datePickerDialog.setTitle(getString(R.string.update_birthday)); - datePickerDialog.show(); + setBirthdayPicker(); } else { Log.e(TAG, "accountBean is null. can`t modify account."); } @@ -175,6 +152,60 @@ public class AccountInfoActivity extends BaseActivity mRecyclerView.setAdapter(infoAdapter); } + private void setSexDialog() { + AlertDialog ad = new AlertDialog.Builder(this, R.style.RadioDialogTheme) + .setTitle(getString(R.string.update_sexes)) + .setSingleChoiceItems(sexOption, accountBean.getGender() - 1, + (dialog, which) -> { + accountBean.setGender(which + 1); + presenter.updateAccount(accountBean); + dialog.dismiss(); + }) + .create(); + ad.show(); + } + + private void setBirthdayPicker() { + int year = 0; + int month = 0; + int day = 0; + int todayYear = Calendar.getInstance().get(Calendar.YEAR); + int todayMonth = Calendar.getInstance().get(Calendar.MONTH); + int todayDay = Calendar.getInstance().get(Calendar.DAY_OF_MONTH); + + String oldBirth = accountBean.getDateBirth(); + if (!TextUtils.isEmpty(oldBirth)) { + String[] oldBirthNum = oldBirth.split("-"); + if (oldBirthNum.length >= 3) { + year = Integer.parseInt(oldBirthNum[0]); + month = Integer.parseInt(oldBirthNum[1]) - 1; + day = Integer.parseInt(oldBirthNum[2]); + } + } + if (year <= 0 || month < 0 || day <= 0) { // 之前的生日格式不合法,日历指向今天 + year = todayYear; + month = todayMonth; + day = todayDay; + } + + DatePickerDialog datePickerDialog = new DatePickerDialog(this, + DatePickerDialog.THEME_DEVICE_DEFAULT_LIGHT, + (view, year1, month1, dayOfMonth) -> { + String dateStr = year1 + "-" + (month1 + 1) + "-" + dayOfMonth; + Log.d(TAG, "onDateSet:" + dateStr); + if (year1 > todayYear + || (year1 == todayYear && month1 > todayMonth) + || (year1 == todayYear && month1 == todayMonth && dayOfMonth > todayDay)) { + MyToast.MakeText(getString(R.string.birthday_more_than_today), 1000); + return; + } + accountBean.setDateBirth(dateStr); + presenter.updateAccount(accountBean); + }, year, month, day); + datePickerDialog.setTitle(getString(R.string.update_birthday)); + datePickerDialog.show(); + } + @Override public int getLayout() { return R.layout.activity_account; @@ -222,4 +253,10 @@ public class AccountInfoActivity extends BaseActivity public void showError(String msg, int errorCode) { } + + @Override + public void onDestroy() { + super.onDestroy(); + EventBus.getDefault().unregister(this); + } } \ No newline at end of file diff --git a/model_zoo/official/lite/MindSpore_inhand/app/src/main/java/com/mindspore/himindspore/ui/me/LoginActivity.java b/model_zoo/official/lite/MindSpore_inhand/app/src/main/java/com/mindspore/himindspore/ui/me/LoginActivity.java index 1631aa29d08923096abdf8dbf9314fde39d656a0..c2cb099683e7743ec82d805f364e682f0c8902c6 100644 --- a/model_zoo/official/lite/MindSpore_inhand/app/src/main/java/com/mindspore/himindspore/ui/me/LoginActivity.java +++ b/model_zoo/official/lite/MindSpore_inhand/app/src/main/java/com/mindspore/himindspore/ui/me/LoginActivity.java @@ -9,6 +9,7 @@ import com.google.android.exoplayer2.util.Log; import com.mindspore.common.base.mvp.BaseActivity; import com.mindspore.common.netbean.request.RequestLoginBean; import com.mindspore.common.netbean.response.LoginResBean; +import com.mindspore.common.utils.EncryptedUtils; import com.mindspore.common.utils.PhoneFormatCheckUtils; import com.mindspore.common.utils.UserUtils; import com.mindspore.customview.ui.MyToast; @@ -19,6 +20,8 @@ import com.mindspore.himindspore.ui.me.mvp.LoginPresenter; import org.greenrobot.eventbus.EventBus; +import okhttp3.ResponseBody; + public class LoginActivity extends BaseActivity implements View.OnClickListener, LoginContract.LoginView { private static final String TAG = LoginActivity.class.getSimpleName(); @@ -42,7 +45,7 @@ public class LoginActivity extends BaseActivity implements View.OnClickListener, postBtn.setOnClickListener(this); changeStateTv = findViewById(R.id.change_state); changeStateTv.setOnClickListener(this); - presenter = LoginPresenter.getInstance(this); + presenter = new LoginPresenter(this); } @Override @@ -84,12 +87,12 @@ public class LoginActivity extends BaseActivity implements View.OnClickListener, private void postRequest() { String nickname = userNameEt.getText().toString(); String mobile = userPhoneEt.getText().toString(); - String passWd = userPasswdEt.getText().toString(); + String password = userPasswdEt.getText().toString(); if (TextUtils.isEmpty(mobile)) { MyToast.MakeText(getString(R.string.login_phone_null), 1000); return; } - if (TextUtils.isEmpty(passWd)) { + if (TextUtils.isEmpty(password)) { MyToast.MakeText(getString(R.string.login_pwd_null), 1000); return; } @@ -97,15 +100,16 @@ public class LoginActivity extends BaseActivity implements View.OnClickListener, MyToast.MakeText(getString(R.string.login_phone_illegal), 1000); return; } - if (passWd.length() < 6) { + if (password.length() < 6) { MyToast.MakeText(getString(R.string.login_pwd_illegal), 1000); return; } + String md5Password = EncryptedUtils.stringToMD5(password); if (state == LOGIN_STATE) { - presenter.login(new RequestLoginBean(mobile, passWd)); + presenter.login(new RequestLoginBean(mobile, md5Password)); } else if (state == REGISTER_STATE) { - RequestLoginBean loginBean = new RequestLoginBean(mobile, passWd); + RequestLoginBean loginBean = new RequestLoginBean(mobile, md5Password); loginBean.setNickname(nickname); presenter.register(loginBean); } else { @@ -123,26 +127,33 @@ public class LoginActivity extends BaseActivity implements View.OnClickListener, } + /** + * login 的成功回调 + */ @Override public void getResponseData(LoginResBean responseBean) { - if (responseBean.getState() == LOGIN_STATE) { - String token = responseBean.getToken(); - if (!TextUtils.isEmpty(token)) { - UserUtils.saveUserInfo(token); - EventBus.getDefault().post(new LoginStateChangedEvent()); - finish(); - } else { - MyToast.MakeText(getResources().getString(R.string.login_fail), 1000); - } - } else if (responseBean.getState() == REGISTER_STATE) { - MyToast.MakeText(getResources().getString(R.string.register_success), 1000); - changedState(); + String token = responseBean.getToken(); + if (!TextUtils.isEmpty(token)) { + UserUtils.saveUserInfo(token); + EventBus.getDefault().post(new LoginStateChangedEvent()); + MyToast.MakeText(getResources().getString(R.string.login_success), 1000); + LoginActivity.this.finish(); } else { - Log.d(TAG, "state is error:"+ responseBean.getState()); + MyToast.MakeText(getResources().getString(R.string.login_fail), 1000); } + } @Override public void showError(String msg, int errorCode) { } + + /** + * Register 的成功回调 + */ + @Override + public void getResponseRegisterData(ResponseBody responseBean) { + MyToast.MakeText(getResources().getString(R.string.register_success), 1000); + changedState(); + } } \ No newline at end of file diff --git a/model_zoo/official/lite/MindSpore_inhand/app/src/main/java/com/mindspore/himindspore/ui/me/PersonalFragment.java b/model_zoo/official/lite/MindSpore_inhand/app/src/main/java/com/mindspore/himindspore/ui/me/PersonalFragment.java index b1287f48e8093bbf0ef85ce603b20bf2cdbe7009..445034eb0415f5d0b0e3de39fcc48cfad872a4c2 100644 --- a/model_zoo/official/lite/MindSpore_inhand/app/src/main/java/com/mindspore/himindspore/ui/me/PersonalFragment.java +++ b/model_zoo/official/lite/MindSpore_inhand/app/src/main/java/com/mindspore/himindspore/ui/me/PersonalFragment.java @@ -448,4 +448,10 @@ public class PersonalFragment extends BaseFragment implements public void showError(String msg, int errorCode) { } + + @Override + public void onDestroy() { + super.onDestroy(); + EventBus.getDefault().unregister(this); + } } diff --git a/model_zoo/official/lite/MindSpore_inhand/app/src/main/java/com/mindspore/himindspore/ui/me/SetActivity.java b/model_zoo/official/lite/MindSpore_inhand/app/src/main/java/com/mindspore/himindspore/ui/me/SetActivity.java index ce60b99be72d43795514ff58e09d56574c0987f8..9140596019bfdccb34a853f4a5f0287d17652661 100644 --- a/model_zoo/official/lite/MindSpore_inhand/app/src/main/java/com/mindspore/himindspore/ui/me/SetActivity.java +++ b/model_zoo/official/lite/MindSpore_inhand/app/src/main/java/com/mindspore/himindspore/ui/me/SetActivity.java @@ -56,7 +56,7 @@ public class SetActivity extends BaseActivity implements View.OnClickListener, findViewById(R.id.privacy_view).setOnClickListener(this); findViewById(R.id.safety_view).setOnClickListener(this); - presenter = LogoutPresenter.getInstance(this); + presenter = new LogoutPresenter(this); } @Override @@ -99,7 +99,7 @@ public class SetActivity extends BaseActivity implements View.OnClickListener, dialog.dismiss(); break; case id.account_info: - if (true) { + if (UserUtils.isHasLogin()) { startActivity(new Intent(SetActivity.this, AccountInfoActivity.class)); } else { startActivity(new Intent(SetActivity.this, LoginActivity.class)); diff --git a/model_zoo/official/lite/MindSpore_inhand/app/src/main/java/com/mindspore/himindspore/ui/me/mvp/AccountInfoPresenter.java b/model_zoo/official/lite/MindSpore_inhand/app/src/main/java/com/mindspore/himindspore/ui/me/mvp/AccountInfoPresenter.java index 0bbbd759314e8aeb81932b7a425b3b70eea204ce..67ef64190c37085f8001cad8634052ef9c4327e7 100644 --- a/model_zoo/official/lite/MindSpore_inhand/app/src/main/java/com/mindspore/himindspore/ui/me/mvp/AccountInfoPresenter.java +++ b/model_zoo/official/lite/MindSpore_inhand/app/src/main/java/com/mindspore/himindspore/ui/me/mvp/AccountInfoPresenter.java @@ -23,19 +23,11 @@ public class AccountInfoPresenter extends BaseActivityPresenter implements AccountContract.AccountViewPresenter { - private static final String TAG = AccountPresenter.class.getSimpleName(); - private static AccountPresenter instance; - - private AccountPresenter(PersonalFragment fragment) { - this.view = fragment; - } - - public static synchronized AccountPresenter getInstance(PersonalFragment personalFragment) { - if (instance == null) { - instance = new AccountPresenter(personalFragment); - } - return instance; - } - - @Override - public void getAccount() { - HttpClient.Builder.getDataServer().getAccount().subscribeOn(Schedulers.io()) - .observeOn(AndroidSchedulers.mainThread()) - .subscribe(new BaseObserver() { - - @Override - protected void onStart() { - super.onStart(); - } - - @Override - public void onFailed(String msg, int errorCode) { - super.onFailed(msg, errorCode); - Log.e(TAG, "AccountPresenter.getAccount.onFailed, Throwable:" + msg + "errorCode>>" + errorCode); - MyToast.MakeText(msg, 1000); - } - - @Override - public void onNext(@NonNull AccountBean responseBean) { - Log.d(TAG, "AccountPresenter.getAccount.onNext."); - if (view != null) { - view.getResponseData(responseBean); - } - } - - @Override - public void onError(@NonNull Throwable e) { - super.onError(e); - String message = e.getMessage(); - Log.e(TAG, "AccountPresenter.getAccount.onError, Throwable:" + message); - } - - @Override - public void onComplete() { - Log.d(TAG, "LoginPresenter.login.onComplete."); - } - }); - } - - @Override - public void updateAccount(AccountBean accountBean) { - // 该页面没有更新用户信息的功能,所以此方法不做任何事情 - // do nothing. - } - - @Override - public void clear() { - super.clear(); - instance = null; - } -} diff --git a/model_zoo/official/lite/MindSpore_inhand/app/src/main/java/com/mindspore/himindspore/ui/me/mvp/LoginContract.java b/model_zoo/official/lite/MindSpore_inhand/app/src/main/java/com/mindspore/himindspore/ui/me/mvp/LoginContract.java index f042da94c5ee00bde3d92ab8d6e4b59823c4be38..38b9d4114ee0fe2c3dc14c58e176f1e190af8ee5 100644 --- a/model_zoo/official/lite/MindSpore_inhand/app/src/main/java/com/mindspore/himindspore/ui/me/mvp/LoginContract.java +++ b/model_zoo/official/lite/MindSpore_inhand/app/src/main/java/com/mindspore/himindspore/ui/me/mvp/LoginContract.java @@ -5,9 +5,13 @@ import com.mindspore.common.netbean.request.RequestLoginBean; import com.mindspore.common.netbean.response.LoginResBean; import com.mindspore.himindspore.ui.view.BaseContractView; +import okhttp3.ResponseBody; + public interface LoginContract { - interface LoginView extends BaseContractView {} + interface LoginView extends BaseContractView { + void getResponseRegisterData(ResponseBody responseBean); + } interface LoginViewPresenter { void login(RequestLoginBean loginBean); diff --git a/model_zoo/official/lite/MindSpore_inhand/app/src/main/java/com/mindspore/himindspore/ui/me/mvp/LoginPresenter.java b/model_zoo/official/lite/MindSpore_inhand/app/src/main/java/com/mindspore/himindspore/ui/me/mvp/LoginPresenter.java index 00240b8396436d1221523b2df0119b959c3ca0d7..9b67b5a77f855028ddea7817b077ed6d62d03c74 100644 --- a/model_zoo/official/lite/MindSpore_inhand/app/src/main/java/com/mindspore/himindspore/ui/me/mvp/LoginPresenter.java +++ b/model_zoo/official/lite/MindSpore_inhand/app/src/main/java/com/mindspore/himindspore/ui/me/mvp/LoginPresenter.java @@ -12,29 +12,19 @@ import com.mindspore.common.netbean.request.RequestLoginBean; import com.mindspore.common.netbean.response.LoginResBean; import com.mindspore.customview.ui.MyToast; import com.mindspore.himindspore.ui.me.LoginActivity; -import com.mindspore.himindspore.ui.me.event.LoginStateChangedEvent; - -import org.greenrobot.eventbus.EventBus; import io.reactivex.android.schedulers.AndroidSchedulers; import io.reactivex.schedulers.Schedulers; +import okhttp3.ResponseBody; public class LoginPresenter extends BaseActivityPresenter implements LoginContract.LoginViewPresenter { private final static String TAG = LoginPresenter.class.getSimpleName(); - private static LoginPresenter instance; - private LoginPresenter(LoginActivity loginActivity) { + public LoginPresenter(LoginActivity loginActivity) { this.view = loginActivity; } - public static synchronized LoginPresenter getInstance(LoginActivity loginActivity) { - if (instance == null) { - instance = new LoginPresenter(loginActivity); - } - return instance; - } - @Override public void login(RequestLoginBean loginBean) { HttpClient.Builder.getDataServer().login(loginBean).subscribeOn(Schedulers.io()) @@ -49,16 +39,14 @@ public class LoginPresenter extends BaseActivityPresenter impleme @Override public void onFailed(String msg, int errorCode) { super.onFailed(msg, errorCode); - Log.e(TAG, "LoginPresenter.login.onFailed, Throwable:" + msg + "errorCode>>" + errorCode); + Log.e(TAG, "login.onFailed, Throwable:" + msg + "errorCode>>" + errorCode); MyToast.MakeText(msg, 1000); } @Override public void onNext(@NonNull LoginResBean responseBean) { - Log.d(TAG, "LoginPresenter.login.onNext."); - EventBus.getDefault().post(new LoginStateChangedEvent()); + Log.d(TAG, "login.onNext."); if (view != null) { - responseBean.setState(LoginActivity.LOGIN_STATE); view.getResponseData(responseBean); } } @@ -70,12 +58,12 @@ public class LoginPresenter extends BaseActivityPresenter impleme if (view != null) { view.showError(message, view.LOGIN_STATE); } - Log.e(TAG, "LoginPresenter.login.onError, Throwable:" + message); + Log.e(TAG, "login.onError, Throwable:" + message); } @Override public void onComplete() { - Log.d(TAG, "LoginPresenter.login.onComplete."); + Log.d(TAG, "login.onComplete."); } }); } @@ -84,7 +72,7 @@ public class LoginPresenter extends BaseActivityPresenter impleme public void register(RequestLoginBean loginBean) { HttpClient.Builder.getDataServer().register(loginBean).subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) - .subscribe(new BaseObserver() { + .subscribe(new BaseObserver() { @Override protected void onStart() { super.onStart(); @@ -96,10 +84,9 @@ public class LoginPresenter extends BaseActivityPresenter impleme } @Override - public void onNext(@NonNull LoginResBean responseBean) { + public void onNext(@NonNull ResponseBody responseBean) { if (view != null) { - responseBean.setState(LoginActivity.REGISTER_STATE); - view.getResponseData(responseBean); + view.getResponseRegisterData(responseBean); } } @@ -107,12 +94,12 @@ public class LoginPresenter extends BaseActivityPresenter impleme public void onError(@NonNull Throwable e) { super.onError(e); String message = e.getMessage(); - Log.e(TAG, "LoginPresenter.login.onError, Throwable:" + message); + Log.e(TAG, "register.onError, Throwable:" + message); } @Override public void onComplete() { - Log.d(TAG, "LoginPresenter.register.onComplete."); + Log.d(TAG, "register.onComplete."); } }); } @@ -120,6 +107,5 @@ public class LoginPresenter extends BaseActivityPresenter impleme @Override public void clear() { super.clear(); - instance = null; } } diff --git a/model_zoo/official/lite/MindSpore_inhand/app/src/main/java/com/mindspore/himindspore/ui/me/mvp/LogoutPresenter.java b/model_zoo/official/lite/MindSpore_inhand/app/src/main/java/com/mindspore/himindspore/ui/me/mvp/LogoutPresenter.java index f5f391e3eb24224eac66a25928818801b2a3f638..bd0395bbd9d4b3c9c6646e0a31944913c15ec254 100644 --- a/model_zoo/official/lite/MindSpore_inhand/app/src/main/java/com/mindspore/himindspore/ui/me/mvp/LogoutPresenter.java +++ b/model_zoo/official/lite/MindSpore_inhand/app/src/main/java/com/mindspore/himindspore/ui/me/mvp/LogoutPresenter.java @@ -16,19 +16,11 @@ import io.reactivex.schedulers.Schedulers; public class LogoutPresenter extends BaseActivityPresenter implements LoginContract.LogoutViewPresenter { private final static String TAG = LogoutPresenter.class.getSimpleName(); - private static LogoutPresenter instance; - private LogoutPresenter(SetActivity setActivity) { + public LogoutPresenter(SetActivity setActivity) { this.view = setActivity; } - public static synchronized LogoutPresenter getInstance(SetActivity setActivity) { - if (instance == null) { - instance = new LogoutPresenter(setActivity); - } - return instance; - } - @Override public void logout() { HttpClient.Builder.getDataServer().logout().subscribeOn(Schedulers.io()) @@ -40,7 +32,7 @@ public class LogoutPresenter extends BaseActivityPresenter implemen @Override public void onNext(@NonNull LoginResBean responseBean) { - Log.d(TAG, "LoginPresenter.logout.onNext, success."); + Log.d(TAG, "logout.onNext, success."); } @Override @@ -50,12 +42,12 @@ public class LogoutPresenter extends BaseActivityPresenter implemen if (view != null) { view.showError(message, 0); } - Log.e(TAG, "LoginPresenter.login.onError, Throwable:" + message); + Log.e(TAG, "logout.onError, Throwable:" + message); } @Override public void onComplete() { - Log.d(TAG, "LoginPresenter.login.onComplete."); + Log.d(TAG, "logout.onComplete."); } }); } @@ -63,6 +55,5 @@ public class LogoutPresenter extends BaseActivityPresenter implemen @Override public void clear() { super.clear(); - instance = null; } } diff --git a/model_zoo/official/lite/MindSpore_inhand/app/src/main/java/com/mindspore/himindspore/ui/me/mvp/PersonalPresenter.java b/model_zoo/official/lite/MindSpore_inhand/app/src/main/java/com/mindspore/himindspore/ui/me/mvp/PersonalPresenter.java index dc1918b2f15dee01cdd09962c36bf4b249f709ea..b288bd3b389b2387e5cdff64d2e13ee6cd89b3f3 100644 --- a/model_zoo/official/lite/MindSpore_inhand/app/src/main/java/com/mindspore/himindspore/ui/me/mvp/PersonalPresenter.java +++ b/model_zoo/official/lite/MindSpore_inhand/app/src/main/java/com/mindspore/himindspore/ui/me/mvp/PersonalPresenter.java @@ -33,7 +33,6 @@ public class PersonalPresenter extends BaseFragmentPresenter i this.view = mView; } - @Override public void getUpdateInfo() { HttpClient.Builder.getAPPService().getUpdateInfo().subscribeOn(Schedulers.io()) @@ -86,13 +85,13 @@ public class PersonalPresenter extends BaseFragmentPresenter i @Override public void onFailed(String msg, int errorCode) { super.onFailed(msg, errorCode); - Log.e(TAG, "AccountPresenter.getAccount.onFailed, Throwable:" + msg + "errorCode>>" + errorCode); + Log.e(TAG, "getAccount.onFailed, Throwable:" + msg + "errorCode>>" + errorCode); MyToast.MakeText(msg, 1000); } @Override public void onNext(@NonNull AccountBean responseBean) { - Log.d(TAG, "AccountPresenter.getAccount.onNext."); + Log.d(TAG, "getAccount.onNext."); if (view != null) { view.getResponseData(responseBean); } @@ -102,12 +101,12 @@ public class PersonalPresenter extends BaseFragmentPresenter i public void onError(@NonNull Throwable e) { super.onError(e); String message = e.getMessage(); - Log.e(TAG, "AccountPresenter.getAccount.onError, Throwable:" + message); + Log.e(TAG, "getAccount.onError, Throwable:" + message); } @Override public void onComplete() { - Log.d(TAG, "LoginPresenter.login.onComplete."); + Log.d(TAG, "getAccount.onComplete."); } }); } diff --git a/model_zoo/official/lite/MindSpore_inhand/app/src/main/res/values/strings.xml b/model_zoo/official/lite/MindSpore_inhand/app/src/main/res/values/strings.xml index 4128cbb06801aae5a4d5091c4584c9a518a7bd19..83ff289a7a6d7c8fd3c6982b8be8a250ccf7ffaa 100644 --- a/model_zoo/official/lite/MindSpore_inhand/app/src/main/res/values/strings.xml +++ b/model_zoo/official/lite/MindSpore_inhand/app/src/main/res/values/strings.xml @@ -155,6 +155,7 @@ 注册失败 注册成功,请登录 登录失败 + 登录成功 请使用合法的中国大陆手机号码 手机号不能为空 请输入6位以上密码 @@ -222,6 +223,7 @@ 性别 选择性别 修改出生日期 + 不能超过当前日期 出生年月 个性签名 历史观看课程 diff --git a/model_zoo/official/lite/MindSpore_inhand/common/src/main/java/com/mindspore/common/base/mvp/BaseActivity.java b/model_zoo/official/lite/MindSpore_inhand/common/src/main/java/com/mindspore/common/base/mvp/BaseActivity.java index 6dd84c6ff4069cc24946ae7baf3db55acceeb98a..036d18f6572556a0194aaccca666491f40dc2299 100644 --- a/model_zoo/official/lite/MindSpore_inhand/common/src/main/java/com/mindspore/common/base/mvp/BaseActivity.java +++ b/model_zoo/official/lite/MindSpore_inhand/common/src/main/java/com/mindspore/common/base/mvp/BaseActivity.java @@ -41,9 +41,6 @@ public abstract class BaseActivity extends AppC @Override protected void onDestroy() { super.onDestroy(); - if (presenter != null) { - presenter.clear(); - } } protected abstract void init(); diff --git a/model_zoo/official/lite/MindSpore_inhand/common/src/main/java/com/mindspore/common/http/HttpClient.java b/model_zoo/official/lite/MindSpore_inhand/common/src/main/java/com/mindspore/common/http/HttpClient.java index d7832845191eba066e0c5057ec79e007334c75b9..0014f6b1ef1608240ccfda7858fe465914b5ded4 100644 --- a/model_zoo/official/lite/MindSpore_inhand/common/src/main/java/com/mindspore/common/http/HttpClient.java +++ b/model_zoo/official/lite/MindSpore_inhand/common/src/main/java/com/mindspore/common/http/HttpClient.java @@ -71,7 +71,7 @@ public interface HttpClient { @Headers("Content-Type: application/json") @POST("api/register") - Observable register(@Body RequestLoginBean loginBean); + Observable register(@Body RequestLoginBean loginBean); @Headers("Content-Type: application/json") @POST("api/logout") diff --git a/model_zoo/official/lite/MindSpore_inhand/common/src/main/java/com/mindspore/common/netbean/request/RequestLoginBean.java b/model_zoo/official/lite/MindSpore_inhand/common/src/main/java/com/mindspore/common/netbean/request/RequestLoginBean.java index 90c2b949bbd0b5f49e17962ba638209c89949bc3..37cdcad17f11b7f0a68dba1ce663ae0b0a766d69 100644 --- a/model_zoo/official/lite/MindSpore_inhand/common/src/main/java/com/mindspore/common/netbean/request/RequestLoginBean.java +++ b/model_zoo/official/lite/MindSpore_inhand/common/src/main/java/com/mindspore/common/netbean/request/RequestLoginBean.java @@ -2,12 +2,12 @@ package com.mindspore.common.netbean.request; public class RequestLoginBean { private String mobile; - private String passWd; + private String passwd; private String nickname; public RequestLoginBean(String mobile, String passwd) { this.mobile = mobile; - this.passWd = passwd; + this.passwd = passwd; } public String getMobile() { @@ -18,12 +18,12 @@ public class RequestLoginBean { this.mobile = mobile; } - public String getPassWd() { - return passWd; + public String getPasswd() { + return passwd; } - public void setPassWd(String passWd) { - this.passWd = passWd; + public void setPasswd(String passwd) { + this.passwd = passwd; } public String getNickname() { @@ -38,7 +38,7 @@ public class RequestLoginBean { public String toString() { return "RequestLoginBean{" + "mobile='" + mobile + '\'' + - ", passwd='" + passWd + '\'' + + ", passwd='" + passwd + '\'' + ", nickname='" + nickname + '\'' + '}'; } diff --git a/model_zoo/official/lite/MindSpore_inhand/common/src/main/java/com/mindspore/common/netbean/response/LoginResBean.java b/model_zoo/official/lite/MindSpore_inhand/common/src/main/java/com/mindspore/common/netbean/response/LoginResBean.java index 9a171d30375362d995cba6b8b29a0fd7d739fd23..aa4c38f203332355357f85daf907600c5b5f0abe 100644 --- a/model_zoo/official/lite/MindSpore_inhand/common/src/main/java/com/mindspore/common/netbean/response/LoginResBean.java +++ b/model_zoo/official/lite/MindSpore_inhand/common/src/main/java/com/mindspore/common/netbean/response/LoginResBean.java @@ -2,15 +2,6 @@ package com.mindspore.common.netbean.response; public class LoginResBean { private String Token; - private int state = -1; - - public int getState() { - return state; - } - - public void setState(int state) { - this.state = state; - } public String getToken() { return Token; diff --git a/model_zoo/official/lite/MindSpore_inhand/common/src/main/java/com/mindspore/common/utils/EncryptedUtils.java b/model_zoo/official/lite/MindSpore_inhand/common/src/main/java/com/mindspore/common/utils/EncryptedUtils.java new file mode 100644 index 0000000000000000000000000000000000000000..8637af114c555cb2a931e18228dbd1d2b5e1f362 --- /dev/null +++ b/model_zoo/official/lite/MindSpore_inhand/common/src/main/java/com/mindspore/common/utils/EncryptedUtils.java @@ -0,0 +1,22 @@ +package com.mindspore.common.utils; + +import java.math.BigInteger; +import java.security.MessageDigest; +import java.security.NoSuchAlgorithmException; + +public class EncryptedUtils { + public static String stringToMD5(String plainText) { + byte[] secretBytes = null; + try { + secretBytes = MessageDigest.getInstance("md5").digest( + plainText.getBytes()); + } catch (NoSuchAlgorithmException e) { + throw new RuntimeException("没有这个md5算法!"); + } + String md5code = new BigInteger(1, secretBytes).toString(16); + for (int i = 0; i < 32 - md5code.length(); i++) { + md5code = "0" + md5code; + } + return md5code; + } +}