|
|
@ -9,6 +9,7 @@ import io.legado.app.utils.invisible |
|
|
|
import io.legado.app.utils.visible |
|
|
|
import io.legado.app.utils.visible |
|
|
|
import kotlinx.android.synthetic.main.item_font.view.* |
|
|
|
import kotlinx.android.synthetic.main.item_font.view.* |
|
|
|
import org.jetbrains.anko.sdk27.listeners.onClick |
|
|
|
import org.jetbrains.anko.sdk27.listeners.onClick |
|
|
|
|
|
|
|
import org.jetbrains.anko.toast |
|
|
|
import java.io.File |
|
|
|
import java.io.File |
|
|
|
|
|
|
|
|
|
|
|
class FontAdapter(context: Context, val callBack: CallBack) : |
|
|
|
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<Any>) { |
|
|
|
override fun convert(holder: ItemViewHolder, item: File, payloads: MutableList<Any>) { |
|
|
|
with(holder.itemView) { |
|
|
|
with(holder.itemView) { |
|
|
|
|
|
|
|
try { |
|
|
|
val typeface = Typeface.createFromFile(item) |
|
|
|
val typeface = Typeface.createFromFile(item) |
|
|
|
tv_font.typeface = typeface |
|
|
|
tv_font.typeface = typeface |
|
|
|
|
|
|
|
} catch (e: Exception) { |
|
|
|
|
|
|
|
context.toast("读取${item.name}字体失败") |
|
|
|
|
|
|
|
} |
|
|
|
tv_font.text = item.name |
|
|
|
tv_font.text = item.name |
|
|
|
this.onClick { callBack.onClick(item) } |
|
|
|
this.onClick { callBack.onClick(item) } |
|
|
|
if (item.name == callBack.curFilePath.substringAfterLast(File.separator)) { |
|
|
|
if (item.name == callBack.curFilePath.substringAfterLast(File.separator)) { |
|
|
|