package app.furmeet.events.brasilfurfest

import android.content.Context
import android.content.res.Configuration
import android.view.MenuItem
import androidx.appcompat.app.AppCompatActivity
import app.furmeet.events.brasilfurfest.helper.LocaleManager


abstract class TranslatableAppCompatActivity : AppCompatActivity() {
    override fun attachBaseContext(baseContext: Context) {
        super.attachBaseContext(LocaleManager(baseContext).patchedContext)
    }

    override fun onConfigurationChanged(newConfig: Configuration) {
        newConfig.setLocale(LocaleManager(this).locale)
        super.onConfigurationChanged(newConfig)
    }

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