|
|
|
@ -1,9 +1,12 @@ |
|
|
|
|
package io.legado.app.ui.book.chapterlist |
|
|
|
|
|
|
|
|
|
import android.annotation.SuppressLint |
|
|
|
|
import android.app.Activity |
|
|
|
|
import android.content.Intent |
|
|
|
|
import android.os.AsyncTask |
|
|
|
|
import android.os.Bundle |
|
|
|
|
import android.view.View |
|
|
|
|
import android.widget.EditText |
|
|
|
|
import androidx.lifecycle.LiveData |
|
|
|
|
import androidx.lifecycle.Observer |
|
|
|
|
import androidx.paging.LivePagedListBuilder |
|
|
|
@ -13,9 +16,16 @@ import io.legado.app.App |
|
|
|
|
import io.legado.app.R |
|
|
|
|
import io.legado.app.base.VMBaseFragment |
|
|
|
|
import io.legado.app.data.entities.Bookmark |
|
|
|
|
import io.legado.app.lib.dialogs.alert |
|
|
|
|
import io.legado.app.lib.dialogs.customView |
|
|
|
|
import io.legado.app.lib.dialogs.noButton |
|
|
|
|
import io.legado.app.lib.dialogs.yesButton |
|
|
|
|
import io.legado.app.lib.theme.ATH |
|
|
|
|
import io.legado.app.ui.widget.recycler.VerticalDivider |
|
|
|
|
import io.legado.app.utils.applyTint |
|
|
|
|
import io.legado.app.utils.getViewModelOfActivity |
|
|
|
|
import io.legado.app.utils.requestInputMethod |
|
|
|
|
import kotlinx.android.synthetic.main.dialog_edit_text.view.* |
|
|
|
|
import kotlinx.android.synthetic.main.fragment_bookmark.* |
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -68,7 +78,8 @@ class BookmarkFragment : VMBaseFragment<ChapterListViewModel>(R.layout.fragment_ |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
override fun open(bookmark: Bookmark) { |
|
|
|
|
|
|
|
|
|
override fun onClick(bookmark: Bookmark) { |
|
|
|
|
val bookmarkData = Intent() |
|
|
|
|
bookmarkData.putExtra("index", bookmark.chapterIndex) |
|
|
|
|
bookmarkData.putExtra("pageIndex", bookmark.pageIndex) |
|
|
|
@ -76,7 +87,33 @@ class BookmarkFragment : VMBaseFragment<ChapterListViewModel>(R.layout.fragment_ |
|
|
|
|
activity?.finish() |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
override fun delBookmark(bookmark: Bookmark) { |
|
|
|
|
App.db.bookmarkDao().delete(bookmark) |
|
|
|
|
@SuppressLint("InflateParams") |
|
|
|
|
override fun onLongClick(bookmark: Bookmark) { |
|
|
|
|
viewModel.book?.let { book -> |
|
|
|
|
requireContext().alert(R.string.bookmark) { |
|
|
|
|
var editText: EditText? = null |
|
|
|
|
message = book.name + " • " + bookmark.chapterName |
|
|
|
|
customView { |
|
|
|
|
layoutInflater.inflate(R.layout.dialog_edit_text, null).apply { |
|
|
|
|
editText = edit_view.apply { |
|
|
|
|
setHint(R.string.note_content) |
|
|
|
|
setText(bookmark.content) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
yesButton { |
|
|
|
|
editText?.text?.toString()?.let { editContent -> |
|
|
|
|
AsyncTask.execute { |
|
|
|
|
bookmark.content = editContent |
|
|
|
|
App.db.bookmarkDao().update(bookmark) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
noButton() |
|
|
|
|
neutralButton(R.string.delete) { |
|
|
|
|
App.db.bookmarkDao().delete(bookmark) |
|
|
|
|
} |
|
|
|
|
}.show().applyTint().requestInputMethod() |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |