package com.test.basd.smartjunkcleaner.activity.photocompress.photo

import android.graphics.Color
import androidx.activity.OnBackPressedCallback
import androidx.core.view.updatePadding
import com.blankj.utilcode.util.BarUtils
import com.test.basd.smartjunkcleaner.databinding.ActivityCompressionPhotoListBinding
import com.test.basd.smartjunkcleaner.helps.BaseActivity
import com.test.basd.smartjunkcleaner.helps.ads.AdmobUtils


class CompressionPhotoListActivity : BaseActivity<ActivityCompressionPhotoListBinding>(),
    AlbumsSelectListener {
    override val isLightMode =true
    private var mPhotoListManager: PhotoListManager? = null

    companion object {
        var mActivity: CompressionPhotoListActivity? = null
    }

    override val binding: ActivityCompressionPhotoListBinding by lazy {
        ActivityCompressionPhotoListBinding.inflate(layoutInflater)
    }


    override fun initView() {
        BarUtils.setStatusBarColor(this, Color.TRANSPARENT)
        binding.root.updatePadding(top = BarUtils.getStatusBarHeight())
        binding.fanhui.setOnClickListener {
            onBackPressedDispatcher.onBackPressed()
        }
        onBackPressedDispatcher.addCallback(object : OnBackPressedCallback(true) {
            override fun handleOnBackPressed() {
                AdmobUtils.showInterstitialAd(this@CompressionPhotoListActivity){
                    PhotoCache.getInstance().clearCache()
                    finishToMain()
                }

            }
        })
        mActivity = this
        mPhotoListManager = PhotoListManager(this)
        BottomSheetManager(this, this)
    }


    override fun onBackPressed() {
        PhotoCache.getInstance().clearCache()
        super.onBackPressed()
    }

    override fun onSelectAlbum(albums: AlbumBean) {
        mPhotoListManager?.onSelectAlbum(albums)
    }

}