Page.java 1.82 KB
/*
 * Copyright (c) People Technologies Co., Ltd. 2019-2022. All rights reserved.
 */

package com.wd.display.comp.layoutdata;

import java.util.List;

import com.orhanobut.logger.Logger;
import com.people.entity.custom.comp.GroupBean;
import com.people.entity.custom.comp.PageBean;
import com.wondertek.wheat.ability.tools.StringUtils;

/**
 * Page类<BR>
 * 可以看做是一个页面,收集多个Group。瀑布流展示页面
 *
 * @author zhangbo
 * @version [V1.0.0, 2021/12/8]
 * @since V1.0.0
 */
public class Page extends AbsPage {

    private static final String TAG = "Page";

    private PageBean mPageBean;

    /**
     * 构造器
     */
    public Page() {
        super();
    }


    /**
     * 数据解析,组装group列表数据
     *
     * @param pageBean PageBean数据
     */
    public void createGroup(PageBean pageBean) {
        if (pageBean == null) {
            Logger.t(TAG).e( "createGroup, pageBean is null");
            return;
        }
        this.setId(pageBean.getId());
        this.getGroups().clear();
        //收集楼层排序和编号,
        List<GroupBean> groups =  pageBean.getGroups();
        for (int i = 0 ; i < groups.size();i++) {
            GroupBean bean = groups.get(i);
            if (StringUtils.isEmpty(bean.getId())) {
                // 丢弃无效group数据
                continue;
            }
            Group groupBean = new Group(bean.getId(), this);
            groupBean.setPosition(i);
            groupBean.setBlockDesc(bean.getBlockDesc());
            groupBean.setStartPosition(i);
            groupBean.setGroupStrategy(bean.getGroupStrategy());
            this.getGroups().add(groupBean);
        }
    }

    public PageBean getPage() {
        return mPageBean;
    }

    public void setPage(PageBean pageBean) {
        this.mPageBean = pageBean;
    }
}