完善个人资料,选择性别弹窗构建

This commit is contained in:
18401019693
2023-05-11 10:26:05 +08:00
parent 73b075b2a7
commit 8410439a90
13 changed files with 294 additions and 17 deletions

View File

@@ -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);
}
}