feat:删除用户信息页不必要的请求

This commit is contained in:
max
2024-06-24 19:58:18 +08:00
parent 16a8f9a52a
commit 0a70c6a478
6 changed files with 1 additions and 554 deletions

View File

@@ -138,7 +138,6 @@ public class UserInfoActivity extends BaseBindingActivity<ActivityUserInfoBindin
super.onResume();
viewModel.getUserInfo();
viewModel.getUserInfoDetail();
viewModel.getUserHallAndClan();
}
private void initAttentionView() {

View File

@@ -1,56 +0,0 @@
package com.chwl.app.ui.user.fragment
import android.content.Intent
import android.widget.LinearLayout
import android.widget.TextView
import androidx.fragment.app.Fragment
import com.chwl.app.R
import com.chwl.app.avroom.adapter.CommonVPAdapter
import com.chwl.app.base.BaseViewBindingFragment
import com.chwl.app.databinding.FragmentUserinfoGiftWallBinding
import com.chwl.app.ui.user.activity.UserGiftActivity
import com.chwl.app.ui.user.adapter.CommonWrapIndicatorAdapter
import com.chwl.app.ui.widget.magicindicator.MagicIndicator
import com.chwl.app.ui.widget.magicindicator.ViewPagerHelper
import com.chwl.app.ui.widget.magicindicator.buildins.commonnavigator.CommonNavigator
class UserInfoGiftWallFragment : BaseViewBindingFragment<FragmentUserinfoGiftWallBinding>() {
override fun init() {
initGiftList()
binding.ivGiftDetail.setOnClickListener {
val starter = Intent(context, UserGiftActivity::class.java)
context?.startActivity(starter)
}
}
/**
* 礼物列表
*
* @param list
*/
private fun initGiftList() {
val viewPager = binding.viewPagerGift
val magicIndicator: MagicIndicator = binding.magicIndicatorGift
val fragmentList: MutableList<Fragment> = ArrayList(2)
//礼物类型 1:普通礼物;2:辛运礼物
fragmentList.add(UserInfoGiftFragment.newInstance(1, false))
fragmentList.add(UserInfoGiftFragment.newInstance(2, false))
val tagList: MutableList<String> = ArrayList(2)
tagList.add(getString(R.string.me_ordinary_gift))
tagList.add(getString(R.string.me_lucky_gift))
val commonNavigator = CommonNavigator(context)
commonNavigator.setTitleWrapContent(true)
val magicIndicatorAdapter = CommonWrapIndicatorAdapter(context, tagList)
magicIndicatorAdapter.setOnItemSelectListener { position: Int, view: TextView? ->
viewPager.currentItem = position
}
commonNavigator.adapter = magicIndicatorAdapter
magicIndicator.navigator = commonNavigator
commonNavigator.titleContainer.showDividers = LinearLayout.SHOW_DIVIDER_MIDDLE
viewPager.offscreenPageLimit = 2
viewPager.adapter = CommonVPAdapter(childFragmentManager, lifecycle, fragmentList)
ViewPagerHelper.bind(magicIndicator, viewPager)
}
}

View File

@@ -1,268 +0,0 @@
package com.chwl.app.ui.user.fragment
import android.view.View
import androidx.fragment.app.activityViewModels
import com.netease.nim.uikit.common.util.sys.TimeUtil
import com.chwl.app.R
import com.chwl.app.base.BaseViewBindingFragment
import com.chwl.app.databinding.FragmentUserinfoUserinfoBinding
import com.chwl.app.module_hall.hall.activity.ModuleClanActivity
import com.chwl.app.module_hall.hall.activity.ModuleHallActivity
import com.chwl.app.ui.user.viewmodel.UserInfoViewModel
import com.chwl.app.ui.webview.CommonWebViewActivity
import com.chwl.core.UriProvider
import com.chwl.core.auth.AuthModel
import com.chwl.core.family.bean.FamilyInfo
import com.chwl.core.module_hall.hall.bean.ClanAndHallInfo
import com.chwl.core.module_hall.hall.bean.ClanInfo
import com.chwl.core.module_hall.hall.bean.H5FamilyInfo
import com.chwl.core.module_hall.hall.bean.HallInfo
import com.chwl.core.user.UserInfoUiMgr
import com.chwl.core.user.bean.UserDetailInfo
class UserInfoInfoFragment : BaseViewBindingFragment<FragmentUserinfoUserinfoBinding>() {
private val vm: UserInfoViewModel by activityViewModels()
// private var dynamicAdapter: UserInfoDynamicAdapter? = null
override fun init() {
// EventBus.getDefault().register(this)
vm.userClanData.observe(this) {
val clanInfo = it.asClanHall()
if (clanInfo != null) {
initPersonalData(clanInfo)
} else {
val familyInfo = it.asFamily()
if (familyInfo != null) {
initPersonalData(familyInfo)
}
}
}
vm.userInfoDetailData.observe(this) {
initInfoData(it)
// initDynamicList(it.dynamicInfo)
}
}
private fun initInfoData(bean: UserDetailInfo.DataBean) {
val birth = TimeUtil.getChinaDateTimeString(bean.birth, "yyyy-MM-dd")
binding.tvBirth.text = birth
binding.tvArea.text = bean.region
}
private fun initPersonalData(clanAndHallInfo: ClanAndHallInfo) {
val hallInfo: HallInfo? = clanAndHallInfo.hall
val clanInfo: ClanInfo? = clanAndHallInfo.clan
if (AuthModel.get().currentUid == UserInfoUiMgr.get().uid) {
binding.tvMore.visibility = View.GONE
binding.llRoom.visibility = View.VISIBLE
binding.llAssociation.visibility = View.VISIBLE
} else {
binding.tvMore.visibility = View.VISIBLE
binding.llRoom.visibility = View.GONE
binding.llAssociation.visibility = View.GONE
binding.tvMore.setOnClickListener {
binding.tvMore.visibility = View.GONE
binding.llRoom.visibility = View.VISIBLE
if (clanInfo != null && clanInfo.id > 0) {
binding.llAssociation.visibility = View.VISIBLE
} else {
binding.llAssociation.visibility = View.GONE
}
}
}
if (hallInfo != null && hallInfo.hallId > 0) {
binding.tvRoom.visibility = View.VISIBLE
binding.tvJoinRoom.visibility = View.GONE
binding.tvRoom.text = hallInfo.hallName
} else {
binding.tvRoom.visibility = View.GONE
binding.tvJoinRoom.visibility = View.VISIBLE
if (AuthModel.get().currentUid == UserInfoUiMgr.get().uid) {
binding.tvJoinRoom.text = getString(R.string.no_room_has_been_added_yet)
} else {
binding.tvJoinRoom.text = getString(R.string.user_no_room_has_been_added_yet)
}
}
if (clanInfo != null && clanInfo.id > 0) {
binding.tvAssociation.text = clanInfo.name
} else {
binding.llAssociation.visibility = View.GONE
}
binding.tvRoom.setOnClickListener {
if (hallInfo != null && hallInfo.hallId != 0L) {
ModuleHallActivity.start(
context,
hallInfo.hallId,
hallInfo.ownerUid
)
}
}
binding.tvAssociation.setOnClickListener {
ModuleClanActivity.start(context, vm.userId)
}
}
private fun initPersonalData(familyInfo: H5FamilyInfo) {
if (AuthModel.get().currentUid == UserInfoUiMgr.get().uid) {
binding.tvMore.visibility = View.GONE
binding.llRoom.visibility = View.GONE
binding.llAssociation.visibility = View.VISIBLE
} else {
binding.tvMore.visibility = View.VISIBLE
binding.llRoom.visibility = View.GONE
binding.llAssociation.visibility = View.GONE
binding.tvMore.setOnClickListener {
binding.tvMore.visibility = View.GONE
binding.llRoom.visibility = View.VISIBLE
if ((familyInfo.familyId ?: 0) > 0L) {
binding.llAssociation.visibility = View.VISIBLE
} else {
binding.llAssociation.visibility = View.GONE
}
}
}
binding.tvJoinRoom.visibility = View.GONE
if ((familyInfo.familyId ?: 0) > 0L) {
binding.tvAssociation.text = familyInfo.familyName
} else {
binding.llAssociation.visibility = View.GONE
}
binding.tvAssociation.setOnClickListener {
CommonWebViewActivity.start(context, familyInfo.getFullMyFamilyUrl())
}
}
// /**
// * 动态列表
// *
// * @param worldDynamicList
// */
// private fun initDynamicList(worldDynamicList: List<WorldDynamicBean>) {
// if (dynamicAdapter == null) {
// dynamicAdapter = UserInfoDynamicAdapter(mContext)
// dynamicAdapter?.setEnableLoadMore(false)
// dynamicAdapter?.setOnItemChildClickListener { _, view: View, pos: Int ->
// val bean: WorldDynamicBean =
// dynamicAdapter?.getItem(pos) ?: return@setOnItemChildClickListener
// if (view.id == R.id.iv_more) {
// val list: MutableList<ButtonItem> = ArrayList()
// if (!UserModel.get().isMyseft(bean.uid)) {
// val item = ButtonItem(
// getString(R.string.me_shield_dynamic)
// ) {
// UserModel.get().addReport(bean.dynamicId, 0)
// .subscribe(object : BeanObserver<String?>() {
// override fun onErrorMsg(error: String) {
// dialogManager.dismissDialog()
// toast(error)
// }
//
// override fun onSuccess(s: String) {
// dialogManager.dismissDialog()
// toast(ResUtil.getString(R.string.me_shield_success))
// if (pos < (dynamicAdapter?.data?.size ?: 0)) {
// if (bean == dynamicAdapter?.getItem(pos)) {
// dynamicAdapter?.remove(pos)
// }
// }
// }
// })
// }
// list.add(item)
// }
// if (!UserModel.get().isMyseft(bean.uid)) {
// val blackListItem = ButtonItemFactory.createAddToBlackListItem(
// dialogManager, bean.uid.toString()
// )
// list.add(blackListItem)
// }
// if (!UserModel.get().isMyseft(bean.uid)) {
// val item = ButtonItem(
// getString(R.string.me_report_dynamic)
// ) {
// UIHelper.showReportPage(
// mContext, bean.uid,
// XConstants.REPORT_TYPE_DYNAMIC_SQUARE
// )
// }
// list.add(item)
// }
// if (UserModel.get().isMyseft(bean.uid) ||
// isThisWorldOwner(bean)
// ) {
// val item = ButtonItem(
// getString(R.string.me_delete)
// ) { deleteDynamic(pos, dynamicAdapter) }
// list.add(item)
// }
// dialogManager.showCommonPopupDialog(list, getString(R.string.cancel))
// } else if (view.id == R.id.ll_share) {
// ShareDynamicHelper(activity).share(bean)
// }
// }
// binding.mRecyclerView.adapter = dynamicAdapter
// }
// dynamicAdapter?.setNewData(worldDynamicList)
// }
//
// private fun deleteDynamic(pos: Int, adapter: UserInfoDynamicAdapter?) {
// dialogManager.showOkCancelWithTitleDialog(getString(R.string.me_cannot_be_restored),
// DialogManager.OkCancelDialogListener {
// val bean = adapter?.getItem(pos) ?: return@OkCancelDialogListener
// DynamicModel.get().delete(bean.worldId, bean.dynamicId)
// .compose(bindUntilEvent(FragmentEvent.DESTROY_VIEW))
// .doOnSubscribe { dialogManager.showProgressDialog(mContext) }
// .subscribe(object : DontWarnObserver<String?>() {
// override fun accept(s: String?, error: String?) {
// super.accept(s, error)
// dialogManager.dismissDialog()
// if (error != null) {
// toast(error)
// } else {
// toast(getString(R.string.me_successfully_delete))
// if (pos < adapter.data.size) {
// if (bean == adapter.getItem(pos)) {
// adapter.remove(pos)
// }
// }
// }
// }
// })
// })
// }
// /**
// * 判断自己是不是该世界的创始人
// */
// private fun isThisWorldOwner(bean: WorldDynamicBean?): Boolean {
// return bean != null && bean.worldUid == AuthModel.get().currentUid
// }
// @Subscribe(threadMode = ThreadMode.MAIN)
// fun onDynamicRefreshEvent(event: DynamicRefreshEvent?) {
// if (isResumed) {
// vm.userInfoDetailData.observe(this) {
// initInfoData(it)
// initDynamicList(it.dynamicInfo)
// }
// }
// }
// override fun onDestroyView() {
// EventBus.getDefault().unregister(this)
// super.onDestroyView()
// }
}

View File

@@ -1,53 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.core.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_marginHorizontal="@dimen/dp_15"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:id="@+id/ll_top"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/bg_ffffff_8"
android:orientation="vertical"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent">
<com.chwl.app.ui.widget.magicindicator.MagicIndicator
android:id="@+id/magic_indicator_gift"
android:layout_width="wrap_content"
android:layout_height="22dp"
android:layout_gravity="center_horizontal"
android:layout_marginTop="@dimen/dp_14" />
<androidx.viewpager2.widget.ViewPager2
android:id="@+id/view_pager_gift"
android:layout_width="match_parent"
android:layout_height="320dp" />
</LinearLayout>
<ImageView
android:id="@+id/iv_gift_detail"
android:src="@drawable/icon_arrow_right_small"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingStart="@dimen/dp_8"
android:paddingEnd="@dimen/dp_8"
android:paddingTop="@dimen/dp_8"
android:paddingBottom="@dimen/dp_8"
android:layout_marginEnd="15dp"
android:layout_marginTop="15dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"/>
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.core.widget.NestedScrollView>

View File

@@ -1,175 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.core.widget.NestedScrollView 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"
android:layout_marginHorizontal="@dimen/dp_15">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:id="@+id/ll_personal_data"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/bg_ffffff_8"
android:orientation="vertical"
android:padding="@dimen/dp_12"
tools:visibility="visible">
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/tv_hall_detail1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/personal_data"
android:textColor="@color/text_title_color"
android:textSize="@dimen/sp_14"
android:textStyle="bold"
android:visibility="visible" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_12"
android:orientation="horizontal">
<androidx.appcompat.widget.AppCompatTextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/user_birthday"
android:textColor="@color/text_title_color"
android:textSize="@dimen/sp_12" />
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/tvBirth"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/dp_10"
android:textColor="@color/text_title_color"
android:textSize="@dimen/sp_12"
tools:text="1999-10-21" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_6"
android:orientation="horizontal">
<androidx.appcompat.widget.AppCompatTextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/user_area"
android:textColor="@color/text_title_color"
android:textSize="@dimen/sp_12" />
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/tvArea"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/dp_10"
android:textColor="@color/text_title_color"
android:textSize="@dimen/sp_12"
tools:text="馬來西亞" />
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/tvMore"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/dp_10"
android:drawableEnd="@drawable/ic_room_yellow_arrow"
android:gravity="center"
android:text="@string/home_more"
android:textColor="@color/color_ffbc51"
android:textSize="@dimen/sp_12"
android:visibility="gone" />
</LinearLayout>
<LinearLayout
android:id="@+id/llRoom"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_6"
android:orientation="horizontal">
<androidx.appcompat.widget.AppCompatTextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/user_room"
android:textColor="@color/text_title_color"
android:textSize="@dimen/sp_12" />
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/tvRoom"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/dp_10"
android:drawableEnd="@drawable/ic_room_yellow_arrow"
android:gravity="center"
android:textColor="@color/color_ffbc51"
android:textSize="@dimen/sp_12"
tools:text="QX家族" />
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/tvJoinRoom"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/dp_10"
android:gravity="center"
android:textColor="@color/text_title_color"
android:textSize="@dimen/sp_12"
android:visibility="gone"
tools:text="@string/no_room_has_been_added_yet" />
</LinearLayout>
<LinearLayout
android:id="@+id/llAssociation"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_6"
android:orientation="horizontal">
<androidx.appcompat.widget.AppCompatTextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/user_association"
android:textColor="@color/text_title_color"
android:textSize="@dimen/sp_12" />
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/tvAssociation"
android:gravity="center_vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/dp_10"
android:drawableEnd="@drawable/ic_room_yellow_arrow"
android:textColor="@color/color_ffbc51"
android:textSize="@dimen/sp_12"
tools:text="無憂傳媒" />
</LinearLayout>
</LinearLayout>
<!-- <androidx.recyclerview.widget.RecyclerView-->
<!-- android:id="@+id/mRecyclerView"-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:layout_marginTop="@dimen/dp_14"-->
<!-- android:layout_marginBottom="@dimen/dp_60"-->
<!-- android:background="@drawable/bg_ffffff_8"-->
<!-- android:nestedScrollingEnabled="false"-->
<!-- android:overScrollMode="never"-->
<!-- android:scrollbars="none"-->
<!-- app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" />-->
</LinearLayout>
</androidx.core.widget.NestedScrollView>

View File

@@ -32,7 +32,7 @@ COMPILE_SDK_VERSION=33
MIN_SDK_VERSION=21
TARGET_SDK_VERSION=33
version_name=1.0.8
version_name=1.0.9
version_code=11
#systemProp.https.proxyHost=127.0.0.1