@Override
  public void onActivityCreated2(Bundle savedInstanceState) {

    HashMap<String, String> url_maps = new HashMap<String, String>();
    url_maps.put(
        "Hannibal",
        "http://static2.hypable.com/wp-content/uploads/2013/12/hannibal-season-2-release-date.jpg");
    url_maps.put("Big Bang Theory", "http://tvfiles.alphacoders.com/100/hdclearart-10.png");
    url_maps.put("House of Cards", "http://cdn3.nflximg.net/images/3093/2043093.jpg");
    url_maps.put(
        "Game of Thrones",
        "http://images.boomsbeat.com/data/images/full/19640/game-of-thrones-season-4-jpg.jpg");
    for (String name : url_maps.keySet()) {
      DefaultSliderView defaultSliderView = new DefaultSliderView(getActivity());
      defaultSliderView.image(url_maps.get(name));
      TextSliderView textSliderView = new TextSliderView(getActivity());
      // initialize a SliderLayout
      textSliderView
          .description(name)
          .image(url_maps.get(name))
          .setScaleType(BaseSliderView.ScaleType.Fit)
          .setOnSliderClickListener(this);
      // add your extra information
      textSliderView.getBundle().putString("extra", name);
      mDemoSlider.addSlider(defaultSliderView);
    }
    mDemoSlider.setPresetTransformer(SliderLayout.Transformer.Accordion);
    mDemoSlider.setPresetIndicator(SliderLayout.PresetIndicators.Center_Bottom);
    mDemoSlider.setCustomAnimation(new DescriptionAnimation());
    mDemoSlider.setDuration(4000);
    mDemoSlider.setCustomIndicator(customIndicator);
  }
  public SliderLayout(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    mContext = context;
    LayoutInflater.from(context).inflate(R.layout.slider_layout, this, true);

    final TypedArray attributes =
        context.getTheme().obtainStyledAttributes(attrs, R.styleable.SliderLayout, defStyle, 0);

    mTransformerSpan = attributes.getInteger(R.styleable.SliderLayout_pager_animation_span, 1100);
    mTransformerId =
        attributes.getInt(R.styleable.SliderLayout_pager_animation, Transformer.Default.ordinal());
    mAutoCycle = attributes.getBoolean(R.styleable.SliderLayout_auto_cycle, true);
    int visibility = attributes.getInt(R.styleable.SliderLayout_indicator_visibility, 0);
    for (PagerIndicator.IndicatorVisibility v : PagerIndicator.IndicatorVisibility.values()) {
      if (v.ordinal() == visibility) {
        mIndicatorVisibility = v;
        break;
      }
    }
    mSliderAdapter = new SliderAdapter(mContext);
    PagerAdapter wrappedAdapter = new InfinitePagerAdapter(mSliderAdapter);

    mViewPager = (InfiniteViewPager) findViewById(R.id.daimajia_slider_viewpager);
    mViewPager.setAdapter(wrappedAdapter);

    mViewPager.setOnTouchListener(
        new OnTouchListener() {
          @Override
          public boolean onTouch(View v, MotionEvent event) {
            int action = event.getAction();
            switch (action) {
              case MotionEvent.ACTION_UP:
                recoverCycle();
                break;
            }
            return false;
          }
        });

    attributes.recycle();
    setPresetIndicator(PresetIndicators.Center_Bottom);
    setPresetTransformer(mTransformerId);
    setSliderTransformDuration(mTransformerSpan, null);
    setIndicatorVisibility(mIndicatorVisibility);
    if (mAutoCycle) {
      startAutoCycle();
    }
  }
Esempio n. 3
0
  private void initSlider() {

    if (mBanner != null) {

      for (Banner banner : mBanner) {

        TextSliderView textSliderView = new TextSliderView(this.getActivity());
        textSliderView.image(banner.getImgUrl());
        textSliderView.description(banner.getName());
        textSliderView.setScaleType(BaseSliderView.ScaleType.Fit);
        mSliderLayout.addSlider(textSliderView);
      }
    }

    mSliderLayout.setPresetIndicator(SliderLayout.PresetIndicators.Center_Bottom);

    mSliderLayout.setCustomAnimation(new DescriptionAnimation());
    mSliderLayout.setPresetTransformer(SliderLayout.Transformer.RotateUp);
    mSliderLayout.setDuration(3000);
  }