@ -20,7 +20,6 @@ import android.view.accessibility.AccessibilityEvent
import android.widget.Button
import android.widget.LinearLayout
import android.widget.PopupWindow
import androidx.annotation.StringRes
import androidx.appcompat.app.AlertDialog
import androidx.constraintlayout.widget.ConstraintLayout
import androidx.constraintlayout.widget.ConstraintSet
@ -133,11 +132,11 @@ class HomeFragment : Fragment() {
private val collectionStorageObserver = object : TabCollectionStorage . Observer {
override fun onCollectionCreated ( title : String , sessions : List < Session > ) {
scrollAndAnimateCollection ( sessions . size )
scrollAndAnimateCollection ( )
}
override fun onTabsAdded ( tabCollection : TabCollection , sessions : List < Session > ) {
scrollAndAnimateCollection ( sessions. size , tabCollection)
scrollAndAnimateCollection ( tabCollection)
}
override fun onCollectionRenamed ( tabCollection : TabCollection , title : String ) {
@ -788,7 +787,6 @@ class HomeFragment : Fragment() {
}
private fun scrollAndAnimateCollection (
tabsAddedToCollectionSize : Int ,
changedCollection : TabCollection ? = null
) {
if ( view != null ) {
@ -819,7 +817,7 @@ class HomeFragment : Fragment() {
) {
super . onScrollStateChanged ( recyclerView , newState )
if ( newState == SCROLL _STATE _IDLE ) {
animateCollection ( tabsAddedToCollectionSize, indexOfCollection)
animateCollection ( indexOfCollection)
recyclerView . removeOnScrollListener ( this )
}
}
@ -827,13 +825,13 @@ class HomeFragment : Fragment() {
recyclerView . addOnScrollListener ( onScrollListener )
recyclerView . smoothScrollToPosition ( indexOfCollection )
} else {
animateCollection ( tabsAddedToCollectionSize, indexOfCollection)
animateCollection ( indexOfCollection)
}
}
}
}
private fun animateCollection ( addedTabsSize: Int , indexOfCollection: Int ) {
private fun animateCollection ( indexOfCollection: Int ) {
viewLifecycleOwner . lifecycleScope . launch {
val viewHolder =
sessionControlView !! . view . findViewHolderForAdapterPosition ( indexOfCollection )
@ -860,26 +858,20 @@ class HomeFragment : Fragment() {
?. setDuration ( FADE _ANIM _DURATION )
?. setListener ( listener ) ?. start ( )
} . invokeOnCompletion {
showSavedSnackbar ( addedTabsSize )
showSavedSnackbar ( )
}
}
private fun showSavedSnackbar ( tabSize : Int ) {
private fun showSavedSnackbar ( ) {
viewLifecycleOwner . lifecycleScope . launch {
delay ( ANIM _SNACKBAR _DELAY )
view ?. let { view ->
@StringRes
val stringRes = if ( tabSize > 1 ) {
R . string . create _collection _tabs _saved
} else {
R . string . create _collection _tab _saved
}
FenixSnackbar . make (
view = view ,
duration = Snackbar . LENGTH _LONG ,
isDisplayedWithBrowserToolbar = false
)
. setText ( view . context . getString ( stringRes ) )
. setText ( view . context . getString ( R . string . create _collection _tabs _saved _new _collection ) )
. setAnchorView ( snackbarAnchorView )
. show ( )
}