|
|
|
|
@ -190,6 +190,60 @@ class ProjectFragment : Fragment() {
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
loadData()
|
|
|
|
|
|
|
|
|
|
adapter.submitList(techniker as List<ProjectTechnikerViewState>?)
|
|
|
|
|
binding.recyclerView.layoutManager = LinearLayoutManager(myContext)
|
|
|
|
|
binding.recyclerView.adapter = adapter
|
|
|
|
|
|
|
|
|
|
binding.addButton.setOnClickListener {
|
|
|
|
|
val name = sharedPref.getString("name", "invalid")!!
|
|
|
|
|
if (!adminMode) selfAdd(name) else bothAdd(name)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
emptyCheck()
|
|
|
|
|
|
|
|
|
|
if (adminMode) {
|
|
|
|
|
binding.resetButton.visibility = View.VISIBLE
|
|
|
|
|
binding.resetButton.setOnClickListener {
|
|
|
|
|
MaterialDialog(myContext).show {
|
|
|
|
|
message(text = "Möchtest du alle eingetragenen Techniker entfernen?")
|
|
|
|
|
positiveButton(text = "Ja") {
|
|
|
|
|
val query = ParseQuery<ParseObject>("Teilnahme")
|
|
|
|
|
query.whereEqualTo("an", ParseObject.createWithoutData("Einsatz", childKey))
|
|
|
|
|
query.findInBackground { objects, e ->
|
|
|
|
|
if (e == null) {
|
|
|
|
|
ParseObject.deleteAllInBackground(objects)
|
|
|
|
|
techniker.clear()
|
|
|
|
|
adapter.notifyDataSetChanged()
|
|
|
|
|
showDivider(false)
|
|
|
|
|
binding.technikerView.text = "Techniker: 0"
|
|
|
|
|
} else {
|
|
|
|
|
Toasty.error(myContext, "Fehler bei Techniker-Abfrage", Toasty.LENGTH_SHORT).show()
|
|
|
|
|
Log.e("TechnikLogger.TechSuche", e.message.toString())
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
negativeButton(text = "Abbrechen")
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
binding.swipeRefreshLayout.setOnRefreshListener {
|
|
|
|
|
binding.titleView.text = ""
|
|
|
|
|
binding.dateView.text = ""
|
|
|
|
|
binding.locationView.text = ""
|
|
|
|
|
techniker.clear()
|
|
|
|
|
adapter.notifyDataSetChanged()
|
|
|
|
|
showDivider(false)
|
|
|
|
|
binding.technikerView.text = "Techniker: 0"
|
|
|
|
|
loadData()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return root
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private fun loadData() {
|
|
|
|
|
val query = ParseQuery.getQuery<ParseObject>("Einsatz")
|
|
|
|
|
query.getInBackground(childKey) { einsatz, e ->
|
|
|
|
|
if (e == null) {
|
|
|
|
|
@ -239,46 +293,8 @@ class ProjectFragment : Fragment() {
|
|
|
|
|
Toasty.error(myContext, "Fehler bei Einsatz-Suche").show()
|
|
|
|
|
Log.e("TechnikLogger.EinsSuche", e.message.toString())
|
|
|
|
|
}
|
|
|
|
|
binding.swipeRefreshLayout.isRefreshing = false
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
adapter.submitList(techniker as List<ProjectTechnikerViewState>?)
|
|
|
|
|
binding.recyclerView.layoutManager = LinearLayoutManager(myContext)
|
|
|
|
|
binding.recyclerView.adapter = adapter
|
|
|
|
|
|
|
|
|
|
binding.addButton.setOnClickListener {
|
|
|
|
|
val name = sharedPref.getString("name", "invalid")!!
|
|
|
|
|
if (!adminMode) selfAdd(name) else bothAdd(name)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
emptyCheck()
|
|
|
|
|
|
|
|
|
|
if (adminMode) {
|
|
|
|
|
binding.resetButton.visibility = View.VISIBLE
|
|
|
|
|
binding.resetButton.setOnClickListener {
|
|
|
|
|
MaterialDialog(myContext).show {
|
|
|
|
|
message(text = "Möchtest du alle eingetragenen Techniker entfernen?")
|
|
|
|
|
positiveButton(text = "Ja") {
|
|
|
|
|
val query = ParseQuery<ParseObject>("Teilnahme")
|
|
|
|
|
query.whereEqualTo("an", ParseObject.createWithoutData("Einsatz", childKey))
|
|
|
|
|
query.findInBackground { objects, e ->
|
|
|
|
|
if (e == null) {
|
|
|
|
|
ParseObject.deleteAllInBackground(objects)
|
|
|
|
|
techniker.clear()
|
|
|
|
|
adapter.notifyDataSetChanged()
|
|
|
|
|
showDivider(false)
|
|
|
|
|
binding.technikerView.text = "Techniker: 0"
|
|
|
|
|
} else {
|
|
|
|
|
Toasty.error(myContext, "Fehler bei Techniker-Abfrage", Toasty.LENGTH_SHORT).show()
|
|
|
|
|
Log.e("TechnikLogger.TechSuche", e.message.toString())
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
negativeButton(text = "Abbrechen")
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return root
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private fun technikerExists(name: String): Boolean {
|
|
|
|
|
|