mirror of
https://github.com/anyproto/anytype-kotlin.git
synced 2025-06-08 05:47:05 +09:00
Handle exceptions when emojifier fails to provide uri for emoji icon (#856)
This commit is contained in:
parent
2d46bb52ad
commit
376b9a77a8
7 changed files with 53 additions and 25 deletions
|
@ -4,6 +4,7 @@
|
|||
|
||||
### New features 🚀
|
||||
|
||||
* Archive (#547)
|
||||
* Link to existing object (#770)
|
||||
* Move-to from one document to other document (#770)
|
||||
|
||||
|
@ -14,6 +15,7 @@
|
|||
|
||||
### Fixes & tech 🚒
|
||||
|
||||
* Handle exceptions when emojifier fails to provide uri for emoji icon (#856)
|
||||
* Render children for all text blocks (#846)
|
||||
* Scroll-and-move restrictions issues (#847)
|
||||
* Cannot add block after document's title via add-block-menu (#827)
|
||||
|
|
|
@ -34,6 +34,7 @@ import com.agileburo.anytype.ui.page.modals.DocumentEmojiIconPickerFragment
|
|||
import com.bumptech.glide.Glide
|
||||
import com.bumptech.glide.load.engine.DiskCacheStrategy
|
||||
import kotlinx.android.synthetic.main.action_toolbar_page_icon.*
|
||||
import timber.log.Timber
|
||||
import javax.inject.Inject
|
||||
|
||||
class DocumentIconActionMenuFragment : BaseFragment(R.layout.action_toolbar_page_icon),
|
||||
|
@ -69,11 +70,15 @@ class DocumentIconActionMenuFragment : BaseFragment(R.layout.action_toolbar_page
|
|||
|
||||
private fun setIcon() {
|
||||
arguments?.getString(EMOJI_KEY)?.let { unicode ->
|
||||
Glide
|
||||
.with(emojiIconImage)
|
||||
.load(Emojifier.uri(unicode))
|
||||
.diskCacheStrategy(DiskCacheStrategy.ALL)
|
||||
.into(emojiIconImage)
|
||||
try {
|
||||
Glide
|
||||
.with(emojiIconImage)
|
||||
.load(Emojifier.uri(unicode))
|
||||
.diskCacheStrategy(DiskCacheStrategy.ALL)
|
||||
.into(emojiIconImage)
|
||||
} catch (e: Throwable) {
|
||||
Timber.e(e, "Error while setting emoji icon for: $unicode")
|
||||
}
|
||||
}
|
||||
arguments?.getString(IMAGE_KEY)?.let { url ->
|
||||
Glide
|
||||
|
|
|
@ -10,6 +10,7 @@ import com.agileburo.anytype.core_utils.ext.visible
|
|||
import com.agileburo.anytype.emojifier.Emojifier
|
||||
import com.bumptech.glide.Glide
|
||||
import com.bumptech.glide.load.engine.DiskCacheStrategy
|
||||
import timber.log.Timber
|
||||
|
||||
class PageBlockActionToolbar : BlockActionToolbar() {
|
||||
|
||||
|
@ -38,11 +39,15 @@ class PageBlockActionToolbar : BlockActionToolbar() {
|
|||
when {
|
||||
block.emoji != null -> {
|
||||
image.setImageDrawable(null)
|
||||
Glide
|
||||
.with(emoji)
|
||||
.load(Emojifier.uri(block.emoji!!))
|
||||
.diskCacheStrategy(DiskCacheStrategy.ALL)
|
||||
.into(emoji)
|
||||
try {
|
||||
Glide
|
||||
.with(emoji)
|
||||
.load(Emojifier.uri(block.emoji!!))
|
||||
.diskCacheStrategy(DiskCacheStrategy.ALL)
|
||||
.into(emoji)
|
||||
} catch (e: Throwable) {
|
||||
Timber.e(e, "Error while setting emoji icon for: ${block.emoji}")
|
||||
}
|
||||
}
|
||||
block.image != null -> {
|
||||
image.visible()
|
||||
|
|
|
@ -10,6 +10,7 @@ import com.agileburo.anytype.emojifier.Emojifier
|
|||
import com.bumptech.glide.Glide
|
||||
import com.bumptech.glide.load.engine.DiskCacheStrategy
|
||||
import kotlinx.android.synthetic.main.item_block_page.view.*
|
||||
import timber.log.Timber
|
||||
|
||||
class Page(view: View) : BlockViewHolder(view), BlockViewHolder.IndentableHolder, SupportNesting {
|
||||
|
||||
|
@ -35,11 +36,15 @@ class Page(view: View) : BlockViewHolder(view), BlockViewHolder.IndentableHolder
|
|||
when {
|
||||
item.emoji != null -> {
|
||||
image.setImageDrawable(null)
|
||||
Glide
|
||||
.with(emoji)
|
||||
.load(Emojifier.uri(item.emoji))
|
||||
.diskCacheStrategy(DiskCacheStrategy.ALL)
|
||||
.into(emoji)
|
||||
try {
|
||||
Glide
|
||||
.with(emoji)
|
||||
.load(Emojifier.uri(item.emoji))
|
||||
.diskCacheStrategy(DiskCacheStrategy.ALL)
|
||||
.into(emoji)
|
||||
} catch (e: Throwable) {
|
||||
Timber.e(e, "Error while setting emoji icon for: ${item.emoji}")
|
||||
}
|
||||
}
|
||||
item.image != null -> {
|
||||
image.visible()
|
||||
|
|
|
@ -153,11 +153,15 @@ sealed class Title(view: View) : BlockViewHolder(view), TextHolder {
|
|||
private fun setEmoji(item: BlockView.Title.Document) {
|
||||
try {
|
||||
if (item.emoji != null) {
|
||||
Glide
|
||||
.with(emoji)
|
||||
.load(Emojifier.uri(item.emoji))
|
||||
.diskCacheStrategy(DiskCacheStrategy.ALL)
|
||||
.into(emoji)
|
||||
try {
|
||||
Glide
|
||||
.with(emoji)
|
||||
.load(Emojifier.uri(item.emoji))
|
||||
.diskCacheStrategy(DiskCacheStrategy.ALL)
|
||||
.into(emoji)
|
||||
} catch (e: Throwable) {
|
||||
Timber.e(e, "Error while setting emoji icon for: ${item.emoji}")
|
||||
}
|
||||
}
|
||||
} catch (e: Throwable) {
|
||||
Timber.e(e, "Could not set emoji icon")
|
||||
|
|
|
@ -11,6 +11,7 @@ import com.agileburo.anytype.emojifier.Emojifier
|
|||
import com.bumptech.glide.Glide
|
||||
import com.bumptech.glide.load.engine.DiskCacheStrategy
|
||||
import kotlinx.android.synthetic.main.item_mention.view.*
|
||||
import timber.log.Timber
|
||||
|
||||
class MentionAdapter(
|
||||
private var data: ArrayList<Mention>,
|
||||
|
@ -97,11 +98,15 @@ class MentionAdapter(
|
|||
tvTitle.text = item.title
|
||||
when {
|
||||
!item.emoji.isNullOrBlank() -> {
|
||||
Glide
|
||||
.with(image)
|
||||
.load(Emojifier.uri(item.emoji))
|
||||
.diskCacheStrategy(DiskCacheStrategy.ALL)
|
||||
.into(image)
|
||||
try {
|
||||
Glide
|
||||
.with(image)
|
||||
.load(Emojifier.uri(item.emoji))
|
||||
.diskCacheStrategy(DiskCacheStrategy.ALL)
|
||||
.into(image)
|
||||
} catch (e: Throwable) {
|
||||
Timber.e(e, "Error while setting emoji icon for: ${item.emoji}")
|
||||
}
|
||||
}
|
||||
!item.image.isNullOrBlank() -> {
|
||||
Glide
|
||||
|
|
|
@ -13,6 +13,7 @@ object Emojifier {
|
|||
* @param unicode emoji unicode
|
||||
* @return uri for loading emoji as image
|
||||
*/
|
||||
@Throws(IllegalStateException::class)
|
||||
fun uri(unicode: String): String {
|
||||
val (page, index) = search(unicode)
|
||||
return uri(page, index)
|
||||
|
@ -31,6 +32,7 @@ object Emojifier {
|
|||
* @param unicode emoji unicode
|
||||
* @return a pair constisting of emoji's page and emoji's index for this [unicode]
|
||||
*/
|
||||
@Throws(IllegalStateException::class)
|
||||
private fun search(unicode: String): Pair<Int, Int> {
|
||||
val cached = cache[unicode]
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue