add 编辑资料-职业、身高、爱好

This commit is contained in:
zlzw 2024-03-20 11:03:29 +08:00
parent 3127a5faaf
commit 938bee4fdb
24 changed files with 1473 additions and 577 deletions

View File

@ -0,0 +1,76 @@
package com.yunbao.common.bean;
import com.google.gson.annotations.SerializedName;
import java.util.List;
public class CareerBean extends BaseModel {
int id;
int pid;
@SerializedName("cn_title")
String titleCn;
@SerializedName("en_title")
String titleEn;
@SerializedName("create_time")
long createTime;
@SerializedName("uplong_time")
long uplongTime;
@SerializedName("children")
List<CareerBean> children;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public int getPid() {
return pid;
}
public void setPid(int pid) {
this.pid = pid;
}
public String getTitleCn() {
return titleCn;
}
public void setTitleCn(String titleCn) {
this.titleCn = titleCn;
}
public String getTitleEn() {
return titleEn;
}
public void setTitleEn(String titleEn) {
this.titleEn = titleEn;
}
public long getCreateTime() {
return createTime;
}
public void setCreateTime(long createTime) {
this.createTime = createTime;
}
public long getUplongTime() {
return uplongTime;
}
public void setUplongTime(long uplongTime) {
this.uplongTime = uplongTime;
}
public List<CareerBean> getChildren() {
return children;
}
public void setChildren(List<CareerBean> children) {
this.children = children;
}
}

View File

@ -10,6 +10,7 @@ import com.yunbao.common.bean.BattlePassPoints;
import com.yunbao.common.bean.BattlePassTask; import com.yunbao.common.bean.BattlePassTask;
import com.yunbao.common.bean.BattlePassUserInfoBean; import com.yunbao.common.bean.BattlePassUserInfoBean;
import com.yunbao.common.bean.BlindBoxInfoModel; import com.yunbao.common.bean.BlindBoxInfoModel;
import com.yunbao.common.bean.CareerBean;
import com.yunbao.common.bean.CheckLiveModel; import com.yunbao.common.bean.CheckLiveModel;
import com.yunbao.common.bean.CheckRemainingBalance; import com.yunbao.common.bean.CheckRemainingBalance;
import com.yunbao.common.bean.ContributeModel; import com.yunbao.common.bean.ContributeModel;
@ -1267,4 +1268,24 @@ public interface PDLiveApi {
@GET("/api/public/?service=Pdluserhome.getUserHomeInfo") @GET("/api/public/?service=Pdluserhome.getUserHomeInfo")
Observable<ResponseModel<HomeUserExhibitInfoBean>> getUserHomeExhibitInfo(@Query("select_uid") String tuid); Observable<ResponseModel<HomeUserExhibitInfoBean>> getUserHomeExhibitInfo(@Query("select_uid") String tuid);
@GET("/api/public/?service=Pdlinfos.getCareer")
Observable<ResponseModel<List<CareerBean>>> getCareer();
@GET("/api/public/?service=Pdlinfos.setCareer")
Observable<ResponseModel<List<BaseModel>>> setCareer(
@Query("career") String career,
@Query("en_career") String en
);
@GET("/api/public/?service=Pdlinfos.setHeight")
Observable<ResponseModel<List<BaseModel>>> setUserHeight(
@Query("height") String height
);
@GET("/api/public/?service=Pdllable.get")
Observable<ResponseModel<List<CareerBean>>> getHobby();
@GET("/api/public/?service=Pdlinfos.setLabel")
Observable<ResponseModel<List<BaseModel>>> setHobby(
@Query("labels") String labelsId
);
} }

View File

