package com.gh.gamecenter.feedback.provider

import android.app.Activity
import android.content.Context
import android.content.Intent
import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import androidx.fragment.app.Fragment
import com.therouter.router.Route
import com.gh.gamecenter.common.base.fragment.BaseFragment
import com.gh.gamecenter.common.constant.RouteConsts
import com.gh.gamecenter.common.entity.SimpleGameEntity
import com.gh.gamecenter.common.entity.SuggestType
import com.gh.gamecenter.common.provider.IHelpAndFeedbackProvider
import com.gh.gamecenter.feedback.view.help.HelpAndFeedbackFragment
import com.gh.gamecenter.feedback.view.qa.HelpContainerFragment
import com.gh.gamecenter.feedback.view.qa.QaFeedbackDialogFragment
import com.gh.gamecenter.feedback.view.suggest.SuggestionActivity

@com.therouter.inject.ServiceProvider
class HelpAndFeedbackProviderImpl : IHelpAndFeedbackProvider {
    override fun isSuggestionActivity(activity: Activity): Boolean = activity is SuggestionActivity

    override fun startSuggestionActivity(
        context: Context?,
        suggestType: SuggestType?,
        suggestHintType: String?,
        content: String?
    ) {
        SuggestionActivity.startSuggestionActivity(
            context,
            suggestType,
            suggestHintType = suggestHintType,
            content = content
        )
    }


    override fun startSuggestionActivity(
        context: Context?,
        suggestType: SuggestType?,
        suggestHintType: String?,
        content: String?,
        game: SimpleGameEntity?
    ) {
        SuggestionActivity.startSuggestionActivity(
            context,
            suggestType,
            suggestHintType = suggestHintType,
            content = content,
            game = game
        )
    }

    override fun startSuggestionActivity(context: Context?, suggestType: SuggestType?, hint: String?) {
        SuggestionActivity.startSuggestionActivity(context, suggestType, hiddenHint = hint)
    }

    override fun getIntent(
        context: Context?,
        suggestType: SuggestType?,
        hiddenHint: String?,
        suggestHintType: String?,
        content: String?,
        game: SimpleGameEntity?,
        isQaFeedback: Boolean,
        qaContentId: String?,
        fromRatingKey: Boolean,
        diagnosis: String,
        forceLogin: Boolean,
        isSmoothGame: Boolean
    ): Intent? {
        return SuggestionActivity.getIntent(
            context,
            suggestType,
            hiddenHint,
            suggestHintType,
            content,
            game,
            isQaFeedback,
            qaContentId,
            fromRatingKey,
            diagnosis,
            forceLogin,
            isSmoothGame
        )
    }

    override fun getSuggestionCategoryIntent(context: Context, bundle: Bundle?): Intent {
        return SuggestionActivity.getSuggestionCategoryIntent(context, bundle)
    }

    override fun showQaFeedbackDialogFragment(activity: AppCompatActivity, contentId: String) {
        QaFeedbackDialogFragment.show(activity, contentId)
    }

    override fun getHelpAndFeedbackFragment(): BaseFragment<Any> {
        return HelpAndFeedbackFragment()
    }

    override fun getHelpContainerFragmentClass(): String {
        return HelpContainerFragment::class.java.name
    }
}