mirror of
https://github.com/melihaksoy/Android-Kotlin-Modulerized-CleanArchitecture.git
synced 2026-01-17 06:27:05 +01:00
Using SnackbarBehaviour for pushing list when there's an error
Using SnackbarBehaviour for pushing list when there's an error
This commit is contained in:
@@ -4,18 +4,20 @@ import android.content.Context
|
||||
import android.util.AttributeSet
|
||||
import android.view.View
|
||||
import androidx.coordinatorlayout.widget.CoordinatorLayout
|
||||
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout
|
||||
import com.google.android.material.snackbar.Snackbar
|
||||
|
||||
/**
|
||||
* Simple behaviour for pushing views when snackbar is animating so none of views will remain under snackbar
|
||||
*/
|
||||
class SnackbarBehaviour constructor(
|
||||
context: Context,
|
||||
attributeSet: AttributeSet
|
||||
) : CoordinatorLayout.Behavior<SwipeRefreshLayout>() {
|
||||
) : CoordinatorLayout.Behavior<View>() {
|
||||
|
||||
override fun layoutDependsOn(parent: CoordinatorLayout, child: SwipeRefreshLayout, dependency: View): Boolean =
|
||||
override fun layoutDependsOn(parent: CoordinatorLayout, child: View, dependency: View): Boolean =
|
||||
dependency is Snackbar.SnackbarLayout
|
||||
|
||||
override fun onDependentViewChanged(parent: CoordinatorLayout, child: SwipeRefreshLayout, dependency: View): Boolean {
|
||||
override fun onDependentViewChanged(parent: CoordinatorLayout, child: View, dependency: View): Boolean {
|
||||
val translationY = Math.min(0.0f, (dependency.translationY - dependency.height))
|
||||
child.translationY = translationY
|
||||
return true
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<layout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools">
|
||||
|
||||
@@ -17,7 +18,8 @@
|
||||
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
|
||||
android:id="@+id/swipeRefreshLayout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
android:layout_height="match_parent"
|
||||
app:layout_behavior="com.melih.core.utils.SnackbarBehaviour">
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/rocketList"
|
||||
|
||||
Reference in New Issue
Block a user