package com.gh.common.provider

import android.content.Context
import android.content.Intent
import android.net.Uri
import com.gh.gamecenter.CropImageActivity
import com.gh.gamecenter.R
import com.gh.gamecenter.core.provider.ICropImageProvider
import com.gh.gamecenter.personalhome.background.BackgroundClipActivity
import com.halo.assistant.fragment.user.UserPortraitCropImageActivity
import com.lightgame.utils.Utils
import com.zhihu.matisse.internal.utils.PathUtils

@com.therouter.inject.ServiceProvider
class CropImageProviderImpl : ICropImageProvider {
    override fun getCropImageIntent(data: List<Uri>, imageType: Int, entrance: String, context: Context): Intent? {
        if (data.isEmpty()) {
            return null
        }
        val picturePath = PathUtils.getPath(context, data[0])
        Utils.log("picturePath = $picturePath")
        return when (imageType) {

            IMAGE_TYPE_AVATAR -> {// 上传头像
                UserPortraitCropImageActivity.getIntent(
                    context,
                    picturePath,
                    "我的光环(选择头像)"
                )
            }

            IMAGE_TYPE_GAME_COLLECTION_COVER -> {// 游戏单封面
                CropImageActivity.getIntent(
                    context,
                    picturePath,
                    142 / 328F,
                    false,
                    R.layout.layout_game_collection_crop_image_assist,
                    entrance
                )
            }

            IMAGE_TYPE_PERSONAL_BACKGROUND -> { // 用户主页背景
                BackgroundClipActivity.getIntent(context, picturePath, entrance)
            }

            else ->
                null
        }

    }

    companion object {
        const val IMAGE_TYPE_AVATAR = 1
        const val IMAGE_TYPE_GAME_COLLECTION_COVER = 2
        const val IMAGE_TYPE_PERSONAL_BACKGROUND = 3
    }
}