修复bug

This commit is contained in:
gedoor 2021-08-08 15:24:15 +08:00
parent 230bc50229
commit 090227d063
3 changed files with 14 additions and 4 deletions

View File

@ -33,7 +33,7 @@ import javax.script.SimpleBindings
class CacheViewModel(application: Application) : BaseViewModel(application) {
fun getExportFileName(book: Book): String {
private fun getExportFileName(book: Book): String {
val jsStr = AppConfig.bookExportFileName
if (jsStr.isNullOrBlank()) {
return "${book.name} 作者:${book.getRealAuthor()}"
@ -56,6 +56,7 @@ class CacheViewModel(application: Application) : BaseViewModel(application) {
}
}.onError {
finally(it.localizedMessage ?: "ERROR")
it.printStackTrace()
}.onSuccess {
finally(context.getString(R.string.success))
}
@ -185,6 +186,7 @@ class CacheViewModel(application: Application) : BaseViewModel(application) {
}
}.onError {
finally(it.localizedMessage ?: "ERROR")
it.printStackTrace()
}.onSuccess {
finally(context.getString(R.string.success))
}

View File

@ -3,6 +3,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:padding="16dp">
<TextView
@ -10,6 +11,8 @@
android:layout_width="0dp"
android:layout_height="wrap_content"
android:singleLine="true"
android:textColor="@color/primaryText"
tools:text="@string/name"
app:layout_constraintRight_toLeftOf="@+id/iv_download"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintLeft_toLeftOf="parent" />
@ -19,6 +22,8 @@
android:layout_width="0dp"
android:layout_height="wrap_content"
android:singleLine="true"
android:textColor="@color/primaryText"
tools:text="@string/author"
app:layout_constraintRight_toLeftOf="@+id/iv_download"
app:layout_constraintTop_toBottomOf="@+id/tv_name"
app:layout_constraintLeft_toLeftOf="parent" />
@ -28,6 +33,8 @@
android:layout_width="0dp"
android:layout_height="wrap_content"
android:singleLine="true"
android:textColor="@color/secondaryText"
tools:text="@string/action_download"
app:layout_constraintRight_toLeftOf="@+id/iv_download"
app:layout_constraintTop_toBottomOf="@id/tv_author"
app:layout_constraintLeft_toLeftOf="parent" />
@ -52,6 +59,7 @@
android:background="?attr/selectableItemBackground"
android:padding="10dp"
android:text="@string/export"
android:textColor="@color/primaryText"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintRight_toRightOf="parent" />

View File

@ -51,9 +51,9 @@ public class ResourceUtil {
public static Resource createPublicResource(String name, String author, String intro, String kind, String wordCount, String model, String href) {
String html = model.replace("{name}", name)
.replace("{author}", author)
.replace("{kind}", kind)
.replace("{wordCount}", wordCount)
.replace("{intro}", StringUtil.formatHtml(intro));
.replace("{kind}", kind == null ? "" : kind)
.replace("{wordCount}", wordCount == null ? "" : wordCount)
.replace("{intro}", StringUtil.formatHtml(intro == null ? "" : intro));
return new Resource(html.getBytes(), href);
}