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