コード例 #1
0
ファイル: PageView2.java プロジェクト: litingwen624/magazine
  /**
   * 初始化第一个GroupView
   *
   * @param group
   */
  private void intialFirstGroupView(Group group) {
    List<Hot> hots = group.getHots();
    List<Picture> pictures = group.getPictures();
    List<Layer> layers = group.getLayers();
    List<Animation> animations = group.getAnimations();
    List<Video> videos = group.getVideos();
    List<PictureSet> pictureSets = group.getPictureSets();
    List<Slider> sliders = group.getSliders();
    List<Shutter> shutters = group.getShutters();
    List<Group> groups = group.getGroups();
    List<Rotater> rotater = group.getRotaters();
    int[] frames = FrameUtil.frame2int(group.getFrame());
    if (frames[2] >= 1024
        && frames[3] >= 768
        && (hots.size() != 0
            || layers.size() != 0
            || animations.size() != 0
            || videos.size() != 0
            || pictureSets.size() != 0
            || pictures.size() != 0
            || sliders.size() != 0
            || shutters.size() != 0
            || groups.size() > 1
            || rotater.size() != 0)) {
      FirstGroupView firstGroupView = new FirstGroupView(context, group, flipperPageView, this);
      getFrameLayout().addView(firstGroupView);
      firstGroup = group;
    } else {
      if (group.getGroups().size() > 0) {
        intialFirstGroupView(group.getGroups().get(0));
      }
    }

    /*List<Hot> hots=group.getHots();
    List<Picture> pictures=group.getPictures();
    List<Layer> layers=group.getLayers();
    List<Animation> animations=group.getAnimations();
    List<Video> videos=group.getVideos();
    List<PictureSet> pictureSets=group.getPictureSets();
    List<Slider> sliders=group.getSliders();
    List<Shutter> shutters=group.getShutters();
    //List<Group> groups=group.getGroups();
    if(hots.size()!=0||layers.size()!=0||animations.size()!=0||videos.size()!=0||pictureSets.size()!=0||pictures.size()!=0||sliders.size()!=0||shutters.size()!=0){
    	int[] frames=FrameUtil.frame2int(group.getFrame());
    	if(frames[2]>=1024&&frames[3]>=768){
    		FirstGroupView firstGroupView=new FirstGroupView(context,group,flipperPageView,this);
    		getFrameLayout().addView(firstGroupView);
    		firstGroup=group;
    		return;
    	}
    }else{
    	List<Group> groups=group.getGroups();
    	if(groups!=null&&groups.size()!=0){
    		for(Group g:groups){
    			intialFirstGroupView(g);
    		}
    	}
    }*/
  }
コード例 #2
0
ファイル: PageView2.java プロジェクト: litingwen624/magazine
  /**
   * 递归构建GroupView
   *
   * @param group
   */
  private void buildGroupView(Group group) {
    if (group == null) {
      return;
    }
    List<Group> groups = group.getGroups();
    if (groups != null && groups.size() != 0) {
      for (Group g : groups) {
        String oritentation = g.getOrientation();
        View groupView = null;
        int childCount;
        if (oritentation.equals(BasicView.HORIZONTAL)) {
          HorizontalGroupView hGroupView =
              new HorizontalGroupView(context, g, flipperPageView, this);
          childCount = hGroupView.getFrameLayout().getChildCount();
          groupView = hGroupView;

        } else {
          GroupView2 vGroupView = new GroupView2(context, g, flipperPageView, this);
          childCount = vGroupView.getFrameLayout().getChildCount();
          groupView = vGroupView;
        }
        // 如果Group里只有嵌套的Group子控件则不添加到PageView里
        if (childCount != 0) {
          String frame = g.getFrame();
          int[] frames = FrameUtil.frame2int(frame);
          // 如果该层Group覆盖了整个屏幕,那么就将该Group下的子控件添加到该Group下
          if (getBigGroupView() != null) {
            ((GroupView2) getBigGroupView()).getFrameLayout().addView(groupView);
          } else {
            getFrameLayout().addView(groupView);
          }
          if (frames[0] == 0
              && frames[1] == 0
              && frames[2] >= 1024
              && frames[3] >= 768
              && oritentation.equals(BasicView.VERTICAL)) {
            setBigGroupView(groupView);
          }
          groupViewList.add(groupView);
        } else {
          groupView = null;
        }
        List<Group> groups_ = g.getGroups();
        if (groups_ != null && groups_.size() != 0) {
          for (Group g_ : groups_) {
            buildGroupView(g_);
          }
        }
      }
    } else {
      if (firstGroup != group) {
        List<Hot> hots = group.getHots();
        List<Picture> pictures = group.getPictures();
        List<Layer> layers = group.getLayers();
        List<Animation> animations = group.getAnimations();
        List<Video> videos = group.getVideos();
        List<PictureSet> pictureSets = group.getPictureSets();
        List<Slider> sliders = group.getSliders();
        List<Shutter> shutters = group.getShutters();
        if (hots.size() != 0
            || layers.size() != 0
            || animations.size() != 0
            || videos.size() != 0
            || pictureSets.size() != 0
            || pictures.size() != 0
            || sliders.size() != 0
            || shutters.size() != 0) {
          View groupView = null;
          String oritentation = group.getOrientation();
          if (oritentation.equals(BasicView.HORIZONTAL)) {
            groupView = new HorizontalGroupView(context, group, flipperPageView, this);
          } else {
            groupView = new GroupView2(context, group, flipperPageView, this);
          }
          if (getBigGroupView() != null) {
            View bigGroupView = getBigGroupView();
            if (bigGroupView instanceof HorizontalGroupView) {
              ((HorizontalGroupView) bigGroupView).getFrameLayout().addView(groupView);
            } else if (bigGroupView instanceof GroupView2) {
              ((GroupView2) bigGroupView).getFrameLayout().addView(groupView);
            }
          } else {
            getFrameLayout().addView(groupView);
          }
          groupViewList.add(groupView);
        }
      }
    }
  }