Ejemplo n.º 1
0
  void init() {
    mediaViewList = new ArrayList<MediaView>();
    LayoutInflater inflater = LayoutInflater.from(context);
    View view = inflater.inflate(R.layout.banner_layout, null, false);

    LinearLayout llPager = (LinearLayout) view.findViewById(R.id.llPager);

    if (height == 0) {
      height = 215;
    }
    horizontal_pager = new HorizontalPager(context);
    horizontal_pager.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, height));
    llPager.addView(horizontal_pager);

    llPagerIndicator = (LinearLayout) view.findViewById(R.id.llPagerIndicator);
    if (allMedias.size() <= 1) {
      llPagerIndicator.setVisibility(View.GONE);
    } else {
      llPagerIndicator.setVisibility(View.VISIBLE);
      pageIndicator = new PageIndicatorView(context, allMedias.size());
      llPagerIndicator.addView(pageIndicator);
    }
    this.addView(view);
    for (int i = 0; i < allMedias.size(); i++) {
      MediaObject media = allMedias.get(i);
      MediaView mediaView = new MediaView(context, media, isFragment);
      horizontal_pager.addView(mediaView);
      mediaViewList.add(mediaView);
    }
    horizontal_pager.setOnScreenSwitchListener(onScreenSwitchListener);
  }