|
|
|
@ -27,6 +27,7 @@ class EinsatzPusher : AppCompatActivity() {
|
|
|
|
private lateinit var databaseReference: DatabaseReference
|
|
|
|
private lateinit var databaseReference: DatabaseReference
|
|
|
|
private lateinit var databaseReferenceNew: DatabaseReference
|
|
|
|
private lateinit var databaseReferenceNew: DatabaseReference
|
|
|
|
private var date = ""
|
|
|
|
private var date = ""
|
|
|
|
|
|
|
|
private var time = ""
|
|
|
|
private lateinit var time1: Time
|
|
|
|
private lateinit var time1: Time
|
|
|
|
private lateinit var time2: Time
|
|
|
|
private lateinit var time2: Time
|
|
|
|
private var duration = ""
|
|
|
|
private var duration = ""
|
|
|
|
@ -35,7 +36,6 @@ class EinsatzPusher : AppCompatActivity() {
|
|
|
|
private val simpleDateFormat = SimpleDateFormat("dd.MM.yyyy", Locale.GERMANY)
|
|
|
|
private val simpleDateFormat = SimpleDateFormat("dd.MM.yyyy", Locale.GERMANY)
|
|
|
|
|
|
|
|
|
|
|
|
@SuppressLint("SetTextI18n")
|
|
|
|
@SuppressLint("SetTextI18n")
|
|
|
|
@Suppress("DEPRECATION")
|
|
|
|
|
|
|
|
override fun onCreate(savedInstanceState: Bundle?) {
|
|
|
|
override fun onCreate(savedInstanceState: Bundle?) {
|
|
|
|
getBundleInformation()
|
|
|
|
getBundleInformation()
|
|
|
|
super.onCreate(savedInstanceState)
|
|
|
|
super.onCreate(savedInstanceState)
|
|
|
|
@ -48,39 +48,58 @@ class EinsatzPusher : AppCompatActivity() {
|
|
|
|
supportActionBar?.setDisplayHomeAsUpEnabled(true)
|
|
|
|
supportActionBar?.setDisplayHomeAsUpEnabled(true)
|
|
|
|
|
|
|
|
|
|
|
|
val builder = MaterialDatePicker.Builder.datePicker().setTitleText("Datum")
|
|
|
|
val builder = MaterialDatePicker.Builder.datePicker().setTitleText("Datum")
|
|
|
|
val picker = builder.build()
|
|
|
|
val builder2 = MaterialTimePicker.Builder().setTimeFormat(TimeFormat.CLOCK_24H).setTitleText("Von")
|
|
|
|
var builder2 = MaterialTimePicker.Builder().setTimeFormat(TimeFormat.CLOCK_24H)
|
|
|
|
val builder3 = MaterialTimePicker.Builder().setTimeFormat(TimeFormat.CLOCK_24H).setTitleText("Bis")
|
|
|
|
var picker2 = builder2.setTitleText("Von").build()
|
|
|
|
|
|
|
|
var builder3 = MaterialTimePicker.Builder().setTimeFormat(TimeFormat.CLOCK_24H)
|
|
|
|
|
|
|
|
var picker3 = builder3.setTitleText("Bis").build()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
date_button.setOnClickListener {
|
|
|
|
date_button.setOnClickListener {
|
|
|
|
|
|
|
|
if (date != "null") {
|
|
|
|
|
|
|
|
val dateInMillis = simpleDateFormat.parse(date)!!.time
|
|
|
|
|
|
|
|
builder.setSelection(dateInMillis + 3600000)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (time != "null") {
|
|
|
|
|
|
|
|
val times = time.split(" - ")
|
|
|
|
|
|
|
|
builder2.setHour(times[0].split(":")[0].toInt())
|
|
|
|
|
|
|
|
.setMinute(times[0].split(":")[1].toInt())
|
|
|
|
|
|
|
|
builder3.setHour(times[1].split(":")[0].toInt())
|
|
|
|
|
|
|
|
.setMinute(times[1].split(":")[1].toInt())
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
var tempTime = ""
|
|
|
|
|
|
|
|
val picker = builder.build()
|
|
|
|
|
|
|
|
val picker2 = builder2.build()
|
|
|
|
|
|
|
|
val picker3 = builder3.build()
|
|
|
|
|
|
|
|
var hour: String
|
|
|
|
|
|
|
|
var minute: String
|
|
|
|
|
|
|
|
var hoursInMillis: Long
|
|
|
|
|
|
|
|
var minutesInMillis: Long
|
|
|
|
picker.addOnPositiveButtonClickListener {
|
|
|
|
picker.addOnPositiveButtonClickListener {
|
|
|
|
date = simpleDateFormat.format(Date(it))
|
|
|
|
date = simpleDateFormat.format(Date(it))
|
|
|
|
date_view.text = Html.fromHtml("<b>Datum:</b><br/>${date}")
|
|
|
|
date_view.text = Html.fromHtml("<b>Datum:</b><br/>${date}")
|
|
|
|
picker.clearOnPositiveButtonClickListeners()
|
|
|
|
|
|
|
|
picker2.show(supportFragmentManager, picker2.tag)
|
|
|
|
picker2.show(supportFragmentManager, picker2.tag)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
picker2.addOnPositiveButtonClickListener {
|
|
|
|
picker2.addOnPositiveButtonClickListener {
|
|
|
|
time1 = Time(0)
|
|
|
|
hour = picker2.hour.toString()
|
|
|
|
time1.hours = picker2.hour
|
|
|
|
hour = if (hour.length != 1) hour else "0$hour"
|
|
|
|
time1.minutes = picker2.minute
|
|
|
|
minute = picker2.minute.toString()
|
|
|
|
picker2.clearOnPositiveButtonClickListeners()
|
|
|
|
minute = if (minute.length != 1) minute else "0$minute"
|
|
|
|
builder2 = MaterialTimePicker.Builder().setTimeFormat(TimeFormat.CLOCK_24H)
|
|
|
|
hoursInMillis = picker2.hour.toLong() * 3600000
|
|
|
|
picker2 = builder2.setTitleText("Von").build()
|
|
|
|
minutesInMillis = picker2.minute.toLong() * 60000
|
|
|
|
|
|
|
|
time1 = Time(hoursInMillis + minutesInMillis)
|
|
|
|
|
|
|
|
tempTime += "${hour}:${minute} - "
|
|
|
|
picker3.show(supportFragmentManager, picker3.tag)
|
|
|
|
picker3.show(supportFragmentManager, picker3.tag)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
picker3.addOnPositiveButtonClickListener {
|
|
|
|
picker3.addOnPositiveButtonClickListener {
|
|
|
|
time2 = Time(0)
|
|
|
|
hour = picker3.hour.toString()
|
|
|
|
time2.hours = picker3.hour
|
|
|
|
hour = if (hour.length != 1) hour else "0$hour"
|
|
|
|
time2.minutes = picker3.minute
|
|
|
|
minute = picker3.minute.toString()
|
|
|
|
picker3.clearOnPositiveButtonClickListeners()
|
|
|
|
minute = if (minute.length != 1) minute else "0$minute"
|
|
|
|
builder3 = MaterialTimePicker.Builder().setTimeFormat(TimeFormat.CLOCK_24H)
|
|
|
|
hoursInMillis = hour.toLong() * 3600000
|
|
|
|
picker3 = builder3.setTitleText("Bis").build()
|
|
|
|
minutesInMillis = minute.toLong() * 60000
|
|
|
|
|
|
|
|
time2 = Time(hoursInMillis + minutesInMillis)
|
|
|
|
|
|
|
|
tempTime += "${hour}:${minute}"
|
|
|
|
|
|
|
|
time = tempTime
|
|
|
|
duration = DecimalFormat("#.#").format((time2.time - time1.time) / 3600 / 1000.toFloat())
|
|
|
|
duration = DecimalFormat("#.#").format((time2.time - time1.time) / 3600 / 1000.toFloat())
|
|
|
|
duration = duration.replace(",", ".")
|
|
|
|
duration = duration.replace(",", ".")
|
|
|
|
duration_view.text = Html.fromHtml("<b>Dauer:</b> $duration Stunden")
|
|
|
|
duration_view.text = Html.fromHtml("<b>Dauer:</b> $time Uhr, $duration Stunden")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
picker.show(supportFragmentManager, picker.tag)
|
|
|
|
picker.show(supportFragmentManager, picker.tag)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -109,6 +128,7 @@ class EinsatzPusher : AppCompatActivity() {
|
|
|
|
databaseReferenceNew.child("name").setValue(name)
|
|
|
|
databaseReferenceNew.child("name").setValue(name)
|
|
|
|
databaseReferenceNew.child("location").setValue(location)
|
|
|
|
databaseReferenceNew.child("location").setValue(location)
|
|
|
|
databaseReferenceNew.child("date").setValue(date)
|
|
|
|
databaseReferenceNew.child("date").setValue(date)
|
|
|
|
|
|
|
|
databaseReferenceNew.child("time").setValue(time)
|
|
|
|
databaseReferenceNew.child("duration").setValue(duration)
|
|
|
|
databaseReferenceNew.child("duration").setValue(duration)
|
|
|
|
finish()
|
|
|
|
finish()
|
|
|
|
startActivity(Intent(applicationContext, MainActivity::class.java))
|
|
|
|
startActivity(Intent(applicationContext, MainActivity::class.java))
|
|
|
|
@ -123,6 +143,7 @@ class EinsatzPusher : AppCompatActivity() {
|
|
|
|
name = intent.extras?.getString("name").toString()
|
|
|
|
name = intent.extras?.getString("name").toString()
|
|
|
|
location = intent.extras?.getString("location").toString()
|
|
|
|
location = intent.extras?.getString("location").toString()
|
|
|
|
date = intent.extras?.getString("date").toString()
|
|
|
|
date = intent.extras?.getString("date").toString()
|
|
|
|
|
|
|
|
time = intent.extras?.getString("time").toString()
|
|
|
|
duration = intent.extras?.getString("duration").toString()
|
|
|
|
duration = intent.extras?.getString("duration").toString()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ -136,7 +157,9 @@ class EinsatzPusher : AppCompatActivity() {
|
|
|
|
if (date != "null") {
|
|
|
|
if (date != "null") {
|
|
|
|
date_view.text = Html.fromHtml("<b>Datum:</b><br/>${date}")
|
|
|
|
date_view.text = Html.fromHtml("<b>Datum:</b><br/>${date}")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (duration != "null") {
|
|
|
|
if (time != "null") {
|
|
|
|
|
|
|
|
duration_view.text = Html.fromHtml("<b>Dauer:</b> $time Uhr, $duration Stunden")
|
|
|
|
|
|
|
|
} else if (duration != "null") {
|
|
|
|
duration_view.text = Html.fromHtml("<b>Dauer:</b> $duration Stunden")
|
|
|
|
duration_view.text = Html.fromHtml("<b>Dauer:</b> $duration Stunden")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|