Skip to content

Commit 713c510

Browse files
committed
fix cache bug where fresh installs include 1 null recent sticker
1 parent 43cda57 commit 713c510

2 files changed

Lines changed: 5 additions & 3 deletions

File tree

app/src/main/java/com/fredhappyface/ewesticker/ImageKeyboard.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -506,7 +506,7 @@ class ImageKeyboard : InputMethodService(), StickerClickListener {
506506
* @param sticker: File
507507
*/
508508
override fun onStickerClicked(sticker: File) {
509-
this.recentCache.add(sticker.absolutePath)
509+
this.recentCache.add(sticker.path)
510510
this.stickerSender.sendSticker(sticker)
511511
}
512512

app/src/main/java/com/fredhappyface/ewesticker/utilities/Cache.kt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import java.util.ArrayDeque
55
import java.util.Deque
66

77
/**
8-
* Basically this behaved like an ordered set with some maximum capacity. When this capacity is
8+
* Basically this behaves like an ordered set with some maximum capacity. When this capacity is
99
* exceeded an element is removed from the start
1010
*/
1111
class Cache(private val capacity: Int = 30) {
@@ -49,6 +49,8 @@ class Cache(private val capacity: Int = 30) {
4949
/** convert from a string (shared-pref) to this */
5050
fun fromSharedPref(raw: String) {
5151
data.clear()
52-
data.addAll(raw.split("\n"))
52+
if (raw.trim().isNotEmpty()) {
53+
data.addAll(raw.split("\n"))
54+
}
5355
}
5456
}

0 commit comments

Comments
 (0)