From 20033f844a458b98d86fc8bad877617848e38321 Mon Sep 17 00:00:00 2001 From: Konrad Pozniak Date: Mon, 23 Apr 2018 09:26:03 +0200 Subject: [PATCH] fix emoji & toot size limit caching --- .../keylesspalace/tusky/ComposeActivity.java | 18 +++++++++++------- app/src/main/res/layout/activity_compose.xml | 3 ++- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/com/keylesspalace/tusky/ComposeActivity.java b/app/src/main/java/com/keylesspalace/tusky/ComposeActivity.java index 04c43993..015721b2 100644 --- a/app/src/main/java/com/keylesspalace/tusky/ComposeActivity.java +++ b/app/src/main/java/com/keylesspalace/tusky/ComposeActivity.java @@ -286,7 +286,7 @@ public final class ComposeActivity @Override public void onResponse(@NonNull Call> call, @NonNull Response> response) { emojiList = response.body(); - enableButton(emojiButton, true, emojiList.size() > 0); + setEmojiList(emojiList); cacheInstanceMetadata(activeAccount); } @@ -1447,15 +1447,19 @@ public final class ComposeActivity Integer max = instanceEntity.getMaximumTootCharacters(); maximumTootCharacters = (max == null ? STATUS_CHARACTER_LIMIT : max); emojiList = instanceEntity.getEmojiList(); - if (emojiList != null) { - emojiView.setAdapter(new EmojiAdapter(emojiList, ComposeActivity.this)); - enableButton(emojiButton, true, emojiList.size() > 0); - } + setEmojiList(emojiList); + updateVisibleCharactersLeft(); } } - private void cacheInstanceMetadata(@NotNull AccountEntity activeAccount) - { + private void setEmojiList(@Nullable List emojiList) { + if (emojiList != null) { + emojiView.setAdapter(new EmojiAdapter(emojiList, ComposeActivity.this)); + enableButton(emojiButton, true, emojiList.size() > 0); + } + } + + private void cacheInstanceMetadata(@NotNull AccountEntity activeAccount) { InstanceEntity instanceEntity = new InstanceEntity(activeAccount.getDomain(), emojiList, maximumTootCharacters); TuskyApplication.getDB().instanceDao().insertOrReplace(instanceEntity); } diff --git a/app/src/main/res/layout/activity_compose.xml b/app/src/main/res/layout/activity_compose.xml index debf87a4..c381d98e 100644 --- a/app/src/main/res/layout/activity_compose.xml +++ b/app/src/main/res/layout/activity_compose.xml @@ -275,7 +275,8 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:textColor="?android:textColorTertiary" - android:textSize="?attr/status_text_medium" /> + android:textSize="?attr/status_text_medium" + tools:text="500"/>