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-27 20:24:09 +00:00
|
|
|
import android.graphics.Color
|
2018-07-09 17:16:33 +00:00
|
|
|
import android.os.Bundle
|
2018-07-13 21:09:43 +00:00
|
|
|
import android.support.design.widget.TabLayout
|
|
|
|
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-27 20:24:09 +00:00
|
|
|
import android.view.WindowManager
|
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-07-13 21:09:43 +00:00
|
|
|
import com.adlerosn.brasilfurfest.helper.runtimeLanguage
|
2018-07-17 19:38:11 +00:00
|
|
|
import com.adlerosn.brasilfurfest.legal.SoftwareLicensesActivity
|
2018-07-13 21:09:43 +00:00
|
|
|
import com.adlerosn.brasilfurfest.schedule.adapters.DaysPagerAdapter
|
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-13 21:09:43 +00:00
|
|
|
lateinit var pagerAdapter: FragmentPagerAdapter
|
|
|
|
|
2018-07-09 17:16:33 +00:00
|
|
|
override fun onCreate(savedInstanceState: Bundle?) {
|
|
|
|
super.onCreate(savedInstanceState)
|
|
|
|
setContentView(R.layout.activity_schedule)
|
2018-07-13 21:09:43 +00:00
|
|
|
|
2018-07-09 17:16:33 +00:00
|
|
|
setSupportActionBar(toolbar)
|
2018-07-13 21:09:43 +00:00
|
|
|
// Create the adapter that will return a fragment for each of the three
|
|
|
|
// primary sections of the activity.
|
2018-07-09 17:16:33 +00:00
|
|
|
|
2018-07-13 21:09:43 +00:00
|
|
|
scheduleManager = ScheduleManager(this)
|
2018-07-14 19:43:24 +00:00
|
|
|
scheduleManager.onAttendeeIntentionsChanged()
|
2018-07-13 21:09:43 +00:00
|
|
|
toolbar.title = scheduleManager.convention.name
|
|
|
|
toolbar.subtitle = scheduleManager.convention.theme[this.runtimeLanguage]
|
|
|
|
|
|
|
|
pagerAdapter = DaysPagerAdapter(supportFragmentManager, this, scheduleManager)
|
|
|
|
tabs.setupWithViewPager(container)
|
|
|
|
|
|
|
|
// Set up the ViewPager with the sections adapter.
|
|
|
|
container.adapter = pagerAdapter
|
|
|
|
container.offscreenPageLimit = pagerAdapter.count
|
|
|
|
|
|
|
|
container.addOnPageChangeListener(TabLayout.TabLayoutOnPageChangeListener(tabs))
|
|
|
|
tabs.addOnTabSelectedListener(TabLayout.ViewPagerOnTabSelectedListener(container))
|
|
|
|
|
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-13 21:09:43 +00:00
|
|
|
|
2018-07-09 17:16:33 +00:00
|
|
|
override fun onCreateOptionsMenu(menu: Menu): Boolean {
|
|
|
|
// Inflate the menu; this adds items to the action bar if it is present.
|
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 {
|
|
|
|
// Handle action bar item clicks here. The action bar will
|
|
|
|
// automatically handle clicks on the Home/Up button, so long
|
|
|
|
// as you specify a parent activity in AndroidManifest.xml.
|
|
|
|
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-07-09 17:16:33 +00:00
|
|
|
dialog.setTitle(getString(R.string.schedule_clear_planning_question))
|
|
|
|
dialog.setMessage(getString(R.string.this_cannot_be_undone))
|
2018-07-17 19:38:11 +00:00
|
|
|
dialog.setButton(AlertDialog.BUTTON_NEUTRAL, getString(R.string.dialog_cancel)) { _: DialogInterface, _: Int ->
|
2018-07-09 17:16:33 +00:00
|
|
|
dialog.dismiss()
|
|
|
|
}
|
2018-07-17 19:38:11 +00:00
|
|
|
dialog.setButton(AlertDialog.BUTTON_NEGATIVE, getString(R.string.dialog_confirm)) { _: 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-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
|
|
|
|
|
|
|
}
|