mirror of
https://github.com/meshtastic/Meshtastic-Android.git
synced 2026-04-20 22:23:37 +00:00
Clear cache based on tile source
This commit is contained in:
parent
e22c7f8c35
commit
ee388db491
2 changed files with 116 additions and 1 deletions
|
|
@ -22,6 +22,8 @@ import com.geeksville.mesh.databinding.MapViewBinding
|
|||
import com.geeksville.mesh.model.UIViewModel
|
||||
import com.geeksville.mesh.model.map.CustomOverlayManager
|
||||
import com.geeksville.mesh.model.map.CustomTileSource
|
||||
import com.geeksville.mesh.util.SqlTileWriterExt
|
||||
import com.geeksville.mesh.util.SqlTileWriterExt.SourceCount
|
||||
import com.geeksville.mesh.util.formatAgo
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||
import com.google.android.material.floatingactionbutton.FloatingActionButton
|
||||
|
|
@ -60,6 +62,7 @@ class MapFragment : ScreenFragment("Map"), Logging, View.OnClickListener {
|
|||
private lateinit var executeJob: Button
|
||||
private var downloadPrompt: AlertDialog? = null
|
||||
private var alertDialog: AlertDialog? = null
|
||||
private var cache: SqlTileWriterExt? = null
|
||||
|
||||
// constants
|
||||
private val defaultMinZoom = 1.5
|
||||
|
|
@ -170,7 +173,7 @@ class MapFragment : ScreenFragment("Map"), Logging, View.OnClickListener {
|
|||
downloadJobAlert()
|
||||
dialog.dismiss()
|
||||
}
|
||||
2 -> clearCache()
|
||||
2 -> purgeTileSource()
|
||||
else -> dialog.dismiss()
|
||||
}
|
||||
}
|
||||
|
|
@ -181,6 +184,7 @@ class MapFragment : ScreenFragment("Map"), Logging, View.OnClickListener {
|
|||
alertDialog!!.show()
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Clears active tile source cache
|
||||
*/
|
||||
|
|
@ -193,6 +197,36 @@ class MapFragment : ScreenFragment("Map"), Logging, View.OnClickListener {
|
|||
alertDialog!!.dismiss()
|
||||
}
|
||||
|
||||
private fun purgeTileSource() {
|
||||
cache = SqlTileWriterExt()
|
||||
val builder = AlertDialog.Builder(context)
|
||||
builder.setTitle("Tile Source")
|
||||
val arrayAdapter: ArrayAdapter<String> =
|
||||
ArrayAdapter(context!!, android.R.layout.select_dialog_singlechoice)
|
||||
val sources = cache!!.sources
|
||||
for (i in sources.indices) {
|
||||
arrayAdapter.add(sources[i].source)
|
||||
}
|
||||
builder.setAdapter(arrayAdapter) { dialog, which ->
|
||||
val item = arrayAdapter.getItem(which)
|
||||
val b = cache!!.purgeCache(item)
|
||||
if (b) Toast.makeText(
|
||||
context,
|
||||
"SQL Cache purged",
|
||||
Toast.LENGTH_SHORT
|
||||
)
|
||||
.show() else Toast.makeText(
|
||||
context,
|
||||
"SQL Cache purge failed, see logcat for details",
|
||||
Toast.LENGTH_LONG
|
||||
).show()
|
||||
}
|
||||
builder.setNegativeButton(
|
||||
"Cancel"
|
||||
) { dialog, which -> dialog.cancel() }
|
||||
builder.show()
|
||||
}
|
||||
|
||||
|
||||
private fun showCurrentCacheInfo() {
|
||||
Toast.makeText(activity, "Calculating...", Toast.LENGTH_SHORT).show()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue