Skip to content

Commit 12321f6

Browse files
committed
Improve code
1 parent 1f9e380 commit 12321f6

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

app/src/main/java/net/bible/service/sword/SwordEnvironmentInitialisation.kt

+4-3
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,8 @@ object SwordEnvironmentInitialisation {
9999
SwordBookPath.setAugmentPath(arrayOf(SharedConstants.manualInstallDir, SharedConstants.manualInstallDir2))
100100
}
101101

102+
private val messageShownLast = LruCache<String, Long>(100);
103+
102104
/** JSword calls back to this listener in the event of some types of error
103105
*
104106
*/
@@ -112,7 +114,6 @@ object SwordEnvironmentInitialisation {
112114
showMsg(ev)
113115
}
114116

115-
val messageCache = LruCache<String, Long>(100);
116117

117118
private fun showMsg(ev: ReporterEvent?) {
118119
val msg = when {
@@ -122,8 +123,8 @@ object SwordEnvironmentInitialisation {
122123
getResourceString(R.string.error_occurred_with_link, ev.exception.message!!)
123124
else -> getResourceString(R.string.error_occurred)
124125
}
125-
val lastShown = messageCache.get(msg)
126-
messageCache.put(msg, System.currentTimeMillis())
126+
val lastShown = messageShownLast.get(msg)
127+
messageShownLast.put(msg, System.currentTimeMillis())
127128
if (lastShown != null && System.currentTimeMillis() - lastShown < FIVE_MINUTES_MS) {
128129
return // Error message has been shown recently, let's not spam user!
129130
}

0 commit comments

Comments
 (0)