|
|
|
@ -1,11 +1,15 @@ |
|
|
|
|
package io.legado.app.ui.book.info |
|
|
|
|
|
|
|
|
|
import android.annotation.SuppressLint |
|
|
|
|
import android.app.Activity |
|
|
|
|
import android.content.Intent |
|
|
|
|
import android.graphics.drawable.Drawable |
|
|
|
|
import android.os.Bundle |
|
|
|
|
import android.view.LayoutInflater |
|
|
|
|
import android.view.Menu |
|
|
|
|
import android.view.MenuItem |
|
|
|
|
import android.widget.CheckBox |
|
|
|
|
import android.widget.LinearLayout |
|
|
|
|
import androidx.lifecycle.Observer |
|
|
|
|
import com.bumptech.glide.RequestBuilder |
|
|
|
|
import com.bumptech.glide.load.resource.drawable.DrawableTransitionOptions |
|
|
|
@ -229,23 +233,27 @@ class BookInfoActivity : |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@SuppressLint("InflateParams") |
|
|
|
|
private fun deleteBook() { |
|
|
|
|
viewModel.bookData.value?.let { |
|
|
|
|
if (it.isLocalBook()) { |
|
|
|
|
alert( |
|
|
|
|
titleResource = R.string.sure, |
|
|
|
|
messageResource = R.string.sure_delete_book_file |
|
|
|
|
messageResource = R.string.sure_del |
|
|
|
|
) { |
|
|
|
|
positiveButton(R.string.yes) { |
|
|
|
|
viewModel.delBook(true) { |
|
|
|
|
finish() |
|
|
|
|
} |
|
|
|
|
val checkBox = CheckBox(this@BookInfoActivity).apply { |
|
|
|
|
setText(R.string.delete_book_file) |
|
|
|
|
} |
|
|
|
|
negativeButton(R.string.no) { |
|
|
|
|
viewModel.delBook(false) { |
|
|
|
|
val view = LayoutInflater.from(this@BookInfoActivity) |
|
|
|
|
.inflate(R.layout.dialog_linear_layout, null) |
|
|
|
|
(view as LinearLayout).addView(checkBox) |
|
|
|
|
customView = view |
|
|
|
|
positiveButton(R.string.yes) { |
|
|
|
|
viewModel.delBook(checkBox.isChecked) { |
|
|
|
|
finish() |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
negativeButton(R.string.no) |
|
|
|
|
}.show() |
|
|
|
|
} else { |
|
|
|
|
viewModel.delBook { |
|
|
|
|