|
|
|
@ -41,10 +41,10 @@ class ArrangeBookActivity : VMBaseActivity<ArrangeBookViewModel>(R.layout.activi |
|
|
|
|
private var groupLiveData: LiveData<List<BookGroup>>? = null |
|
|
|
|
private var booksLiveData: LiveData<List<Book>>? = null |
|
|
|
|
private var menu: Menu? = null |
|
|
|
|
private var groupId: Int = -1 |
|
|
|
|
private var groupId: Long = -1 |
|
|
|
|
|
|
|
|
|
override fun onActivityCreated(savedInstanceState: Bundle?) { |
|
|
|
|
groupId = intent.getIntExtra("groupId", -1) |
|
|
|
|
groupId = intent.getLongExtra("groupId", -1) |
|
|
|
|
title_bar.subtitle = intent.getStringExtra("groupName") ?: getString(R.string.all) |
|
|
|
|
initView() |
|
|
|
|
initGroupData() |
|
|
|
@ -85,7 +85,7 @@ class ArrangeBookActivity : VMBaseActivity<ArrangeBookViewModel>(R.layout.activi |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
override fun onClickMainAction() { |
|
|
|
|
selectGroup(0, groupRequestCode) |
|
|
|
|
selectGroup(groupRequestCode, 0) |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
@ -149,7 +149,7 @@ class ArrangeBookActivity : VMBaseActivity<ArrangeBookViewModel>(R.layout.activi |
|
|
|
|
} |
|
|
|
|
else -> if (item.groupId == R.id.menu_group) { |
|
|
|
|
title_bar.subtitle = item.title |
|
|
|
|
groupId = item.itemId |
|
|
|
|
groupId = App.db.bookGroupDao().getByName(item.title.toString())?.groupId ?: 0 |
|
|
|
|
initBookData() |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -167,7 +167,7 @@ class ArrangeBookActivity : VMBaseActivity<ArrangeBookViewModel>(R.layout.activi |
|
|
|
|
viewModel.upCanUpdate(adapter.selectedBooks(), true) |
|
|
|
|
R.id.menu_update_disable -> |
|
|
|
|
viewModel.upCanUpdate(adapter.selectedBooks(), false) |
|
|
|
|
R.id.menu_add_to_group -> selectGroup(0, addToGroupRequestCode) |
|
|
|
|
R.id.menu_add_to_group -> selectGroup(addToGroupRequestCode, 0) |
|
|
|
|
} |
|
|
|
|
return false |
|
|
|
|
} |
|
|
|
@ -176,16 +176,16 @@ class ArrangeBookActivity : VMBaseActivity<ArrangeBookViewModel>(R.layout.activi |
|
|
|
|
menu?.findItem(R.id.menu_book_group)?.subMenu?.let { subMenu -> |
|
|
|
|
subMenu.removeGroup(R.id.menu_group) |
|
|
|
|
groupList.forEach { bookGroup -> |
|
|
|
|
subMenu.add(R.id.menu_group, bookGroup.groupId, Menu.NONE, bookGroup.groupName) |
|
|
|
|
subMenu.add(R.id.menu_group, bookGroup.order, Menu.NONE, bookGroup.groupName) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
override fun selectGroup(groupId: Int, requestCode: Int) { |
|
|
|
|
override fun selectGroup(requestCode: Int, groupId: Long) { |
|
|
|
|
GroupSelectDialog.show(supportFragmentManager, groupId, requestCode) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
override fun upGroup(requestCode: Int, groupId: Int) { |
|
|
|
|
override fun upGroup(requestCode: Int, groupId: Long) { |
|
|
|
|
when (requestCode) { |
|
|
|
|
groupRequestCode -> { |
|
|
|
|
val books = arrayListOf<Book>() |
|
|
|
|