From 37d05f2c9106db9f30ef48b766ecf5c5269d98a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=96ppen?= Date: Wed, 19 Aug 2020 12:33:16 +0100 Subject: [PATCH] add cache clear menu option --- app/src/main/java/oppen/tva/io/RuntimeCache.kt | 2 ++ app/src/main/java/oppen/tva/ui/TvaActivity.kt | 5 +++++ app/src/main/res/menu/overflow_menu.xml | 2 ++ app/src/main/res/values/strings.xml | 1 + 4 files changed, 10 insertions(+) diff --git a/app/src/main/java/oppen/tva/io/RuntimeCache.kt b/app/src/main/java/oppen/tva/io/RuntimeCache.kt index 3d11451..12368b5 100644 --- a/app/src/main/java/oppen/tva/io/RuntimeCache.kt +++ b/app/src/main/java/oppen/tva/io/RuntimeCache.kt @@ -13,4 +13,6 @@ object RuntimeCache { } fun get(uri: URI): Pair>? = lruCache[uri.toString()] + + fun clear() = lruCache.evictAll() } \ No newline at end of file diff --git a/app/src/main/java/oppen/tva/ui/TvaActivity.kt b/app/src/main/java/oppen/tva/ui/TvaActivity.kt index f5439ff..da7e91a 100644 --- a/app/src/main/java/oppen/tva/ui/TvaActivity.kt +++ b/app/src/main/java/oppen/tva/ui/TvaActivity.kt @@ -16,6 +16,7 @@ import com.google.android.material.snackbar.Snackbar import oppen.tva.R import oppen.tva.databinding.ActivityTvaBinding import oppen.tva.io.GeminiResponse +import oppen.tva.io.RuntimeCache import oppen.tva.io.TvaState import oppen.tva.io.history.CacheInterface import oppen.tva.ui.about.AboutDialog @@ -91,6 +92,10 @@ class TvaActivity : AppCompatActivity() { startActivity(Intent.createChooser(this, null)) } } + R.id.overflow_menu_clear_cache -> { + RuntimeCache.clear() + showAlert("Runtime cache cleared") + } R.id.overflow_menu_about -> AboutDialog.show(this) R.id.overflow_menu_set_home -> { SetHomeDialog.show(this, binding.addressEdit.text.toString()){ diff --git a/app/src/main/res/menu/overflow_menu.xml b/app/src/main/res/menu/overflow_menu.xml index 68b0573..90bbf77 100644 --- a/app/src/main/res/menu/overflow_menu.xml +++ b/app/src/main/res/menu/overflow_menu.xml @@ -9,6 +9,8 @@ android:title="@string/set_home" /> + diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 9d796cf..307d7b8 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -16,4 +16,5 @@ \nThis program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or any later version.\n \nThis program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.\n \nYou should have received a copy of the GNU General Public License along with this program. If not, see www.gnu.org/licenses + Clear cache \ No newline at end of file