UpdatesFragment: Restore update all button as action button
Signed-off-by: Aayush Gupta <aayushgupta219@gmail.com>
This commit is contained in:
@@ -101,37 +101,6 @@ class UpdatesFragment : BaseFragment<FragmentUpdatesBinding>() {
|
||||
updateController(map)
|
||||
viewModel.updateAllEnqueued =
|
||||
map?.values?.all { it?.isRunning == true } ?: false
|
||||
|
||||
if (!map.isNullOrEmpty()) {
|
||||
binding.updateFab.apply {
|
||||
visibility = View.VISIBLE
|
||||
if (viewModel.updateAllEnqueued) {
|
||||
setImageDrawable(
|
||||
ContextCompat.getDrawable(
|
||||
requireContext(),
|
||||
R.drawable.ic_cancel
|
||||
)
|
||||
)
|
||||
} else {
|
||||
setImageDrawable(
|
||||
ContextCompat.getDrawable(
|
||||
requireContext(),
|
||||
R.drawable.ic_installation
|
||||
)
|
||||
)
|
||||
}
|
||||
setOnClickListener {
|
||||
if (viewModel.updateAllEnqueued) {
|
||||
cancelAll()
|
||||
} else {
|
||||
map.keys.forEach { updateSingle(it, true) }
|
||||
}
|
||||
binding.recycler.requestModelBuild()
|
||||
}
|
||||
}
|
||||
} else {
|
||||
binding.updateFab.visibility = View.GONE
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -145,6 +114,10 @@ class UpdatesFragment : BaseFragment<FragmentUpdatesBinding>() {
|
||||
binding.swipeRefreshLayout.setOnRefreshListener {
|
||||
viewModel.fetchUpdates()
|
||||
}
|
||||
|
||||
binding.searchFab.setOnClickListener {
|
||||
findNavController().navigate(R.id.searchSuggestionFragment)
|
||||
}
|
||||
}
|
||||
|
||||
private fun updateController(appList: Map<Update, Download?>?) {
|
||||
@@ -179,9 +152,20 @@ class UpdatesFragment : BaseFragment<FragmentUpdatesBinding>() {
|
||||
else
|
||||
getString(R.string.updates_available)
|
||||
)
|
||||
.action(getString(R.string.action_manage))
|
||||
.action(
|
||||
if (viewModel.updateAllEnqueued) {
|
||||
getString(R.string.action_cancel)
|
||||
} else {
|
||||
getString(R.string.action_update_all)
|
||||
}
|
||||
)
|
||||
.click { _ ->
|
||||
findNavController().navigate(R.id.blacklistFragment)
|
||||
if (viewModel.updateAllEnqueued) {
|
||||
cancelAll()
|
||||
} else {
|
||||
appList.keys.forEach { updateSingle(it, true) }
|
||||
}
|
||||
requestModelBuild()
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user