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

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

View File

@@ -0,0 +1,59 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="213.5dp"
android:background="@mipmap/bg_gift_completely"
android:orientation="horizontal">
<LinearLayout
android:id="@+id/linear_man"
android:layout_width="0dp"
android:background="?android:attr/selectableItemBackground"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center"
android:orientation="vertical">
<ImageView
android:id="@+id/image_man"
android:layout_width="50dp"
android:layout_height="50dp"
android:src="@mipmap/icon_male_highlighted" />
<TextView
android:id="@+id/text_man"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="9.5dp"
android:text="@string/man_student"
android:textColor="#333333"
android:textSize="13sp" />
</LinearLayout>
<LinearLayout
android:id="@+id/linear_girl"
android:layout_width="0dp"
android:background="?android:attr/selectableItemBackground"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center"
android:orientation="vertical">
<ImageView
android:id="@+id/image_girl"
android:layout_width="50dp"
android:layout_height="50dp"
android:src="@mipmap/icon_female_highlight" />
<TextView
android:id="@+id/text_girl"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="9.5dp"
android:text="@string/girl_student"
android:textColor="#333333"
android:textSize="13sp" />
</LinearLayout>
</LinearLayout>

Binary file not shown.

After

Width:  |  Height:  |  Size: 32 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

View File

@@ -1155,4 +1155,6 @@ Limited ride And limited avatar frame</string>
<string name="love_powder">真愛粉\n頭像框(7天)</string>
<string name="golden_beans_128">128金豆</string>
<string name="love_powder_medal">真愛粉\n勛章(7天)</string>
<string name="man_student">男生</string>
<string name="girl_student">女生</string>
</resources>