语音社交源码群聊开发,需要实现礼物打赏功能

语音社交源码群聊打赏礼物的效果如图:
语音社交源码礼物和背包都是可以很多页的,可能这是唯一稍微麻烦一点的地方,直接贴全部详细代码 。
1、首先写一个名为ft的,是整个的语音社交源码的弹框(包括礼物和背包模块,以及点击可以跳转到别的模块的小游戏“摇糖罐”),ft继承自我封装的抽象类 。
2、语音社交源码礼物和背包的分页,思路是创建一个view的集合,每页设置8个礼物,下面会贴出礼物的页面.kt的代码 。
3、关于语音社交源码送礼物走的接口就是看具体情况了,现在送礼物走的是接口,然后回调走的,通知语音社交源码房间里的其他人进行下一步操作 。其实最好的方案是进房间走一次接口,其他所有的操作都走,关于这个分类其他文章会写 。
.kt的代码:
abstract class BaseDialogFragment2 : DialogFragment() {protected val TAG = javaClass.simpleNameprotected lateinit var mContext: Contextabstract val layoutRes: Intoverride fun onCreate(savedInstanceState: Bundle?) {super.onCreate(savedInstanceState)mContext = activity as Context}override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {var rootView = inflater.inflate(layoutRes, null)mContext = activity as Contextreturn rootView}override fun onViewCreated(view: View, savedInstanceState: Bundle?) {initView()super.onViewCreated(view, savedInstanceState)}private fun initView() {initAll()setListener()processLogic()}protected abstract fun initAll()protected abstract fun setListener()protected abstract fun processLogic()protected fun hideSoftKeyboard(view: View) {activity?.inputMethodManager?.hideSoftInputFromWindow(view.windowToken, 0)}protected fun showSoftKeyboard(view: View) {activity?.inputMethodManager?.showSoftInput(view, InputMethodManager.SHOW_FORCED)}}

语音社交源码群聊开发,需要实现礼物打赏功能

文章插图
ft.kt的代码:
class FragmentRoomDetailGift : BaseDialogFragment2() {override val layoutRes: Intget() = R.layout.dialog_room_detail_gift//礼物和背包的fragment的集合var mFragments: Array? = null//礼物和背包的标题集合var title: Array? = null//礼物和背包的pageadaptervar adapter: CustomFragmentPagerAdapter? = null//选择打赏对象的弹框var popGiftLeft: PopGiftLeft? = null//选择赠送多个礼物的弹框var popGiftRight: PopGiftRight? = null//一个礼物赠送多次的自定义弹框,这里的数据是本地的var beenRight = arrayListOf()//麦上人员的信息/选择被打赏的人var beenResultLeft = mutableListOf()//一次送出多个礼物的礼物数据var beanResultRight: GiftRightBean? = null//点击摇糖罐的接口的实现方法var mListener: OnFragmentInteractionListener? = null//语音直播间的idvar room_id = ""//语音直播间的环信idvar chatrooms = ""//送给某人的选中的user_idvar to_user_id = ""override fun onStart() {super.onStart()//弹框的样式和动画等的配置dialog.window.setBackgroundDrawable(ColorDrawable(getResources().getColor(R.color.transparent)))dialog.window.setGravity(Gravity.BOTTOM)dialog.window.setLayout(ScreenUtils.getScreenWidth(), (ScreenUtils.getScreenHeight() * 5.2 / 10).toInt())dialog.window.setWindowAnimations(R.style.ShowDialogBottom)}override fun onAttach(context: Context) {super.onAttach(context)if (context is OnFragmentInteractionListener) {mListener = context as OnFragmentInteractionListener} else {throw RuntimeException("$context must implement OnFragmentInteractionListener")}}override fun onDetach() {super.onDetach()mListener = null}override fun initAll() {//setStyle(DialogFragment.STYLE_NO_FRAME, R.style.custom_dialog1)//从直播间详情传递的麦上人员信息var list = arguments?.getSerializable("bean") as MutableListbeenResultLeft = list.filter { !it.user_id.isNullOrEmpty() } as MutableList