From a2bde00a9e0a1e0577c15be384339acfc92075b2 Mon Sep 17 00:00:00 2001 From: kunfei Date: Sun, 8 Mar 2020 20:28:03 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/io/legado/app/ui/widget/font/FontAdapter.kt | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/widget/font/FontAdapter.kt b/app/src/main/java/io/legado/app/ui/widget/font/FontAdapter.kt index f2724abcd..ab6e34a1c 100644 --- a/app/src/main/java/io/legado/app/ui/widget/font/FontAdapter.kt +++ b/app/src/main/java/io/legado/app/ui/widget/font/FontAdapter.kt @@ -9,6 +9,7 @@ import io.legado.app.utils.invisible import io.legado.app.utils.visible import kotlinx.android.synthetic.main.item_font.view.* import org.jetbrains.anko.sdk27.listeners.onClick +import org.jetbrains.anko.toast import java.io.File class FontAdapter(context: Context, val callBack: CallBack) : @@ -16,8 +17,12 @@ class FontAdapter(context: Context, val callBack: CallBack) : override fun convert(holder: ItemViewHolder, item: File, payloads: MutableList) { with(holder.itemView) { - val typeface = Typeface.createFromFile(item) - tv_font.typeface = typeface + try { + val typeface = Typeface.createFromFile(item) + tv_font.typeface = typeface + } catch (e: Exception) { + context.toast("读取${item.name}字体失败") + } tv_font.text = item.name this.onClick { callBack.onClick(item) } if (item.name == callBack.curFilePath.substringAfterLast(File.separator)) {