package com.base.superfilemanager.activity.photocompress.photo

import android.graphics.Color
import androidx.activity.OnBackPressedCallback
import androidx.core.view.updatePadding
import com.blankj.utilcode.util.BarUtils
import com.base.superfilemanager.databinding.ActivityCompressionPhotoListBinding
import com.base.superfilemanager.helps.BaseActivity
import com.base.superfilemanager.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)
    }

}