Skip to content

Commit

Permalink
Add option to apply a stateListAnimator to preference views
Browse files Browse the repository at this point in the history
  • Loading branch information
Maxr1998 committed Oct 2, 2020
1 parent 00c6912 commit 1ec0406
Showing 1 changed file with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

package de.Maxr1998.modernpreferences

import android.animation.StateListAnimator
import android.os.Parcelable
import android.view.LayoutInflater
import android.view.View
Expand Down Expand Up @@ -63,6 +64,13 @@ class PreferencesAdapter @VisibleForTesting constructor(
field?.onScreenChanged(currentScreen, isInSubScreen())
}

/**
* A [StateListAnimator] that will be applied to all Preference item views
*
* *Attention*: This animator will be cloned using [Object.clone] before getting applied.
*/
var stateListAnimator: StateListAnimator? = null

var secondScreenAdapter: PreferencesAdapter? = null

init {
Expand Down Expand Up @@ -143,6 +151,7 @@ class PreferencesAdapter @VisibleForTesting constructor(
else -> R.layout.map_preference
}
val view = layoutInflater.inflate(layout, parent, false)
view.stateListAnimator = stateListAnimator?.clone()
if (viewType > 0)
layoutInflater.inflate(viewType, view.findViewById(R.id.map_widget_frame), true)
return ViewHolder(view)
Expand Down

0 comments on commit 1ec0406

Please sign in to comment.