package com.sambath.sbc.base

import android.os.Bundle
import android.view.MenuItem
import androidx.appcompat.app.AppCompatActivity
import com.sambath.sbc.R
import java.text.DecimalFormat

abstract class BaseActivity : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        if (savedInstanceState == null) overridePendingTransition(
            R.anim.slide_in,
            R.anim.slide_out
        )
    }
    fun currencyFormat(amount: Int): String? {
        val formatter = DecimalFormat("#,###")
        return formatter.format(amount)
    }

    fun currencyFormat(amount: Long): String? {
        val formatter = DecimalFormat("#,###")
        return formatter.format(amount)
    }

    fun currencyFormat(amount: Double): String? {
        val formatter = DecimalFormat("#,###")
        return formatter.format(amount)
    }
    override fun finish() {
        super.finish()
        overridePendingTransition(
            R.anim.slide_in_exit,
            R.anim.slide_out_exit
        )
    }

    override fun onOptionsItemSelected(item: MenuItem): Boolean {
        if (item.itemId == android.R.id.home) {
            onBackPressed()
            return true
        }
        return super.onOptionsItemSelected(item)
    }

    override fun onBackPressed() {
        super.onBackPressed()
        overridePendingTransition(
            R.anim.slide_in_exit,
            R.anim.slide_out_exit
        )
    }
}