[Modify]标签功能
This commit is contained in:
5
app/src/common/res/drawable/selector_user_info_label.xml
Normal file
5
app/src/common/res/drawable/selector_user_info_label.xml
Normal file
@@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:drawable="@drawable/bg_user_info_label_select" android:state_selected="true" />
|
||||
<item android:drawable="@drawable/bg_user_info_label" android:state_selected="false" />
|
||||
</selector>
|
@@ -30,7 +30,6 @@ import com.yizhuan.xchat_android_core.user.UserModel
|
||||
import com.yizhuan.xchat_android_core.user.bean.UserLabelInfo
|
||||
import com.yizhuan.xchat_android_library.common.entity.CommonTabEntity
|
||||
import com.yizhuan.xchat_android_library.utils.ResUtil
|
||||
import com.yizhuan.xchat_android_library.utils.StringUtils
|
||||
import io.reactivex.SingleObserver
|
||||
import io.reactivex.disposables.Disposable
|
||||
import org.greenrobot.eventbus.EventBus
|
||||
@@ -50,13 +49,9 @@ class EditUserTagActivity : BaseViewBindingActivity<ActivityEditUserTagBinding>(
|
||||
private var userLabelInfo: UserLabelInfo? = null
|
||||
|
||||
companion object {
|
||||
|
||||
private const val USER_LABEL = "user_label"
|
||||
|
||||
@JvmStatic
|
||||
fun start(context: Context, userLabelInfo: UserLabelInfo) {
|
||||
fun start(context: Context) {
|
||||
val starter = Intent(context, EditUserTagActivity::class.java)
|
||||
starter.putExtra(USER_LABEL, userLabelInfo)
|
||||
context.startActivity(starter)
|
||||
}
|
||||
}
|
||||
@@ -69,7 +64,7 @@ class EditUserTagActivity : BaseViewBindingActivity<ActivityEditUserTagBinding>(
|
||||
EventBus.getDefault().register(this)
|
||||
|
||||
initTitleBar(
|
||||
getString(R.string.my_tag),
|
||||
getString(R.string.my_label),
|
||||
object : TitleBar.TextAction(
|
||||
getString(R.string.done),
|
||||
ContextCompat.getColor(this, R.color.color_white)
|
||||
@@ -88,6 +83,7 @@ class EditUserTagActivity : BaseViewBindingActivity<ActivityEditUserTagBinding>(
|
||||
override fun onSuccess(s: String) {
|
||||
dialogManager.dismissDialog()
|
||||
toast(getString(R.string.update_success))
|
||||
finish()
|
||||
}
|
||||
|
||||
override fun onError(e: Throwable) {
|
||||
@@ -99,11 +95,33 @@ class EditUserTagActivity : BaseViewBindingActivity<ActivityEditUserTagBinding>(
|
||||
}
|
||||
})
|
||||
|
||||
userLabelInfo = intent.getSerializableExtra(USER_LABEL) as UserLabelInfo?
|
||||
|
||||
initTop()
|
||||
initTabTitle()
|
||||
initViewPager()
|
||||
initData()
|
||||
}
|
||||
|
||||
private fun initData() {
|
||||
dialogManager.showProgressDialog(
|
||||
this@EditUserTagActivity,
|
||||
ResUtil.getString(R.string.ui_user_userinfomodifyactivity_02)
|
||||
)
|
||||
UserModel.get().userLabelInfo.subscribe(object : SingleObserver<UserLabelInfo> {
|
||||
override fun onSubscribe(d: Disposable) {
|
||||
mCompositeDisposable.add(d)
|
||||
}
|
||||
|
||||
override fun onSuccess(data: UserLabelInfo) {
|
||||
dialogManager.dismissDialog()
|
||||
userLabelInfo = data
|
||||
initTabTitle()
|
||||
initViewPager()
|
||||
}
|
||||
|
||||
override fun onError(e: Throwable) {
|
||||
dialogManager.dismissDialog()
|
||||
toast(e.message)
|
||||
}
|
||||
|
||||
})
|
||||
}
|
||||
|
||||
private fun initTop() {
|
||||
@@ -119,11 +137,14 @@ class EditUserTagActivity : BaseViewBindingActivity<ActivityEditUserTagBinding>(
|
||||
mMyLabelAdapter.remove(position)
|
||||
}
|
||||
|
||||
userLabelInfo?.meLabels?.let {
|
||||
val labelList = UserModel.get().cacheLoginUserInfo?.labels
|
||||
|
||||
labelList?.let {
|
||||
if (it.isNotEmpty()) {
|
||||
binding.group.visibility = View.GONE
|
||||
mMyLabelAdapter.setNewData(it)
|
||||
} else {
|
||||
binding.group.visibility = View.GONE
|
||||
binding.group.visibility = View.VISIBLE
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,7 +1,5 @@
|
||||
package com.yizhuan.erban.ui.user.activity;
|
||||
|
||||
import static com.yizhuan.erban.ui.user.activity.UserInfoActivity.IdentityState.OWN;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.ClipData;
|
||||
import android.content.ClipboardManager;
|
||||
@@ -21,6 +19,8 @@ import androidx.fragment.app.Fragment;
|
||||
import androidx.lifecycle.ViewModelProvider;
|
||||
import androidx.viewpager.widget.ViewPager;
|
||||
|
||||
import com.google.android.flexbox.AlignItems;
|
||||
import com.google.android.flexbox.FlexDirection;
|
||||
import com.netease.nim.uikit.StatusBarUtil;
|
||||
import com.netease.nim.uikit.impl.cache.NimUserInfoCache;
|
||||
import com.netease.nimlib.sdk.RequestCallbackWrapper;
|
||||
@@ -44,12 +44,13 @@ import com.yizhuan.erban.family.view.activity.FamilyMemberListActivity;
|
||||
import com.yizhuan.erban.family.view.activity.FamilyMemberSearchActivity;
|
||||
import com.yizhuan.erban.ui.im.avtivity.NimFriendModel;
|
||||
import com.yizhuan.erban.ui.im.avtivity.NimP2PMessageActivity;
|
||||
import com.yizhuan.erban.ui.user.adapter.UserPhotoAdapter;
|
||||
import com.yizhuan.erban.ui.user.adapter.SelfPhotoAdapter;
|
||||
import com.yizhuan.erban.ui.user.adapter.UserInfoIndicatorAdapter;
|
||||
import com.yizhuan.erban.ui.user.adapter.UserInfoLabelAdapter;
|
||||
import com.yizhuan.erban.ui.user.adapter.UserInfoPagerAdapter;
|
||||
import com.yizhuan.erban.ui.user.adapter.UserInfoPhotoAdapter;
|
||||
import com.yizhuan.erban.ui.user.dialog.UserTagDialog;
|
||||
import com.yizhuan.erban.ui.user.adapter.UserPhotoAdapter;
|
||||
import com.yizhuan.erban.ui.user.dialog.UserLabelDialog;
|
||||
import com.yizhuan.erban.ui.user.fragment.UserInfoGiftWallFragment;
|
||||
import com.yizhuan.erban.ui.user.fragment.UserInfoInfoFragment;
|
||||
import com.yizhuan.erban.ui.user.viewmodel.UserInfoViewModel;
|
||||
@@ -86,6 +87,7 @@ import com.yizhuan.xchat_android_core.user.event.LoginUserInfoUpdateEvent;
|
||||
import com.yizhuan.xchat_android_core.utils.LogUtils;
|
||||
import com.yizhuan.xchat_android_core.utils.Logger;
|
||||
import com.yizhuan.xchat_android_library.annatation.ActLayoutRes;
|
||||
import com.yizhuan.xchat_android_library.common.widget.LinesFlexBoxLayoutManager;
|
||||
import com.yizhuan.xchat_android_library.utils.ListUtils;
|
||||
import com.yizhuan.xchat_android_library.utils.ResUtil;
|
||||
import com.yizhuan.xchat_android_library.utils.SingleToastUtil;
|
||||
@@ -98,6 +100,8 @@ import org.greenrobot.eventbus.ThreadMode;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static com.yizhuan.erban.ui.user.activity.UserInfoActivity.IdentityState.OWN;
|
||||
|
||||
/**
|
||||
* create by lvzebiao on 2018/8/31
|
||||
*/
|
||||
@@ -122,7 +126,6 @@ public class UserInfoActivity extends BaseBindingActivity<ActivityUserInfoBindin
|
||||
private StaticPagerAdapterWrapper bannerAdapter;
|
||||
|
||||
private UserInfoViewModel viewModel;
|
||||
private UserInfoPagerAdapter pagerAdapter;
|
||||
|
||||
private boolean audioPlaying = false;
|
||||
|
||||
@@ -238,7 +241,7 @@ public class UserInfoActivity extends BaseBindingActivity<ActivityUserInfoBindin
|
||||
List<Fragment> fragmentList = new ArrayList<>(2);
|
||||
fragmentList.add(new UserInfoInfoFragment());
|
||||
fragmentList.add(new UserInfoGiftWallFragment());
|
||||
pagerAdapter = new UserInfoPagerAdapter(getSupportFragmentManager(), fragmentList);
|
||||
UserInfoPagerAdapter pagerAdapter = new UserInfoPagerAdapter(getSupportFragmentManager(), fragmentList);
|
||||
final List<String> tagList = new ArrayList<>(2);
|
||||
tagList.add(getString(R.string.me_data));
|
||||
tagList.add(getString(R.string.me_gift_wall));
|
||||
@@ -347,6 +350,8 @@ public class UserInfoActivity extends BaseBindingActivity<ActivityUserInfoBindin
|
||||
|
||||
initVoiceShow(userInfo.getAudioCard());
|
||||
|
||||
initLabel(userInfo.getLabels());
|
||||
|
||||
mBinding.tvErbanId.setOnLongClickListener(view -> {
|
||||
try {
|
||||
ClipboardManager cm = (ClipboardManager) UserInfoActivity.this.getSystemService(Context.CLIPBOARD_SERVICE);
|
||||
@@ -361,6 +366,39 @@ public class UserInfoActivity extends BaseBindingActivity<ActivityUserInfoBindin
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 标签
|
||||
*
|
||||
* @param labels
|
||||
*/
|
||||
private void initLabel(List<String> labels) {
|
||||
if (labels.isEmpty()) {
|
||||
if (AuthModel.get().getCurrentUid() != userInfo.getUid()) {
|
||||
mBinding.groupLabel.setVisibility(View.GONE);
|
||||
mBinding.tvEditLabel.setVisibility(View.GONE);
|
||||
} else {
|
||||
mBinding.groupLabel.setVisibility(View.GONE);
|
||||
mBinding.tvEditLabel.setVisibility(View.VISIBLE);
|
||||
mBinding.tvEditLabel.setOnClickListener(view -> {
|
||||
EditUserTagActivity.start(this);
|
||||
});
|
||||
}
|
||||
return;
|
||||
} else {
|
||||
mBinding.groupLabel.setVisibility(View.VISIBLE);
|
||||
}
|
||||
UserInfoLabelAdapter userInfoLabelAdapter = new UserInfoLabelAdapter();
|
||||
|
||||
LinesFlexBoxLayoutManager labelLayoutManager = new LinesFlexBoxLayoutManager(this);
|
||||
labelLayoutManager.setFlexDirection(FlexDirection.ROW);
|
||||
labelLayoutManager.setAlignItems(AlignItems.FLEX_START);
|
||||
labelLayoutManager.setMaxLines(1);
|
||||
mBinding.mLabelRecyclerView.setLayoutManager(labelLayoutManager);
|
||||
mBinding.mLabelRecyclerView.setAdapter(userInfoLabelAdapter);
|
||||
|
||||
userInfoLabelAdapter.setNewData(labels);
|
||||
}
|
||||
|
||||
/**
|
||||
* 相册
|
||||
*/
|
||||
@@ -506,7 +544,7 @@ public class UserInfoActivity extends BaseBindingActivity<ActivityUserInfoBindin
|
||||
public void onClick(View v) {
|
||||
switch (v.getId()) {
|
||||
case R.id.ivTagArrow:
|
||||
UserTagDialog.newInstance().show(this);
|
||||
UserLabelDialog.newInstance(userInfo.getLabels()).show(this);
|
||||
break;
|
||||
|
||||
case R.id.iv_user_back:
|
||||
|
@@ -29,6 +29,8 @@ import com.yizhuan.erban.databinding.ActivityUserInfoModifyBinding
|
||||
import com.yizhuan.erban.ui.login.ModifyInfoActivity
|
||||
import com.yizhuan.erban.ui.user.adapter.UserPhotoAdapter
|
||||
import com.yizhuan.erban.ui.user.adapter.UserPhotoAdapter.ImageClickListener
|
||||
import com.yizhuan.erban.ui.user.dialog.UserAreaDialog
|
||||
import com.yizhuan.erban.ui.user.dialog.UserLabelDialog.Companion.newInstance
|
||||
import com.yizhuan.erban.ui.utils.ImageLoadUtils
|
||||
import com.yizhuan.erban.ui.widget.dialog.CommonTipDialog
|
||||
import com.yizhuan.erban.utils.RegexUtil
|
||||
@@ -36,7 +38,6 @@ import com.yizhuan.xchat_android_core.auth.AuthModel
|
||||
import com.yizhuan.xchat_android_core.file.FileModel
|
||||
import com.yizhuan.xchat_android_core.user.UserModel
|
||||
import com.yizhuan.xchat_android_core.user.bean.UserInfo
|
||||
import com.yizhuan.xchat_android_core.user.bean.UserLabelInfo
|
||||
import com.yizhuan.xchat_android_core.user.bean.UserPhoto
|
||||
import com.yizhuan.xchat_android_core.utils.Logger
|
||||
import com.yizhuan.xchat_android_library.common.file.FileHelper
|
||||
@@ -142,6 +143,7 @@ class UserInfoModifyActivity : BaseViewBindingActivity<ActivityUserInfoModifyBin
|
||||
binding.tvSoundTip.visibility = View.VISIBLE
|
||||
binding.llAudio.visibility = View.GONE
|
||||
}
|
||||
binding.tvArea.text = userInfo.region
|
||||
}
|
||||
}
|
||||
|
||||
@@ -152,6 +154,7 @@ class UserInfoModifyActivity : BaseViewBindingActivity<ActivityUserInfoModifyBin
|
||||
binding.layoutPhotos.setOnClickListener(this)
|
||||
binding.llAudioRecord.setOnClickListener(this)
|
||||
binding.llDesc.setOnClickListener(this)
|
||||
binding.layoutArea.setOnClickListener(this)
|
||||
binding.layoutTag.setOnClickListener(this)
|
||||
val mLayoutManager = LinearLayoutManager(this, LinearLayoutManager.HORIZONTAL, true)
|
||||
binding.rvPhotos.layoutManager = mLayoutManager
|
||||
@@ -268,19 +271,19 @@ class UserInfoModifyActivity : BaseViewBindingActivity<ActivityUserInfoModifyBin
|
||||
userId,
|
||||
Method.PHOTO
|
||||
)
|
||||
R.id.layout_tag -> {
|
||||
R.id.layout_area -> {
|
||||
dialogManager.showProgressDialog(
|
||||
this@UserInfoModifyActivity,
|
||||
ResUtil.getString(R.string.ui_user_userinfomodifyactivity_02)
|
||||
)
|
||||
UserModel.get().userLabelInfo.subscribe(object : SingleObserver<UserLabelInfo>{
|
||||
UserModel.get().areaInfo.subscribe(object : SingleObserver<List<String>> {
|
||||
override fun onSubscribe(d: Disposable) {
|
||||
mCompositeDisposable.add(d)
|
||||
}
|
||||
|
||||
override fun onSuccess(userLabelInfo: UserLabelInfo) {
|
||||
override fun onSuccess(areaList: List<String>) {
|
||||
dialogManager.dismissDialog()
|
||||
EditUserTagActivity.start(this@UserInfoModifyActivity, userLabelInfo)
|
||||
UserAreaDialog.newInstance(areaList).show(this@UserInfoModifyActivity)
|
||||
}
|
||||
|
||||
override fun onError(e: Throwable) {
|
||||
@@ -290,6 +293,9 @@ class UserInfoModifyActivity : BaseViewBindingActivity<ActivityUserInfoModifyBin
|
||||
|
||||
})
|
||||
}
|
||||
R.id.layout_tag -> {
|
||||
EditUserTagActivity.start(this@UserInfoModifyActivity)
|
||||
}
|
||||
else -> {}
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,22 @@
|
||||
package com.yizhuan.erban.ui.user.adapter
|
||||
|
||||
import androidx.appcompat.widget.AppCompatTextView
|
||||
import com.chad.library.adapter.base.BaseQuickAdapter
|
||||
import com.chad.library.adapter.base.BaseViewHolder
|
||||
import com.yizhuan.erban.R
|
||||
|
||||
/**
|
||||
* author: wushaocheng
|
||||
* Created by wushaocheng on 2023/2/16.
|
||||
* desc: 用户标签
|
||||
*/
|
||||
class UserInfoLabelAdapter :
|
||||
BaseQuickAdapter<String, BaseViewHolder>(R.layout.item_user_info_label) {
|
||||
|
||||
override fun convert(helper: BaseViewHolder, item: String) {
|
||||
val tvLabel = helper.getView<AppCompatTextView>(R.id.tv_user_tag)
|
||||
tvLabel.isSelected = helper.layoutPosition <3
|
||||
helper.setText(R.id.tv_user_tag, item)
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,23 @@
|
||||
package com.yizhuan.erban.ui.user.adapter
|
||||
|
||||
import androidx.appcompat.widget.AppCompatTextView
|
||||
import com.chad.library.adapter.base.BaseQuickAdapter
|
||||
import com.chad.library.adapter.base.BaseViewHolder
|
||||
import com.yizhuan.erban.R
|
||||
import com.yizhuan.xchat_android_core.user.bean.UserLabelItemInfo
|
||||
|
||||
/**
|
||||
* author: wushaocheng
|
||||
* Created by wushaocheng on 2023/2/16.
|
||||
* desc: 用户标签
|
||||
*/
|
||||
class UserLabelDialogAdapter :
|
||||
BaseQuickAdapter<String, BaseViewHolder>(R.layout.item_user_tag) {
|
||||
|
||||
override fun convert(helper: BaseViewHolder, item: String) {
|
||||
val tvLabel = helper.getView<AppCompatTextView>(R.id.tv_user_tag)
|
||||
tvLabel.isSelected = helper.layoutPosition <3
|
||||
helper.setText(R.id.tv_user_tag, item)
|
||||
}
|
||||
|
||||
}
|
@@ -1,20 +0,0 @@
|
||||
package com.yizhuan.erban.ui.user.adapter
|
||||
|
||||
import com.chad.library.adapter.base.BaseQuickAdapter
|
||||
import com.chad.library.adapter.base.BaseViewHolder
|
||||
import com.yizhuan.erban.R
|
||||
import com.yizhuan.xchat_android_core.user.bean.UserLabelItemInfo
|
||||
|
||||
/**
|
||||
* author: wushaocheng
|
||||
* Created by wushaocheng on 2023/2/16.
|
||||
* desc: 用户标签
|
||||
*/
|
||||
class UserTagAdapter :
|
||||
BaseQuickAdapter<UserLabelItemInfo, BaseViewHolder>(R.layout.item_user_tag) {
|
||||
|
||||
override fun convert(helper: BaseViewHolder, item: UserLabelItemInfo) {
|
||||
helper.setText(R.id.tv_user_tag, item.label)
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,55 @@
|
||||
package com.yizhuan.erban.ui.user.dialog
|
||||
|
||||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import com.google.android.flexbox.FlexDirection
|
||||
import com.google.android.flexbox.FlexWrap
|
||||
import com.google.android.flexbox.FlexboxLayoutManager
|
||||
import com.google.android.flexbox.JustifyContent
|
||||
import com.yizhuan.erban.R
|
||||
import com.yizhuan.erban.base.BaseDialog
|
||||
import com.yizhuan.erban.databinding.DialogUserTagBinding
|
||||
import com.yizhuan.erban.ui.user.activity.EditUserTagActivity
|
||||
import com.yizhuan.erban.ui.user.adapter.UserLabelDialogAdapter
|
||||
import com.yizhuan.xchat_android_core.auth.AuthModel
|
||||
import com.yizhuan.xchat_android_core.user.UserModel
|
||||
import java.io.Serializable
|
||||
|
||||
/**
|
||||
* 用户地区
|
||||
* Created by wushaocheng on 2023/2/17.
|
||||
*/
|
||||
class UserAreaDialog :
|
||||
BaseDialog<DialogUserTagBinding>() {
|
||||
|
||||
companion object {
|
||||
const val KEY_AREA = "key_area"
|
||||
|
||||
@JvmStatic
|
||||
fun newInstance(area: List<String>): UserAreaDialog {
|
||||
val userLabelDialog = UserAreaDialog()
|
||||
val bundle = Bundle()
|
||||
bundle.putSerializable(KEY_AREA, area as Serializable?)
|
||||
userLabelDialog.arguments = bundle
|
||||
return userLabelDialog
|
||||
}
|
||||
}
|
||||
|
||||
private val mTagAdapter by lazy { UserLabelDialogAdapter() }
|
||||
|
||||
override fun init() {
|
||||
val areaList = arguments?.getSerializable(KEY_AREA) as List<String?>?
|
||||
|
||||
initListener()
|
||||
}
|
||||
|
||||
private fun initListener() {
|
||||
binding.ivClose.setOnClickListener { dismissAllowingStateLoss() }
|
||||
|
||||
binding.tvEdit.setOnClickListener {
|
||||
dismissAllowingStateLoss()
|
||||
context?.let { it1 -> EditUserTagActivity.start(it1) }
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,76 @@
|
||||
package com.yizhuan.erban.ui.user.dialog
|
||||
|
||||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import com.google.android.flexbox.FlexDirection
|
||||
import com.google.android.flexbox.FlexWrap
|
||||
import com.google.android.flexbox.FlexboxLayoutManager
|
||||
import com.google.android.flexbox.JustifyContent
|
||||
import com.yizhuan.erban.R
|
||||
import com.yizhuan.erban.base.BaseDialog
|
||||
import com.yizhuan.erban.databinding.DialogUserTagBinding
|
||||
import com.yizhuan.erban.ui.user.activity.EditUserTagActivity
|
||||
import com.yizhuan.erban.ui.user.adapter.UserLabelDialogAdapter
|
||||
import com.yizhuan.xchat_android_core.auth.AuthModel
|
||||
import com.yizhuan.xchat_android_core.user.UserModel
|
||||
import java.io.Serializable
|
||||
|
||||
/**
|
||||
* 用户标签
|
||||
* Created by wushaocheng on 2023/2/16.
|
||||
*/
|
||||
class UserLabelDialog :
|
||||
BaseDialog<DialogUserTagBinding>() {
|
||||
|
||||
companion object {
|
||||
const val KEY_LABEL = "key_label"
|
||||
|
||||
@JvmStatic
|
||||
fun newInstance(label: List<String>): UserLabelDialog {
|
||||
val userLabelDialog = UserLabelDialog()
|
||||
val bundle = Bundle()
|
||||
bundle.putSerializable(KEY_LABEL, label as Serializable?)
|
||||
userLabelDialog.arguments = bundle
|
||||
return userLabelDialog
|
||||
}
|
||||
}
|
||||
|
||||
private val mTagAdapter by lazy { UserLabelDialogAdapter() }
|
||||
|
||||
override fun init() {
|
||||
initListener()
|
||||
initAdapter()
|
||||
initLabel()
|
||||
}
|
||||
|
||||
private fun initListener() {
|
||||
binding.ivClose.setOnClickListener { dismissAllowingStateLoss() }
|
||||
|
||||
binding.tvEdit.setOnClickListener {
|
||||
dismissAllowingStateLoss()
|
||||
context?.let { it1 -> EditUserTagActivity.start(it1) }
|
||||
}
|
||||
}
|
||||
|
||||
private fun initAdapter() {
|
||||
val flexBoxLayoutManager = FlexboxLayoutManager(context)
|
||||
flexBoxLayoutManager.flexDirection = FlexDirection.ROW//主轴为水平方向,起点在左端
|
||||
flexBoxLayoutManager.flexWrap = FlexWrap.WRAP//按正常方向换行
|
||||
flexBoxLayoutManager.justifyContent = JustifyContent.FLEX_START//交叉轴的起点对齐
|
||||
binding.mRecyclerView.layoutManager = flexBoxLayoutManager
|
||||
binding.mRecyclerView.adapter = mTagAdapter
|
||||
}
|
||||
|
||||
private fun initLabel() {
|
||||
if (AuthModel.get().currentUid != UserModel.get().cacheLoginUserInfo?.uid) {
|
||||
binding.tvTitle.text = getString(R.string.other_label)
|
||||
binding.tvEdit.visibility = View.GONE
|
||||
} else {
|
||||
binding.tvTitle.text = getString(R.string.my_label)
|
||||
binding.tvEdit.visibility = View.VISIBLE
|
||||
}
|
||||
val labelList = arguments?.getSerializable(KEY_LABEL) as List<String?>?
|
||||
mTagAdapter.setNewData(labelList)
|
||||
}
|
||||
|
||||
}
|
@@ -1,63 +0,0 @@
|
||||
package com.yizhuan.erban.ui.user.dialog
|
||||
|
||||
import com.hjq.toast.ToastUtils
|
||||
import com.yizhuan.erban.base.BaseDialog
|
||||
import com.yizhuan.erban.databinding.DialogUserTagBinding
|
||||
import com.yizhuan.erban.ui.user.activity.EditUserTagActivity
|
||||
import com.yizhuan.erban.ui.user.adapter.UserTagAdapter
|
||||
import com.yizhuan.xchat_android_core.user.UserModel
|
||||
import com.yizhuan.xchat_android_core.user.bean.UserLabelInfo
|
||||
import io.reactivex.SingleObserver
|
||||
import io.reactivex.disposables.Disposable
|
||||
|
||||
/**
|
||||
* 用户标签
|
||||
* Created by wushaocheng on 2023/2/16.
|
||||
*/
|
||||
class UserTagDialog :
|
||||
BaseDialog<DialogUserTagBinding>() {
|
||||
|
||||
companion object {
|
||||
@JvmStatic
|
||||
fun newInstance(): UserTagDialog {
|
||||
return UserTagDialog()
|
||||
}
|
||||
}
|
||||
|
||||
private val mTagAdapter by lazy { UserTagAdapter() }
|
||||
|
||||
override fun init() {
|
||||
|
||||
initAdapter()
|
||||
|
||||
initListener()
|
||||
|
||||
}
|
||||
|
||||
private fun initAdapter() {
|
||||
binding.mRecyclerView.adapter = mTagAdapter
|
||||
}
|
||||
|
||||
private fun initListener() {
|
||||
binding.ivClose.setOnClickListener { dismissAllowingStateLoss() }
|
||||
|
||||
binding.tvEdit.setOnClickListener {
|
||||
UserModel.get().userLabelInfo.subscribe(object : SingleObserver<UserLabelInfo> {
|
||||
override fun onSubscribe(d: Disposable) {
|
||||
|
||||
}
|
||||
|
||||
override fun onSuccess(userLabelInfo: UserLabelInfo) {
|
||||
context?.let { it1 -> EditUserTagActivity.start(it1, userLabelInfo) }
|
||||
dismissAllowingStateLoss()
|
||||
}
|
||||
|
||||
override fun onError(e: Throwable) {
|
||||
ToastUtils.show(e.message)
|
||||
}
|
||||
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@@ -69,6 +69,7 @@ class UserInfoInfoFragment : BaseViewBindingFragment<FragmentUserinfoUserinfoBin
|
||||
}
|
||||
val birth = TimeUtil.getDateTimeString(bean.birth, "yyyy-MM-dd")
|
||||
binding.tvBirth.text = birth
|
||||
binding.tvArea.text = bean.region
|
||||
}
|
||||
|
||||
private fun initPersonalData(clanAndHallInfo: ClanAndHallInfo) {
|
||||
|
@@ -0,0 +1,42 @@
|
||||
package com.yizhuan.erban.ui.widget.recyclerview.decoration
|
||||
|
||||
import android.graphics.Rect
|
||||
import android.view.View
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import androidx.recyclerview.widget.RecyclerView.ItemDecoration
|
||||
import com.google.android.flexbox.FlexboxLayoutManager
|
||||
|
||||
/**
|
||||
* 标签列表的ItemDecoration
|
||||
* 使用FlexboxLayoutManager的RecyclerView的ItemDecoration
|
||||
* @param verSpacing 纵向间距
|
||||
* @param horSpacing 横向间距
|
||||
*/
|
||||
class TagItemDecoration(private val verSpacing: Int, private val horSpacing: Int) : ItemDecoration() {
|
||||
private var mOnLineListener: ((Int, Int, Int) -> Unit)? = null
|
||||
private var mLineCount = 0
|
||||
private var mLineFirstPosition = 0
|
||||
|
||||
override fun getItemOffsets(outRect: Rect, view: View, parent: RecyclerView, state: RecyclerView.State) {
|
||||
super.getItemOffsets(outRect, view, parent, state)
|
||||
val currentPosition = parent.getChildAdapterPosition(view)
|
||||
outRect.left = horSpacing / 2
|
||||
outRect.right = horSpacing / 2
|
||||
outRect.top = verSpacing
|
||||
|
||||
|
||||
if (mOnLineListener != null) {
|
||||
(parent.layoutManager as? FlexboxLayoutManager)?.let {
|
||||
if (mLineCount != it.flexLines.size) {
|
||||
mLineCount = it.flexLines.size
|
||||
mLineFirstPosition = currentPosition
|
||||
}
|
||||
mOnLineListener?.invoke(mLineCount, currentPosition, mLineFirstPosition)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun setOnLineListener(body: (Int, Int, Int) -> Unit) {
|
||||
this.mOnLineListener = body
|
||||
}
|
||||
}
|
@@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<item android:color="@color/color_00C4EA" android:state_selected="true" />
|
||||
<item android:color="@color/color_6D6B89" />
|
||||
|
||||
</selector>
|
7
app/src/main/res/color/color_selector_user_label.xml
Normal file
7
app/src/main/res/color/color_selector_user_label.xml
Normal file
@@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<item android:color="@color/color_9168FA" android:state_selected="true" />
|
||||
<item android:color="@color/color_1F1B4F" />
|
||||
|
||||
</selector>
|
BIN
app/src/main/res/drawable-xhdpi/ic_user_info_label_edit.webp
Normal file
BIN
app/src/main/res/drawable-xhdpi/ic_user_info_label_edit.webp
Normal file
Binary file not shown.
After Width: | Height: | Size: 334 B |
9
app/src/main/res/drawable/bg_user_info_label.xml
Normal file
9
app/src/main/res/drawable/bg_user_info_label.xml
Normal file
@@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="rectangle">
|
||||
|
||||
<corners android:radius="@dimen/dp_9"/>
|
||||
|
||||
<solid android:color="@color/color_F3F5F9"/>
|
||||
|
||||
</shape>
|
8
app/src/main/res/drawable/bg_user_info_label_select.xml
Normal file
8
app/src/main/res/drawable/bg_user_info_label_select.xml
Normal file
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="rectangle">
|
||||
|
||||
<solid android:color="#213AD5F8" />
|
||||
<corners android:radius="@dimen/dp_9" />
|
||||
|
||||
</shape>
|
@@ -386,15 +386,14 @@
|
||||
</LinearLayout>
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/mTagRecyclerView"
|
||||
android:id="@+id/mLabelRecyclerView"
|
||||
android:orientation="horizontal"
|
||||
android:layout_marginTop="@dimen/dp_12"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_constraintTop_toBottomOf="@id/ll_level"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toStartOf="@+id/ivTagArrow"
|
||||
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"/>
|
||||
app:layout_constraintEnd_toStartOf="@+id/ivTagArrow" />
|
||||
|
||||
<androidx.appcompat.widget.AppCompatImageView
|
||||
android:id="@+id/ivTagArrow"
|
||||
@@ -402,13 +401,37 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/ic_tag_arrow"
|
||||
android:layout_marginTop="@dimen/dp_12"
|
||||
android:layout_marginEnd="@dimen/dp_12"
|
||||
app:layout_constraintTop_toBottomOf="@id/ll_level"
|
||||
app:layout_constraintEnd_toEndOf="parent"/>
|
||||
|
||||
<androidx.constraintlayout.widget.Group
|
||||
android:id="@+id/groupLabel"
|
||||
android:visibility="gone"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
app:constraint_referenced_ids="mTagRecyclerView,ivTagArrow"/>
|
||||
app:constraint_referenced_ids="mLabelRecyclerView,ivTagArrow"/>
|
||||
|
||||
<com.coorchice.library.SuperTextView
|
||||
android:id="@+id/tvEditLabel"
|
||||
android:text="@string/edit_your_user_label"
|
||||
android:textSize="@dimen/sp_10"
|
||||
android:textColor="@color/color_00C4EA"
|
||||
android:visibility="gone"
|
||||
android:gravity="center"
|
||||
android:drawableStart="@drawable/ic_user_info_label_edit"
|
||||
android:drawablePadding="@dimen/dp_10"
|
||||
app:corner="@dimen/dp_10"
|
||||
app:solid="@color/color_E1FAFF"
|
||||
android:paddingStart="@dimen/dp_9"
|
||||
android:paddingEnd="@dimen/dp_15"
|
||||
android:paddingTop="@dimen/dp_3"
|
||||
android:paddingBottom="@dimen/dp_3"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/dp_12"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/mLabelRecyclerView"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_desc"
|
||||
@@ -419,7 +442,7 @@
|
||||
android:maxLines="2"
|
||||
android:textColor="@color/color_B3B3C3"
|
||||
android:textSize="@dimen/sp_13"
|
||||
app:layout_constraintTop_toBottomOf="@id/mTagRecyclerView"
|
||||
app:layout_constraintTop_toBottomOf="@id/tvEditLabel"
|
||||
tools:text="@string/layout_activity_user_info_04" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
@@ -32,11 +32,11 @@
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
tools:text="TA的标签"/>
|
||||
tools:text="@string/other_label"/>
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/mRecyclerView"
|
||||
android:layout_marginTop="@dimen/dp_15"
|
||||
android:layout_marginTop="@dimen/dp_7"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="@dimen/dp_15"
|
||||
|
15
app/src/main/res/layout/item_user_info_label.xml
Normal file
15
app/src/main/res/layout/item_user_info_label.xml
Normal file
@@ -0,0 +1,15 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.appcompat.widget.AppCompatTextView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/tv_user_tag"
|
||||
android:textColor="@color/color_selector_user_info_label"
|
||||
android:textSize="@dimen/sp_10"
|
||||
android:layout_marginEnd="@dimen/dp_5"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingStart="@dimen/dp_6"
|
||||
android:paddingTop="@dimen/dp_2"
|
||||
android:paddingEnd="@dimen/dp_6"
|
||||
android:paddingBottom="@dimen/dp_2"
|
||||
android:background="@drawable/selector_user_info_label"
|
||||
tools:text="上班族" />
|
@@ -11,7 +11,7 @@
|
||||
android:paddingTop="@dimen/dp_8"
|
||||
android:paddingEnd="@dimen/dp_16"
|
||||
android:paddingBottom="@dimen/dp_8"
|
||||
android:textColor="@color/color_1F1B4F"
|
||||
android:textColor="@color/color_selector_user_label"
|
||||
android:textSize="@dimen/sp_13"
|
||||
android:background="@drawable/selector_user_label"
|
||||
tools:text="上班族" />
|
@@ -1,16 +1,17 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<com.coorchice.library.SuperTextView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<androidx.appcompat.widget.AppCompatTextView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/tv_user_tag"
|
||||
android:textColor="@color/color_6D6B89"
|
||||
android:textColor="@color/color_selector_user_info_label"
|
||||
android:textSize="@dimen/sp_10"
|
||||
android:layout_marginEnd="@dimen/dp_5"
|
||||
android:layout_marginTop="@dimen/dp_7"
|
||||
android:layout_marginBottom="@dimen/dp_7"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingStart="@dimen/dp_6"
|
||||
android:paddingTop="@dimen/dp_2"
|
||||
android:paddingEnd="@dimen/dp_6"
|
||||
android:paddingBottom="@dimen/dp_2"
|
||||
app:corner="@dimen/dp_9"
|
||||
app:solid="@color/color_F3F5F9"
|
||||
android:background="@drawable/selector_user_info_label"
|
||||
tools:text="上班族" />
|
@@ -647,5 +647,8 @@
|
||||
<color name="color_D8D8D8">#D8D8D8</color>
|
||||
<color name="color_F3F5F9">#F3F5F9</color>
|
||||
<color name="color_1F1B4F">#1F1B4F</color>
|
||||
<color name="color_3AD5F8">#3AD5F8</color>
|
||||
<color name="color_00C4EA">#00C4EA</color>
|
||||
<color name="color_E1FAFF">#E1FAFF</color>
|
||||
|
||||
</resources>
|
||||
|
@@ -5068,10 +5068,12 @@
|
||||
<string name="gold_exchange_power">的金幣兌換權限嗎?</string>
|
||||
<string name="edit_tag">編輯標簽</string>
|
||||
<string name="edit_your_tags_tip">編輯你的標簽,可以大大提高你的人氣~</string>
|
||||
<string name="my_tag">我的標簽</string>
|
||||
<string name="my_label">我的標簽</string>
|
||||
<string name="setting_personal_tags_will_be_more_popular">設置個人標簽將更受歡迎~</string>
|
||||
<string name="gold_exchange_permission_of_the_user_has_been_disabled">已關閉該用戶的金幣兌換權限~</string>
|
||||
<string name="gold_exchange_permission_of_the_user_has_been_enabled">已開啟該用戶的金幣兌換權限~</string>
|
||||
<string name="max_to_add_label">最多只能添加20個標簽哦~</string>
|
||||
<string name="edit_your_user_label">設置你的個人標簽</string>
|
||||
<string name="other_label">TA的标签</string>
|
||||
|
||||
</resources>
|
@@ -242,4 +242,9 @@ public interface IUserModel extends IModel {
|
||||
*/
|
||||
Single<String> saveLabel(String label);
|
||||
|
||||
/**
|
||||
* 获取地区列表
|
||||
*/
|
||||
Single<List<String>> getAreaInfo();
|
||||
|
||||
}
|
||||
|
@@ -830,6 +830,13 @@ public final class UserModel extends BaseModel implements IUserModel {
|
||||
@Override
|
||||
public Single<String> saveLabel(String label) {
|
||||
return api.saveLabel(label)
|
||||
.compose(RxHelper.handleStringData())
|
||||
.compose(RxHelper.handleSchedulers());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Single<List<String>> getAreaInfo() {
|
||||
return api.getAreaInfo()
|
||||
.compose(RxHelper.handleBeanData())
|
||||
.compose(RxHelper.handleSchedulers());
|
||||
}
|
||||
@@ -1096,5 +1103,11 @@ public final class UserModel extends BaseModel implements IUserModel {
|
||||
@POST("/label/save")
|
||||
Single<ServiceResult<String>> saveLabel(@Query("labels") String labels);
|
||||
|
||||
/**
|
||||
* 获取地区列表
|
||||
*/
|
||||
@GET("/region/config")
|
||||
Single<ServiceResult<List<String>>> getAreaInfo();
|
||||
|
||||
}
|
||||
}
|
||||
|
@@ -70,6 +70,15 @@ public class UserDetailInfo implements Serializable {
|
||||
private List<PrivatePhotoBean> privatePhoto;
|
||||
private String nameplatePic;
|
||||
private String nameplateWord;
|
||||
private String region;
|
||||
|
||||
public String getRegion() {
|
||||
return region;
|
||||
}
|
||||
|
||||
public void setRegion(String region) {
|
||||
this.region = region;
|
||||
}
|
||||
|
||||
public long getRoomUid() {
|
||||
return roomUid;
|
||||
|
@@ -106,6 +106,8 @@ public class UserInfo implements Serializable {
|
||||
//1普通账号,2官方账号,3机器账号 ,4公会账号
|
||||
private int defUser;
|
||||
//地区
|
||||
@Getter
|
||||
@Setter
|
||||
private String region;
|
||||
//个人简介
|
||||
private String userDesc;
|
||||
@@ -302,6 +304,12 @@ public class UserInfo implements Serializable {
|
||||
@Setter
|
||||
private boolean hasPermitRoom;
|
||||
|
||||
/**
|
||||
* 标签
|
||||
*/
|
||||
@Getter
|
||||
private List<String> labels;
|
||||
|
||||
public UserInfo() {
|
||||
|
||||
}
|
||||
@@ -519,14 +527,6 @@ public class UserInfo implements Serializable {
|
||||
this.defUser = defUser;
|
||||
}
|
||||
|
||||
public String getRegion() {
|
||||
return region;
|
||||
}
|
||||
|
||||
public void setRegion(String region) {
|
||||
this.region = region;
|
||||
}
|
||||
|
||||
public String getUserDesc() {
|
||||
return userDesc;
|
||||
}
|
||||
|
@@ -16,5 +16,4 @@ public class ClanInfo {
|
||||
private boolean userIsElder;
|
||||
private long hallId;
|
||||
private String levelIcon;
|
||||
|
||||
}
|
||||
|
@@ -41,4 +41,5 @@ public class HallInfo {
|
||||
* 厅主昵称
|
||||
*/
|
||||
private String ownerNick;
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user