From 1818b15f91e44024f20d7c9d0b430c6f39555b5d Mon Sep 17 00:00:00 2001 From: 18561577093 <17882492@qq.com> Date: Sat, 28 Aug 2021 17:39:47 +0800 Subject: [PATCH] [AD] 00030 [describe] modify changed account data ui [Submitter] wanglixue --- .../app/src/main/AndroidManifest.xml | 3 + .../ui/me/AccountInfoActivity.java | 222 ++++++++++++--- .../himindspore/ui/me/LoginActivity.java | 8 +- .../ui/me/ModifyStringActivity.java | 67 +++++ .../himindspore/ui/me/PersonalFragment.java | 110 +++++++- .../himindspore/ui/me/SetActivity.java | 39 +-- .../ui/me/adapter/UserInfoAdapter.java | 5 +- .../ui/me/event/AccountChangedEvent.java | 4 + .../ui/me/event/LoginStateChangedEvent.java | 4 + .../ui/me/mvp/AccountContract.java | 13 + .../ui/me/mvp/AccountInfoPresenter.java | 121 +++++++++ .../ui/me/mvp/AccountPresenter.java | 83 ++++++ .../himindspore/ui/me/mvp/LoginPresenter.java | 9 +- .../ui/me/mvp/LogoutPresenter.java | 4 +- .../src/main/res/layout/activity_account.xml | 53 ++-- .../activity_account_modify_string_data.xml | 35 +++ .../res/layout/activity_set_up_layout.xml | 2 +- ...ut_dialog.xml => layout_logout_dialog.xml} | 30 +- .../app/src/main/res/values-en/strings.xml | 2 +- .../app/src/main/res/values-zh/strings.xml | 4 +- .../app/src/main/res/values/strings.xml | 5 +- .../app/src/main/res/values/styles.xml | 3 + .../base/mvp/BaseFragmentPresenter.java | 4 + .../com/mindspore/common/http/HttpClient.java | 14 +- .../common/netbean/response/AccountBean.java | 257 ++++++++++++++++++ .../MindSpore_inhand/customView/build.gradle | 1 + .../customview/ui/AccountViewBean.java | 39 +++ .../ui/LeftTextCenterTextRightImageView.java | 3 +- .../main/res/layout/layout_user_info_view.xml | 59 ++-- 29 files changed, 1042 insertions(+), 161 deletions(-) create mode 100644 model_zoo/official/lite/MindSpore_inhand/app/src/main/java/com/mindspore/himindspore/ui/me/ModifyStringActivity.java create mode 100644 model_zoo/official/lite/MindSpore_inhand/app/src/main/java/com/mindspore/himindspore/ui/me/event/AccountChangedEvent.java create mode 100644 model_zoo/official/lite/MindSpore_inhand/app/src/main/java/com/mindspore/himindspore/ui/me/event/LoginStateChangedEvent.java create mode 100644 model_zoo/official/lite/MindSpore_inhand/app/src/main/java/com/mindspore/himindspore/ui/me/mvp/AccountContract.java create mode 100644 model_zoo/official/lite/MindSpore_inhand/app/src/main/java/com/mindspore/himindspore/ui/me/mvp/AccountInfoPresenter.java create mode 100644 model_zoo/official/lite/MindSpore_inhand/app/src/main/java/com/mindspore/himindspore/ui/me/mvp/AccountPresenter.java create mode 100644 model_zoo/official/lite/MindSpore_inhand/app/src/main/res/layout/activity_account_modify_string_data.xml rename model_zoo/official/lite/MindSpore_inhand/app/src/main/res/layout/{layout_signout_dialog.xml => layout_logout_dialog.xml} (70%) create mode 100644 model_zoo/official/lite/MindSpore_inhand/common/src/main/java/com/mindspore/common/netbean/response/AccountBean.java create mode 100644 model_zoo/official/lite/MindSpore_inhand/customView/src/main/java/com/mindspore/customview/ui/AccountViewBean.java diff --git a/model_zoo/official/lite/MindSpore_inhand/app/src/main/AndroidManifest.xml b/model_zoo/official/lite/MindSpore_inhand/app/src/main/AndroidManifest.xml index 6a9fffa36f..93ab4cba46 100644 --- a/model_zoo/official/lite/MindSpore_inhand/app/src/main/AndroidManifest.xml +++ b/model_zoo/official/lite/MindSpore_inhand/app/src/main/AndroidManifest.xml @@ -42,6 +42,9 @@ + 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 57018769a0..0fff3c0b0d 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 @@ -15,71 +15,219 @@ */ package com.mindspore.himindspore.ui.me; -import android.os.Bundle; +import android.app.DatePickerDialog; +import android.content.Intent; +import android.util.Log; import android.widget.ImageView; -import androidx.appcompat.app.AppCompatActivity; +import androidx.annotation.Nullable; +import androidx.appcompat.app.AlertDialog; import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.RecyclerView; +import com.bumptech.glide.Glide; +import com.bumptech.glide.load.resource.bitmap.RoundedCorners; +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.himindspore.R; import com.mindspore.himindspore.ui.me.adapter.UserInfoAdapter; +import com.mindspore.himindspore.ui.me.event.AccountChangedEvent; +import com.mindspore.himindspore.ui.me.mvp.AccountContract; +import com.mindspore.himindspore.ui.me.mvp.AccountInfoPresenter; + +import org.greenrobot.eventbus.EventBus; +import org.greenrobot.eventbus.Subscribe; +import org.greenrobot.eventbus.ThreadMode; import java.util.ArrayList; +import java.util.Calendar; + +import io.reactivex.annotations.NonNull; + +public class AccountInfoActivity extends BaseActivity implements AccountContract.AccountView { -public class AccountInfoActivity extends AppCompatActivity { + private static final String TAG = AccountInfoActivity.class.getSimpleName(); + + private final int SEX_MAN = 1; + private final int SEX_WOMAN = 2; + private final int SEX_SECRET = 3; + private final String SEX_MAN_STR = "男"; + private final String SEX_WOMAN_STR = "女"; + private final String SEX_SECRET_STR = "保密"; + private String[] sexOption = new String[]{SEX_MAN_STR, SEX_WOMAN_STR, SEX_SECRET_STR}; private ImageView avatar; - private ArrayList mList = new ArrayList<>(); + private ArrayList mList = new ArrayList<>(); + private AccountBean accountBean = new AccountBean(); + private AccountInfoPresenter presenter; + + AccountViewBean nicknameViewBean; + AccountViewBean sexViewBean; + AccountViewBean birthdayViewBean; + AccountViewBean personalSignatureVb; + private UserInfoAdapter infoAdapter; + private Calendar calendar = Calendar.getInstance(); + + @Subscribe(threadMode = ThreadMode.MAIN) + public void onEventMainThread(AccountChangedEvent event) { + if (presenter == null) { + presenter = AccountInfoPresenter.getInstance(this); + } + presenter.getAccount(); + } + + @Override + protected void onResume() { + super.onResume(); + } @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_account); - init(); + protected void onDestroy() { + super.onDestroy(); + presenter.clear(); + } + + @Override + protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) { + super.onActivityResult(requestCode, resultCode, data); + if (accountBean != null) { + if (requestCode == ModifyStringActivity.MODIFY_NICKNAME_CODE + && resultCode == RESULT_OK) { + accountBean.setNickname(data.getStringExtra(ModifyStringActivity.MODIFY_CONTENT)); + } else if (requestCode == ModifyStringActivity.MODIFY_SIGNATURES_CODE + && resultCode == RESULT_OK) { + accountBean.setSignature(data.getStringExtra(ModifyStringActivity.MODIFY_CONTENT)); + } else { + Log.e(TAG, "ModifyStringActivity result is error"); + return; + } + presenter.updateAccount(accountBean); + } } - private void init() { - AccountBean accountBean = new AccountBean(getResources().getString(R.string.user_nick_name), "飞来的银河系"); - AccountBean accountBean1 = new AccountBean(getResources().getString(R.string.user_sexes), "女"); - AccountBean accountBean2 = new AccountBean(getResources().getString(R.string.user_age), "1998-09-10"); - AccountBean accountBean3 = new AccountBean(getResources().getString(R.string.user_signatures), "哥只是个传说"); - mList.add(accountBean); - mList.add(accountBean1); - mList.add(accountBean2); - mList.add(accountBean3); + @Override + public void init() { + EventBus.getDefault().register(this); + presenter = AccountInfoPresenter.getInstance(this); + presenter.getAccount(); + nicknameViewBean = new AccountViewBean(getResources().getString(R.string.user_nick_name), ""); + sexViewBean = new AccountViewBean(getResources().getString(R.string.user_sexes), ""); + birthdayViewBean = new AccountViewBean(getResources().getString(R.string.user_age), ""); + personalSignatureVb = new AccountViewBean(getResources().getString(R.string.user_signatures), ""); + + nicknameViewBean.setOnClickListener(v -> { + if (accountBean != null) { + ModifyStringActivity.start(this, getString(R.string.user_nick_name), + accountBean.getNickname(), ModifyStringActivity.MODIFY_NICKNAME_CODE); + } else { + Log.e(TAG, "accountBean is null. can`t modify account."); + } + + }); + + 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(); + } else { + Log.e(TAG, "accountBean is null. can`t modify account."); + } + }); + + 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(); + } else { + Log.e(TAG, "accountBean is null. can`t modify account."); + } + }); + + personalSignatureVb.setOnClickListener(v -> { + ModifyStringActivity.start(this, getString(R.string.user_signatures), + accountBean.getSignature(), ModifyStringActivity.MODIFY_SIGNATURES_CODE); + }); + + mList.add(nicknameViewBean); + mList.add(sexViewBean); + mList.add(birthdayViewBean); + mList.add(personalSignatureVb); avatar = findViewById(R.id.account_avatar_image); RecyclerView mRecyclerView = findViewById(R.id.recyclerView); - UserInfoAdapter infoAdapter = new UserInfoAdapter(AccountInfoActivity.this, mList); + infoAdapter = new UserInfoAdapter(AccountInfoActivity.this, mList); LinearLayoutManager manager = new LinearLayoutManager(AccountInfoActivity.this, LinearLayoutManager.VERTICAL, false); mRecyclerView.setLayoutManager(manager); mRecyclerView.setAdapter(infoAdapter); } - //后边需要删除,临时写在这 - public static class AccountBean { - private String leftText; - private String rightText; + @Override + public int getLayout() { + return R.layout.activity_account; + } - public AccountBean(String leftText, String rightText) { - this.leftText = leftText; - this.rightText = rightText; - } + @Override + public void showLoading() { - public String getLeftText() { - return leftText; - } + } - public void setLeftText(String leftText) { - this.leftText = leftText; - } + @Override + public void dismissLoading() { - public String getRightText() { - return rightText; - } + } + + @Override + public void getResponseData(@NonNull AccountBean responseBean) { + accountBean = responseBean; + nicknameViewBean.setRightText(accountBean.getNickname()); + sexViewBean.setRightText(getSexString(accountBean.getGender())); + birthdayViewBean.setRightText(accountBean.getDateBirth()); + personalSignatureVb.setRightText(accountBean.getSignature()); + Glide.with(this) + .load(accountBean.getAvatar()) + .apply(RequestOptions.bitmapTransform(new RoundedCorners(90))) + .error(R.drawable.icon_avatar_default) + .placeholder(R.drawable.icon_avatar_default) + .into(avatar); + infoAdapter.notifyDataSetChanged(); + } - public void setRightText(String rightText) { - this.rightText = rightText; + private String getSexString(int gender) { + switch (gender) { + case SEX_MAN: + return SEX_MAN_STR; + case SEX_WOMAN: + return SEX_WOMAN_STR; + case SEX_SECRET: + default: + return SEX_SECRET_STR; } } + + @Override + public void showError(String msg, int errorCode) { + + } } \ 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 274943f370..5e63e962a7 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 @@ -2,23 +2,23 @@ package com.mindspore.himindspore.ui.me; import android.text.TextUtils; import android.view.View; -import android.widget.Button; import android.widget.EditText; import android.widget.TextView; import com.google.android.exoplayer2.util.Log; -import com.mindspore.common.base.bean.BaseResponseBean; import com.mindspore.common.base.mvp.BaseActivity; -import com.mindspore.common.net.HttpUtils; import com.mindspore.common.netbean.request.RequestLoginBean; import com.mindspore.common.netbean.response.LoginResBean; import com.mindspore.common.utils.PhoneFormatCheckUtils; import com.mindspore.common.utils.UserUtils; import com.mindspore.customview.ui.MyToast; import com.mindspore.himindspore.R; +import com.mindspore.himindspore.ui.me.event.LoginStateChangedEvent; import com.mindspore.himindspore.ui.me.mvp.LoginContract; import com.mindspore.himindspore.ui.me.mvp.LoginPresenter; +import org.greenrobot.eventbus.EventBus; + public class LoginActivity extends BaseActivity implements View.OnClickListener, LoginContract.LoginView { private static final String TAG = LoginActivity.class.getSimpleName(); @@ -135,6 +135,7 @@ public class LoginActivity extends BaseActivity implements View.OnClickListener, 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); @@ -145,7 +146,6 @@ public class LoginActivity extends BaseActivity implements View.OnClickListener, } else { Log.d(TAG, "state is error:"+ responseBean.getState()); } - } @Override diff --git a/model_zoo/official/lite/MindSpore_inhand/app/src/main/java/com/mindspore/himindspore/ui/me/ModifyStringActivity.java b/model_zoo/official/lite/MindSpore_inhand/app/src/main/java/com/mindspore/himindspore/ui/me/ModifyStringActivity.java new file mode 100644 index 0000000000..755b6122bc --- /dev/null +++ b/model_zoo/official/lite/MindSpore_inhand/app/src/main/java/com/mindspore/himindspore/ui/me/ModifyStringActivity.java @@ -0,0 +1,67 @@ +package com.mindspore.himindspore.ui.me; + +import android.app.Activity; +import android.content.Intent; +import android.util.Log; +import android.widget.EditText; +import android.widget.TextView; + +import com.mindspore.common.base.mvp.BaseActivity; +import com.mindspore.customview.ui.AppTitleView; +import com.mindspore.himindspore.R; + +public class ModifyStringActivity extends BaseActivity { + + public static final String MODIFY_TITLE = "title"; + public static final String MODIFY_CONTENT = "content"; + public static final int MODIFY_NICKNAME_CODE = 1; + public static final int MODIFY_SIGNATURES_CODE = 2; + + private static final String TAG = ModifyStringActivity.class.getSimpleName(); + EditText editText; + String modifyName; + String oldContent; + + + public static void start(Activity activity, String title, String content, int requestCode) { + Intent intent = new Intent(activity, ModifyStringActivity.class); + intent.putExtra(MODIFY_TITLE, title); + intent.putExtra(MODIFY_CONTENT, content); + activity.startActivityForResult(intent, requestCode); + } + + @Override + protected void init() { + Intent intent = getIntent(); + modifyName = intent.getStringExtra(MODIFY_TITLE); + oldContent = intent.getStringExtra(MODIFY_CONTENT); + + AppTitleView titleView = findViewById(R.id.account_app_title); + String titlePrefix = getString(R.string.me_modify); + titleView.setTitleTextName(titlePrefix + modifyName); + editText = findViewById(R.id.input_area); + + if (getString(R.string.user_nick_name).equals(modifyName)) { + editText.setMaxLines(1); + editText.setHint(getString(R.string.user_name)); + } else if (getString(R.string.user_signatures).equals(modifyName)) { + editText.setMaxLines(3); + editText.setText(oldContent); + } else { + Log.e(TAG, "modify name is wrong, name:" + modifyName); + } + + TextView saveTv = findViewById(R.id.save); + saveTv.setOnClickListener(v -> { + Intent resultIntent = new Intent(); + resultIntent.putExtra(MODIFY_CONTENT, editText.getText().toString()); + setResult(RESULT_OK, resultIntent); + finish(); + }); + } + + @Override + public int getLayout() { + return R.layout.activity_account_modify_string_data; + } +} 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 b730a7c9fa..1cd114d7ad 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 @@ -28,11 +28,13 @@ import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; +import android.widget.ImageView; import android.widget.TextView; import android.widget.Toast; import androidx.annotation.NonNull; import androidx.annotation.Nullable; +import androidx.constraintlayout.widget.ConstraintLayout; import androidx.core.app.ActivityCompat; import androidx.core.app.ActivityOptionsCompat; import androidx.core.content.FileProvider; @@ -42,13 +44,19 @@ import androidx.recyclerview.widget.RecyclerView; import com.mindspore.common.base.mvp.BaseFragment; import com.mindspore.common.config.MSLinkUtils; import com.mindspore.common.net.FileDownLoadObserver; +import com.mindspore.common.netbean.response.AccountBean; import com.mindspore.common.netbean.response.UpdateInfoBean; import com.mindspore.common.utils.UserUtils; import com.mindspore.customview.dialog.UpdateDialog; import com.mindspore.customview.ui.MyToast; +import com.mindspore.himindspore.R; import com.mindspore.himindspore.ui.main.MainContract; import com.mindspore.himindspore.ui.me.adapter.ServerInfoAdapter; import com.mindspore.himindspore.ui.me.bean.ServerInfoBean; +import com.mindspore.himindspore.ui.me.event.AccountChangedEvent; +import com.mindspore.himindspore.ui.me.event.LoginStateChangedEvent; +import com.mindspore.himindspore.ui.me.mvp.AccountContract; +import com.mindspore.himindspore.ui.me.mvp.AccountPresenter; import com.mindspore.himindspore.ui.webView.WebViewUtilsActivity; import java.io.File; @@ -61,7 +69,12 @@ import static com.mindspore.himindspore.R.id; import static com.mindspore.himindspore.R.layout; import static com.mindspore.himindspore.R.string; -public class PersonalFragment extends BaseFragment implements MainContract.View, View.OnClickListener, ServerInfoAdapter.ServerItemClickListener { +import org.greenrobot.eventbus.EventBus; +import org.greenrobot.eventbus.Subscribe; +import org.greenrobot.eventbus.ThreadMode; + +public class PersonalFragment extends BaseFragment implements + MainContract.View, View.OnClickListener, ServerInfoAdapter.ServerItemClickListener, AccountContract.AccountView { private static final String TAG = PersonalFragment.class.getSimpleName(); private TextView versionText; @@ -72,6 +85,14 @@ public class PersonalFragment extends BaseFragment im private List infoList; private ServerInfoAdapter infoAdapter; private TextView userNameTv; + private ImageView avatarIv; + private AccountPresenter accountPresenter; + + private TextView dynamicTv; + private TextView attentionTv; + private TextView fansTv; + private ConstraintLayout taskLayout; + private TextView oneTaskNameTv; @Override public View onCreateView( @@ -80,30 +101,56 @@ public class PersonalFragment extends BaseFragment im return inflater.inflate(layout.fragment_personal, container, false); } + @Subscribe(threadMode = ThreadMode.MAIN) + public void onEventMainThread(AccountChangedEvent event) { + if (accountPresenter == null) { + accountPresenter = AccountPresenter.getInstance(this); + } + refreshViewData(); + } + + @Subscribe(threadMode = ThreadMode.MAIN) + public void onEventMainThread(LoginStateChangedEvent event) { + if (accountPresenter == null) { + accountPresenter = AccountPresenter.getInstance(this); + } + refreshViewData(); + } + @Override public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { + EventBus.getDefault().register(this); super.onViewCreated(view, savedInstanceState); + accountPresenter = AccountPresenter.getInstance(this); + infoList = new ArrayList<>(); presenter = new PersonalFragmentPresenter(this); versionText = view.findViewById(id.me_vision); userNameTv = view.findViewById(id.user_name); + avatarIv = view.findViewById(id.per_avatar); userNameTv.setOnClickListener(this); - view.findViewById(id.per_set_up).setOnClickListener(this); - view.findViewById(id.per_task_include).setOnClickListener(this); + view.findViewById(id.per_user_layout).setOnClickListener(this); - view.findViewById(id.per_dynamic_number).setOnClickListener(this); + dynamicTv = view.findViewById(id.per_dynamic_number); + dynamicTv.setOnClickListener(this); view.findViewById(id.per_dynamic).setOnClickListener(this); view.findViewById(id.per_attention).setOnClickListener(this); - view.findViewById(id.per_attention_number).setOnClickListener(this); - view.findViewById(id.per_fans_number).setOnClickListener(this); + attentionTv = view.findViewById(id.per_attention_number); + attentionTv.setOnClickListener(this); + fansTv = view.findViewById(id.per_fans_number); + fansTv.setOnClickListener(this); view.findViewById(id.per_fans).setOnClickListener(this); + taskLayout = view.findViewById(id.per_task_include); + taskLayout.setOnClickListener(this); + oneTaskNameTv = view.findViewById(id.per_one_task); view.findViewById(id.per_title_quit).setOnClickListener(this); view.findViewById(id.per_task_title_include).setOnClickListener(this); view.findViewById(id.per_remaining_task_layout).setOnClickListener(this); + view.findViewById(id.per_set_up).setOnClickListener(this); view.findViewById(id.rl_me_version).setOnClickListener(this); view.findViewById(id.per_space_layout).setOnClickListener(this); mRecyclerView = view.findViewById(id.me_recycler); - //推荐服务列表数据,加载位置可自行调换 + // 推荐服务列表数据,加载位置可自行调换 ServerInfoBean myCourseBean = new ServerInfoBean(getActivity().getResources() .getString(string.per_curriculum), getActivity().getResources().getDrawable(drawable.per_curriculum)); @@ -129,20 +176,26 @@ public class PersonalFragment extends BaseFragment im infoAdapter = new ServerInfoAdapter(getActivity(), infoList); mRecyclerView.setAdapter(infoAdapter); showPackageInfo(); + + refreshViewData(); } @Override public void onResume() { super.onResume(); - // 判断是否登录过, - // 登录过则请求数据,刷新页面,否则显示默认值 - if (UserUtils.isHasLogin()) { - refreshViewData(); - } } private void refreshViewData() { - // TODO 请求数据,刷新页面。 + if (UserUtils.isHasLogin()) { + accountPresenter.getAccount(); + } else { + userNameTv.setText(getContext().getResources() + .getString(R.string.title_splash_welcome_name)); + dynamicTv.setText("-"); + attentionTv.setText("-"); + fansTv.setText("-"); + taskLayout.setVisibility(View.GONE); + } } private void showPackageInfo() { @@ -188,6 +241,7 @@ public class PersonalFragment extends BaseFragment im case id.rl_me_version: getUpdateInfo(); break; + case id.per_avatar: case id.user_name: startUserInfo(); break; @@ -198,7 +252,7 @@ public class PersonalFragment extends BaseFragment im private void startUserInfo() { if (UserUtils.isHasLogin()) { - // todo 跳转到用户信息编辑页面 + startActivity(new Intent(getActivity(), AccountInfoActivity.class)); } else { Intent intent = new Intent(getActivity(), LoginActivity.class); startActivity(intent); @@ -369,4 +423,32 @@ public class PersonalFragment extends BaseFragment im // break; } } + + @Override + public void showLoading() { + + } + + @Override + public void dismissLoading() { + + } + + @Override + public void getResponseData(@NonNull AccountBean responseBean) { + userNameTv.setText(responseBean.getNickname()); + dynamicTv.setText(responseBean.getDynamic() + ""); + attentionTv.setText(responseBean.getAttention() + ""); + fansTv.setText(responseBean.getFansNumber() + ""); + List taskList = responseBean.getTaskEntityList(); + if (taskList != null && !taskList.isEmpty()) { + taskLayout.setVisibility(View.VISIBLE); + oneTaskNameTv.setText(responseBean.getTaskEntityList().get(0).getTaskDescription()); + } + } + + @Override + public void showError(String msg, int errorCode) { + + } } 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 3a9e82867f..b6fdbec261 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 @@ -23,32 +23,33 @@ import android.view.View; import android.view.WindowManager; import android.widget.TextView; -import com.mindspore.common.base.bean.BaseResponseBean; import com.mindspore.common.base.mvp.BaseActivity; import com.mindspore.common.config.MSLinkUtils; -import com.mindspore.common.net.HttpUtils; import com.mindspore.common.netbean.response.LoginResBean; import com.mindspore.common.utils.ScreenUtils; import com.mindspore.common.utils.UserUtils; import com.mindspore.himindspore.R; import com.mindspore.himindspore.R.id; +import com.mindspore.himindspore.ui.me.event.LoginStateChangedEvent; import com.mindspore.himindspore.ui.me.mvp.LoginContract; import com.mindspore.himindspore.ui.me.mvp.LogoutPresenter; import com.mindspore.himindspore.ui.webView.WebViewUtilsActivity; -public class SetActivity extends BaseActivity implements View.OnClickListener, LoginContract.LogoutView { +import org.greenrobot.eventbus.EventBus; - private TextView mSignOut; +public class SetActivity extends BaseActivity implements View.OnClickListener, + LoginContract.LogoutView { + + private TextView logoutTv; private AlertDialog dialog; private String TAG = SetActivity.class.getSimpleName(); LogoutPresenter presenter; public void init() { - mSignOut = findViewById(R.id.logout_view); - mSignOut.setOnClickListener(this); - + logoutTv = findViewById(R.id.logout_view); + logoutTv.setOnClickListener(this); - findViewById(R.id.account_number).setOnClickListener(this); + findViewById(R.id.account_info).setOnClickListener(this); findViewById(R.id.safety_view).setOnClickListener(this); findViewById(R.id.user_view).setOnClickListener(this); findViewById(R.id.privacy_view).setOnClickListener(this); @@ -61,9 +62,9 @@ public class SetActivity extends BaseActivity implements View.OnClickListener, L protected void onResume() { super.onResume(); if (UserUtils.isHasLogin()) { - mSignOut.setVisibility(View.VISIBLE); + logoutTv.setVisibility(View.VISIBLE); } else { - mSignOut.setVisibility(View.GONE); + logoutTv.setVisibility(View.GONE); } } @@ -72,9 +73,9 @@ public class SetActivity extends BaseActivity implements View.OnClickListener, L return R.layout.activity_set_up_layout; } - private void signOutDialog() { + private void logoutDialog() { AlertDialog.Builder builder = new AlertDialog.Builder(this); - final View view = getLayoutInflater().inflate(R.layout.layout_signout_dialog, null); + final View view = getLayoutInflater().inflate(R.layout.layout_logout_dialog, null); dialog = builder.create(); dialog.show(); dialog.getWindow().setBackgroundDrawableResource(R.drawable.set_dialog_bg); @@ -96,17 +97,22 @@ public class SetActivity extends BaseActivity implements View.OnClickListener, L case id.dialog_cancel: dialog.dismiss(); break; - case id.account_number: - startActivity(new Intent(SetActivity.this, AccountInfoActivity.class)); + case id.account_info: + if (true) { + startActivity(new Intent(SetActivity.this, AccountInfoActivity.class)); + } else { + startActivity(new Intent(SetActivity.this, LoginActivity.class)); + } break; case id.logout_view: - signOutDialog(); + logoutDialog(); break; case id.dialog_confirm: presenter.logout(); UserUtils.cleanUserInfo(); + EventBus.getDefault().post(new LoginStateChangedEvent()); dialog.dismiss(); - mSignOut.setVisibility(View.GONE); + logoutTv.setVisibility(View.GONE); break; case id.safety_view: case id.user_view: @@ -131,7 +137,6 @@ public class SetActivity extends BaseActivity implements View.OnClickListener, L @Override public void getResponseData(LoginResBean responseBean) { - } @Override diff --git a/model_zoo/official/lite/MindSpore_inhand/app/src/main/java/com/mindspore/himindspore/ui/me/adapter/UserInfoAdapter.java b/model_zoo/official/lite/MindSpore_inhand/app/src/main/java/com/mindspore/himindspore/ui/me/adapter/UserInfoAdapter.java index e9b4ac9c75..671cd57e1c 100644 --- a/model_zoo/official/lite/MindSpore_inhand/app/src/main/java/com/mindspore/himindspore/ui/me/adapter/UserInfoAdapter.java +++ b/model_zoo/official/lite/MindSpore_inhand/app/src/main/java/com/mindspore/himindspore/ui/me/adapter/UserInfoAdapter.java @@ -8,16 +8,16 @@ import android.view.ViewGroup; import androidx.annotation.NonNull; import androidx.recyclerview.widget.RecyclerView; +import com.mindspore.customview.ui.AccountViewBean; import com.mindspore.customview.ui.LeftTextCenterTextRightImageView; import com.mindspore.himindspore.R; -import com.mindspore.himindspore.ui.me.AccountInfoActivity; import java.util.ArrayList; public class UserInfoAdapter extends RecyclerView.Adapter { private Context mContext; - private ArrayList mList = new ArrayList<>(); + private ArrayList mList = new ArrayList<>(); public UserInfoAdapter(Context mContext, ArrayList mList) { this.mContext = mContext; @@ -35,6 +35,7 @@ public class UserInfoAdapter extends RecyclerView.Adapter {} + + interface AccountViewPresenter { + void getAccount(); + void updateAccount(AccountBean accountBean); + } +} 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 new file mode 100644 index 0000000000..5a93e8dbf5 --- /dev/null +++ b/model_zoo/official/lite/MindSpore_inhand/app/src/main/java/com/mindspore/himindspore/ui/me/mvp/AccountInfoPresenter.java @@ -0,0 +1,121 @@ +package com.mindspore.himindspore.ui.me.mvp; + +import android.util.Log; + +import androidx.annotation.NonNull; + +import com.mindspore.common.base.mvp.BaseActivityPresenter; +import com.mindspore.common.http.HttpClient; +import com.mindspore.common.net.BaseObserver; +import com.mindspore.common.netbean.response.AccountBean; +import com.mindspore.customview.ui.MyToast; +import com.mindspore.himindspore.ui.me.AccountInfoActivity; +import com.mindspore.himindspore.ui.me.event.AccountChangedEvent; + +import org.greenrobot.eventbus.EventBus; + +import io.reactivex.android.schedulers.AndroidSchedulers; +import io.reactivex.schedulers.Schedulers; +import okhttp3.ResponseBody; + +public class AccountInfoPresenter extends BaseActivityPresenter + implements AccountContract.AccountViewPresenter { + + private static final String TAG = AccountInfoPresenter.class.getSimpleName(); + private static AccountInfoPresenter instance; + + private AccountInfoPresenter(AccountInfoActivity activity) { + this.view = activity; + } + + public static synchronized AccountInfoPresenter getInstance(AccountInfoActivity activity) { + if (instance == null) { + instance = new AccountInfoPresenter(activity); + } + 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, "getAccount.onFailed, Throwable:" + msg + "errorCode>>" + errorCode); + MyToast.MakeText(msg, 1000); + } + + @Override + public void onNext(@NonNull AccountBean responseBean) { + Log.d(TAG, "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, "getAccount.onError, Throwable:" + message); + } + + @Override + public void onComplete() { + Log.d(TAG, "getAccount.onComplete."); + } + }); + } + + @Override + public void updateAccount(@NonNull AccountBean accountBean) { + HttpClient.Builder.getDataServer().updateAccount(accountBean).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, "updateAccount.onFailed, Throwable:" + msg + "errorCode>>" + errorCode); + MyToast.MakeText(msg, 1000); + } + + @Override + public void onNext(@NonNull ResponseBody responseBean) { + Log.d(TAG, "updateAccount.onNext."); + EventBus.getDefault().post(new AccountChangedEvent()); + } + + @Override + public void onError(@NonNull Throwable e) { + super.onError(e); + String message = e.getMessage(); + Log.e(TAG, "updateAccount.onError, Throwable:" + message); + } + + @Override + public void onComplete() { + Log.d(TAG, "updateAccount.onComplete."); + } + }); + } + + @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/AccountPresenter.java b/model_zoo/official/lite/MindSpore_inhand/app/src/main/java/com/mindspore/himindspore/ui/me/mvp/AccountPresenter.java new file mode 100644 index 0000000000..1db29c7e70 --- /dev/null +++ b/model_zoo/official/lite/MindSpore_inhand/app/src/main/java/com/mindspore/himindspore/ui/me/mvp/AccountPresenter.java @@ -0,0 +1,83 @@ +package com.mindspore.himindspore.ui.me.mvp; + +import android.util.Log; + +import androidx.annotation.NonNull; + +import com.mindspore.common.base.mvp.BaseFragmentPresenter; +import com.mindspore.common.http.HttpClient; +import com.mindspore.common.net.BaseObserver; +import com.mindspore.common.netbean.response.AccountBean; +import com.mindspore.customview.ui.MyToast; +import com.mindspore.himindspore.ui.me.PersonalFragment; + +import io.reactivex.android.schedulers.AndroidSchedulers; +import io.reactivex.schedulers.Schedulers; + +public class AccountPresenter extends BaseFragmentPresenter 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/LoginPresenter.java b/model_zoo/official/lite/MindSpore_inhand/app/src/main/java/com/mindspore/himindspore/ui/me/mvp/LoginPresenter.java index f6960e5e56..00240b8396 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 @@ -5,16 +5,16 @@ import android.util.Log; import androidx.annotation.NonNull; import com.mindspore.common.base.mvp.BaseActivityPresenter; -import com.mindspore.common.exception.ErrorStatus; -import com.mindspore.common.exception.ExceptionHandle; + import com.mindspore.common.http.HttpClient; import com.mindspore.common.net.BaseObserver; -import com.mindspore.common.net.HttpUtils; import com.mindspore.common.netbean.request.RequestLoginBean; import com.mindspore.common.netbean.response.LoginResBean; import com.mindspore.customview.ui.MyToast; -import com.mindspore.himindspore.R; 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; @@ -56,6 +56,7 @@ public class LoginPresenter extends BaseActivityPresenter impleme @Override public void onNext(@NonNull LoginResBean responseBean) { Log.d(TAG, "LoginPresenter.login.onNext."); + EventBus.getDefault().post(new LoginStateChangedEvent()); if (view != null) { responseBean.setState(LoginActivity.LOGIN_STATE); view.getResponseData(responseBean); 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 af5de7da6c..f5f391e3eb 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 @@ -40,9 +40,7 @@ public class LogoutPresenter extends BaseActivityPresenter implemen @Override public void onNext(@NonNull LoginResBean responseBean) { - if (view != null) { - view.getResponseData(responseBean); - } + Log.d(TAG, "LoginPresenter.logout.onNext, success."); } @Override diff --git a/model_zoo/official/lite/MindSpore_inhand/app/src/main/res/layout/activity_account.xml b/model_zoo/official/lite/MindSpore_inhand/app/src/main/res/layout/activity_account.xml index a2bd5367e4..14aab1dc71 100644 --- a/model_zoo/official/lite/MindSpore_inhand/app/src/main/res/layout/activity_account.xml +++ b/model_zoo/official/lite/MindSpore_inhand/app/src/main/res/layout/activity_account.xml @@ -15,47 +15,44 @@ app:iconLeftBlack="@drawable/icon_back" app:nameTitle="@string/set_up_account" /> - + android:layout_height="wrap_content" + android:layout_marginHorizontal="@dimen/spaceHorizontalSize" + android:orientation="horizontal"> - - - + android:text="@string/user_avatar" /> - + + - + + + + + + + + + \ No newline at end of file diff --git a/model_zoo/official/lite/MindSpore_inhand/app/src/main/res/layout/activity_set_up_layout.xml b/model_zoo/official/lite/MindSpore_inhand/app/src/main/res/layout/activity_set_up_layout.xml index 6380c7893b..0b12d87e25 100644 --- a/model_zoo/official/lite/MindSpore_inhand/app/src/main/res/layout/activity_set_up_layout.xml +++ b/model_zoo/official/lite/MindSpore_inhand/app/src/main/res/layout/activity_set_up_layout.xml @@ -20,7 +20,7 @@ title:nameTitle="@string/setup" /> - + android:text="@string/logout" /> - + android:text="确定退出当前账号" /> - + android:text="@string/cancel" /> - + android:textColor="@color/main_text_blue" /> - \ No newline at end of file diff --git a/model_zoo/official/lite/MindSpore_inhand/app/src/main/res/values-en/strings.xml b/model_zoo/official/lite/MindSpore_inhand/app/src/main/res/values-en/strings.xml index 6864565555..a419c57a64 100644 --- a/model_zoo/official/lite/MindSpore_inhand/app/src/main/res/values-en/strings.xml +++ b/model_zoo/official/lite/MindSpore_inhand/app/src/main/res/values-en/strings.xml @@ -116,7 +116,7 @@ Register Or login Name - please enter user name + please enter nickname please enter password password Sign in diff --git a/model_zoo/official/lite/MindSpore_inhand/app/src/main/res/values-zh/strings.xml b/model_zoo/official/lite/MindSpore_inhand/app/src/main/res/values-zh/strings.xml index 1e0074e633..2235967069 100644 --- a/model_zoo/official/lite/MindSpore_inhand/app/src/main/res/values-zh/strings.xml +++ b/model_zoo/official/lite/MindSpore_inhand/app/src/main/res/values-zh/strings.xml @@ -104,7 +104,7 @@ 登录 或登录 姓名 - 请输入用户名 + 请输入昵称 请输入密码 密码 邮箱 @@ -140,7 +140,7 @@ 我的粉丝 头像 昵称 - 昵称 + 性别 出生年月 个性签名 历史观看课程 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 52d071d096..36e2b2640e 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 @@ -69,6 +69,7 @@ 官方代码仓 问题反馈 版本号 + 修改 同意 不同意并退出 《用户协议和隐私政策》 @@ -162,7 +163,7 @@ 该手机号已经注册 输入不合法 姓名 - 请输入用户名 + 请输入昵称 请输入您的手机号 请输入密码 密码 @@ -217,6 +218,8 @@ 头像 昵称 性别 + 选择性别 + 修改出生日期 出生年月 个性签名 历史观看课程 diff --git a/model_zoo/official/lite/MindSpore_inhand/app/src/main/res/values/styles.xml b/model_zoo/official/lite/MindSpore_inhand/app/src/main/res/values/styles.xml index 80bc85e298..309386892c 100644 --- a/model_zoo/official/lite/MindSpore_inhand/app/src/main/res/values/styles.xml +++ b/model_zoo/official/lite/MindSpore_inhand/app/src/main/res/values/styles.xml @@ -70,5 +70,8 @@ 11sp + \ No newline at end of file diff --git a/model_zoo/official/lite/MindSpore_inhand/common/src/main/java/com/mindspore/common/base/mvp/BaseFragmentPresenter.java b/model_zoo/official/lite/MindSpore_inhand/common/src/main/java/com/mindspore/common/base/mvp/BaseFragmentPresenter.java index d613fb1db5..c937a02b81 100644 --- a/model_zoo/official/lite/MindSpore_inhand/common/src/main/java/com/mindspore/common/base/mvp/BaseFragmentPresenter.java +++ b/model_zoo/official/lite/MindSpore_inhand/common/src/main/java/com/mindspore/common/base/mvp/BaseFragmentPresenter.java @@ -18,4 +18,8 @@ package com.mindspore.common.base.mvp; public class BaseFragmentPresenter { protected T view; + + public void clear(){ + this.view = null; + } } 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 c0b0a01b9e..d8078f5d49 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 @@ -2,11 +2,10 @@ package com.mindspore.common.http; import com.mindspore.common.net.BuildFactory; import com.mindspore.common.net.HttpUtils; -import com.mindspore.common.net.ParamNames; import com.mindspore.common.netbean.request.RequestLoginBean; import com.mindspore.common.netbean.request.RequestPageBean; import com.mindspore.common.netbean.request.RequestIdBean; -import com.mindspore.common.base.bean.BaseResponseBean; +import com.mindspore.common.netbean.response.AccountBean; import com.mindspore.common.netbean.response.CourseDetailsBean; import com.mindspore.common.netbean.response.CourseMainMapBean; import com.mindspore.common.netbean.response.GateDetailBean; @@ -20,11 +19,8 @@ import io.reactivex.Observable; import okhttp3.ResponseBody; import retrofit2.http.Body; import retrofit2.http.GET; -import retrofit2.http.HEAD; import retrofit2.http.Headers; import retrofit2.http.POST; -import retrofit2.http.Part; -import retrofit2.http.Path; import retrofit2.http.Streaming; import retrofit2.http.Url; @@ -86,4 +82,12 @@ public interface HttpClient { @Headers("Content-Type: application/json") @POST("api/logout") Observable logout(); + + @Headers("Content-Type: application/json") + @POST("api/getPersonalDetails") + Observable getAccount(); + + @Headers("Content-Type: application/json") + @POST("api/updatePersonalDetails") + Observable updateAccount(@Body AccountBean accountBean); } \ No newline at end of file diff --git a/model_zoo/official/lite/MindSpore_inhand/common/src/main/java/com/mindspore/common/netbean/response/AccountBean.java b/model_zoo/official/lite/MindSpore_inhand/common/src/main/java/com/mindspore/common/netbean/response/AccountBean.java new file mode 100644 index 0000000000..4a7ce37dcf --- /dev/null +++ b/model_zoo/official/lite/MindSpore_inhand/common/src/main/java/com/mindspore/common/netbean/response/AccountBean.java @@ -0,0 +1,257 @@ +package com.mindspore.common.netbean.response; + +import java.io.Serializable; +import java.util.List; + +public class AccountBean implements Serializable { + /** + * userId : 15 + * mobile : 18561577093 + * nickname : 明明 + * avatar : + * type : 0 + * age : 25 + * dateBirth : 2019-07-22 + * signature : + * gender : 0 + * email : + * job : + * bio : + * gitee : + * createTime : 2021-08-26T07:24:18.000+00:00 + * updateTime : 2021-08-24T07:44:08.000+00:00 + * fansNumber : 0 + * attention : 0 + * dynamic : 0 + * praise : 0 + * taskEntityList : [{"taskId":1,"taskType":1,"taskDescription":"快速入门Git操作","taskState":"正在执行"}] + */ + + private int userId; + private String mobile; + private String nickname; + private String avatar; + private int type; + private int age; + private String dateBirth; + private String signature; + private int gender; + private String email; + private String job; + private String bio; + private String gitee; + private String createTime; + private String updateTime; + private int fansNumber; + private int attention; + private int dynamic; + private int praise; + private List taskEntityList; + + + public static class TaskEntityListBean implements Serializable { + /** + * taskId : 1 + * taskType : 1 + * taskDescription : 快速入门Git操作 + * taskState : 正在执行 + */ + + private int taskId; + private int taskType; + private String taskDescription; + private String taskState; + + public int getTaskId() { + return taskId; + } + + public void setTaskId(int taskId) { + this.taskId = taskId; + } + + public int getTaskType() { + return taskType; + } + + public void setTaskType(int taskType) { + this.taskType = taskType; + } + + public String getTaskDescription() { + return taskDescription; + } + + public void setTaskDescription(String taskDescription) { + this.taskDescription = taskDescription; + } + + public String getTaskState() { + return taskState; + } + + public void setTaskState(String taskState) { + this.taskState = taskState; + } + } + + public int getUserId() { + return userId; + } + + public void setUserId(int userId) { + this.userId = userId; + } + + public String getMobile() { + return mobile; + } + + public void setMobile(String mobile) { + this.mobile = mobile; + } + + public String getNickname() { + return nickname; + } + + public void setNickname(String nickname) { + this.nickname = nickname; + } + + public String getAvatar() { + return avatar; + } + + public void setAvatar(String avatar) { + this.avatar = avatar; + } + + public int getType() { + return type; + } + + public void setType(int type) { + this.type = type; + } + + public int getAge() { + return age; + } + + public void setAge(int age) { + this.age = age; + } + + public String getDateBirth() { + return dateBirth; + } + + public void setDateBirth(String dateBirth) { + this.dateBirth = dateBirth; + } + + public String getSignature() { + return signature; + } + + public void setSignature(String signature) { + this.signature = signature; + } + + public int getGender() { + return gender; + } + + public void setGender(int gender) { + this.gender = gender; + } + + public String getEmail() { + return email; + } + + public void setEmail(String email) { + this.email = email; + } + + public String getJob() { + return job; + } + + public void setJob(String job) { + this.job = job; + } + + public String getBio() { + return bio; + } + + public void setBio(String bio) { + this.bio = bio; + } + + public String getGitee() { + return gitee; + } + + public void setGitee(String gitee) { + this.gitee = gitee; + } + + public String getCreateTime() { + return createTime; + } + + public void setCreateTime(String createTime) { + this.createTime = createTime; + } + + public String getUpdateTime() { + return updateTime; + } + + public void setUpdateTime(String updateTime) { + this.updateTime = updateTime; + } + + public int getFansNumber() { + return fansNumber; + } + + public void setFansNumber(int fansNumber) { + this.fansNumber = fansNumber; + } + + public int getAttention() { + return attention; + } + + public void setAttention(int attention) { + this.attention = attention; + } + + public int getDynamic() { + return dynamic; + } + + public void setDynamic(int dynamic) { + this.dynamic = dynamic; + } + + public int getPraise() { + return praise; + } + + public void setPraise(int praise) { + this.praise = praise; + } + + public List getTaskEntityList() { + return taskEntityList; + } + + public void setTaskEntityList(List taskEntityList) { + this.taskEntityList = taskEntityList; + } +} diff --git a/model_zoo/official/lite/MindSpore_inhand/customView/build.gradle b/model_zoo/official/lite/MindSpore_inhand/customView/build.gradle index 657f579219..8429158923 100644 --- a/model_zoo/official/lite/MindSpore_inhand/customView/build.gradle +++ b/model_zoo/official/lite/MindSpore_inhand/customView/build.gradle @@ -34,6 +34,7 @@ dependencies { implementation "com.google.android.material:material:${config.dependencies.material}" implementation "com.classic.common:multiple-status-view:${config.dependencies.multiple_status_view}" implementation project(path: ':common') + implementation "androidx.constraintlayout:constraintlayout:${config.dependencies.constraintlayout}" testImplementation "org.testng:testng:${config.dependencies.testng}" testImplementation "junit:junit:${config.dependencies.junit}" androidTestImplementation "androidx.test.espresso:espresso-core:${config.dependencies.espresso}" diff --git a/model_zoo/official/lite/MindSpore_inhand/customView/src/main/java/com/mindspore/customview/ui/AccountViewBean.java b/model_zoo/official/lite/MindSpore_inhand/customView/src/main/java/com/mindspore/customview/ui/AccountViewBean.java new file mode 100644 index 0000000000..9b2682b15d --- /dev/null +++ b/model_zoo/official/lite/MindSpore_inhand/customView/src/main/java/com/mindspore/customview/ui/AccountViewBean.java @@ -0,0 +1,39 @@ +package com.mindspore.customview.ui; + +import android.view.View; + +public class AccountViewBean { + private String leftText; + private String rightText; + + public View.OnClickListener getOnClickListener() { + return onClickListener; + } + + public void setOnClickListener(View.OnClickListener onClickListener) { + this.onClickListener = onClickListener; + } + + private View.OnClickListener onClickListener; + + public AccountViewBean(String leftText, String rightText) { + this.leftText = leftText; + this.rightText = rightText; + } + + public String getLeftText() { + return leftText; + } + + public void setLeftText(String leftText) { + this.leftText = leftText; + } + + public String getRightText() { + return rightText; + } + + public void setRightText(String rightText) { + this.rightText = rightText; + } +} diff --git a/model_zoo/official/lite/MindSpore_inhand/customView/src/main/java/com/mindspore/customview/ui/LeftTextCenterTextRightImageView.java b/model_zoo/official/lite/MindSpore_inhand/customView/src/main/java/com/mindspore/customview/ui/LeftTextCenterTextRightImageView.java index 22a8fa8ff9..12a723e097 100644 --- a/model_zoo/official/lite/MindSpore_inhand/customView/src/main/java/com/mindspore/customview/ui/LeftTextCenterTextRightImageView.java +++ b/model_zoo/official/lite/MindSpore_inhand/customView/src/main/java/com/mindspore/customview/ui/LeftTextCenterTextRightImageView.java @@ -36,7 +36,8 @@ public class LeftTextCenterTextRightImageView extends RelativeLayout { @Override protected void onFinishInflate() { super.onFinishInflate(); - userInfoLayout = (RelativeLayout) LayoutInflater.from(getContext()).inflate(R.layout.layout_user_info_view, this, true); + userInfoLayout = (RelativeLayout) LayoutInflater.from(getContext()) + .inflate(R.layout.layout_user_info_view, this, true); leftText = userInfoLayout.findViewById(R.id.left_text); rightText = userInfoLayout.findViewById(R.id.user_info_text); rightText.setText(textRightInfo); diff --git a/model_zoo/official/lite/MindSpore_inhand/customView/src/main/res/layout/layout_user_info_view.xml b/model_zoo/official/lite/MindSpore_inhand/customView/src/main/res/layout/layout_user_info_view.xml index 63e2411dc5..5e83b1340e 100644 --- a/model_zoo/official/lite/MindSpore_inhand/customView/src/main/res/layout/layout_user_info_view.xml +++ b/model_zoo/official/lite/MindSpore_inhand/customView/src/main/res/layout/layout_user_info_view.xml @@ -1,44 +1,57 @@ - - + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toTopOf="parent" /> + + - - + android:layout_marginEnd="@dimen/spaceHorizontalSize" + android:src="@drawable/me_go" + app:layout_constraintBottom_toTopOf="@+id/line_view" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintTop_toTopOf="parent" /> + android:layout_marginStart="@dimen/spaceHorizontalSize" + android:background="@color/cache_adapter_line_view" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintStart_toStartOf="parent" /> - \ No newline at end of file + \ No newline at end of file -- Gitee