//package com.zxhl.main.page.activity
//
//import android.app.Activity
//import android.text.TextUtils
//import android.view.View
//import androidx.recyclerview.widget.LinearLayoutManager
//import androidx.recyclerview.widget.RecyclerView
//import com.zxhl.cms.AppContext
//import com.zxhl.cms.common.base.BaseActivity
//import com.zxhl.cms.net.SettingPreference
//import com.zxhl.cms.net.model.chat.ChatMessageChargeOrNotEntity
//import com.zxhl.cms.net.model.chat.ChatStausEvent
//import com.zxhl.cms.net.model.chat.FollowEntity
//import com.zxhl.cms.utils.*
//import com.zxhl.cms.widget.ChatDialogUtils
//import com.zxhl.main.R
//import com.zxhl.main.page.adapter.LikesAdpater
//import com.zxhl.main.page.contract.MyLikesContract
//import com.zxhl.main.page.presenter.MyLikesPresenter
//import kotlinx.android.synthetic.main.activity_layout_my_likes.*
//import kotlinx.android.synthetic.main.activity_layout_my_likes.id_refresh_layout
//import kotlinx.android.synthetic.main.fragment_popular.*
//import kotlinx.android.synthetic.main.layout_empty_view.*
//import org.greenrobot.eventbus.EventBus
//import org.greenrobot.eventbus.Subscribe
//import org.greenrobot.eventbus.ThreadMode
//
////喜欢我页面
//class MyLikesActivity : BaseActivity(), MyLikesContract.View,
//    OnRecycleItemClickListener<FollowEntity> {
//    private var mPresenter: MyLikesPresenter? = null
//    private var mAdapter: LikesAdpater? = null
//    override fun onClick(v: View?) {
//
//    }
//
//    override fun before() {
//        super.before()
//        setStatusBarBackground(AppContext.get().resources.getColor(R.color.transparent))
//    }
//
//    override fun layoutID(): Int {
//        return R.layout.activity_layout_my_likes
//    }
//    fun initAdapter() {
//        mAdapter = LikesAdpater(this, this,free)
//        id_rl_likes?.layoutManager = LinearLayoutManager(this)
//        id_rl_likes?.adapter = mAdapter
//        id_rl_likes.addOnScrollListener(object : RecyclerView.OnScrollListener() {
//            override fun onScrollStateChanged(recyclerView: RecyclerView, newState: Int) {
//                super.onScrollStateChanged(recyclerView, newState)
//
//            }
//
//            override fun onScrolled(recyclerView: RecyclerView, dx: Int, dy: Int) {
//                super.onScrolled(recyclerView, dx, dy)
//                if (Utils.isSlideToBottom(recyclerView)) {
//                    if ((mAdapter?.list?.size ?: 0) >= 20) {
//                        // mPresenter?.getLikesList(false)
//                        ChargeOrNot(false)
//                    }
//                }
//            }
//        })
//        id_refresh_layout.setColorSchemeColors(resources.getColor(com.zxhl.cms.R.color.color_aa60ff))
//        id_refresh_layout?.setOnRefreshListener {
//            //mPresenter?.getLikesList(true)
//            ChargeOrNot(true)
//        }
//    }
//    override fun init() {
//        EventBus.getDefault().register(this)
//        id_img_back?.setOnClickListener {
//            finish()
//        }
//
//        mPresenter = MyLikesPresenter(this)
//
//        ChargeOrNot(true)
//        //  mPresenter?.getLikesList(true)
//    }
//
//    var mylikeEntity:FollowEntity?=null
//    override fun onItemClick(view: View?, position: Int, data: FollowEntity?) {
//        mylikeEntity=data
//        JumpUtils.startC2CChatActivity(mylikeEntity?.chatStatus!!,data?.uid, data?.nickname)
//    }
//
//    var free: Int = 0
//    private var content = "开启会员解锁无限查看喜欢我的用户权限"
//    private var tipcontent = "星币解锁本次查看"
//    fun ChargeOrNot(refsh: Boolean) {
//        ChatMessageChargeUtils.getChatMessageChargeOrNot(
//            "" + ChatMessageChargeUtils.MESSAGE_LIKE_ME,
//            "",
//            object : ChatCallback<ChatMessageChargeOrNotEntity> {
//                override fun onResult(result: ChatMessageChargeOrNotEntity?) {
//                    if (result?.charge!! <=0) {
//                        free = 0
//                        initAdapter()
//                        mPresenter?.getLikesList(refsh, free,result)
//                    } else {
//                        free = 2
//                        initAdapter()
//                        mPresenter?.getLikesList(refsh, free,result)
//
//                        return
//                    }
//                }
//
//
//                override fun onError(code: String?, errorMsg: String?) {
//                    if (TextUtils.isEmpty(errorMsg)) {
//                        return
//                    }
//                    Utils.showToast(context, errorMsg)
//                }
//            })
//    }
//    fun showtrip(result: ChatMessageChargeOrNotEntity?,refsh: Boolean){
//        ChatDialogUtils.showMemberChargeTip(
//            mActivity as Activity,
//            result,
//            content,
//            tipcontent,
//            object : ChatDialogUtils.ChatDialogCallBackParams {
//                override fun confirm(type: Int) {
//                    //兑换
//                    if (type == 0) {
//                        if (SettingPreference.getUserInfoData() != null
//                            && SettingPreference.getUserInfoData().starBalance < result?.charge!!
//                        ) {
//                            ChatDialogUtils.showMemberTrip(
//                                mActivity as Activity,
//                                object : ChatDialogUtils.ChatDialogCallBack {
//                                    override fun confirm() {
//                                        JumpUtils.starCoinpayJump()
//                                    }
//
//                                    override fun cancel() {}
//                                })
//                        } else {
//                            free = 1
//                            initAdapter()
//                            mPresenter?.getLikesList(refsh, free,result)
//                            //ifChareOrNot(true)
//                        }
//
//                    } else {
//                        JumpUtils.payJump()
//                    }
//                }
//
//                override fun cancel() {}
//            })
//    }
//    override fun setData(isRefresh: Boolean, reslut: List<FollowEntity>?,result2: ChatMessageChargeOrNotEntity?) {
//        if(free==2){
//            showtrip(result2,isRefresh)
//        }
//
//        id_ll_empty?.visibility = View.GONE
//        if (isRefresh) {
//            mAdapter?.clear()
//        }
//        id_refresh_layout?.isRefreshing = false
//        val start = mAdapter?.getItemCount() ?: 0
//        mAdapter?.appendToList(reslut)
//        if (isRefresh) {
//            mAdapter?.notifyDataSetChanged()
//        } else {
//            val end = mAdapter?.getItemCount() ?: 0
//            mAdapter?.notifyItemRangeChanged(start, end)
//        }
//    }
//
//    override fun setEmptyView() {
//        id_refresh_layout?.isRefreshing = false
//        id_ll_empty?.visibility = View.VISIBLE
//        id_tv_empty_text.text = "暂时没有人喜欢你，快去找用户喜欢你吧～"
//    }
//    @Subscribe(threadMode = ThreadMode.MAIN)
//    fun onEvent(chatStausEvent: ChatStausEvent){
//        mylikeEntity?.chatStatus=chatStausEvent.chatstatus?.toInt()
//        mAdapter?.notifyDataSetChanged()
//        //chatStaus=chatStausEvent.chatstatus?.toInt()
//    }
//    override fun onDestroy() {
//        super.onDestroy()
//        EventBus.getDefault().unregister(this)
//    }
//}