@ -15,6 +15,7 @@ import com.yunbao.common.bean.BattlePassPoints;
import com.yunbao.common.bean.BattlePassTask; import com.yunbao.common.bean.BattlePassTask;
import com.yunbao.common.bean.BattlePassUserInfoBean; import com.yunbao.common.bean.BattlePassUserInfoBean;
import com.yunbao.common.bean.BlindBoxInfoModel; import com.yunbao.common.bean.BlindBoxInfoModel;
import com.yunbao.common.bean.CareerBean;
import com.yunbao.common.bean.CheckLiveModel; import com.yunbao.common.bean.CheckLiveModel;
import com.yunbao.common.bean.CheckRemainingBalance; import com.yunbao.common.bean.CheckRemainingBalance;
import com.yunbao.common.bean.CoolConfig; import com.yunbao.common.bean.CoolConfig;
@ -3381,7 +3382,101 @@ public class LiveNetManager {
} }
}).isDisposed(); }).isDisposed();
} }
public void getCareer(HttpCallback<List<CareerBean>> callback) {
API.get().pdLiveApi(mContext)
.getCareer()
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(roomMicStatusModelResponseModel -> {
if (callback != null) {
callback.onSuccess(roomMicStatusModelResponseModel.getData().getInfo());
}
}, new Consumer<Throwable>() {
@Override
public void accept(Throwable throwable) throws Exception {
throwable.printStackTrace();
if (callback != null) {
callback.onError(mContext.getString(R.string.net_error));
}
}
}).isDisposed();
}
public void setCareer(String career,String careerEn, HttpCallback<HttpCallbackModel> callback) {
API.get().pdLiveApi(mContext)
.setCareer(career,careerEn)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(listResponseModel -> {
if (callback != null) {
callback.onSuccess(new HttpCallbackModel(listResponseModel.getData().getCode(), listResponseModel.getData().getMsg()));
}
}, new Consumer<Throwable>() {
@Override
public void accept(Throwable throwable) throws Exception {
throwable.printStackTrace();
if (callback != null) {
callback.onError(mContext.getString(R.string.net_error));
}
}
}).isDisposed();
}
public void setUserHeight(String height, HttpCallback<HttpCallbackModel> callback) {
API.get().pdLiveApi(mContext)
.setUserHeight(height)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(listResponseModel -> {
if (callback != null) {
callback.onSuccess(new HttpCallbackModel(listResponseModel.getData().getCode(), listResponseModel.getData().getMsg()));
}
}, new Consumer<Throwable>() {
@Override
public void accept(Throwable throwable) throws Exception {
throwable.printStackTrace();
if (callback != null) {
callback.onError(mContext.getString(R.string.net_error));
}
}
}).isDisposed();
}
public void getHobby(HttpCallback<List<CareerBean>> callback) {
API.get().pdLiveApi(mContext)
.getHobby()
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(roomMicStatusModelResponseModel -> {
if (callback != null) {
callback.onSuccess(roomMicStatusModelResponseModel.getData().getInfo());
}
}, new Consumer<Throwable>() {
@Override
public void accept(Throwable throwable) throws Exception {
throwable.printStackTrace();
if (callback != null) {
callback.onError(mContext.getString(R.string.net_error));
}
}
}).isDisposed();
}
public void setHobby(String ids, HttpCallback<HttpCallbackModel> callback) {
API.get().pdLiveApi(mContext)
.setHobby(ids)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(listResponseModel -> {
if (callback != null) {
callback.onSuccess(new HttpCallbackModel(listResponseModel.getData().getCode(), listResponseModel.getData().getMsg()));
}
}, new Consumer<Throwable>() {
@Override
public void accept(Throwable throwable) throws Exception {
throwable.printStackTrace();
if (callback != null) {
callback.onError(mContext.getString(R.string.net_error));
}
}
}).isDisposed();
}
private MultipartBody.Part createUploadFile(File file) { private MultipartBody.Part createUploadFile(File file) {
RequestBody requestBody = RequestBody.create(MediaType.parse("multipart/form-data"), file); RequestBody requestBody = RequestBody.create(MediaType.parse("multipart/form-data"), file);
return MultipartBody.Part.createFormData("file", file.getName(), requestBody); return MultipartBody.Part.createFormData("file", file.getName(), requestBody);

View File

@ -0,0 +1,69 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="72dp"
android:paddingTop="24dp">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@+id/titleView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_centerHorizontal="true"
android:gravity="center"
android:textColor="@color/textColor"
android:textSize="18sp"
android:textStyle="bold" />
<ImageView
android:id="@+id/btn_back"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_centerVertical="true"
android:onClick="backClick"
android:padding="9dp"
android:src="@mipmap/icon_back"
android:tint="@color/textColor" />
<ImageView
android:id="@+id/img_more"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:padding="9dp"
android:src="@mipmap/btn_more_black"
android:tint="@color/textColor"
android:visibility="gone" />
<TextView
android:id="@+id/rView"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_toLeftOf="@+id/redPacketMain"
android:layout_marginRight="10dp"
android:gravity="center"
android:textColor="@color/textColor"
android:textSize="13sp"
android:textStyle="bold"
android:text="@string/not_received"
android:visibility="gone"
tools:visibility="visible" />
<ImageView
android:id="@+id/redPacketMain"
android:layout_width="20dp"
android:layout_height="match_parent"
android:layout_alignParentRight="true"
android:layout_marginRight="15dp"
android:visibility="invisible"
app:srcCompat="@mipmap/ic_red_packet_record"
tools:visibility="visible" />
</RelativeLayout>
</FrameLayout>

View File

@ -98,6 +98,13 @@
<item name="android:paddingRight">15dp</item> <item name="android:paddingRight">15dp</item>
<item name="android:background">@color/white</item> <item name="android:background">@color/white</item>
</style> </style>
<style name="edit_profile_group_not_color" parent="AppTheme">
<item name="android:layout_width">match_parent</item>
<item name="android:layout_height">45dp</item>
<item name="android:paddingLeft">15dp</item>
<item name="android:paddingRight">15dp</item>
</style>
<style name="Theme.PayssionTrans" parent="Theme.AppCompat.Light"> <style name="Theme.PayssionTrans" parent="Theme.AppCompat.Light">
<item name="android:windowIsTranslucent">true</item> <item name="android:windowIsTranslucent">true</item>

View File

@ -170,6 +170,7 @@
android:screenOrientation="portrait" /> android:screenOrientation="portrait" />
<activity android:name=".activity.CompleteUserInfoActivity" <activity android:name=".activity.CompleteUserInfoActivity"
android:screenOrientation="portrait" /> android:screenOrientation="portrait" />
<activity android:name=".activity.EditUserHobbyActivity" android:screenOrientation="portrait" />
</application> </application>
</manifest> </manifest>

View File

@ -13,6 +13,10 @@ import android.widget.TextView;
import com.alibaba.android.arouter.facade.annotation.Route; import com.alibaba.android.arouter.facade.annotation.Route;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.bigkoo.pickerview.builder.OptionsPickerBuilder;
import com.bigkoo.pickerview.configure.PickerOptions;
import com.bigkoo.pickerview.listener.OnOptionsSelectListener;
import com.bigkoo.pickerview.view.OptionsPickerView;
import com.lxj.xpopup.XPopup; import com.lxj.xpopup.XPopup;
import com.lxj.xpopup.core.BasePopupView; import com.lxj.xpopup.core.BasePopupView;
import com.lxj.xpopup.interfaces.XPopupCallback; import com.lxj.xpopup.interfaces.XPopupCallback;
@ -27,6 +31,9 @@ import com.yunbao.common.CommonAppConfig;
import com.yunbao.common.Constants; import com.yunbao.common.Constants;
import com.yunbao.common.activity.AbsActivity; import com.yunbao.common.activity.AbsActivity;
import com.yunbao.common.activity.WebViewActivity; import com.yunbao.common.activity.WebViewActivity;
import com.yunbao.common.bean.CareerBean;
import com.yunbao.common.bean.HttpCallbackModel;
import com.yunbao.common.bean.MessageUserInfoBean;
import com.yunbao.common.bean.UserBean; import com.yunbao.common.bean.UserBean;
import com.yunbao.common.event.UpdateFieldEvent; import com.yunbao.common.event.UpdateFieldEvent;
import com.yunbao.common.glide.ImgLoader; import com.yunbao.common.glide.ImgLoader;
@ -59,6 +66,8 @@ import org.greenrobot.eventbus.ThreadMode;
import java.io.File; import java.io.File;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import cn.qqtheme.framework.entity.City; import cn.qqtheme.framework.entity.City;
import cn.qqtheme.framework.entity.County; import cn.qqtheme.framework.entity.County;
@ -90,6 +99,7 @@ public class EditProfileActivity extends AbsActivity {
private View viewProgress1, viewProgress2, viewProgress3; private View viewProgress1, viewProgress2, viewProgress3;
private FrameLayout completeInformation, completeInformation1, completeInformation2, completeInformation3; private FrameLayout completeInformation, completeInformation1, completeInformation2, completeInformation3;
private TextView information, information1, information2, information3, submit; private TextView information, information1, information2, information3, submit;
private MessageUserInfoBean userInfoBean;
@Override @Override
protected int getLayoutId() { protected int getLayoutId() {
@ -130,10 +140,10 @@ public class EditProfileActivity extends AbsActivity {
public void onSuccess(File file) { public void onSuccess(File file) {
if (file != null) { if (file != null) {
System.err.println("头像---->收到头像文件 file = "+file.getAbsolutePath()+" | length = "+file.length()); System.err.println("头像---->收到头像文件 file = " + file.getAbsolutePath() + " | length = " + file.length());
if (file.getName().contains(".gif")){ if (file.getName().contains(".gif")) {
ToastUtil.show(WordUtil.isNewZh()?"暫不支持該文件":"This file is not supported"); ToastUtil.show(WordUtil.isNewZh() ? "暫不支持該文件" : "This file is not supported");
}else { } else {
ImgLoader.display(mContext, file, mAvatar); ImgLoader.display(mContext, file, mAvatar);
MainHttpUtil.updateAvatar(file, new HttpCallback() { MainHttpUtil.updateAvatar(file, new HttpCallback() {
@Override @Override
@ -185,12 +195,14 @@ public class EditProfileActivity extends AbsActivity {
mUserBean = CommonAppConfig.getInstance().getUserBean(); mUserBean = CommonAppConfig.getInstance().getUserBean();
if (mUserBean != null) { if (mUserBean != null) {
showData(mUserBean); showData(mUserBean);
initUserInfoData();
} else { } else {
MainHttpUtil.getBaseInfo(new CommonCallback<UserBean>() { MainHttpUtil.getBaseInfo(new CommonCallback<UserBean>() {
@Override @Override
public void callback(UserBean u) { public void callback(UserBean u) {
mUserBean = u; mUserBean = u;
showData(u); showData(u);
initUserInfoData();
} }
}); });
} }
@ -399,9 +411,102 @@ public class EditProfileActivity extends AbsActivity {
.putExtra("token", CommonAppConfig.getInstance().getToken()) .putExtra("token", CommonAppConfig.getInstance().getToken())
.putExtra("isBind", isBind) .putExtra("isBind", isBind)
.putExtra("mobile", mobile)); .putExtra("mobile", mobile));
} else if (i == R.id.btn_occupation) {
showOccupationDialog();
} else if (i == R.id.btn_height) {
showUserHeightDialog();
} else if (i == R.id.btn_hobby) {
startActivity(new Intent(this, EditUserHobbyActivity.class));
} }
} }
List<CareerBean> careerBeans;
private void showOccupationDialog() {
LiveNetManager.get(mContext)
.getCareer(new com.yunbao.common.http.base.HttpCallback<List<CareerBean>>() {
@Override
public void onSuccess(List<CareerBean> data) {
careerBeans = new ArrayList<>(data);
List<String> items1 = new ArrayList<>();
List<List<String>> items2 = new ArrayList<>();
for (CareerBean bean : data) {
items1.add(WordUtil.isNewZh() ? bean.getTitleCn() : bean.getTitleEn());
List<String> tmp = new ArrayList<>();
for (CareerBean child : bean.getChildren()) {
tmp.add(WordUtil.isNewZh() ? child.getTitleCn() : child.getTitleEn());
}
items2.add(tmp);
}
OptionsPickerView<String> pickerView = new OptionsPickerBuilder(mContext, new OnOptionsSelectListener() {
@Override
public void onOptionsSelect(int i, int i1, int i2, View view) {
CareerBean val = careerBeans.get(i).getChildren().get(i1);
setOccupation(val.getTitleCn(), val.getTitleEn());
}
private void setOccupation(String cn, String en) {
LiveNetManager.get(mContext)
.setCareer(cn, en, new com.yunbao.common.http.base.HttpCallback<HttpCallbackModel>() {
@Override
public void onSuccess(HttpCallbackModel data) {
ToastUtil.show(data.getMsg());
((TextView) findViewById(R.id.occupation)).setText(WordUtil.isNewZh() ? cn : en);
}
@Override
public void onError(String error) {
ToastUtil.show(error);
}
});
}
}).build();
pickerView.setPicker(items1, items2);
pickerView.show();
}
@Override
public void onError(String error) {
ToastUtil.show(error);
}
});
}
private void showUserHeightDialog() {
List<String> height = new ArrayList<>();
for (int i = 50; i <= 250; i++) {
height.add(i + "cm");
}
OptionsPickerView<String> pickerView = new OptionsPickerBuilder(mContext, new OnOptionsSelectListener() {
@Override
public void onOptionsSelect(int i, int i1, int i2, View view) {
String height = (i + 50) + "";
setUserHeight(height);
}
private void setUserHeight(String height) {
LiveNetManager.get(mContext)
.setUserHeight(height, new com.yunbao.common.http.base.HttpCallback<HttpCallbackModel>() {
@Override
public void onSuccess(HttpCallbackModel data) {
ToastUtil.show(data.getMsg());
((TextView) findViewById(R.id.height)).setText(height + "cm");
}
@Override
public void onError(String error) {
ToastUtil.show(error);
}
});
}
}).setSelectOptions(120)
.build();
pickerView.setPicker(height);
pickerView.show();
}
private void showTaskDialog() { private void showTaskDialog() {
final Dialog dialog = new Dialog(EditProfileActivity.this, com.yunbao.live.R.style.dialog); final Dialog dialog = new Dialog(EditProfileActivity.this, com.yunbao.live.R.style.dialog);
dialog.setContentView(R.layout.dialog_task); dialog.setContentView(R.layout.dialog_task);
@ -418,7 +523,7 @@ public class EditProfileActivity extends AbsActivity {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
String url = CommonAppConfig.HOST + "/index.php?g=Appapi&m=task&a=index&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&tabIndex=1"; String url = CommonAppConfig.HOST + "/index.php?g=Appapi&m=task&a=index&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&tabIndex=1";
WebViewActivity.forward(mContext, url,false); WebViewActivity.forward(mContext, url, false);
dialog.dismiss(); dialog.dismiss();
} }
}); });
@ -453,7 +558,7 @@ public class EditProfileActivity extends AbsActivity {
} }
Constants.myIntoIndex = 2; Constants.myIntoIndex = 2;
Intent intent = new Intent(mContext, MyWebViewActivity2.class); Intent intent = new Intent(mContext, MyWebViewActivity2.class);
intent.putExtra(Constants.URL, CommonAppConfig.HOST + "/h5/table/Modify-information.html" + "?token=" + CommonAppConfig.getInstance().getToken() + "&uid=" + CommonAppConfig.getInstance().getUid()+ "&isZh=" + (WordUtil.isNewZh() ? "1" : 0)); intent.putExtra(Constants.URL, CommonAppConfig.HOST + "/h5/table/Modify-information.html" + "?token=" + CommonAppConfig.getInstance().getToken() + "&uid=" + CommonAppConfig.getInstance().getUid() + "&isZh=" + (WordUtil.isNewZh() ? "1" : 0));
startActivity(intent); startActivity(intent);
} }
@ -767,12 +872,37 @@ public class EditProfileActivity extends AbsActivity {
}); });
} }
private void initUserInfoData() {
LiveNetManager.get(mContext)
.getOtherInfo(userModel.getId() + "", new com.yunbao.common.http.base.HttpCallback<MessageUserInfoBean>() {
@Override
public void onSuccess(MessageUserInfoBean data) {
userInfoBean = data;
((TextView) findViewById(R.id.occupation)).setText(data.getInfo().getCareer());
((TextView) findViewById(R.id.height)).setText(data.getInfo().getHeight() + "cm");
List<String> tags = WordUtil.isNewZh() ? data.getInfo().getCn_label() : data.getInfo().getEn_label();
if (tags == null || tags.isEmpty()) return;
StringBuilder sb = new StringBuilder();
for (String tag : tags) {
sb.append(tag).append(",");
}
((TextView) findViewById(R.id.hobby)).setText(sb.substring(0, sb.length() - 1));
}
@Override
public void onError(String error) {
}
});
}
@Override @Override
protected void onResume() { protected void onResume() {
super.onResume(); super.onResume();
if (Constants.isShowPage != -1) { if (Constants.isShowPage != -1) {
finish(); finish();
} }
initUserInfoData();
MainHttpUtil.getBaseInfo(new CommonCallback<UserBean>() { MainHttpUtil.getBaseInfo(new CommonCallback<UserBean>() {
@Override @Override
public void callback(UserBean u) { public void callback(UserBean u) {

View File

@ -0,0 +1,126 @@
package com.yunbao.main.activity;
import android.widget.Button;
import android.widget.TextView;
import androidx.recyclerview.widget.RecyclerView;
import com.alibaba.fastjson.JSONArray;
import com.yunbao.common.CommonAppConfig;
import com.yunbao.common.activity.AbsActivity;
import com.yunbao.common.bean.CareerBean;
import com.yunbao.common.bean.HttpCallbackModel;
import com.yunbao.common.bean.MessageUserInfoBean;
import com.yunbao.common.http.base.HttpCallback;
import com.yunbao.common.http.live.LiveNetManager;
import com.yunbao.common.interfaces.OnItemClickListener;
import com.yunbao.common.utils.StringUtil;
import com.yunbao.common.utils.ToastUtil;
import com.yunbao.common.utils.WordUtil;
import com.yunbao.main.R;
import com.yunbao.main.adapter.EditUserHobbyAdapter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
public class EditUserHobbyActivity extends AbsActivity {
TextView mNumber;
RecyclerView recyclerView;
EditUserHobbyAdapter adapter;
Button mSave, mCancel;
@Override
protected int getLayoutId() {
return R.layout.activity_edit_user_hobby;
}
@Override
protected void main() {
super.main();
mNumber = findViewById(R.id.number);
recyclerView = findViewById(R.id.recyclerView);
mSave = findViewById(R.id.btn_save);
mCancel = findViewById(R.id.btn_cancel);
adapter = new EditUserHobbyAdapter();
recyclerView.setAdapter(adapter);
adapter.setOnItemClickListener(new OnItemClickListener<List<String>>() {
@Override
public void onItemClick(List<String> bean, int position) {
mNumber.setText(String.format("(%s/%s)", position, "5"));
System.out.println(JSONArray.toJSONString(bean));
}
});
initData();
mCancel.setOnClickListener(view -> {
finish();
});
mSave.setOnClickListener(view -> {
List<String> strings = adapter.getmSelectedList();
uploadSelectData(strings);
});
}
private void uploadSelectData(List<String> strings) {
StringBuilder sb = new StringBuilder();
String hobby = "";
for (String tag : strings) {
if (!StringUtil.isEmpty(tag)) {
sb.append(tag).append(",");
}
}
if (sb.length() != 0) {
hobby = sb.substring(0, sb.length() - 1);
}
LiveNetManager.get(mContext)
.setHobby(hobby, new HttpCallback<HttpCallbackModel>() {
@Override
public void onSuccess(HttpCallbackModel data) {
ToastUtil.show(data.getMsg());
finish();
}
@Override
public void onError(String error) {
ToastUtil.show(error);
}
});
}
private void initData() {
LiveNetManager.get(mContext)
.getHobby(new HttpCallback<List<CareerBean>>() {
@Override
public void onSuccess(List<CareerBean> data) {
adapter.setHobbyData(data);
adapter.notifyDataSetChanged();
}
@Override
public void onError(String error) {
}
});
LiveNetManager.get(mContext)
.getOtherInfo(CommonAppConfig.getInstance().getUid(), new HttpCallback<MessageUserInfoBean>() {
@Override
public void onSuccess(MessageUserInfoBean data) {
String labelIds = data.getInfo().getLabel_id();
if (StringUtil.isEmpty(labelIds)) {
adapter.setSelectData(new ArrayList<>());
return;
}
List<String> list = new ArrayList<>(Arrays.asList(labelIds.split(",")));
mNumber.setText(String.format("(%s/%s)", list.size(), "5"));
adapter.setSelectData(list);
adapter.notifyDataSetChanged();
}
@Override
public void onError(String error) {
}
});
}
}

View File

@ -0,0 +1,86 @@
package com.yunbao.main.adapter;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import com.yunbao.common.bean.CareerBean;
import com.yunbao.common.interfaces.OnItemClickListener;
import com.yunbao.common.utils.WordUtil;
import com.yunbao.main.R;
import java.util.ArrayList;
import java.util.List;
public class EditUserHobbyAdapter extends RecyclerView.Adapter<EditUserHobbyAdapter.ViewHolder> {
List<CareerBean> mList = new ArrayList<>();
List<String> mSelectedList = new ArrayList<>();
OnItemClickListener<List<String>> onItemClickListener;
@NonNull
@Override
public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
return new ViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.item_edit_user_hobby, parent, false));
}
@Override
public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
holder.setData(mList.get(position), position);
}
public void setOnItemClickListener(OnItemClickListener<List<String>> onItemClickListener) {
this.onItemClickListener = onItemClickListener;
}
@Override
public int getItemCount() {
return mList.size();
}
public void setSelectData(List<String> list) {
mSelectedList = list;
}
public List<String> getmSelectedList() {
return mSelectedList;
}
public void setHobbyData(List<CareerBean> data) {
mList = data;
}
public class ViewHolder extends RecyclerView.ViewHolder {
Button button;
public ViewHolder(@NonNull View itemView) {
super(itemView);
button = itemView.findViewById(R.id.btn);
}
public void setData(CareerBean careerBean, int position) {
button.setBackgroundResource(R.drawable.dialog_bg_chat_status_config);
String tag = careerBean.getId() + "";
for (String select : mSelectedList) {
if (select.equals(tag)) {
button.setBackgroundResource(R.drawable.dialog_bg_chat_status_config_select);
}
}
button.setOnClickListener(view -> {
if (mSelectedList.contains(tag)) {
mSelectedList.remove(tag);
} else if (mSelectedList.size() < 5) {
mSelectedList.add(tag);
}
if (onItemClickListener != null) {
onItemClickListener.onItemClick(mSelectedList, mSelectedList.size());
}
notifyDataSetChanged();
});
button.setText(WordUtil.isNewZh() ? careerBean.getTitleCn() : careerBean.getTitleEn());
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,76 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<include
android:id="@+id/include5"
layout="@layout/view_title_not_color"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/titleView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="15dp"
android:text="@string/edit_profile_hobby"
android:textColor="#333333"
android:textSize="30sp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/include5" />
<TextView
android:id="@+id/number"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:text="(0/5)"
android:textColor="#777777"
android:textSize="11sp"
app:layout_constraintStart_toStartOf="@+id/titleView"
app:layout_constraintTop_toBottomOf="@+id/titleView" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recyclerView"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginStart="15dp"
android:layout_marginTop="20dp"
app:layoutManager="androidx.recyclerview.widget.GridLayoutManager"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/number"
app:spanCount="4"
tools:listitem="@layout/item_edit_user_hobby" />
<Button
android:id="@+id/btn_save"
android:layout_width="186dp"
android:layout_height="54dp"
android:textColor="#FFFFFF"
android:layout_marginEnd="21dp"
android:layout_marginBottom="112dp"
android:background="@drawable/bg_msg_address_book_user_btn_fan"
android:text="@string/edit_profile_hobby_save"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent" />
<Button
android:id="@+id/btn_cancel"
android:layout_width="122dp"
android:layout_height="54dp"
android:layout_marginStart="21dp"
android:layout_marginBottom="112dp"
android:background="@drawable/dialog_bg_chat_status_config"
android:text="@string/edit_profile_hobby_cancel"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/btn_save"
app:layout_constraintStart_toStartOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="wrap_content"
android:layout_marginBottom="15dp"
android:layout_marginEnd="15dp"
android:layout_height="wrap_content">
<Button
android:id="@+id/btn"
android:layout_width="wrap_content"
android:background="@drawable/dialog_bg_chat_status_config"
android:layout_height="wrap_content"
android:text="Button" />
</LinearLayout>

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 909 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

View File

@ -74,4 +74,9 @@
<string name="activity_msg_chat_top_status_online">在线</string> <string name="activity_msg_chat_top_status_online">在线</string>
<string name="activity_msg_chat_top_status_offline">离线</string> <string name="activity_msg_chat_top_status_offline">离线</string>
<string name="activity_msg_chat_list_card">[名片]</string> <string name="activity_msg_chat_list_card">[名片]</string>
<string name="edit_profile_occupation">職業</string>
<string name="edit_profile_height">身高</string>
<string name="edit_profile_hobby">愛好</string>
<string name="edit_profile_hobby_save">完成</string>
<string name="edit_profile_hobby_cancel">退出</string>
</resources> </resources>

View File

@ -74,4 +74,9 @@
<string name="activity_msg_chat_top_status_online">Online</string> <string name="activity_msg_chat_top_status_online">Online</string>
<string name="activity_msg_chat_top_status_offline">Offline</string> <string name="activity_msg_chat_top_status_offline">Offline</string>
<string name="activity_msg_chat_list_card">[Card]</string> <string name="activity_msg_chat_list_card">[Card]</string>
<string name="edit_profile_occupation">Profession</string>
<string name="edit_profile_height">Height</string>
<string name="edit_profile_hobby">Hobby</string>
<string name="edit_profile_hobby_save">Save</string>
<string name="edit_profile_hobby_cancel">Cancel</string>
</resources> </resources>