2018-07-09 17:16:33 +00:00
|
|
|
package com.adlerosn.brasilfurfest.schedule
|
|
|
|
|
|
|
|
import android.app.AlertDialog
|
|
|
|
import android.content.DialogInterface
|
2018-07-14 19:43:24 +00:00
|
|
|
import android.content.Intent
|
2018-07-09 17:16:33 +00:00
|
|
|
import android.os.Bundle
|
2018-07-31 23:26:09 +00:00
|
|
|
import android.support.design.widget.Snackbar
|
2018-07-13 21:09:43 +00:00
|
|
|
import android.support.v4.app.FragmentPagerAdapter
|
2018-07-09 17:16:33 +00:00
|
|
|
import android.support.v7.app.AppCompatActivity
|
2018-07-14 19:43:24 +00:00
|
|
|
import android.view.Menu
|
|
|
|
import android.view.MenuItem
|
2018-07-09 17:16:33 +00:00
|
|
|
import com.adlerosn.brasilfurfest.R
|
2018-07-17 19:38:11 +00:00
|
|
|
import com.adlerosn.brasilfurfest.developer.DeveloperActivity
|
2018-12-28 00:28:48 +00:00
|
|
|
import com.adlerosn.brasilfurfest.helper.*
|
2018-12-13 02:04:29 +00:00
|
|
|
import com.adlerosn.brasilfurfest.schedule.managers.ScheduleManagerGetter
|
2018-07-13 21:09:43 +00:00
|
|
|
import com.adlerosn.brasilfurfest.schedule.adapters.DaysPagerAdapter
|
2018-12-13 02:04:29 +00:00
|
|
|
import com.adlerosn.brasilfurfest.schedule.managers.ScheduleManager
|
2018-07-09 17:16:33 +00:00
|
|
|
import kotlinx.android.synthetic.main.activity_schedule.*
|
|
|
|
|
|
|
|
class ScheduleActivity : AppCompatActivity() {
|
|
|
|
private lateinit var scheduleManager: ScheduleManager
|
2018-07-31 23:26:09 +00:00
|
|
|
private lateinit var pagerAdapter: FragmentPagerAdapter
|
2018-07-13 21:09:43 +00:00
|
|
|
|
2018-07-09 17:16:33 +00:00
|
|
|
override fun onCreate(savedInstanceState: Bundle?) {
|
2018-12-12 04:30:34 +00:00
|
|
|
ActivitiesForFragments[this.javaClass.simpleName] = this
|
2018-07-09 17:16:33 +00:00
|
|
|
super.onCreate(savedInstanceState)
|
|
|
|
setContentView(R.layout.activity_schedule)
|
|
|
|
setSupportActionBar(toolbar)
|
2018-12-28 00:28:48 +00:00
|
|
|
resourcesAliased = this.resources
|
2018-12-12 04:30:34 +00:00
|
|
|
scheduleManager = ScheduleManagerGetter[this]
|
2018-12-28 00:28:48 +00:00
|
|
|
|
2018-07-14 19:43:24 +00:00
|
|
|
scheduleManager.onAttendeeIntentionsChanged()
|
2018-07-13 21:09:43 +00:00
|
|
|
toolbar.title = scheduleManager.convention.name
|
2018-12-28 00:28:48 +00:00
|
|
|
toolbar.subtitle = scheduleManager.convention.theme.solved
|
|
|
|
pagerAdapter = DaysPagerAdapter(supportFragmentManager, scheduleManager)
|
2018-07-13 21:09:43 +00:00
|
|
|
container.adapter = pagerAdapter
|
2018-12-28 00:28:48 +00:00
|
|
|
tabs.fullSetup(container)
|
2018-07-13 21:09:43 +00:00
|
|
|
|
2018-12-28 00:28:48 +00:00
|
|
|
container.offscreenPageLimit = pagerAdapter.count
|
2018-07-13 21:09:43 +00:00
|
|
|
|
2018-07-14 19:43:24 +00:00
|
|
|
fab.setOnClickListener {
|
|
|
|
Intent(this, FavoritesActivity::class.java).apply {
|
|
|
|
startActivity(this)
|
|
|
|
}
|
2018-07-09 17:16:33 +00:00
|
|
|
}
|
2018-07-31 23:26:09 +00:00
|
|
|
fab.isLongClickable = true
|
|
|
|
fab.setOnLongClickListener {
|
|
|
|
Snackbar.make(it, R.string.schedule_events_favorites, Snackbar.LENGTH_LONG).apply {
|
2018-12-28 00:28:48 +00:00
|
|
|
setActionTextColor(this@ScheduleActivity.getColorCompat(R.color.colorBase20))
|
|
|
|
view.setBackgroundColor(this@ScheduleActivity.getColorCompat(R.color.colorBase03))
|
2018-07-31 23:26:09 +00:00
|
|
|
show()
|
|
|
|
}
|
|
|
|
true
|
|
|
|
}
|
2018-07-09 17:16:33 +00:00
|
|
|
}
|
|
|
|
|
2018-07-13 21:09:43 +00:00
|
|
|
|
2018-07-09 17:16:33 +00:00
|
|
|
override fun onCreateOptionsMenu(menu: Menu): Boolean {
|
2018-07-13 21:09:43 +00:00
|
|
|
menuInflater.inflate(R.menu.menu_schedule, menu)
|
2018-07-09 17:16:33 +00:00
|
|
|
return true
|
|
|
|
}
|
|
|
|
|
|
|
|
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
|
|
|
return when (item.itemId) {
|
2018-07-13 21:09:43 +00:00
|
|
|
R.id.action_clear_planning -> {
|
2018-07-17 19:38:11 +00:00
|
|
|
val dialog = AlertDialog.Builder(this).create()
|
2018-12-28 00:28:48 +00:00
|
|
|
dialog.setTitle(R.string.schedule_clear_planning_question.getString())
|
|
|
|
dialog.setMessage(R.string.this_cannot_be_undone.getString())
|
|
|
|
dialog.setButton(AlertDialog.BUTTON_NEUTRAL, R.string.dialog_cancel.getString()) { _: DialogInterface, _: Int ->
|
2018-07-09 17:16:33 +00:00
|
|
|
dialog.dismiss()
|
|
|
|
}
|
2018-12-28 00:28:48 +00:00
|
|
|
dialog.setButton(AlertDialog.BUTTON_NEGATIVE, R.string.dialog_confirm.getString()) { _: DialogInterface, _: Int ->
|
2018-07-09 17:16:33 +00:00
|
|
|
dialog.dismiss()
|
|
|
|
scheduleManager.clearIntentions()
|
2018-07-13 21:09:43 +00:00
|
|
|
scheduleManager.onAttendeeIntentionsChanged()
|
2018-07-09 17:16:33 +00:00
|
|
|
}
|
|
|
|
dialog.show()
|
|
|
|
true
|
|
|
|
}
|
2018-07-17 19:38:11 +00:00
|
|
|
R.id.action_developer -> {
|
|
|
|
Intent(this, DeveloperActivity::class.java).apply {
|
|
|
|
startActivity(this)
|
|
|
|
}
|
|
|
|
true
|
|
|
|
}
|
2018-12-12 04:30:34 +00:00
|
|
|
R.id.action_search_filter -> {
|
|
|
|
Intent(this, SearchFilterActivity::class.java).apply {
|
|
|
|
startActivity(this)
|
|
|
|
}
|
|
|
|
true
|
|
|
|
}
|
2018-07-09 17:16:33 +00:00
|
|
|
else -> super.onOptionsItemSelected(item)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-07-27 20:24:09 +00:00
|
|
|
override fun onBackPressed() {
|
|
|
|
if (tabs.selectedTabPosition == 0)
|
|
|
|
super.onBackPressed()
|
|
|
|
else
|
|
|
|
container.setCurrentItem(0, true)
|
|
|
|
}
|
2018-07-09 17:16:33 +00:00
|
|
|
|
|
|
|
}
|