2018-07-09 17:16:33 +00:00
|
|
|
package com.adlerosn.brasilfurfest.schedule
|
|
|
|
|
|
|
|
import android.app.AlertDialog
|
|
|
|
import android.content.DialogInterface
|
|
|
|
import android.os.Bundle
|
2018-07-13 21:09:43 +00:00
|
|
|
import android.support.design.widget.Snackbar
|
|
|
|
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-13 21:09:43 +00:00
|
|
|
import android.view.*
|
2018-07-09 17:16:33 +00:00
|
|
|
import com.adlerosn.brasilfurfest.R
|
2018-07-13 21:09:43 +00:00
|
|
|
import com.adlerosn.brasilfurfest.helper.runtimeLanguage
|
|
|
|
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
|
|
|
/**
|
|
|
|
* The [android.support.v4.view.PagerAdapter] that will provide
|
|
|
|
* fragments for each of the sections. We use a
|
|
|
|
* {@link FragmentPagerAdapter} derivative, which will keep every
|
|
|
|
* loaded fragment in memory. If this becomes too memory intensive, it
|
|
|
|
* may be best to switch to a
|
|
|
|
* [android.support.v4.app.FragmentStatePagerAdapter].
|
|
|
|
*/
|
|
|
|
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)
|
|
|
|
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))
|
|
|
|
|
|
|
|
fab.setOnClickListener { view ->
|
|
|
|
Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
|
|
|
|
.setAction("Action", null).show()
|
2018-07-09 17:16:33 +00:00
|
|
|
}
|
2018-07-13 21:09:43 +00:00
|
|
|
|
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-09 17:16:33 +00:00
|
|
|
val dialog = AlertDialog.Builder(this, R.style.Theme_AppCompat_Light_Dialog_Alert).create()
|
|
|
|
dialog.setTitle(getString(R.string.schedule_clear_planning_question))
|
|
|
|
dialog.setMessage(getString(R.string.this_cannot_be_undone))
|
2018-07-13 21:09:43 +00:00
|
|
|
dialog.setButton(AlertDialog.BUTTON_NEGATIVE, getString(R.string.dialog_cancel)) { _: DialogInterface, _: Int ->
|
2018-07-09 17:16:33 +00:00
|
|
|
dialog.dismiss()
|
|
|
|
}
|
2018-07-13 21:09:43 +00:00
|
|
|
dialog.setButton(AlertDialog.BUTTON_POSITIVE, 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
|
|
|
|
}
|
|
|
|
else -> super.onOptionsItemSelected(item)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|