/** * return a random Transformer between [0, the length of enum -1) * * @return BaseTransformer */ public BaseTransformer getShuffleTransformer() { BaseTransformer t = null; int transformerNumber = Transformer.values().length; int random = new Random().nextInt(transformerNumber - 1); Transformer ts = Transformer.values()[random]; switch (ts) { case Default: t = new DefaultTransformer(); break; case Accordion: t = new AccordionTransformer(); break; case Background2Foreground: t = new BackgroundToForegroundTransformer(); break; case CubeIn: t = new CubeInTransformer(); break; case DepthPage: t = new DepthPageTransformer(); break; case Fade: t = new FadeTransformer(); break; case FlipHorizontal: t = new FlipHorizontalTransformer(); break; case FlipPage: t = new FlipPageViewTransformer(); break; case Foreground2Background: t = new ForegroundToBackgroundTransformer(); break; case RotateDown: t = new RotateDownTransformer(); break; case RotateUp: t = new RotateUpTransformer(); break; case Stack: t = new StackTransformer(); break; case Tablet: t = new TabletTransformer(); break; case ZoomIn: t = new ZoomInTransformer(); break; case ZoomOutSlide: t = new ZoomOutSlideTransformer(); break; case ZoomOut: t = new ZoomOutTransformer(); break; } return t; }
/** * set preset PagerTransformer via the name of transforemer. * * @param transformerName the transformer name in string */ public void setPresetTransformer(String transformerName) { for (Transformer t : Transformer.values()) { if (t.equals(transformerName)) { setPresetTransformer(t); return; } } }
/** * set a preset viewpager transformer by id. * * @param transformerId the recongized transformer ID */ public void setPresetTransformer(int transformerId) { for (Transformer t : Transformer.values()) { if (t.ordinal() == transformerId) { setPresetTransformer(t); break; } } }