## Types of changes - [ ] I have read the **CONTRIBUTING** document. - [ ] My code follows the code style of this project. - [ ] I have updated the documentation accordingly. - [ ] I have added tests to cover my changes. - [ ] All new and existing tests passed. - [ ] This is **NOT** translation related. This closes issue #XXX This is implements feature #YYY This finishes chore #ZZZ Reviewed-on: #176 Co-authored-by: Amine <amine.bouabdallaoui@pm.me> Co-committed-by: Amine <amine.bouabdallaoui@pm.me>
This commit is contained in:
parent
3b3a575dae
commit
ce255b23cd
@ -317,13 +317,9 @@ class HomeActivity :
|
|||||||
|
|
||||||
private fun reloadLayoutManager() {
|
private fun reloadLayoutManager() {
|
||||||
val currentManager = binding.recyclerView.layoutManager
|
val currentManager = binding.recyclerView.layoutManager
|
||||||
val layoutManager: RecyclerView.LayoutManager
|
|
||||||
|
|
||||||
// This will only update the layout manager if settings changed
|
fun gridLayoutManager() {
|
||||||
when (currentManager) {
|
val layoutManager =
|
||||||
is StaggeredGridLayoutManager ->
|
|
||||||
if (!appSettingsService.isCardViewEnabled()) {
|
|
||||||
layoutManager =
|
|
||||||
GridLayoutManager(
|
GridLayoutManager(
|
||||||
this,
|
this,
|
||||||
calculateNoOfColumns(),
|
calculateNoOfColumns(),
|
||||||
@ -331,9 +327,8 @@ class HomeActivity :
|
|||||||
binding.recyclerView.layoutManager = layoutManager
|
binding.recyclerView.layoutManager = layoutManager
|
||||||
}
|
}
|
||||||
|
|
||||||
is GridLayoutManager ->
|
fun staggererdGridLayoutManager() {
|
||||||
if (appSettingsService.isCardViewEnabled()) {
|
var layoutManager =
|
||||||
layoutManager =
|
|
||||||
StaggeredGridLayoutManager(
|
StaggeredGridLayoutManager(
|
||||||
calculateNoOfColumns(),
|
calculateNoOfColumns(),
|
||||||
StaggeredGridLayoutManager.VERTICAL,
|
StaggeredGridLayoutManager.VERTICAL,
|
||||||
@ -343,24 +338,23 @@ class HomeActivity :
|
|||||||
binding.recyclerView.layoutManager = layoutManager
|
binding.recyclerView.layoutManager = layoutManager
|
||||||
}
|
}
|
||||||
|
|
||||||
|
when (currentManager) {
|
||||||
|
is StaggeredGridLayoutManager ->
|
||||||
|
if (!appSettingsService.isCardViewEnabled()) {
|
||||||
|
gridLayoutManager()
|
||||||
|
}
|
||||||
|
|
||||||
|
is GridLayoutManager ->
|
||||||
|
if (appSettingsService.isCardViewEnabled()) {
|
||||||
|
staggererdGridLayoutManager()
|
||||||
|
}
|
||||||
|
|
||||||
else ->
|
else ->
|
||||||
if (currentManager == null) {
|
if (currentManager == null) {
|
||||||
if (!appSettingsService.isCardViewEnabled()) {
|
if (!appSettingsService.isCardViewEnabled()) {
|
||||||
layoutManager =
|
gridLayoutManager()
|
||||||
GridLayoutManager(
|
|
||||||
this,
|
|
||||||
calculateNoOfColumns(),
|
|
||||||
)
|
|
||||||
binding.recyclerView.layoutManager = layoutManager
|
|
||||||
} else {
|
} else {
|
||||||
layoutManager =
|
staggererdGridLayoutManager()
|
||||||
StaggeredGridLayoutManager(
|
|
||||||
calculateNoOfColumns(),
|
|
||||||
StaggeredGridLayoutManager.VERTICAL,
|
|
||||||
)
|
|
||||||
layoutManager.gapStrategy =
|
|
||||||
StaggeredGridLayoutManager.GAP_HANDLING_MOVE_ITEMS_BETWEEN_SPANS
|
|
||||||
binding.recyclerView.layoutManager = layoutManager
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -485,8 +479,8 @@ class HomeActivity :
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun handleListResult(appendResults: Boolean = false) {
|
private fun handleListResult(appendResults: Boolean = false) {
|
||||||
if (appendResults) {
|
|
||||||
val oldManager = binding.recyclerView.layoutManager
|
val oldManager = binding.recyclerView.layoutManager
|
||||||
|
if (appendResults) {
|
||||||
firstVisible =
|
firstVisible =
|
||||||
when (oldManager) {
|
when (oldManager) {
|
||||||
is StaggeredGridLayoutManager ->
|
is StaggeredGridLayoutManager ->
|
||||||
@ -499,7 +493,13 @@ class HomeActivity :
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (recyclerAdapter == null) {
|
@Suppress("detekt:ComplexCondition")
|
||||||
|
if (recyclerAdapter == null ||
|
||||||
|
(
|
||||||
|
(recyclerAdapter is ItemListAdapter && appSettingsService.isCardViewEnabled()) ||
|
||||||
|
(recyclerAdapter is ItemCardAdapter && !appSettingsService.isCardViewEnabled())
|
||||||
|
)
|
||||||
|
) {
|
||||||
if (appSettingsService.isCardViewEnabled()) {
|
if (appSettingsService.isCardViewEnabled()) {
|
||||||
recyclerAdapter =
|
recyclerAdapter =
|
||||||
ItemCardAdapter(
|
ItemCardAdapter(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user