个人主页礼物墙接口对接
This commit is contained in:
@@ -28,8 +28,9 @@ public class UserGiftActivity extends BaseActivity {
|
||||
ViewPager viewPager = findViewById(R.id.view_pager);
|
||||
MagicIndicator magicIndicator = findViewById(R.id.magic_indicator);
|
||||
List<Fragment> fragmentList = new ArrayList<>(2);
|
||||
fragmentList.add(UserInfoGiftFragment.newInstance());
|
||||
fragmentList.add(UserInfoGiftFragment.newInstance());
|
||||
//礼物类型 1:常规礼物;2:辛运礼物
|
||||
fragmentList.add(UserInfoGiftFragment.newInstance(1,true));
|
||||
fragmentList.add(UserInfoGiftFragment.newInstance(2,true));
|
||||
UserInfoPagerAdapter pagerAdapter = new UserInfoPagerAdapter(getSupportFragmentManager(), fragmentList);
|
||||
final List<String> tagList = new ArrayList<>(2);
|
||||
tagList.add("普通礼物");
|
||||
|
@@ -1,10 +1,13 @@
|
||||
package com.yizhuan.erban.ui.user;
|
||||
|
||||
import androidx.lifecycle.Observer;
|
||||
|
||||
import android.os.Bundle;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.recyclerview.widget.GridLayoutManager;
|
||||
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
@@ -54,9 +57,15 @@ public class UserInfoGiftFragment extends BaseBindingFragment<FragmentUserInfoGi
|
||||
private UserGiftAdapter userGiftAdapter;
|
||||
private Observer mObserver;
|
||||
private Observer mUidObserver;
|
||||
private boolean isDetails = false;
|
||||
|
||||
public static UserInfoGiftFragment newInstance() {
|
||||
return new UserInfoGiftFragment();
|
||||
public static UserInfoGiftFragment newInstance(int giftType, boolean isDetails) {
|
||||
UserInfoGiftFragment userInfoGiftFragment = new UserInfoGiftFragment();
|
||||
Bundle args = new Bundle();
|
||||
args.putInt("giftType", giftType);
|
||||
args.putBoolean("isDetails", isDetails);
|
||||
userInfoGiftFragment.setArguments(args);
|
||||
return userInfoGiftFragment;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -90,8 +99,9 @@ public class UserInfoGiftFragment extends BaseBindingFragment<FragmentUserInfoGi
|
||||
|
||||
@Override
|
||||
public void initiate() {
|
||||
isDetails = requireArguments().getBoolean("isDetails", false);
|
||||
mBinding.rvGift.setLayoutManager(new GridLayoutManager(mContext, 4));
|
||||
userGiftAdapter = new UserGiftAdapter(mContext, userInfoItems);
|
||||
userGiftAdapter = new UserGiftAdapter(mContext, userInfoItems, isDetails);
|
||||
userGiftAdapter.bindToRecyclerView(mBinding.rvGift);
|
||||
userGiftAdapter.setSpanSizeLookup(new BaseQuickAdapter.SpanSizeLookup() {
|
||||
@Override
|
||||
@@ -123,7 +133,7 @@ public class UserInfoGiftFragment extends BaseBindingFragment<FragmentUserInfoGi
|
||||
return;
|
||||
}
|
||||
time = System.currentTimeMillis();
|
||||
UserModel.get().requestUserGiftWall(userId, 2)
|
||||
UserModel.get().requestUserGiftWall(userId, requireArguments().getInt("giftType"), 2)
|
||||
.compose(bindUntilEvent(FragmentEvent.DESTROY_VIEW))
|
||||
.subscribe(new BeanObserver<List<GiftWallInfo>>() {
|
||||
@Override
|
||||
@@ -148,12 +158,16 @@ public class UserInfoGiftFragment extends BaseBindingFragment<FragmentUserInfoGi
|
||||
|
||||
// 刷新数据
|
||||
if (ListUtils.isListEmpty(giftWallInfoList)) {
|
||||
UserInfoItem userInfoItem = new UserInfoItem(UserInfoItem.TYPE_GIFT_EMPTY);
|
||||
userInfoItems.add(userInfoItem);
|
||||
userInfoItems.add(new UserInfoItem<>(UserInfoItem.TYPE_GIFT_EMPTY));
|
||||
} else {
|
||||
for (GiftWallInfo giftWallInfo : giftWallInfoList) {
|
||||
UserInfoItem<GiftWallInfo> userInfoItem = new UserInfoItem<>(UserInfoItem.TYPE_GIFT_ITEM, giftWallInfo);
|
||||
UserInfoItem<GiftWallInfo> userInfoItem;
|
||||
for (int i = 0; i < giftWallInfoList.size(); i++) {
|
||||
userInfoItem = new UserInfoItem<>(UserInfoItem.TYPE_GIFT_ITEM, giftWallInfoList.get(i));
|
||||
userInfoItems.add(userInfoItem);
|
||||
//非礼物详情页主需要12个就够了
|
||||
if (!isDetails && i == 11){
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -1,9 +1,11 @@
|
||||
package com.yizhuan.erban.ui.user.adapter;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import android.widget.ImageView;
|
||||
|
||||
import com.chad.library.adapter.base.BaseViewHolder;
|
||||
@@ -20,13 +22,13 @@ import java.util.List;
|
||||
|
||||
public class UserGiftAdapter extends UserTabBaseAdapter {
|
||||
|
||||
private final boolean isDetails;
|
||||
|
||||
public UserGiftAdapter(Context context, List<UserInfoItem> data) {
|
||||
public UserGiftAdapter(Context context, List<UserInfoItem> data, boolean isDetails) {
|
||||
super(context, data);
|
||||
addItemType(UserInfoItem.TYPE_GIFT_ITEM, R.layout.list_item_gift_wall_info);
|
||||
addItemType(UserInfoItem.TYPE_GIFT_EMPTY, R.layout.layout_gift_empty);
|
||||
|
||||
|
||||
this.isDetails = isDetails;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -53,9 +55,12 @@ public class UserGiftAdapter extends UserTabBaseAdapter {
|
||||
|
||||
if (giftWallInfo != null) {
|
||||
|
||||
helper.setText(R.id.gift_name, giftWallInfo.getGiftName());
|
||||
helper.setText(R.id.gift_num, "x"+String.valueOf(giftWallInfo.getReciveCount()));
|
||||
helper.setText(R.id.gift_price,giftWallInfo.getGiftPrice()+"");
|
||||
helper.setText(R.id.gift_name, giftWallInfo.getGiftName())
|
||||
.setGone(R.id.gift_name, isDetails)
|
||||
.setText(R.id.gift_num, "x" + giftWallInfo.getReciveCount())
|
||||
.setBackgroundRes(R.id.gift_num, isDetails ? R.drawable.bg_user_gift_item_details : R.drawable.bg_user_gift_item)
|
||||
.setText(R.id.gift_price, giftWallInfo.getGiftPrice() + "")
|
||||
.setGone(R.id.gift_price, isDetails);
|
||||
|
||||
ImageView giftPic = helper.itemView.findViewById(R.id.gift_img);
|
||||
ImageLoadUtils.loadImage(mContext, giftWallInfo.getPicUrl(), giftPic);
|
||||
|
@@ -5,18 +5,18 @@ import android.content.Intent
|
||||
import android.graphics.Color
|
||||
import android.graphics.drawable.GradientDrawable
|
||||
import android.view.Gravity
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.LinearLayout
|
||||
import android.widget.TextView
|
||||
import androidx.core.view.isVisible
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.fragment.app.activityViewModels
|
||||
import androidx.recyclerview.widget.GridLayoutManager
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import androidx.viewpager.widget.ViewPager
|
||||
import androidx.viewpager.widget.ViewPager.OnPageChangeListener
|
||||
import com.netease.nim.uikit.support.glide.GlideApp
|
||||
import com.yizhuan.erban.R
|
||||
import com.yizhuan.erban.audio.helper.AudioPlayerHelper
|
||||
import com.yizhuan.erban.audio.helper.OnPlayListener
|
||||
import com.yizhuan.erban.base.BaseViewBindingFragment
|
||||
import com.yizhuan.erban.databinding.FragmentUserinfoUserinfoBinding
|
||||
import com.yizhuan.erban.module_hall.HallDataManager
|
||||
@@ -27,11 +27,17 @@ import com.yizhuan.erban.skill.activity.SkillHomeActivity.Companion.PAGE_TYPE_CU
|
||||
import com.yizhuan.erban.skill.activity.SkillHomeActivity.Companion.PAGE_TYPE_SELF
|
||||
import com.yizhuan.erban.ui.user.UserGiftActivity
|
||||
import com.yizhuan.erban.ui.user.UserInfoActivity
|
||||
import com.yizhuan.erban.ui.user.UserInfoGiftFragment
|
||||
import com.yizhuan.erban.ui.user.adapter.GiftAdapter
|
||||
import com.yizhuan.erban.ui.user.adapter.SkillCardAdapter
|
||||
import com.yizhuan.erban.ui.user.adapter.UserInfoIndicatorAdapter
|
||||
import com.yizhuan.erban.ui.user.adapter.UserInfoPagerAdapter
|
||||
import com.yizhuan.erban.ui.user.decorationsend.UserInfoSkillDecoration
|
||||
import com.yizhuan.erban.ui.user.viewmodel.UserInfoViewModel
|
||||
import com.yizhuan.erban.ui.widget.magicindicator.MagicIndicator
|
||||
import com.yizhuan.erban.ui.widget.magicindicator.ViewPagerHelper
|
||||
import com.yizhuan.erban.ui.widget.magicindicator.buildins.UIUtil
|
||||
import com.yizhuan.erban.ui.widget.magicindicator.buildins.commonnavigator.CommonNavigator
|
||||
import com.yizhuan.xchat_android_core.auth.AuthModel
|
||||
import com.yizhuan.xchat_android_core.module_hall.hall.HallModel
|
||||
import com.yizhuan.xchat_android_core.module_hall.hall.bean.ClanAndHallInfo
|
||||
@@ -41,7 +47,6 @@ import com.yizhuan.xchat_android_core.user.bean.UserDetailInfo.DataBean.UserGift
|
||||
import com.yizhuan.xchat_android_core.user.bean.UserInfoSkillEntity
|
||||
import com.yizhuan.xchat_android_core.utils.net.BeanObserver
|
||||
import com.yizhuan.xchat_android_core.utils.net.RxHelper
|
||||
import com.yizhuan.xchat_android_core.utils.toast
|
||||
import com.yizhuan.xchat_android_library.annatation.ActLayoutRes
|
||||
|
||||
|
||||
@@ -138,29 +143,44 @@ class UserInfoInfoFragment : BaseViewBindingFragment<FragmentUserinfoUserinfoBin
|
||||
*
|
||||
* @param list
|
||||
*/
|
||||
private fun initGiftList(list: MutableList<UserGiftWallBean?>) {
|
||||
if (giftAdapter == null) {
|
||||
giftAdapter = GiftAdapter(context, null)
|
||||
val layoutManager = GridLayoutManager(context, 4)
|
||||
binding.rvGift.layoutManager = layoutManager
|
||||
giftAdapter?.setHeaderAndEmpty(true)
|
||||
val emptyView = LayoutInflater.from(context)
|
||||
.inflate(R.layout.item_userinfo_gift_empty, null, false)
|
||||
giftAdapter?.emptyView = emptyView
|
||||
giftAdapter?.setEnableLoadMore(false)
|
||||
giftAdapter?.bindToRecyclerView(binding.rvGift)
|
||||
binding.labelsView.setLabels(arrayListOf("常规礼物", "幸运礼物"))
|
||||
binding.labelsView.setSelects(0)
|
||||
binding.labelsView.setOnLabelClickListener { _, _, position ->
|
||||
if (position == 0) {
|
||||
giftAdapter?.setNewData(list)
|
||||
} else {
|
||||
//list.addAll(list)
|
||||
// giftAdapter?.setNewData(list)
|
||||
}
|
||||
}
|
||||
private fun initGiftList() {
|
||||
val viewPager: 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 pagerAdapter = UserInfoPagerAdapter(childFragmentManager, fragmentList)
|
||||
val tagList: MutableList<String> = ArrayList(2)
|
||||
tagList.add("普通礼物")
|
||||
tagList.add("幸运礼物")
|
||||
val commonNavigator = CommonNavigator(context)
|
||||
commonNavigator.setTitleWrapContent(true)
|
||||
val magicIndicatorAdapter = UserInfoIndicatorAdapter(context, tagList)
|
||||
magicIndicatorAdapter.setOnItemSelectListener { position: Int, view: TextView? ->
|
||||
viewPager.currentItem = position
|
||||
}
|
||||
giftAdapter?.setNewData(list)
|
||||
commonNavigator.adapter = magicIndicatorAdapter
|
||||
magicIndicator.navigator = commonNavigator
|
||||
commonNavigator.titleContainer.showDividers = LinearLayout.SHOW_DIVIDER_MIDDLE
|
||||
viewPager.offscreenPageLimit = 2
|
||||
viewPager.adapter = pagerAdapter
|
||||
ViewPagerHelper.bind(magicIndicator, viewPager)
|
||||
viewPager.addOnPageChangeListener(object : OnPageChangeListener {
|
||||
override fun onPageScrolled(
|
||||
position: Int,
|
||||
positionOffset: Float,
|
||||
positionOffsetPixels: Int
|
||||
) {
|
||||
}
|
||||
|
||||
override fun onPageSelected(position: Int) {
|
||||
viewPager.requestLayout()
|
||||
}
|
||||
|
||||
override fun onPageScrollStateChanged(state: Int) {}
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -230,15 +250,7 @@ class UserInfoInfoFragment : BaseViewBindingFragment<FragmentUserinfoUserinfoBin
|
||||
}
|
||||
|
||||
override fun init() {
|
||||
vm.userInfoDetailData.observe(this) {
|
||||
if (it.userGiftWall.size > 12) {
|
||||
val subList = it.userGiftWall.subList(0, 12)
|
||||
initGiftList(subList)
|
||||
} else {
|
||||
initGiftList(it.userGiftWall)
|
||||
}
|
||||
|
||||
}
|
||||
initGiftList()
|
||||
vm.hallData.observe(this) {
|
||||
initClanAndHall(it)
|
||||
}
|
||||
|
@@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="rectangle">
|
||||
<solid android:color="#FFF0C9" />
|
||||
<solid android:color="#F1F1FA" />
|
||||
<corners
|
||||
android:bottomLeftRadius="6dp"
|
||||
android:bottomRightRadius="2dp"
|
||||
|
10
app/src/main/res/drawable/bg_user_gift_item_details.xml
Normal file
10
app/src/main/res/drawable/bg_user_gift_item_details.xml
Normal file
@@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="rectangle">
|
||||
<solid android:color="@color/white" />
|
||||
<corners
|
||||
android:bottomLeftRadius="6dp"
|
||||
android:bottomRightRadius="2dp"
|
||||
android:topLeftRadius="2dp"
|
||||
android:topRightRadius="6dp" />
|
||||
</shape>
|
@@ -304,29 +304,17 @@
|
||||
android:textSize="@dimen/sp_13"
|
||||
android:textStyle="bold" />
|
||||
|
||||
<com.donkingliang.labels.LabelsView
|
||||
android:id="@+id/labels_view"
|
||||
<com.yizhuan.erban.ui.widget.magicindicator.MagicIndicator
|
||||
android:id="@+id/magic_indicator_gift"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="10dp"
|
||||
app:labelBackground="@color/transparent"
|
||||
app:labelTextColor="@color/color_selector_app_color_false_999999"
|
||||
app:labelTextSize="@dimen/sp_13"
|
||||
app:maxSelect="1"
|
||||
app:selectType="SINGLE"
|
||||
app:wordMargin="10dp" />
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/rv_gift"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_height="20dp"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:layout_marginTop="@dimen/dp_14"
|
||||
android:layout_marginBottom="@dimen/dp_15"
|
||||
android:clipToPadding="false"
|
||||
android:paddingStart="10dp"
|
||||
android:paddingEnd="10dp"
|
||||
android:paddingBottom="5dp" />
|
||||
/>
|
||||
|
||||
<androidx.viewpager.widget.ViewPager
|
||||
android:id="@+id/view_pager_gift"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="280dp" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
@@ -5,12 +5,11 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center"
|
||||
android:orientation="vertical"
|
||||
android:paddingStart="@dimen/dp_10"
|
||||
android:paddingEnd="@dimen/dp_10">
|
||||
>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/gift_img"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_width="60dp"
|
||||
android:layout_height="60dp"
|
||||
android:layout_marginTop="10dp" />
|
||||
|
||||
@@ -19,13 +18,12 @@
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:layout_marginTop="-10dp"
|
||||
android:background="@drawable/bg_user_gift_item"
|
||||
android:gravity="center"
|
||||
android:includeFontPadding="false"
|
||||
android:paddingStart="8dp"
|
||||
android:paddingEnd="@dimen/dp_8"
|
||||
android:textColor="@color/app_248cfe"
|
||||
android:textColor="@color/color_333333"
|
||||
android:textSize="12dp"
|
||||
tools:text="x120" />
|
||||
|
||||
@@ -38,7 +36,7 @@
|
||||
android:ellipsize="end"
|
||||
android:lines="1"
|
||||
android:textColor="@color/text_normal_c6c6e9"
|
||||
android:textSize="13dp"
|
||||
android:textSize="12dp"
|
||||
tools:text="天使" />
|
||||
|
||||
<TextView
|
||||
@@ -49,7 +47,7 @@
|
||||
android:layout_marginTop="3dp"
|
||||
android:drawableStart="@drawable/ic_gift_diamond"
|
||||
android:gravity="center_vertical"
|
||||
android:textColor="@color/text_secondary_4f516a"
|
||||
android:textColor="@color/color_999999"
|
||||
android:textSize="11dp"
|
||||
tools:text="10" />
|
||||
|
||||
|
@@ -128,7 +128,7 @@ public interface IUserModel extends IModel {
|
||||
*
|
||||
* @param uid
|
||||
*/
|
||||
public Single<List<GiftWallInfo>> requestUserGiftWall(long uid, int orderType);
|
||||
public Single<List<GiftWallInfo>> requestUserGiftWall(long uid, int giftType, int orderType);
|
||||
|
||||
/**
|
||||
* 关键词搜索用户
|
||||
|
@@ -8,7 +8,6 @@ import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.yizhuan.xchat_android_core.auth.AuthModel;
|
||||
import com.yizhuan.xchat_android_core.auth.entity.ThirdUserInfo;
|
||||
import com.yizhuan.xchat_android_core.auth.event.LoginEvent;
|
||||
import com.yizhuan.xchat_android_core.auth.event.LogoutEvent;
|
||||
import com.yizhuan.xchat_android_core.base.BaseModel;
|
||||
@@ -571,12 +570,10 @@ public final class UserModel extends BaseModel implements IUserModel {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Single<List<GiftWallInfo>> requestUserGiftWall(long uid, int orderType) {
|
||||
|
||||
return api.giftWall(
|
||||
String.valueOf(uid),
|
||||
String.valueOf(orderType)
|
||||
)
|
||||
public Single<List<GiftWallInfo>> requestUserGiftWall(long uid, int giftType, int orderType) {
|
||||
return api.giftWall(String.valueOf(uid),
|
||||
giftType,
|
||||
String.valueOf(orderType))
|
||||
.compose(RxHelper.handleBeanData())
|
||||
.compose(RxHelper.handleSchedulers());
|
||||
}
|
||||
@@ -927,8 +924,9 @@ public final class UserModel extends BaseModel implements IUserModel {
|
||||
* @param orderType
|
||||
* @return
|
||||
*/
|
||||
@GET("/giftwall/get")
|
||||
@GET("/giftwall/getByGiftType")
|
||||
Single<GiftWallListResult> giftWall(@Query("uid") String uid,
|
||||
@Query("giftType") int giftType,
|
||||
@Query("orderType") String orderType);
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user