package com.adealink.weparty.room

import android.content.Intent
import androidx.annotation.LayoutRes
import com.adealink.frame.room.data.LeaveRoomReason
import com.adealink.weparty.commonui.BaseFragment
import com.adealink.weparty.room.listener.IRoomCloseCallback
import com.adealink.weparty.room.listener.IRoomOpListener

abstract class BaseRoomFragment(@LayoutRes contentLayoutId: Int) :
    BaseFragment(contentLayoutId), IRoomCloseCallback {

    /**
     * 可能fragment未add就会调用,需要判断当前Fragment是否valid
     */
    abstract fun handleNewIntent(intent: Intent?)

    fun exitRoom(reason: LeaveRoomReason, showCloseTip: Boolean = true) {
        if (showCloseTip) {
            (activity as? IRoomOpListener)?.showRoomCloseTipDialog(reason)
        } else {
            (activity as? IRoomOpListener)?.exitRoom(reason)
        }
    }
}