Skip to content

Commit

Permalink
fix: home animating on reduce animations
Browse files Browse the repository at this point in the history
  • Loading branch information
Hamza417 committed Dec 29, 2024
1 parent f00cd13 commit e3b30a6
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,9 @@ open class TypeFaceEditText : AppCompatEditText, ThemeChangedListener {
val valueAnimator = ValueAnimator.ofArgb(backgroundTintList!!.defaultColor, endColor)
valueAnimator.duration = resources.getInteger(R.integer.theme_change_duration).toLong()
valueAnimator.interpolator = DecelerateInterpolator()
valueAnimator.addUpdateListener { animation: ValueAnimator -> backgroundTintList = ColorStateList.valueOf(animation.animatedValue as Int) }
valueAnimator.addUpdateListener { animation: ValueAnimator ->
backgroundTintList = ColorStateList.valueOf(animation.animatedValue as Int)
}
valueAnimator.start()
return valueAnimator
}
Expand All @@ -171,7 +173,7 @@ open class TypeFaceEditText : AppCompatEditText, ThemeChangedListener {
open fun hideInput() {
clearFocus()
(context.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager)
.hideSoftInputFromWindow(windowToken, InputMethodManager.RESULT_UNCHANGED_SHOWN)
.hideSoftInputFromWindow(windowToken, InputMethodManager.HIDE_NOT_ALWAYS)
}

@Suppress("unused")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import androidx.annotation.AnimRes;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import app.simple.inure.preferences.AccessibilityPreferences;

/**
* An extension of RecyclerView, focused more on resembling a GridView.
Expand Down Expand Up @@ -39,24 +40,26 @@ public GridRecyclerView(Context context, AttributeSet attrs, int defStyle) {
@Override
protected void attachLayoutAnimationParameters(View child, ViewGroup.LayoutParams params, int index, int count) {
if (getAdapter() != null && getLayoutManager() instanceof GridLayoutManager) {
GridLayoutAnimationController.AnimationParameters animationParams =
(GridLayoutAnimationController.AnimationParameters) params.layoutAnimationParameters;

if (animationParams == null) {
animationParams = new GridLayoutAnimationController.AnimationParameters();
params.layoutAnimationParameters = animationParams;
if (!AccessibilityPreferences.INSTANCE.isAnimationReduced()) { // Do not animate if user has disabled animations
GridLayoutAnimationController.AnimationParameters animationParams =
(GridLayoutAnimationController.AnimationParameters) params.layoutAnimationParameters;

if (animationParams == null) {
animationParams = new GridLayoutAnimationController.AnimationParameters();
params.layoutAnimationParameters = animationParams;
}

int columns = ((GridLayoutManager) getLayoutManager()).getSpanCount();

animationParams.count = count;
animationParams.index = index;
animationParams.columnsCount = columns;
animationParams.rowsCount = count / columns;

final int invertedIndex = count - 1 - index;
animationParams.column = columns - 1 - (invertedIndex % columns);
animationParams.row = animationParams.rowsCount - 1 - invertedIndex / columns;
}

int columns = ((GridLayoutManager) getLayoutManager()).getSpanCount();

animationParams.count = count;
animationParams.index = index;
animationParams.columnsCount = columns;
animationParams.rowsCount = count / columns;

final int invertedIndex = count - 1 - index;
animationParams.column = columns - 1 - (invertedIndex % columns);
animationParams.row = animationParams.rowsCount - 1 - invertedIndex / columns;
} else {
// throw new IllegalStateException("GridRecyclerView must have a GridLayoutManager");
Log.e("GridRecyclerView", "attachLayoutAnimationParameters: GridRecyclerView must have a GridLayoutManager");
Expand Down

0 comments on commit e3b30a6

Please sign in to comment.