package app.furmeet.events.brasilfurfest.schedule

import android.graphics.Color
import android.os.Bundle
import android.view.WindowManager
import androidx.recyclerview.widget.LinearLayoutManager
import com.adlerosn.brasilfurfest.R
import app.furmeet.events.brasilfurfest.TranslatableAppCompatActivity
import app.furmeet.events.brasilfurfest.helper.*
import app.furmeet.events.brasilfurfest.schedule.adapters.FavoritesAdapter
import app.furmeet.events.brasilfurfest.schedule.managers.ScheduleManagerGetter
import kotlinx.android.synthetic.main.activity_favorites.*

class FavoritesActivity : TranslatableAppCompatActivity() {

    override fun onCreate(savedInstanceState: Bundle?) {
        ActivitiesForFragments[this.javaClass.simpleName] = this
        super.onCreate(savedInstanceState)
        window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS)
        window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS)
        window.addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION)
        window.statusBarColor = Color.TRANSPARENT
        setContentView(R.layout.activity_favorites)
        resourcesAliased = this.resources
        setSupportActionBar(toolbar)
        val scheduleManager = ScheduleManagerGetter[this]
        collapsingToolbar.setExpandedTitleTextAppearance(R.style.ExpandedAppBar)
        collapsingToolbar.setCollapsedTitleTextAppearance(R.style.CollapsedAppBar)
        collapsingToolbar.title = getString(R.string.schedule_events_favorites)
        scheduleManager.convention.imageFavorites.solved
                ?.fromCache(scheduleManager)
                ?.toDrawable()
                ?.asImageOf(app_bar_image)
        favorites.layoutManager = LinearLayoutManager(this)
        FavoritesAdapter(this, scheduleManager).apply {
            favorites.adapter = this
            scheduleManager.addObserver(this)
        }
    }
}
