package com.zxhyis.toolss.ui.page.photocompress.photo

import android.graphics.Color
import androidx.activity.OnBackPressedCallback
import androidx.core.view.updatePadding
import com.blankj.utilcode.util.BarUtils
import com.zxhyis.toolss.base.TopActivity
import com.zxhyis.toolss.databinding.ActivityCompressionPhotoListBinding
import com.zxhyis.toolss.logic.setOnClick


class CompressionPhotoListActivity : TopActivity<ActivityCompressionPhotoListBinding>(),
    AlbumsSelectListener {

    private var mPhotoListManager: PhotoListManager? = null

    companion object {
        var mActivity: CompressionPhotoListActivity? = null
    }

    override fun getViewBinding1(): ActivityCompressionPhotoListBinding {
        return ActivityCompressionPhotoListBinding.inflate(layoutInflater)
    }

    override fun init() {
        BarUtils.setStatusBarLightMode(this, true)
        BarUtils.setStatusBarColor(this, Color.TRANSPARENT)
        vb.root.updatePadding(top = BarUtils.getStatusBarHeight())
        vb.fanhui.setOnClick(javaClass.simpleName){
            onBackPressedDispatcher.onBackPressed()
        }
        onBackPressedDispatcher.addCallback(object : OnBackPressedCallback(true) {
            override fun handleOnBackPressed() {
                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)
    }

}