mirror of
https://github.com/mihonapp/mihon.git
synced 2024-11-07 19:27:25 +01:00
Refresh adapter after the cover is changed. Some minor changes on categories.
This commit is contained in:
parent
4dde6d1a31
commit
61c7feca87
@ -51,7 +51,7 @@ class CategoryActivity : BaseRxActivity<CategoryPresenter>(), ActionMode.Callbac
|
|||||||
* @param context context information.
|
* @param context context information.
|
||||||
*/
|
*/
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
fun newIntent(context: Context): Intent? {
|
fun newIntent(context: Context): Intent {
|
||||||
return Intent(context, CategoryActivity::class.java)
|
return Intent(context, CategoryActivity::class.java)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -106,21 +106,12 @@ class CategoryActivity : BaseRxActivity<CategoryPresenter>(), ActionMode.Callbac
|
|||||||
adapter.setItems(categories)
|
adapter.setItems(categories)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Delete selected categories
|
|
||||||
*
|
|
||||||
* @param categories list containing categories
|
|
||||||
*/
|
|
||||||
private fun deleteCategories(categories: List<Category?>?) {
|
|
||||||
presenter.deleteCategories(categories)
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the selected categories
|
* Returns the selected categories
|
||||||
*
|
*
|
||||||
* @return list of selected categories
|
* @return list of selected categories
|
||||||
*/
|
*/
|
||||||
private fun getSelectedCategories(): List<Category?>? {
|
private fun getSelectedCategories(): List<Category> {
|
||||||
// Create a list of the selected categories
|
// Create a list of the selected categories
|
||||||
return adapter.selectedItems.map { adapter.getItem(it) }
|
return adapter.selectedItems.map { adapter.getItem(it) }
|
||||||
}
|
}
|
||||||
@ -130,13 +121,13 @@ class CategoryActivity : BaseRxActivity<CategoryPresenter>(), ActionMode.Callbac
|
|||||||
*
|
*
|
||||||
* @param category category that will be edited.
|
* @param category category that will be edited.
|
||||||
*/
|
*/
|
||||||
private fun editCategory(category: Category?) {
|
private fun editCategory(category: Category) {
|
||||||
MaterialDialog.Builder(this)
|
MaterialDialog.Builder(this)
|
||||||
.title(R.string.action_rename_category)
|
.title(R.string.action_rename_category)
|
||||||
.negativeText(R.string.button_cancel)
|
.negativeText(R.string.button_cancel)
|
||||||
.onNegative { materialDialog, dialogAction -> destroyActionModeIfNeeded() }
|
.onNegative { materialDialog, dialogAction -> destroyActionModeIfNeeded() }
|
||||||
.input(getString(R.string.name), category?.name, false)
|
.input(getString(R.string.name), category.name, false)
|
||||||
{ dialog, input -> presenter.renameCategory(category as Category, input.toString()) }
|
{ dialog, input -> presenter.renameCategory(category, input.toString()) }
|
||||||
.show()
|
.show()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -175,7 +166,7 @@ class CategoryActivity : BaseRxActivity<CategoryPresenter>(), ActionMode.Callbac
|
|||||||
*
|
*
|
||||||
* @return false
|
* @return false
|
||||||
*/
|
*/
|
||||||
override fun onPrepareActionMode(p0: ActionMode?, p1: Menu?): Boolean {
|
override fun onPrepareActionMode(actionMode: ActionMode, menu: Menu): Boolean {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -191,11 +182,11 @@ class CategoryActivity : BaseRxActivity<CategoryPresenter>(), ActionMode.Callbac
|
|||||||
when (menuItem.itemId) {
|
when (menuItem.itemId) {
|
||||||
R.id.action_delete -> {
|
R.id.action_delete -> {
|
||||||
// Delete select categories.
|
// Delete select categories.
|
||||||
deleteCategories(getSelectedCategories())
|
presenter.deleteCategories(getSelectedCategories())
|
||||||
}
|
}
|
||||||
R.id.action_edit -> {
|
R.id.action_edit -> {
|
||||||
// Edit selected category
|
// Edit selected category
|
||||||
editCategory(getSelectedCategories()?.get(0))
|
editCategory(getSelectedCategories()[0])
|
||||||
}
|
}
|
||||||
else -> return false
|
else -> return false
|
||||||
}
|
}
|
||||||
|
@ -28,18 +28,18 @@ class CategoryHolder(view: View, adapter: CategoryAdapter, listener: FlexibleVie
|
|||||||
|
|
||||||
init {
|
init {
|
||||||
// Create round letter image onclick to simulate long click
|
// Create round letter image onclick to simulate long click
|
||||||
itemView.image.setOnClickListener({ v ->
|
itemView.image.setOnClickListener {
|
||||||
// Simulate long click on this view to enter selection mode
|
// Simulate long click on this view to enter selection mode
|
||||||
onLongClick(view)
|
onLongClick(view)
|
||||||
})
|
}
|
||||||
|
|
||||||
// Set on touch listener for reorder image
|
// Set on touch listener for reorder image
|
||||||
itemView.reorder.setOnTouchListener({ v, event ->
|
itemView.reorder.setOnTouchListener { v, event ->
|
||||||
if (MotionEventCompat.getActionMasked(event) == MotionEvent.ACTION_DOWN) {
|
if (MotionEventCompat.getActionMasked(event) == MotionEvent.ACTION_DOWN) {
|
||||||
dragListener.onStartDrag(this)
|
dragListener.onStartDrag(this)
|
||||||
}
|
}
|
||||||
false
|
false
|
||||||
})
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -266,7 +266,6 @@ class LibraryFragment : BaseRxFragment<LibraryPresenter>(), ActionMode.Callback
|
|||||||
when (item.itemId) {
|
when (item.itemId) {
|
||||||
R.id.action_edit_cover -> {
|
R.id.action_edit_cover -> {
|
||||||
changeSelectedCover(presenter.selectedMangas)
|
changeSelectedCover(presenter.selectedMangas)
|
||||||
adapter.refreshRegisteredAdapters()
|
|
||||||
destroyActionModeIfNeeded()
|
destroyActionModeIfNeeded()
|
||||||
}
|
}
|
||||||
R.id.action_move_to_category -> {
|
R.id.action_move_to_category -> {
|
||||||
@ -329,8 +328,11 @@ class LibraryFragment : BaseRxFragment<LibraryPresenter>(), ActionMode.Callback
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
// Update cover to selected file, show error if something went wrong
|
// Update cover to selected file, show error if something went wrong
|
||||||
if (!presenter.editCoverWithLocalFile(picture, manga))
|
if (presenter.editCoverWithLocalFile(picture, manga)) {
|
||||||
|
adapter.refreshRegisteredAdapters()
|
||||||
|
} else {
|
||||||
ToastUtil.showShort(context, R.string.notification_manga_update_failed)
|
ToastUtil.showShort(context, R.string.notification_manga_update_failed)
|
||||||
|
}
|
||||||
|
|
||||||
} catch (e: IOException) {
|
} catch (e: IOException) {
|
||||||
e.printStackTrace()
|
e.printStackTrace()
|
||||||
|
Loading…
Reference in New Issue
Block a user