added logic to validate map naming window

pull/391/head
PWRxPSYCHO 2022-03-02 09:04:31 -05:00
rodzic 07dd8a826f
commit ee68c98e98
1 zmienionych plików z 21 dodań i 11 usunięć

Wyświetl plik

@ -1,6 +1,7 @@
package com.geeksville.mesh.ui package com.geeksville.mesh.ui
import android.app.AlertDialog import android.app.AlertDialog
import android.content.DialogInterface
import android.graphics.Color import android.graphics.Color
import android.os.Bundle import android.os.Bundle
import android.os.Handler import android.os.Handler
@ -647,18 +648,27 @@ class MapFragment : ScreenFragment("Map"), Logging {
nameRegionDialog.setNegativeButton("Cancel") { dialog, _ -> nameRegionDialog.setNegativeButton("Cancel") { dialog, _ ->
dialog.cancel() dialog.cancel()
} }
nameRegionDialog.setPositiveButton("Save") { _, _ -> nameRegionDialog.setPositiveButton(
"Save", null
)
val dialog = nameRegionDialog.create()
dialog.show()
dialog.getButton(AlertDialog.BUTTON_POSITIVE)
.setOnClickListener {
if (userInput.text.isEmpty()) { if (userInput.text.isEmpty()) {
// Error out dialog val text =
"You must enter a name"
val duration = Toast.LENGTH_LONG
val toast = Toast.makeText(requireContext(), text, duration)
toast.show()
} else { } else {
this.regionName = userInput.text.toString() this.regionName = userInput.text.toString()
userInput.setText("") userInput.setText("")
dialog.dismiss()
downloadOfflineRegion(styleURI) downloadOfflineRegion(styleURI)
} }
} }
nameRegionDialog.create()
nameRegionDialog.show()
} }
private val offlineRegionAdapter = object : RecyclerView.Adapter<ViewHolder>() { private val offlineRegionAdapter = object : RecyclerView.Adapter<ViewHolder>() {