|
|
|
@ -10,10 +10,14 @@ import android.view.View
|
|
|
|
import androidx.appcompat.app.AppCompatActivity
|
|
|
|
import androidx.appcompat.app.AppCompatActivity
|
|
|
|
import com.afollestad.materialdialogs.MaterialDialog
|
|
|
|
import com.afollestad.materialdialogs.MaterialDialog
|
|
|
|
import com.google.android.material.datepicker.MaterialDatePicker
|
|
|
|
import com.google.android.material.datepicker.MaterialDatePicker
|
|
|
|
|
|
|
|
import com.google.android.material.timepicker.MaterialTimePicker
|
|
|
|
|
|
|
|
import com.google.android.material.timepicker.TimeFormat
|
|
|
|
import com.google.firebase.database.DatabaseReference
|
|
|
|
import com.google.firebase.database.DatabaseReference
|
|
|
|
import com.google.firebase.database.FirebaseDatabase
|
|
|
|
import com.google.firebase.database.FirebaseDatabase
|
|
|
|
import es.dmoral.toasty.Toasty
|
|
|
|
import es.dmoral.toasty.Toasty
|
|
|
|
import kotlinx.android.synthetic.main.activity_einsatz_pusher.*
|
|
|
|
import kotlinx.android.synthetic.main.activity_einsatz_pusher.*
|
|
|
|
|
|
|
|
import java.sql.Time
|
|
|
|
|
|
|
|
import java.text.DecimalFormat
|
|
|
|
import java.text.SimpleDateFormat
|
|
|
|
import java.text.SimpleDateFormat
|
|
|
|
import java.util.*
|
|
|
|
import java.util.*
|
|
|
|
|
|
|
|
|
|
|
|
@ -23,6 +27,9 @@ 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 lateinit var time1: Time
|
|
|
|
|
|
|
|
private lateinit var time2: Time
|
|
|
|
|
|
|
|
private var duration = ""
|
|
|
|
private lateinit var location: String
|
|
|
|
private lateinit var location: String
|
|
|
|
private lateinit var name: String
|
|
|
|
private lateinit var name: String
|
|
|
|
private val simpleDateFormat = SimpleDateFormat("dd.MM.yyyy", Locale.GERMANY)
|
|
|
|
private val simpleDateFormat = SimpleDateFormat("dd.MM.yyyy", Locale.GERMANY)
|
|
|
|
@ -42,11 +49,38 @@ class EinsatzPusher : AppCompatActivity() {
|
|
|
|
|
|
|
|
|
|
|
|
val builder = MaterialDatePicker.Builder.datePicker().setTitleText("Datum")
|
|
|
|
val builder = MaterialDatePicker.Builder.datePicker().setTitleText("Datum")
|
|
|
|
val picker = builder.build()
|
|
|
|
val picker = builder.build()
|
|
|
|
|
|
|
|
var builder2 = MaterialTimePicker.Builder().setTimeFormat(TimeFormat.CLOCK_24H)
|
|
|
|
|
|
|
|
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 {
|
|
|
|
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.addOnPositiveButtonClickListener {
|
|
|
|
|
|
|
|
time1 = Time(0)
|
|
|
|
|
|
|
|
time1.hours = picker2.hour
|
|
|
|
|
|
|
|
time1.minutes = picker2.minute
|
|
|
|
|
|
|
|
picker2.clearOnPositiveButtonClickListeners()
|
|
|
|
|
|
|
|
builder2 = MaterialTimePicker.Builder().setTimeFormat(TimeFormat.CLOCK_24H)
|
|
|
|
|
|
|
|
picker2 = builder2.setTitleText("Von").build()
|
|
|
|
|
|
|
|
picker3.show(supportFragmentManager, picker3.tag)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
picker3.addOnPositiveButtonClickListener {
|
|
|
|
|
|
|
|
time2 = Time(0)
|
|
|
|
|
|
|
|
time2.hours = picker3.hour
|
|
|
|
|
|
|
|
time2.minutes = picker3.minute
|
|
|
|
|
|
|
|
picker3.clearOnPositiveButtonClickListeners()
|
|
|
|
|
|
|
|
builder3 = MaterialTimePicker.Builder().setTimeFormat(TimeFormat.CLOCK_24H)
|
|
|
|
|
|
|
|
picker3 = builder3.setTitleText("Bis").build()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
duration = DecimalFormat("#.#").format((time2.time - time1.time) / 3600 / 1000.toFloat())
|
|
|
|
|
|
|
|
duration = duration.replace(",", ".")
|
|
|
|
|
|
|
|
duration_view.text = Html.fromHtml("<b>Dauer:</b> $duration Stunden")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
picker.show(supportFragmentManager, picker.tag)
|
|
|
|
picker.show(supportFragmentManager, picker.tag)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -75,6 +109,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("duration").setValue(duration)
|
|
|
|
finish()
|
|
|
|
finish()
|
|
|
|
startActivity(Intent(applicationContext, MainActivity::class.java))
|
|
|
|
startActivity(Intent(applicationContext, MainActivity::class.java))
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
@ -88,6 +123,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()
|
|
|
|
|
|
|
|
duration = intent.extras?.getString("duration").toString()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private fun restoreInformation() {
|
|
|
|
private fun restoreInformation() {
|
|
|
|
@ -98,7 +134,10 @@ class EinsatzPusher : AppCompatActivity() {
|
|
|
|
locationEditText.text = SpannableStringBuilder(location)
|
|
|
|
locationEditText.text = SpannableStringBuilder(location)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (date != "null") {
|
|
|
|
if (date != "null") {
|
|
|
|
date_view.text = "Datum:\n$date"
|
|
|
|
date_view.text = Html.fromHtml("<b>Datum:</b><br/>${date}")
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (duration != "null") {
|
|
|
|
|
|
|
|
duration_view.text = Html.fromHtml("<b>Dauer:</b> $duration Stunden")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (childKey == "null") {
|
|
|
|
if (childKey == "null") {
|
|
|
|
|