Back to project page unknown-pleasures.
The source code is released under:
Creative Commons Attribution NonCommercial NoDerivs (CC-NC-ND) THE WORK (AS DEFINED BELOW) IS PROVIDED UNDER THE TERMS OF THIS CREATIVE COMMONS PUBLIC LICENSE ("CCPL" OR "LICENSE"). THE WORK IS PROTE...
If you think the Android project unknown-pleasures listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
/** * AnimatorFactory.java// w w w . j a v a 2 s . c o m * Author: marek.brodziak@gmail.com * Created: May 6, 2014 * Copyright 2014 by miniti */ package pl.miniti.android.pleasures.animation; import android.util.Log; /** * Factory of the {@see Animator} implementations */ public class AnimatorFactory { /** * Tag name for the logger */ private static final String T = AnimatorFactory.class.getSimpleName(); /** * Enumeration of available implementations */ private enum Impl { /** * Default implementation for this factory */ DEFAULT(ScrollableOriginalCoverAnimator.class), /** */ VERTICAL(ScrollableOriginalCoverAnimator.class), /** */ STRECH(StrechOriginalCoverAnimator.class), /** */ HORIZONTAL(HorizontalScrollAnimator.class); private Class<? extends Animator> animatorClass; private Impl(Class<? extends Animator> ac) { if (ac == null) { throw new IllegalArgumentException( "null is not a valid Animator implementation"); } animatorClass = ac; } } /** * Construct a new instance based on the configuration * * @param value * configuration value * @return object instance */ public static Animator newInstance(String value) { Log.d(T, String.format("Searching for Animator %s", value)); try { if (value == null) { Log.d(T, String.format( "Constructing a default Animator implementation %s", Impl.DEFAULT.animatorClass.getSimpleName())); return Impl.DEFAULT.animatorClass.newInstance(); } for (Impl a : Impl.values()) { if (a.animatorClass.getName().equals(value)) { Log.d(T, "Match found"); return a.animatorClass.newInstance(); } } Log.w(T, String.format("%s is not a registered Animator", value)); Log.d(T, String.format( "Constructing a default Animator implementation %s", Impl.DEFAULT.animatorClass.getSimpleName())); return Impl.DEFAULT.animatorClass.newInstance(); } catch (InstantiationException e) { Log.e(T, "Error while creating an Animator", e); } catch (IllegalAccessException e) { Log.e(T, "Error raised while creating an Animator", e); } Log.d(T, "Fall back to constructing from code"); return new ScrollableOriginalCoverAnimator(); } /** * Construct a new default instance * * @return object instance */ public static Animator newInstance() { return newInstance(null); } }