package  com.test.basd.onecleanmaster.display

import android.app.NotificationManager
import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent
import android.util.Log
import com.test.basd.onecleanmaster.helps.LogEx

class CloseNotificationReceiver : BroadcastReceiver() {
    private val TAG = "CloseNotificationReceiver"
    override fun onReceive(context: Context?, intent: Intent?) {
        LogEx.logDebug(TAG, "onReceive")
        intent?.let {
            val notificationId = it.getIntExtra("notificationId", -1)
            if (notificationId != -1 && it.action != "DELETE_NOTIFICATION") {
                val notificationManager = context?.getSystemService(Context.NOTIFICATION_SERVICE) as? NotificationManager
                notificationManager?.cancel(NotificationUtils.NOTIFICATION_TAG, notificationId)
            }
        }
    }

    companion object {
        const val action = "com.file.notification.CloseNotificationReceiver"
    }
}
