|
|
|
|
@@ -1,251 +1,184 @@
|
|
|
|
|
package com.shayu.onetoone.activity.login;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import android.annotation.SuppressLint;
|
|
|
|
|
import android.content.Intent;
|
|
|
|
|
import android.os.Bundle;
|
|
|
|
|
import android.view.View;
|
|
|
|
|
import android.widget.Button;
|
|
|
|
|
import android.widget.EditText;
|
|
|
|
|
import android.widget.ImageView;
|
|
|
|
|
import android.widget.RelativeLayout;
|
|
|
|
|
import android.widget.TextView;
|
|
|
|
|
import android.widget.Toast;
|
|
|
|
|
|
|
|
|
|
import androidx.recyclerview.widget.LinearLayoutManager;
|
|
|
|
|
import androidx.recyclerview.widget.RecyclerView;
|
|
|
|
|
|
|
|
|
|
import com.alibaba.android.arouter.facade.annotation.Route;
|
|
|
|
|
import com.bigkoo.pickerview.builder.TimePickerBuilder;
|
|
|
|
|
import com.bigkoo.pickerview.listener.OnTimeSelectListener;
|
|
|
|
|
import com.bigkoo.pickerview.view.TimePickerView;
|
|
|
|
|
import com.blankj.utilcode.util.StringUtils;
|
|
|
|
|
import com.lxj.xpopup.XPopup;
|
|
|
|
|
import com.shayu.onetoone.R;
|
|
|
|
|
import com.shayu.onetoone.activity.AbsOTOActivity;
|
|
|
|
|
import com.shayu.onetoone.activity.MainActivity;
|
|
|
|
|
import com.shayu.onetoone.bean.AvatarBean;
|
|
|
|
|
import com.shayu.onetoone.adapter.LabelTagAdapter;
|
|
|
|
|
import com.shayu.onetoone.adapter.LableChooseAdapter;
|
|
|
|
|
import com.shayu.onetoone.bean.LabelBean;
|
|
|
|
|
import com.shayu.onetoone.manager.OTONetManager;
|
|
|
|
|
import com.shayu.onetoone.manager.RouteManager;
|
|
|
|
|
import com.shayu.onetoone.view.UserAvatarPopup;
|
|
|
|
|
import com.yunbao.common.CommonAppConfig;
|
|
|
|
|
import com.yunbao.common.Constants;
|
|
|
|
|
import com.xuexiang.xui.widget.flowlayout.FlowTagLayout;
|
|
|
|
|
import com.yunbao.common.bean.HttpCallbackModel;
|
|
|
|
|
import com.yunbao.common.glide.ImgLoader;
|
|
|
|
|
import com.yunbao.common.http.base.HttpCallback;
|
|
|
|
|
import com.yunbao.common.interfaces.ImageResultCallback;
|
|
|
|
|
import com.yunbao.common.utils.L;
|
|
|
|
|
import com.yunbao.common.utils.ProcessImageUtil;
|
|
|
|
|
import com.yunbao.common.utils.ToastUtil;
|
|
|
|
|
|
|
|
|
|
import java.io.File;
|
|
|
|
|
import java.util.Calendar;
|
|
|
|
|
import java.util.Date;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 完善个人资料
|
|
|
|
|
* 设置标签
|
|
|
|
|
*/
|
|
|
|
|
@Route(path = RouteManager.ACTIVITY_COMPLETE)
|
|
|
|
|
@Route(path = RouteManager.ACTIVITY_CHOOSE_LABEL)
|
|
|
|
|
public class ChooseLabelActivity extends AbsOTOActivity {
|
|
|
|
|
|
|
|
|
|
private RelativeLayout editHead; //头像点击事件
|
|
|
|
|
private ImageView userAvatar; //头像
|
|
|
|
|
private TextView txtChoose;
|
|
|
|
|
private EditText userNickName; //昵称
|
|
|
|
|
private TextView userSex1; //性别
|
|
|
|
|
private TextView userSex2; //性别
|
|
|
|
|
private TextView userBirthday; //年龄
|
|
|
|
|
private Button btnRegister; //提交资料
|
|
|
|
|
FlowTagLayout myFlowTag; //我的标签
|
|
|
|
|
|
|
|
|
|
private int sex = -1;
|
|
|
|
|
RecyclerView recyclerView; //系统分类标签
|
|
|
|
|
|
|
|
|
|
ProcessImageUtil cameraUtil;
|
|
|
|
|
TextView next; //跳过
|
|
|
|
|
|
|
|
|
|
private File mAvatarFile;
|
|
|
|
|
LableChooseAdapter lableChooseAdapter;
|
|
|
|
|
|
|
|
|
|
int year;
|
|
|
|
|
int month;
|
|
|
|
|
int day;
|
|
|
|
|
List<LabelBean.Children> myLabelList = new ArrayList<>();
|
|
|
|
|
|
|
|
|
|
private String avatarUrl;
|
|
|
|
|
LabelTagAdapter myAdapter;
|
|
|
|
|
|
|
|
|
|
Button submit; //提交
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
protected int getLayoutId() {
|
|
|
|
|
return R.layout.activity_complete;
|
|
|
|
|
return R.layout.activity_choose_label;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
protected void main(Bundle savedInstanceState) {
|
|
|
|
|
Calendar calendar = Calendar.getInstance();
|
|
|
|
|
year = calendar.get(Calendar.YEAR) - 18;
|
|
|
|
|
month = calendar.get(Calendar.MONTH);
|
|
|
|
|
day = calendar.get(Calendar.DAY_OF_MONTH);
|
|
|
|
|
|
|
|
|
|
initView();
|
|
|
|
|
initCamera();
|
|
|
|
|
initDate();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void initCamera() {
|
|
|
|
|
cameraUtil = new ProcessImageUtil(this, "com.shayu.onetoone.fileprovider");
|
|
|
|
|
cameraUtil.setImageResultCallback(new ImageResultCallback() {
|
|
|
|
|
private void initDate() {
|
|
|
|
|
OTONetManager.getInstance(mContext).getSysLabel(new HttpCallback<List<LabelBean>>() {
|
|
|
|
|
@Override
|
|
|
|
|
public void beforeCamera() {
|
|
|
|
|
|
|
|
|
|
public void onSuccess(List<LabelBean> data) {
|
|
|
|
|
lableChooseAdapter.setList(data);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onSuccess(File file) {
|
|
|
|
|
L.e("cameraUtil.setImageResultCallback:");
|
|
|
|
|
if (file != null) {
|
|
|
|
|
mAvatarFile = file;
|
|
|
|
|
OTONetManager.getInstance(ChooseLabelActivity.this).updateFile(mAvatarFile, new HttpCallback<AvatarBean>() {
|
|
|
|
|
@Override
|
|
|
|
|
public void onSuccess(AvatarBean data) {
|
|
|
|
|
ImgLoader.display(mContext, file, userAvatar);
|
|
|
|
|
//txtChoose.setVisibility(View.GONE);
|
|
|
|
|
avatarUrl = data.getAvatar();
|
|
|
|
|
ToastUtil.show("上传成功");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onError(String error) {
|
|
|
|
|
ToastUtil.show("上传失败");
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onFailure() {
|
|
|
|
|
|
|
|
|
|
public void onError(String error) {
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@SuppressLint("SetTextI18n")
|
|
|
|
|
private void initView() {
|
|
|
|
|
editHead = findViewById(R.id.editHead);
|
|
|
|
|
userAvatar = findViewById(R.id.userAvatar);
|
|
|
|
|
txtChoose = findViewById(R.id.text_choose);
|
|
|
|
|
userNickName = findViewById(R.id.userNickName);
|
|
|
|
|
userSex1 = findViewById(R.id.user_sex_1);
|
|
|
|
|
userSex2 = findViewById(R.id.user_sex_2);
|
|
|
|
|
userBirthday = findViewById(R.id.userBirthday);
|
|
|
|
|
btnRegister = findViewById(R.id.btn_register);
|
|
|
|
|
avatarUrl = CommonAppConfig.getInstance().getUserBean().getAvatar();
|
|
|
|
|
if (!StringUtils.isEmpty(avatarUrl)) {
|
|
|
|
|
ImgLoader.display(ChooseLabelActivity.this, avatarUrl, userAvatar);
|
|
|
|
|
}
|
|
|
|
|
if (!StringUtils.isEmpty(CommonAppConfig.getInstance().getUserBean().getUserNiceName())) {
|
|
|
|
|
userNickName.setText(CommonAppConfig.getInstance().getUserBean().getUserNiceName());
|
|
|
|
|
}
|
|
|
|
|
editHead.setOnClickListener(new View.OnClickListener() {
|
|
|
|
|
submit = findViewById(R.id.submit);
|
|
|
|
|
myFlowTag = findViewById(R.id.myFlowTag);
|
|
|
|
|
recyclerView = findViewById(R.id.recyclerView);
|
|
|
|
|
next = findViewById(R.id.next);
|
|
|
|
|
|
|
|
|
|
myLabelList = new ArrayList<>();
|
|
|
|
|
|
|
|
|
|
myAdapter = new LabelTagAdapter(mContext, new LabelTagAdapter.OnSureOnClickListener() {
|
|
|
|
|
@Override
|
|
|
|
|
public void onClick(View v) {
|
|
|
|
|
chooseImage();
|
|
|
|
|
public void sure(LabelBean.Children labelBean) {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
myFlowTag.setAdapter(myAdapter);
|
|
|
|
|
myFlowTag.setTagCheckedMode(FlowTagLayout.FLOW_TAG_CHECKED_NONE);
|
|
|
|
|
myAdapter.setData(myLabelList);
|
|
|
|
|
|
|
|
|
|
userBirthday.setText(year + " 年 " + (month + 1) + " 月 " + day + " 日 ");
|
|
|
|
|
recyclerView.setHasFixedSize(true);
|
|
|
|
|
LinearLayoutManager layoutManager1 = new LinearLayoutManager(ChooseLabelActivity.this);
|
|
|
|
|
layoutManager1.setOrientation(LinearLayoutManager.VERTICAL);
|
|
|
|
|
recyclerView.setLayoutManager(layoutManager1);
|
|
|
|
|
|
|
|
|
|
userSex1.setOnClickListener(new View.OnClickListener() {
|
|
|
|
|
lableChooseAdapter = new LableChooseAdapter(ChooseLabelActivity.this, new LableChooseAdapter.onItemLabelClicklistener() {
|
|
|
|
|
@Override
|
|
|
|
|
public void onClick(View v) {
|
|
|
|
|
changeSex(0);
|
|
|
|
|
public void onChoose(LabelBean.Children children) {
|
|
|
|
|
addLabel(children);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
userSex2.setOnClickListener(new View.OnClickListener() {
|
|
|
|
|
recyclerView.setAdapter(lableChooseAdapter);
|
|
|
|
|
|
|
|
|
|
next.setOnClickListener(new View.OnClickListener() {
|
|
|
|
|
@Override
|
|
|
|
|
public void onClick(View v) {
|
|
|
|
|
changeSex(1);
|
|
|
|
|
finish();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
userBirthday.setOnClickListener(new View.OnClickListener() {
|
|
|
|
|
submit.setOnClickListener(new View.OnClickListener() {
|
|
|
|
|
@Override
|
|
|
|
|
public void onClick(View v) {
|
|
|
|
|
//时间选择器
|
|
|
|
|
Calendar selectedDate = Calendar.getInstance();
|
|
|
|
|
selectedDate.set(year, month, day);
|
|
|
|
|
TimePickerView pvTime = new TimePickerBuilder(ChooseLabelActivity.this, new OnTimeSelectListener() {
|
|
|
|
|
@Override
|
|
|
|
|
public void onTimeSelect(Date date, View v) {
|
|
|
|
|
|
|
|
|
|
Calendar calendar = Calendar.getInstance();
|
|
|
|
|
calendar.setTime(date);
|
|
|
|
|
|
|
|
|
|
year = calendar.get(Calendar.YEAR);
|
|
|
|
|
month = calendar.get(Calendar.MONTH);
|
|
|
|
|
day = calendar.get(Calendar.DAY_OF_MONTH);
|
|
|
|
|
|
|
|
|
|
userBirthday.setText(year + " 年 " + (month + 1) + " 月 " + day + " 日 ");
|
|
|
|
|
}
|
|
|
|
|
}).setCancelText("生日").setSubmitColor(getResources().getColor(R.color.blue01)).setSubmitText("完成").setContentTextSize(20).setDate(selectedDate).build();
|
|
|
|
|
pvTime.show();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
btnRegister.setOnClickListener(new View.OnClickListener() {
|
|
|
|
|
@Override
|
|
|
|
|
public void onClick(View v) {
|
|
|
|
|
if (StringUtils.isEmpty(userNickName.getText().toString())) {
|
|
|
|
|
Toast.makeText(mContext, "请填写昵称", Toast.LENGTH_SHORT).show();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (sex == -1) {
|
|
|
|
|
Toast.makeText(mContext, "请选择性别", Toast.LENGTH_SHORT).show();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
OTONetManager.getInstance(mContext).setInfo(avatarUrl, userNickName.getText().toString(), sex, year + "-" + month + "-" + day, new HttpCallback<HttpCallbackModel>() {
|
|
|
|
|
@Override
|
|
|
|
|
public void onSuccess(HttpCallbackModel data) {
|
|
|
|
|
Toast.makeText(mContext, data.getMsg(), Toast.LENGTH_SHORT).show();
|
|
|
|
|
if (data.getCode() == 0) {
|
|
|
|
|
Intent intent = new Intent(ChooseLabelActivity.this, MainActivity.class);
|
|
|
|
|
intent.putExtra(Constants.SHOW_INVITE, false);
|
|
|
|
|
startActivity(intent);
|
|
|
|
|
|
|
|
|
|
RouteManager.forwardMainActivity();
|
|
|
|
|
finish();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onError(String error) {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
setLabel();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 选择图片
|
|
|
|
|
* 设置标签
|
|
|
|
|
*/
|
|
|
|
|
private void chooseImage() {
|
|
|
|
|
UserAvatarPopup userAvatarPopup = new UserAvatarPopup(this, userAvatar1 -> {
|
|
|
|
|
avatarUrl = userAvatar1;
|
|
|
|
|
ImgLoader.display(ChooseLabelActivity.this, avatarUrl, userAvatar);
|
|
|
|
|
//txtChoose.setVisibility(View.GONE);
|
|
|
|
|
}, isCamera -> {
|
|
|
|
|
if (isCamera) {
|
|
|
|
|
cameraUtil.getImageByCamera();
|
|
|
|
|
private void setLabel() {
|
|
|
|
|
StringBuffer labels = new StringBuffer();
|
|
|
|
|
for (int i = 0; i < myLabelList.size(); i++) {
|
|
|
|
|
if (i == 0) {
|
|
|
|
|
labels.append(myLabelList.get(i).getId());
|
|
|
|
|
} else {
|
|
|
|
|
cameraUtil.getImageByAlumb();
|
|
|
|
|
labels.append("," + myLabelList.get(i).getId());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
OTONetManager.getInstance(mContext).setLabels(labels.toString(), new HttpCallback<HttpCallbackModel>() {
|
|
|
|
|
@Override
|
|
|
|
|
public void onSuccess(HttpCallbackModel data) {
|
|
|
|
|
Toast.makeText(mContext, data.getMsg(), Toast.LENGTH_SHORT).show();
|
|
|
|
|
if (data.getCode() == 0) {
|
|
|
|
|
RouteManager.forwardMainActivity();
|
|
|
|
|
finish();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onError(String error) {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
new XPopup.Builder(mContext).asCustom(userAvatarPopup).show();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void changeSex(int i) {
|
|
|
|
|
sex = i;
|
|
|
|
|
if (sex == 0) {
|
|
|
|
|
userSex1.setTextColor(getResources().getColor(R.color.white));
|
|
|
|
|
userSex2.setTextColor(getResources().getColor(R.color.text_gray));
|
|
|
|
|
userSex1.setBackgroundResource(R.mipmap.icon_user_sex_02);
|
|
|
|
|
userSex2.setBackgroundResource(R.mipmap.icon_user_sex_00);
|
|
|
|
|
/**
|
|
|
|
|
* 处理标签 +-
|
|
|
|
|
*
|
|
|
|
|
* @param children
|
|
|
|
|
*/
|
|
|
|
|
private void addLabel(LabelBean.Children children) {
|
|
|
|
|
if (children.isSelect()) {
|
|
|
|
|
boolean isAdd = true;
|
|
|
|
|
for (int i = 0; i < myLabelList.size(); i++) {
|
|
|
|
|
if (myLabelList.get(i).getId() == children.getId()) {
|
|
|
|
|
isAdd = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (isAdd) {
|
|
|
|
|
myLabelList.add(children);
|
|
|
|
|
myAdapter.setData(myLabelList);
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
userSex1.setTextColor(getResources().getColor(R.color.text_gray));
|
|
|
|
|
userSex2.setTextColor(getResources().getColor(R.color.white));
|
|
|
|
|
userSex1.setBackgroundResource(R.mipmap.icon_user_sex_00);
|
|
|
|
|
userSex2.setBackgroundResource(R.mipmap.icon_user_sex_01);
|
|
|
|
|
int index = -1;
|
|
|
|
|
for (int i = 0; i < myLabelList.size(); i++) {
|
|
|
|
|
if (myLabelList.get(i).getId() == children.getId()) {
|
|
|
|
|
index = i;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (index != -1) {
|
|
|
|
|
myLabelList.remove(index);
|
|
|
|
|
myAdapter.setData(myLabelList);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (myLabelList.size() > 0) {
|
|
|
|
|
findViewById(R.id.notitle).setVisibility(View.GONE);
|
|
|
|
|
} else {
|
|
|
|
|
findViewById(R.id.notitle).setVisibility(View.VISIBLE);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|