package com.base.superfilemanager.fragment

import android.content.Intent
import com.blankj.utilcode.util.SPUtils
import com.base.superfilemanager.activity.AppManagerActivity
import com.base.superfilemanager.activity.BatteryInfoActivity
import com.base.superfilemanager.activity.LargeFileCleanActivity
import com.base.superfilemanager.activity.NetWorkActivity
import com.base.superfilemanager.activity.RecentAppActivity
import com.base.superfilemanager.activity.RepeaterdPhotoActivity
import com.base.superfilemanager.activity.ScanJunkActivity
import com.base.superfilemanager.activity.SpeakerCleanerActivity
import com.base.superfilemanager.activity.photocompress.photo.StartCompressionPhotoActivity
import com.base.superfilemanager.adapter.ToolsAdapter
import com.base.superfilemanager.databinding.FragmentLayoutToolsBinding
import com.base.superfilemanager.helps.BaseFragment
import com.base.superfilemanager.notificationclean.NotificationCleanActivity
import com.base.superfilemanager.notificationclean.NotificationGuestActivity
import com.base.superfilemanager.view.AFunOb
import com.base.superfilemanager.view.AFunOb.APP_MANAGER
import com.base.superfilemanager.view.AFunOb.BATTERY_INFO
import com.base.superfilemanager.view.AFunOb.LARGE_FILE_CLEANER
import com.base.superfilemanager.view.AFunOb.NETWORK_TRAFFIC
import com.base.superfilemanager.view.AFunOb.NOTIFICATION_CLEANER
import com.base.superfilemanager.view.AFunOb.PHOTO_COMPRESS
import com.base.superfilemanager.view.AFunOb.RECENT_APP_USAGE
import com.base.superfilemanager.view.AFunOb.SIMILAR_PHOTOS
import com.base.superfilemanager.view.AFunOb.SPEAK_CLEANER

class ToolsFragment : BaseFragment<FragmentLayoutToolsBinding>() {
    private lateinit var adapter: ToolsAdapter

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

    override fun setView() {
        adapter = ToolsAdapter(requireActivity()) { kName ->
            when (kName) {
                AFunOb.JUNK_CLEANER -> {
                    startActivity(Intent(requireContext(), ScanJunkActivity::class.java))
                }


                RECENT_APP_USAGE -> {
                    startActivity(Intent(requireActivity(), RecentAppActivity::class.java))
                }

                LARGE_FILE_CLEANER -> {
                    startActivity(Intent(requireContext(), LargeFileCleanActivity::class.java))
                }

                NOTIFICATION_CLEANER -> {
                    if (SPUtils.getInstance().getBoolean("notification_guest", false)) {
                        startActivity(Intent(requireActivity(), NotificationCleanActivity::class.java))
                    } else {
                        startActivity(Intent(requireActivity(), NotificationGuestActivity::class.java))
                    }
                }

                NETWORK_TRAFFIC -> {
                    startActivity(Intent(requireContext(), NetWorkActivity::class.java))
                }

                APP_MANAGER -> {
                    startActivity(Intent(requireContext(), AppManagerActivity::class.java))
                }

                SIMILAR_PHOTOS -> {
                    startActivity(Intent(requireContext(), RepeaterdPhotoActivity::class.java))
                }

                SPEAK_CLEANER -> {
                    startActivity(Intent(requireContext(), SpeakerCleanerActivity::class.java))
                }

                PHOTO_COMPRESS -> {
                    startActivity(Intent(requireActivity(), StartCompressionPhotoActivity::class.java))
                }

                BATTERY_INFO -> {
                    startActivity(Intent(requireActivity(), BatteryInfoActivity::class.java))
                }

            }
        }
        binding.rvTools.adapter = adapter
    }

    override fun onResume() {
        super.onResume()
    }

}