beenResultLeft?.forEach {it.isChecked = false}//房主在麦位,放在第一个显示var admin = beenResultLeft?.filter { it.pit_number == 9 }if (admin?.size != 0) {beenResultLeft?.removeAll(admin)beenResultLeft?.addAll(0, admin)}//不能打赏自己var me = beenResultLeft?.filter { it.user_id == MyApplication.getInstance().user.user_id }beenResultLeft?.removeAll(me)room_id = arguments?.getString("id") ?: ""chatrooms = arguments?.getString("chatrooms") ?: ""to_user_id = arguments?.getString("to_user_id") ?: ""beenResultLeft?.forEach {if (it.user_id == to_user_id) {it.isChecked = true}}refreshCheckedStatus(1)tv_money.text = MyApplication.getInstance().user.moneyif (MyApplication.getInstance().user.is_open_tangguo == 1) {//开启tv_sugar.visibility = View.VISIBLE} else {//关闭tv_sugar.visibility = View.GONE}title = arrayOf("礼物", "背包")mFragments = arrayOf(GiftFragment.newInstance(null), BagFragment.newInstance(null))adapter = CustomFragmentPagerAdapter(mFragments, childFragmentManager)svp.adapter = adapterctl.setViewPager(svp, title)svp.offscreenPageLimit = 2svp.setScroll(true)svp.addOnPageChangeListener(object : ViewPager.OnPageChangeListener {override fun onPageScrollStateChanged(state: Int) {}override fun onPageScrolled(position: Int, positionOffset: Float, positionOffsetPixels: Int) {if (position == 1) {btn_all_bag.visibility = View.VISIBLE} else {btn_all_bag.visibility = View.GONE}}override fun onPageSelected(position: Int) {}})beenRight?.clear()beenRight?.also {it.add(GiftRightBean()?.also { it.name = "1";it.content = "一心一意" })it.add(GiftRightBean()?.also { it.name = "10";it.content = "十全十美" })it.add(GiftRightBean()?.also { it.name = "66";it.content = "一切顺利" })it.add(GiftRightBean()?.also { it.name = "99";it.content = "天长地久" })it.add(GiftRightBean()?.also { it.name = "188";it.content = "要抱抱" })it.add(GiftRightBean()?.also { it.name = "520";it.content = "我爱你" })it.add(GiftRightBean()?.also { it.name = "1314";it.content = "一生一世" })}}override fun setListener() {tv_sugar.setOnClickListener {dismiss()mListener?.onFragmentInteraction(1)}//打赏全麦btn_all_mics.setOnClickListener {if (beenResultLeft == null || beenResultLeft.size == 0) {ToastUtils.showShort("没有打赏对象")return@setOnClickListener}if (beenResultLeft.filter { it.isChecked }.size == beenResultLeft?.size) {beenResultLeft.forEach {it.isChecked = false}} else {beenResultLeft.forEach {it.isChecked = true}}refreshCheckedStatus(2)}//选择打赏对象tv_choose.setOnClickListener {if (beenResultLeft == null || beenResultLeft.size == 0) {ToastUtils.showShort("没有打赏对象")return@setOnClickListener}if (popGiftLeft == null) {popGiftLeft = PopGiftLeft(mContext, beenResultLeft) {beenResultLeft = itrefreshCheckedStatus(2)}}popGiftLeft?.setData(beenResultLeft)var windowPos = SizeUtils.calculatePopWindowPos2(tv_choose, popGiftLeft?.contentView)popGiftLeft?.showAtLocation(tv_choose, Gravity.TOP and Gravity.LEFT, windowPos[0], windowPos[1] - 200)}tv_count.setOnClickListener {if (popGiftRight == null) {popGiftRight = PopGiftRight(mContext, beenRight) {beanResultRight = ittv_count.text = beanResultRight?.name}}var windowPos = SizeUtils.calculatePopWindowPos3(tv_count, popGiftRight?.contentView)popGiftRight?.showAtLocation(tv_count, Gravity.TOP or Gravity.LEFT, windowPos[0], windowPos[1])}//跳转到充值tv_money.setOnClickListener {startActivityForResult(1)}//确认打赏的按钮btn_pay.setOnClickListener {var giftBeen = listOf()when (svp.currentItem) {0 -> {giftBeen = (mFragments!![0] as GiftFragment).allBeen.filter { it.isChecked }}1 -> {giftBeen = (mFragments!![1] as BagFragment).allBeen.filter { it.isChecked }}}if (giftBeen == null || giftBeen.size == 0) {ToastUtils.showShort("请选择礼物")return@setOnClickListener}var userBeen = beenResultLeft.filter { it.isChecked }if (userBeen == null || userBeen.size == 0) {ToastUtils.showShort("请选择打赏对象")return@setOnClickListener}var giftBean = giftBeen[0]var pits = ""var user_ids = ""var pit_names = ""userBeen.forEach {pits = pits + it.pit_number + ","user_ids = user_ids + it.user_id + ","pit_names = pit_names + it.nickname + ","}pits = pits.substring(0, pits.length - 1)user_ids = user_ids.substring(0, user_ids.length - 1)pit_names = pit_names.substring(0, pit_names.length - 1)giveGift(user_ids, giftBean, tv_count.text.toString(), room_id, pits, pit_names, 0, userBeen.size)}//背包礼物全部送出的按钮btn_all_bag.setOnClickListener {var giftBeen = listOf