-
-
Notifications
You must be signed in to change notification settings - Fork 386
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Alexander Bakker <[email protected]>
- Loading branch information
1 parent
f38b6ec
commit 9ff8efa
Showing
9 changed files
with
124 additions
and
26 deletions.
There are no files selected for viewing
54 changes: 54 additions & 0 deletions
54
app/src/main/java/com/beemdevelopment/aegis/helpers/AnimationsHelper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package com.beemdevelopment.aegis.helpers; | ||
|
||
import android.content.Context; | ||
import android.provider.Settings; | ||
import android.view.animation.Animation; | ||
import android.view.animation.AnimationUtils; | ||
import android.view.animation.LayoutAnimationController; | ||
|
||
public class AnimationsHelper { | ||
private AnimationsHelper() { | ||
|
||
} | ||
|
||
public static Animation loadScaledAnimation(Context context, int animationResId) { | ||
return loadScaledAnimation(context, animationResId, Scale.ANIMATOR); | ||
} | ||
|
||
public static Animation loadScaledAnimation(Context context, int animationResId, Scale scale) { | ||
Animation animation = AnimationUtils.loadAnimation(context, animationResId); | ||
long newDuration = (long) (animation.getDuration() * scale.getValue(context)); | ||
animation.setDuration(newDuration); | ||
return animation; | ||
} | ||
|
||
public static LayoutAnimationController loadScaledLayoutAnimation(Context context, int animationResId) { | ||
return loadScaledLayoutAnimation(context, animationResId, Scale.ANIMATOR); | ||
} | ||
|
||
public static LayoutAnimationController loadScaledLayoutAnimation(Context context, int animationResId, Scale scale) { | ||
LayoutAnimationController controller = AnimationUtils.loadLayoutAnimation(context, animationResId); | ||
Animation animation = controller.getAnimation(); | ||
animation.setDuration((long) (animation.getDuration() * scale.getValue(context))); | ||
return controller; | ||
} | ||
|
||
public enum Scale { | ||
ANIMATOR(Settings.Global.ANIMATOR_DURATION_SCALE), | ||
TRANSITION(Settings.Global.TRANSITION_ANIMATION_SCALE); | ||
|
||
private final String _setting; | ||
|
||
Scale(String setting) { | ||
_setting = setting; | ||
} | ||
|
||
public float getValue(Context context) { | ||
return Settings.Global.getFloat(context.getContentResolver(), _setting, 1.0f); | ||
} | ||
|
||
public boolean isZero(Context context) { | ||
return getValue(context) == 0; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters