添加礼物飘屏功能
This commit is contained in:
@@ -9,6 +9,7 @@ import androidx.annotation.Nullable;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.fragment.app.FragmentManager;
|
||||
import androidx.fragment.app.FragmentStatePagerAdapter;
|
||||
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
@@ -27,6 +28,8 @@ import com.qxcm.moduleutil.base.BaseMvpFragment;
|
||||
import com.qxcm.moduleutil.bean.BannerModel;
|
||||
import com.qxcm.moduleutil.bean.RoomTypeModel;
|
||||
import com.qxcm.moduleutil.bean.TopRoom;
|
||||
import com.qxcm.moduleutil.event.MqttBean;
|
||||
import com.qxcm.moduleutil.event.RoomGiftRunable;
|
||||
import com.qxcm.moduleutil.utils.ARouteConstants;
|
||||
import com.qxcm.moduleutil.utils.ImageUtils;
|
||||
import com.stx.xhb.xbanner.XBanner;
|
||||
@@ -34,12 +37,14 @@ import com.sunfusheng.marqueeview.MarqueeView;
|
||||
import com.zhpan.bannerview.constants.PageStyle;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
import org.greenrobot.eventbus.ThreadMode;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*声播
|
||||
* 声播
|
||||
*/
|
||||
public class VoiceCategoryFragment extends BaseMvpFragment<VoiceCategoryPresenter, FragmentVoiceCategoryBinding> implements VoiceCategoryContacts.View {
|
||||
|
||||
@@ -51,7 +56,9 @@ public class VoiceCategoryFragment extends BaseMvpFragment<VoiceCategoryPresente
|
||||
|
||||
private List<TopRoom> roomList;
|
||||
|
||||
CarouselBannerAdapter carouselBannerAdapter ;
|
||||
private List<MqttBean.ListBean> mqttList;
|
||||
private List<String> info;
|
||||
CarouselBannerAdapter carouselBannerAdapter;
|
||||
|
||||
public static VoiceCategoryFragment newInstance() {
|
||||
return new VoiceCategoryFragment();
|
||||
@@ -84,7 +91,7 @@ public class VoiceCategoryFragment extends BaseMvpFragment<VoiceCategoryPresente
|
||||
@Override
|
||||
protected void initData() {
|
||||
MvpPre.getBanners();
|
||||
MvpPre.getCarousels(1,1,"10","2","");//顶部推荐
|
||||
MvpPre.getCarousels(1, 1, "10", "2", "");//顶部推荐
|
||||
MvpPre.getCategories();
|
||||
}
|
||||
|
||||
@@ -159,27 +166,55 @@ public class VoiceCategoryFragment extends BaseMvpFragment<VoiceCategoryPresente
|
||||
.navigation();
|
||||
}
|
||||
});
|
||||
List<String> info = new ArrayList<>();
|
||||
info.add("1. 大家好,我是孙福生。");
|
||||
info.add("2. 欢迎大家关注我哦!");
|
||||
info.add("3. GitHub帐号:sfsheng0322");
|
||||
info.add("4. 新浪微博:孙福生微博");
|
||||
info.add("5. 个人博客:sunfusheng.com");
|
||||
info.add("6. 微信公众号:孙福生");
|
||||
mBinding.marqueeView.startWithList(info);
|
||||
mBinding.marqueeView.setOnItemClickListener(new MarqueeView.OnItemClickListener() {
|
||||
@Override
|
||||
public void onItemClick(int position, TextView textView) {
|
||||
|
||||
ToastUtils.show("点击了第 " + position + " 个 item");
|
||||
}
|
||||
});
|
||||
// mBinding.marqueeView.setOnItemClickListener(new MarqueeView.OnItemClickListener() {
|
||||
// @Override
|
||||
// public void onItemClick(int position, TextView textView) {
|
||||
//
|
||||
// ToastUtils.show("点击了第 " + position + " 个 item");
|
||||
// }
|
||||
// });
|
||||
mBinding.tvWg.setOnClickListener(v -> {
|
||||
ToastUtils.show("点击了第 " + mBinding.marqueeView.getPosition() + " 个 item");
|
||||
ARouter.getInstance().build(ARouteConstants.ROOM_DETAILS).withString("form", "首页热门列表").withString("roomId", mqttList.get(mBinding.marqueeView.getPosition()).getRoomId()).navigation();
|
||||
});
|
||||
|
||||
mBinding.rl.setVisibility(GONE);
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void onEvent(MqttBean event) {
|
||||
|
||||
List<MqttBean> cachedMqttBeans = RoomGiftRunable.getMqttCache();
|
||||
if (cachedMqttBeans == null || cachedMqttBeans.isEmpty()){
|
||||
mBinding.rl.setVisibility(GONE);
|
||||
}else {
|
||||
mBinding.rl.setVisibility(View.VISIBLE);
|
||||
}
|
||||
if (mqttList == null){
|
||||
mqttList = new ArrayList<>();
|
||||
info = new ArrayList<>();
|
||||
}
|
||||
mqttList.clear();
|
||||
info.clear();
|
||||
// 处理缓存数据
|
||||
for (MqttBean mqttBean : cachedMqttBeans) {
|
||||
// 处理每一条 mqttBean 数据
|
||||
mqttList.add(mqttBean.getList());
|
||||
info.add(mqttBean.getList().getFromUserName()+"送给"+mqttBean.getList().getToUserName()+"\n"+mqttBean.getList().getGiftName());
|
||||
}
|
||||
|
||||
// if (mqttList == null) {
|
||||
// info = new ArrayList<>();
|
||||
// mqttList = new ArrayList<>();
|
||||
// }
|
||||
// if (mqttList.size() < 6) {
|
||||
//// info.add(event.getList().getFromUserName()+"送给"+event.getList().getToUserName()+"\n"+event.getList().getGiftName());
|
||||
// mqttList.add(event.getList());
|
||||
// } else {
|
||||
// mqttList.remove(0); // 移除第一条数据
|
||||
// info.remove(0); // 移除第一条数据
|
||||
// mqttList.add(event.getList());
|
||||
// }
|
||||
// info.add(event.getList().getFromUserName()+"送给"+event.getList().getToUserName()+"\n"+event.getList().getGiftName());
|
||||
mBinding.marqueeView.startWithList(info);
|
||||
}
|
||||
|
||||
//
|
||||
@@ -188,6 +223,11 @@ public class VoiceCategoryFragment extends BaseMvpFragment<VoiceCategoryPresente
|
||||
return R.layout.fragment_voice_category;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
onEvent(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCategories(List<RoomTypeModel> list) {
|
||||
@@ -208,14 +248,14 @@ public class VoiceCategoryFragment extends BaseMvpFragment<VoiceCategoryPresente
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTopRoom(List<TopRoom> topRooms,int type) {
|
||||
public void setTopRoom(List<TopRoom> topRooms, int type) {
|
||||
// if (topRooms == null || topRooms.isEmpty() || topRooms.size() < 1) {
|
||||
// mBinding.constraintLayout.setVisibility(View.GONE);
|
||||
// return;
|
||||
// }else {
|
||||
mBinding.constraintLayout.setVisibility(View.VISIBLE);
|
||||
// }
|
||||
roomList= topRooms;
|
||||
roomList = topRooms;
|
||||
mBinding.bannerViewPager.create(topRooms); // 刷新数据并启动自动播放
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user