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)) {