|
|
|
@ -1,10 +1,15 @@ |
|
|
|
|
package io.legado.app.ui.book.bookmark |
|
|
|
|
|
|
|
|
|
import android.os.Bundle |
|
|
|
|
import android.view.Menu |
|
|
|
|
import android.view.MenuItem |
|
|
|
|
import androidx.activity.viewModels |
|
|
|
|
import io.legado.app.R |
|
|
|
|
import io.legado.app.base.VMBaseActivity |
|
|
|
|
import io.legado.app.data.entities.Bookmark |
|
|
|
|
import io.legado.app.databinding.ActivityAllBookmarkBinding |
|
|
|
|
import io.legado.app.ui.document.HandleFileContract |
|
|
|
|
import io.legado.app.utils.launch |
|
|
|
|
import io.legado.app.utils.showDialogFragment |
|
|
|
|
import io.legado.app.utils.viewbindingdelegate.viewBinding |
|
|
|
|
|
|
|
|
@ -17,6 +22,11 @@ class AllBookmarkActivity : VMBaseActivity<ActivityAllBookmarkBinding, AllBookma |
|
|
|
|
private val adapter by lazy { |
|
|
|
|
BookmarkAdapter(this, this) |
|
|
|
|
} |
|
|
|
|
private val exportDir = registerForActivityResult(HandleFileContract()) { |
|
|
|
|
it.uri?.let { uri -> |
|
|
|
|
viewModel.saveToFile(uri) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
override fun onActivityCreated(savedInstanceState: Bundle?) { |
|
|
|
|
initView() |
|
|
|
@ -30,6 +40,18 @@ class AllBookmarkActivity : VMBaseActivity<ActivityAllBookmarkBinding, AllBookma |
|
|
|
|
binding.recyclerView.adapter = adapter |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
override fun onCompatCreateOptionsMenu(menu: Menu): Boolean { |
|
|
|
|
menuInflater.inflate(R.menu.bookmark, menu) |
|
|
|
|
return super.onCompatCreateOptionsMenu(menu) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
override fun onCompatOptionsItemSelected(item: MenuItem): Boolean { |
|
|
|
|
when (item.itemId) { |
|
|
|
|
R.id.menu_export -> exportDir.launch() |
|
|
|
|
} |
|
|
|
|
return super.onCompatOptionsItemSelected(item) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
override fun onItemClick(bookmark: Bookmark, position: Int) { |
|
|
|
|
showDialogFragment(BookmarkDialog(bookmark, position)) |
|
|
|
|
} |
|
|
|
@ -44,4 +66,5 @@ class AllBookmarkActivity : VMBaseActivity<ActivityAllBookmarkBinding, AllBookma |
|
|
|
|
} |
|
|
|
|
adapter.removeItem(pos) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |