diff --git a/common/src/main/java/com/yunbao/common/views/UpdateSexPopup.java b/common/src/main/java/com/yunbao/common/views/UpdateSexPopup.java new file mode 100644 index 000000000..ae8f1a7a9 --- /dev/null +++ b/common/src/main/java/com/yunbao/common/views/UpdateSexPopup.java @@ -0,0 +1,88 @@ +package com.yunbao.common.views; + +import android.content.Context; +import android.graphics.Color; +import android.widget.ImageView; +import android.widget.LinearLayout; +import android.widget.TextView; + +import androidx.annotation.NonNull; + +import com.lxj.xpopup.core.BottomPopupView; +import com.yunbao.common.R; +import com.yunbao.common.glide.ImgLoader; +import com.yunbao.common.views.weight.ViewClicksAntiShake; + +public class UpdateSexPopup extends BottomPopupView { + private int sex; + private LinearLayout linearMan, linearGirl; + private ImageView imageMan, imageGirl; + private TextView textMan, textGirl; + private UpdateSexCallBack callBack; + + public UpdateSexPopup(@NonNull Context context, int sex, UpdateSexCallBack callBack) { + super(context); + this.sex = sex; + this.callBack = callBack; + } + + // 返回自定义弹窗的布局 + @Override + protected int getImplLayoutId() { + return R.layout.view_update_sex_popup; + } + + // 执行初始化操作,比如:findView,设置点击,或者任何你弹窗内的业务逻辑 + @Override + protected void onCreate() { + super.onCreate(); + initView(); + } + + private void initView() { + linearMan = findViewById(R.id.linear_man); + imageMan = findViewById(R.id.image_man); + textMan = findViewById(R.id.text_man); + linearGirl = findViewById(R.id.linear_girl); + imageGirl = findViewById(R.id.image_girl); + textGirl = findViewById(R.id.text_girl); + if (sex == 0) { + ImgLoader.display(getContext(), R.mipmap.icon_male_default, imageMan); + ImgLoader.display(getContext(), R.mipmap.icon_female_default, imageGirl); + textMan.setTextColor(Color.parseColor("#999999")); + textGirl.setTextColor(Color.parseColor("#999999")); + } else if (sex == 1) { + ImgLoader.display(getContext(), R.mipmap.icon_male_highlighted, imageMan); + ImgLoader.display(getContext(), R.mipmap.icon_female_default, imageGirl); + textMan.setTextColor(Color.parseColor("#333333")); + textGirl.setTextColor(Color.parseColor("#999999")); + } else if (sex == 2) { + ImgLoader.display(getContext(), R.mipmap.icon_male_default, imageMan); + ImgLoader.display(getContext(), R.mipmap.icon_female_highlight, imageGirl); + textMan.setTextColor(Color.parseColor("#999999")); + textGirl.setTextColor(Color.parseColor("#333333")); + } + ViewClicksAntiShake.clicksAntiShake(linearMan, new ViewClicksAntiShake.ViewClicksCallBack() { + @Override + public void onViewClicks() { + dismiss(); + if (callBack != null) { + callBack.onSex(1); + } + } + }); + ViewClicksAntiShake.clicksAntiShake(linearGirl, new ViewClicksAntiShake.ViewClicksCallBack() { + @Override + public void onViewClicks() { + dismiss(); + if (callBack != null) { + callBack.onSex(2); + } + } + }); + } + + public interface UpdateSexCallBack { + void onSex(int sex); + } +} diff --git a/common/src/main/res/layout/view_update_sex_popup.xml b/common/src/main/res/layout/view_update_sex_popup.xml new file mode 100644 index 000000000..e4cabf867 --- /dev/null +++ b/common/src/main/res/layout/view_update_sex_popup.xml @@ -0,0 +1,59 @@ + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/main/src/main/res/mipmap-xxxhdpi/bg_gift_completely.png b/common/src/main/res/mipmap-xxhdpi/bg_gift_completely.png similarity index 100% rename from main/src/main/res/mipmap-xxxhdpi/bg_gift_completely.png rename to common/src/main/res/mipmap-xxhdpi/bg_gift_completely.png diff --git a/common/src/main/res/mipmap-xxhdpi/icon_female_default.png b/common/src/main/res/mipmap-xxhdpi/icon_female_default.png new file mode 100644 index 000000000..2a00a4293 Binary files /dev/null and b/common/src/main/res/mipmap-xxhdpi/icon_female_default.png differ diff --git a/common/src/main/res/mipmap-xxhdpi/icon_female_highlight.png b/common/src/main/res/mipmap-xxhdpi/icon_female_highlight.png new file mode 100644 index 000000000..36a708034 Binary files /dev/null and b/common/src/main/res/mipmap-xxhdpi/icon_female_highlight.png differ diff --git a/common/src/main/res/mipmap-xxhdpi/icon_male_default.png b/common/src/main/res/mipmap-xxhdpi/icon_male_default.png new file mode 100644 index 000000000..2d78ab3cf Binary files /dev/null and b/common/src/main/res/mipmap-xxhdpi/icon_male_default.png differ diff --git a/common/src/main/res/mipmap-xxhdpi/icon_male_highlighted.png b/common/src/main/res/mipmap-xxhdpi/icon_male_highlighted.png new file mode 100644 index 000000000..b7971d526 Binary files /dev/null and b/common/src/main/res/mipmap-xxhdpi/icon_male_highlighted.png differ diff --git a/common/src/main/res/values/strings.xml b/common/src/main/res/values/strings.xml index 18ff9e33d..bd29405c7 100644 --- a/common/src/main/res/values/strings.xml +++ b/common/src/main/res/values/strings.xml @@ -1155,4 +1155,6 @@ Limited ride And limited avatar frame 真愛粉\n頭像框(7天) 128金豆 真愛粉\n勛章(7天) + 男生 + 女生 diff --git a/main/src/main/java/com/yunbao/main/activity/BindUserActivity.java b/main/src/main/java/com/yunbao/main/activity/BindUserActivity.java index 7239c3144..6e9e513ef 100644 --- a/main/src/main/java/com/yunbao/main/activity/BindUserActivity.java +++ b/main/src/main/java/com/yunbao/main/activity/BindUserActivity.java @@ -34,10 +34,11 @@ import com.yunbao.common.activity.WebViewActivity; import com.yunbao.common.bean.UserBean; import com.yunbao.common.http.HttpCallback; import com.yunbao.common.interfaces.CommonCallback; +import com.yunbao.common.utils.Bus; import com.yunbao.common.utils.DialogUitl; import com.yunbao.common.utils.ToastUtil; -import com.yunbao.common.utils.WordUtil; import com.yunbao.main.R; +import com.yunbao.main.event.EditProfileEvent; import com.yunbao.main.event.RegSuccessEvent; import com.yunbao.main.http.MainHttpConsts; import com.yunbao.main.http.MainHttpUtil; @@ -73,7 +74,7 @@ public class BindUserActivity extends AbsActivity { private int mCountryCode = 852;//国家代码 private ImageView mIvCountryCode; private LinearLayout lt_now_bind, lt_give, lt_password, lt_password2; - private TextView tv_now_phone,tv_title; + private TextView tv_now_phone, tv_title; private Button btn_goto_updata; private String isBind = "0", mobile = ""; private WebView webview; @@ -107,8 +108,8 @@ public class BindUserActivity extends AbsActivity { btn_goto_updata = findViewById(R.id.btn_goto_updata); tv_title = findViewById(R.id.tv_title); - mGetCode =mContext.getString(R.string.reg_get_code); - mGetCodeAgain =mContext.getString(R.string.reg_get_code_again); + mGetCode = mContext.getString(R.string.reg_get_code); + mGetCodeAgain = mContext.getString(R.string.reg_get_code_again); mTvCountryCodeClick(); mEditPhone.addTextChangedListener(new TextWatcher() { @Override @@ -372,6 +373,7 @@ public class BindUserActivity extends AbsActivity { public void onSuccess(int code, String msg, String[] info) { ToastUtil.show(msg); if (code == 0) { + Bus.get().post(new EditProfileEvent()); finish(); } if (mDialog != null) { @@ -392,6 +394,7 @@ public class BindUserActivity extends AbsActivity { public void onSuccess(int code, String msg, String[] info) { ToastUtil.show(msg); if (code == 0) { + Bus.get().post(new EditProfileEvent()); finish(); } if (mDialog != null) { diff --git a/main/src/main/java/com/yunbao/main/activity/EditProfileActivity.java b/main/src/main/java/com/yunbao/main/activity/EditProfileActivity.java index 0cbe8a563..9afd10571 100644 --- a/main/src/main/java/com/yunbao/main/activity/EditProfileActivity.java +++ b/main/src/main/java/com/yunbao/main/activity/EditProfileActivity.java @@ -12,6 +12,7 @@ import android.widget.TextView; import com.alibaba.android.arouter.facade.annotation.Route; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; +import com.lxj.xpopup.XPopup; import com.sahooz.library.Country; import com.sahooz.library.CountryPicker; import com.sahooz.library.OnPick; @@ -29,17 +30,22 @@ import com.yunbao.common.http.HttpCallback; import com.yunbao.common.interfaces.ActivityResultCallback; import com.yunbao.common.interfaces.CommonCallback; import com.yunbao.common.interfaces.ImageResultCallback; +import com.yunbao.common.utils.Bus; import com.yunbao.common.utils.CityUtil; import com.yunbao.common.utils.DialogUitl; import com.yunbao.common.utils.ProcessImageUtil; import com.yunbao.common.utils.RouteUtil; import com.yunbao.common.utils.StringUtil; import com.yunbao.common.utils.ToastUtil; +import com.yunbao.common.views.UpdateSexPopup; import com.yunbao.main.R; +import com.yunbao.main.event.EditProfileEvent; import com.yunbao.main.http.MainHttpConsts; import com.yunbao.main.http.MainHttpUtil; import org.greenrobot.eventbus.EventBus; +import org.greenrobot.eventbus.Subscribe; +import org.greenrobot.eventbus.ThreadMode; import java.io.File; import java.util.ArrayList; @@ -72,8 +78,8 @@ public class EditProfileActivity extends AbsActivity { private String isBind = "0", mobile = ""; private boolean isName = false; private View viewProgress1, viewProgress2, viewProgress3; - private FrameLayout completeInformation1, completeInformation2, completeInformation3; - private TextView information1, information2, information3; + private FrameLayout completeInformation, completeInformation1, completeInformation2, completeInformation3; + private TextView information, information1, information2, information3, submit; @Override protected int getLayoutId() { @@ -82,6 +88,7 @@ public class EditProfileActivity extends AbsActivity { @Override protected void main() { + Bus.getOn(this); setTitle(mContext.getString(R.string.edit_profile)); mAvatar = (ImageView) findViewById(R.id.avatar); mName = (TextView) findViewById(R.id.name); @@ -93,12 +100,15 @@ public class EditProfileActivity extends AbsActivity { viewProgress1 = findViewById(R.id.view_progress1); viewProgress2 = findViewById(R.id.view_progress2); viewProgress3 = findViewById(R.id.view_progress3); + completeInformation = findViewById(R.id.complete_information); completeInformation1 = findViewById(R.id.complete_information1); completeInformation2 = findViewById(R.id.complete_information2); completeInformation3 = findViewById(R.id.complete_information3); + information = findViewById(R.id.information); information1 = findViewById(R.id.information1); information2 = findViewById(R.id.information2); information3 = findViewById(R.id.information3); + submit = findViewById(R.id.submit); mImageUtil = new ProcessImageUtil(this); mImageUtil.setImageResultCallback(new ImageResultCallback() { @Override @@ -204,8 +214,25 @@ public class EditProfileActivity extends AbsActivity { editBirthday(); } else if (i == R.id.btn_sex) { - forwardSex(); - +// forwardSex(); + new XPopup.Builder(mContext) + .asCustom(new UpdateSexPopup(mContext, userModel.getSex(), new UpdateSexPopup.UpdateSexCallBack() { + @Override + public void onSex(int sex) { + MainHttpUtil.updateFields("{\"sex\":\"" + sex + "\"}", new HttpCallback() { + @Override + public void onSuccess(int code, String msg, String[] info) { + if (code == 0 && info.length > 0) { + JSONObject obj = JSON.parseObject(info[0]); + ToastUtil.show(obj.getString("msg")); + userModel.setSex(sex); + showData(userModel); + } + } + }); + } + })) + .show(); } else if (i == R.id.btn_city) { CountryPicker.newInstance(null, new OnPick() { @Override @@ -221,6 +248,11 @@ public class EditProfileActivity extends AbsActivity { if (u != null) { u.setLocation(country.name); } + if (userModel != null) { + userModel.setLocation(country.name); + } + + showData(userModel); EventBus.getDefault().post(new UpdateFieldEvent()); } ToastUtil.show(obj.getString("msg")); @@ -333,6 +365,12 @@ public class EditProfileActivity extends AbsActivity { ToastUtil.show(JSON.parseObject(info[0]).getString("msg")); mUserBean.setBirthday(date); mBirthday.setText(date); + + if (userModel != null) { + userModel.setBirthday(date); + } + + showData(userModel); EventBus.getDefault().post(new UpdateFieldEvent()); } } else { @@ -371,6 +409,7 @@ public class EditProfileActivity extends AbsActivity { @Override protected void onDestroy() { + Bus.getOff(this); if (mImageUtil != null) { mImageUtil.release(); } @@ -379,11 +418,30 @@ public class EditProfileActivity extends AbsActivity { super.onDestroy(); } + @Subscribe(threadMode = ThreadMode.MAIN) + public void onEditProfileEvent(EditProfileEvent event) { + MainHttpUtil.getBaseInfo(new CommonCallback() { + @Override + public void callback(UserBean u) { + showData(u); + } + }); + } + + private UserBean userModel; + private void showData(UserBean u) { + userModel = u; int index = 0; String birthday = u.getBirthday(); String location = u.getLocation(); String bindPhone = u.getMobile(); + String sex = ""; + if (u.getSex() == 1) { + sex = mContext.getString(R.string.sex_male); + } else if (u.getSex() == 2) { + sex = mContext.getString(R.string.sex_female); + } if (!TextUtils.isEmpty(bindPhone)) { index = index + 1; } @@ -393,59 +451,99 @@ public class EditProfileActivity extends AbsActivity { if (!TextUtils.isEmpty(birthday)) { index = index + 1; } + if (!TextUtils.isEmpty(sex)) { + index = index + 1; + } if (index == 0) { + completeInformation.setBackgroundResource(R.mipmap.bg_complete_information_progress); completeInformation1.setBackgroundResource(R.mipmap.bg_complete_information_progress); completeInformation2.setBackgroundResource(R.mipmap.bg_complete_information_progress); completeInformation3.setBackgroundResource(R.mipmap.bg_complete_information_progress); - information1.setVisibility(View.INVISIBLE); - information2.setVisibility(View.INVISIBLE); - information3.setVisibility(View.INVISIBLE); + information.setVisibility(View.VISIBLE); + information1.setVisibility(View.VISIBLE); + information2.setVisibility(View.VISIBLE); + information3.setVisibility(View.VISIBLE); viewProgress1.setBackgroundColor(Color.parseColor("#DEE4F1")); viewProgress2.setBackgroundColor(Color.parseColor("#DEE4F1")); viewProgress3.setBackgroundColor(Color.parseColor("#DEE4F1")); + submit.setText(R.string.to_complete); + submit.setTextColor(Color.parseColor("#ffffff")); } else if (index == 1) { + completeInformation.setBackgroundResource(R.mipmap.bg_complete_information_progress2); + completeInformation1.setBackgroundResource(R.mipmap.bg_complete_information_progress); + completeInformation2.setBackgroundResource(R.mipmap.bg_complete_information_progress); + completeInformation3.setBackgroundResource(R.mipmap.bg_complete_information_progress); + information.setVisibility(View.INVISIBLE); + information1.setVisibility(View.VISIBLE); + information2.setVisibility(View.VISIBLE); + information3.setVisibility(View.VISIBLE); + viewProgress1.setBackgroundColor(Color.parseColor("#DEE4F1")); + viewProgress2.setBackgroundColor(Color.parseColor("#DEE4F1")); + viewProgress3.setBackgroundColor(Color.parseColor("#DEE4F1")); + submit.setText(R.string.to_complete); + submit.setTextColor(Color.parseColor("#ffffff")); + } else if (index == 2) { + information.setVisibility(View.INVISIBLE); information1.setVisibility(View.INVISIBLE); information2.setVisibility(View.VISIBLE); information3.setVisibility(View.VISIBLE); completeInformation1.setBackgroundResource(R.mipmap.bg_complete_information_progress2); + completeInformation.setBackgroundResource(R.mipmap.bg_complete_information_progress2); completeInformation2.setBackgroundResource(R.mipmap.bg_complete_information_progress); completeInformation3.setBackgroundResource(R.mipmap.bg_complete_information_progress); viewProgress1.setBackgroundColor(Color.parseColor("#FFE5D0")); viewProgress2.setBackgroundColor(Color.parseColor("#DEE4F1")); viewProgress3.setBackgroundColor(Color.parseColor("#DEE4F1")); - } else if (index == 2) { + submit.setText(R.string.to_complete); + submit.setTextColor(Color.parseColor("#ffffff")); + } else if (index == 3) { + information.setVisibility(View.INVISIBLE); information1.setVisibility(View.INVISIBLE); information2.setVisibility(View.INVISIBLE); information3.setVisibility(View.VISIBLE); + completeInformation.setBackgroundResource(R.mipmap.bg_complete_information_progress2); completeInformation1.setBackgroundResource(R.mipmap.bg_complete_information_progress2); completeInformation2.setBackgroundResource(R.mipmap.bg_complete_information_progress2); completeInformation3.setBackgroundResource(R.mipmap.bg_complete_information_progress); viewProgress1.setBackgroundColor(Color.parseColor("#FFE5D0")); viewProgress2.setBackgroundColor(Color.parseColor("#FFE5D0")); viewProgress3.setBackgroundColor(Color.parseColor("#DEE4F1")); - } else if (index == 3) { + submit.setText(R.string.to_complete); + submit.setTextColor(Color.parseColor("#ffffff")); + } else if (index == 4) { + information.setVisibility(View.INVISIBLE); information1.setVisibility(View.INVISIBLE); information2.setVisibility(View.INVISIBLE); information3.setVisibility(View.INVISIBLE); + completeInformation.setBackgroundResource(R.mipmap.bg_complete_information_progress2); completeInformation1.setBackgroundResource(R.mipmap.bg_complete_information_progress2); completeInformation2.setBackgroundResource(R.mipmap.bg_complete_information_progress2); completeInformation3.setBackgroundResource(R.mipmap.bg_complete_information_progress2); viewProgress1.setBackgroundColor(Color.parseColor("#FFE5D0")); viewProgress2.setBackgroundColor(Color.parseColor("#FFE5D0")); viewProgress3.setBackgroundColor(Color.parseColor("#FFE5D0")); + submit.setText(R.string.to_receive); + submit.setTextColor(Color.parseColor("#935902")); } ImgLoader.displayAvatar(mContext, u.getAvatar(), mAvatar); mName.setText(u.getUserNiceName()); mSign.setText(u.getSignature()); mBirthday.setText(u.getBirthday()); - mSex.setText(u.getSex() == 1 ? R.string.sex_male : R.string.sex_female); + if (u.getSex() == 0) { + mSex.setText(""); + } else if (u.getSex() == 1) { + mSex.setText(R.string.sex_male); + } else if (u.getSex() == 2) { + mSex.setText(R.string.sex_female); + } + mCity.setText(u.getLocation()); if ("1".equals(u.getIs_bind())) { mobile = u.getMobile(); tv_bind_phone.setText(mobile); isBind = "1"; } else { - tv_bind_phone.setText(getResources().getString(R.string.bind_phone_text)); + tv_bind_phone.setHint(getResources().getString(R.string.bind_phone_text)); isBind = "0"; } } @@ -537,7 +635,7 @@ public class EditProfileActivity extends AbsActivity { tv_bind_phone.setText(mobile); isBind = "1"; } else { - tv_bind_phone.setText(getResources().getString(R.string.bind_phone_text)); + tv_bind_phone.setHint(getResources().getString(R.string.bind_phone_text)); isBind = "0"; } } diff --git a/main/src/main/java/com/yunbao/main/event/EditProfileEvent.java b/main/src/main/java/com/yunbao/main/event/EditProfileEvent.java new file mode 100644 index 000000000..f04167c71 --- /dev/null +++ b/main/src/main/java/com/yunbao/main/event/EditProfileEvent.java @@ -0,0 +1,6 @@ +package com.yunbao.main.event; + +import com.yunbao.common.bean.BaseModel; + +public class EditProfileEvent extends BaseModel { +} diff --git a/main/src/main/res/layout/activity_edit_profile.xml b/main/src/main/res/layout/activity_edit_profile.xml index 5650af791..7cfa48adc 100644 --- a/main/src/main/res/layout/activity_edit_profile.xml +++ b/main/src/main/res/layout/activity_edit_profile.xml @@ -314,7 +314,7 @@ android:ellipsize="end" android:gravity="right" android:singleLine="true" - android:text="@string/bind_phone_text" + android:hint="@string/bind_phone_text" android:textColor="#353535" android:textSize="14sp" android:textStyle="bold" /> @@ -413,10 +413,19 @@ + + \ No newline at end of file diff --git a/main/src/main/res/mipmap-xxxhdpi/bg_submit.png b/main/src/main/res/mipmap-xxxhdpi/bg_submit.png new file mode 100644 index 000000000..50de73868 Binary files /dev/null and b/main/src/main/res/mipmap-xxxhdpi/bg_submit.png differ