Removed items from RecyclerView cache to allow setting the new visibility Disabled hidden buttons, otherwise they could still be clickedmaster
parent
93a380bff2
commit
167c6dca93
|
@ -0,0 +1,18 @@
|
||||||
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
|
package org.mozilla.fenix.ext
|
||||||
|
|
||||||
|
import android.view.View
|
||||||
|
import android.widget.ImageButton
|
||||||
|
|
||||||
|
fun ImageButton.hideAndDisable() {
|
||||||
|
this.visibility = View.INVISIBLE
|
||||||
|
this.isEnabled = false
|
||||||
|
}
|
||||||
|
|
||||||
|
fun ImageButton.showAndEnable() {
|
||||||
|
this.visibility = View.VISIBLE
|
||||||
|
this.isEnabled = true
|
||||||
|
}
|
|
@ -8,7 +8,6 @@ import android.content.Context
|
||||||
import android.graphics.ColorFilter
|
import android.graphics.ColorFilter
|
||||||
import android.graphics.PorterDuff
|
import android.graphics.PorterDuff
|
||||||
import android.graphics.PorterDuffColorFilter
|
import android.graphics.PorterDuffColorFilter
|
||||||
import android.view.View
|
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import android.widget.ActionMenuView
|
import android.widget.ActionMenuView
|
||||||
import android.widget.ImageButton
|
import android.widget.ImageButton
|
||||||
|
@ -21,9 +20,11 @@ import androidx.core.view.forEach
|
||||||
import androidx.recyclerview.widget.RecyclerView
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
import kotlinx.android.extensions.LayoutContainer
|
import kotlinx.android.extensions.LayoutContainer
|
||||||
import kotlinx.android.synthetic.main.library_site_item.view.*
|
import kotlinx.android.synthetic.main.library_site_item.view.*
|
||||||
import mozilla.components.support.ktx.android.content.getColorFromAttr
|
|
||||||
import org.mozilla.fenix.R
|
import org.mozilla.fenix.R
|
||||||
import org.mozilla.fenix.ext.asActivity
|
import org.mozilla.fenix.ext.asActivity
|
||||||
|
import org.mozilla.fenix.ext.getColorFromAttr
|
||||||
|
import org.mozilla.fenix.ext.hideAndDisable
|
||||||
|
import org.mozilla.fenix.ext.showAndEnable
|
||||||
|
|
||||||
open class LibraryPageView(
|
open class LibraryPageView(
|
||||||
override val containerView: ViewGroup
|
override val containerView: ViewGroup
|
||||||
|
@ -40,8 +41,9 @@ open class LibraryPageView(
|
||||||
context.getColorFromAttr(R.attr.primaryText),
|
context.getColorFromAttr(R.attr.primaryText),
|
||||||
context.getColorFromAttr(R.attr.foundation)
|
context.getColorFromAttr(R.attr.foundation)
|
||||||
)
|
)
|
||||||
libraryItemsList.children.forEach { item ->
|
libraryItemsList.setItemViewCacheSize(0)
|
||||||
item.overflow_menu.visibility = View.VISIBLE
|
libraryItemsList.children.forEach {
|
||||||
|
item -> item.overflow_menu.showAndEnable()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -54,8 +56,9 @@ open class LibraryPageView(
|
||||||
ContextCompat.getColor(context, R.color.white_color),
|
ContextCompat.getColor(context, R.color.white_color),
|
||||||
context.getColorFromAttr(R.attr.accentHighContrast)
|
context.getColorFromAttr(R.attr.accentHighContrast)
|
||||||
)
|
)
|
||||||
libraryItemsList.children.forEach { item ->
|
libraryItemsList.setItemViewCacheSize(0)
|
||||||
item.overflow_menu.visibility = View.INVISIBLE
|
libraryItemsList.children.forEach {
|
||||||
|
item -> item.overflow_menu.hideAndDisable()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,6 +9,8 @@ import androidx.core.content.ContextCompat
|
||||||
import mozilla.components.concept.storage.BookmarkNode
|
import mozilla.components.concept.storage.BookmarkNode
|
||||||
import org.jetbrains.anko.image
|
import org.jetbrains.anko.image
|
||||||
import org.mozilla.fenix.R
|
import org.mozilla.fenix.R
|
||||||
|
import org.mozilla.fenix.ext.hideAndDisable
|
||||||
|
import org.mozilla.fenix.ext.showAndEnable
|
||||||
import org.mozilla.fenix.library.LibrarySiteItemView
|
import org.mozilla.fenix.library.LibrarySiteItemView
|
||||||
import org.mozilla.fenix.library.SelectionHolder
|
import org.mozilla.fenix.library.SelectionHolder
|
||||||
import org.mozilla.fenix.library.bookmarks.BookmarkViewInteractor
|
import org.mozilla.fenix.library.bookmarks.BookmarkViewInteractor
|
||||||
|
@ -31,9 +33,10 @@ class BookmarkFolderViewHolder(
|
||||||
|
|
||||||
if (!item.inRoots()) {
|
if (!item.inRoots()) {
|
||||||
setupMenu(item)
|
setupMenu(item)
|
||||||
containerView.overflowView.visibility = when (selectionHolder.selectedItems.isEmpty()) {
|
if (selectionHolder.selectedItems.isEmpty()) {
|
||||||
true -> View.VISIBLE
|
containerView.overflowView.showAndEnable()
|
||||||
false -> View.INVISIBLE
|
} else {
|
||||||
|
containerView.overflowView.hideAndDisable()
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
containerView.overflowView.visibility = View.GONE
|
containerView.overflowView.visibility = View.GONE
|
||||||
|
|
|
@ -4,8 +4,9 @@
|
||||||
|
|
||||||
package org.mozilla.fenix.library.bookmarks.viewholders
|
package org.mozilla.fenix.library.bookmarks.viewholders
|
||||||
|
|
||||||
import android.view.View
|
|
||||||
import mozilla.components.concept.storage.BookmarkNode
|
import mozilla.components.concept.storage.BookmarkNode
|
||||||
|
import org.mozilla.fenix.ext.hideAndDisable
|
||||||
|
import org.mozilla.fenix.ext.showAndEnable
|
||||||
import org.mozilla.fenix.library.LibrarySiteItemView
|
import org.mozilla.fenix.library.LibrarySiteItemView
|
||||||
import org.mozilla.fenix.library.SelectionHolder
|
import org.mozilla.fenix.library.SelectionHolder
|
||||||
import org.mozilla.fenix.library.bookmarks.BookmarkViewInteractor
|
import org.mozilla.fenix.library.bookmarks.BookmarkViewInteractor
|
||||||
|
@ -23,9 +24,10 @@ class BookmarkItemViewHolder(
|
||||||
|
|
||||||
containerView.displayAs(LibrarySiteItemView.ItemType.SITE)
|
containerView.displayAs(LibrarySiteItemView.ItemType.SITE)
|
||||||
|
|
||||||
containerView.overflowView.visibility = when (selectionHolder.selectedItems.isEmpty()) {
|
if (selectionHolder.selectedItems.isEmpty()) {
|
||||||
true -> View.VISIBLE
|
containerView.overflowView.showAndEnable()
|
||||||
false -> View.INVISIBLE
|
} else {
|
||||||
|
containerView.overflowView.hideAndDisable()
|
||||||
}
|
}
|
||||||
setupMenu(item)
|
setupMenu(item)
|
||||||
containerView.titleView.text = if (item.title.isNullOrBlank()) item.url else item.title
|
containerView.titleView.text = if (item.title.isNullOrBlank()) item.url else item.title
|
||||||
|
|
|
@ -7,7 +7,10 @@ package org.mozilla.fenix.library.history.viewholders
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import androidx.recyclerview.widget.RecyclerView
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
import kotlinx.android.synthetic.main.history_list_item.view.*
|
import kotlinx.android.synthetic.main.history_list_item.view.*
|
||||||
|
import kotlinx.android.synthetic.main.library_site_item.view.*
|
||||||
import org.mozilla.fenix.R
|
import org.mozilla.fenix.R
|
||||||
|
import org.mozilla.fenix.ext.hideAndDisable
|
||||||
|
import org.mozilla.fenix.ext.showAndEnable
|
||||||
import org.mozilla.fenix.library.SelectionHolder
|
import org.mozilla.fenix.library.SelectionHolder
|
||||||
import org.mozilla.fenix.library.history.HistoryInteractor
|
import org.mozilla.fenix.library.history.HistoryInteractor
|
||||||
import org.mozilla.fenix.library.history.HistoryItem
|
import org.mozilla.fenix.library.history.HistoryItem
|
||||||
|
@ -55,6 +58,11 @@ class HistoryListItemViewHolder(
|
||||||
itemView.history_layout.setSelectionInteractor(item, selectionHolder, historyInteractor)
|
itemView.history_layout.setSelectionInteractor(item, selectionHolder, historyInteractor)
|
||||||
itemView.history_layout.changeSelected(item in selectionHolder.selectedItems)
|
itemView.history_layout.changeSelected(item in selectionHolder.selectedItems)
|
||||||
itemView.history_layout.loadFavicon(item.url)
|
itemView.history_layout.loadFavicon(item.url)
|
||||||
|
if (mode === HistoryFragmentState.Mode.Normal) {
|
||||||
|
itemView.overflow_menu.showAndEnable()
|
||||||
|
} else {
|
||||||
|
itemView.overflow_menu.hideAndDisable()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun toggleHeader(headerText: String?) {
|
private fun toggleHeader(headerText: String?) {
|
||||||
|
|
Loading…
Reference in New Issue