Search in sources :

Example 1 with TabbarEntity

use of vip.kuaifan.weiui.ui.component.tabbar.entity.TabbarEntity in project weiui by kuaifan.

the class Tabbar method addPageView.

/**
 * 添加页面
 * @param barBean
 */
private void addPageView(TabbarBean barBean) {
    View view = ((Activity) getContext()).getLayoutInflater().inflate(R.layout.layout_weiui_tabbar_page, null);
    SwipeRefreshLayout v_swipeRefresh = view.findViewById(R.id.v_swipeRefresh);
    FrameLayout v_container = view.findViewById(R.id.v_container);
    ProgressBar v_progress = view.findViewById(R.id.v_progress);
    // 
    WXSDKBean sdkBean = new WXSDKBean();
    sdkBean.setSwipeRefresh(v_swipeRefresh);
    sdkBean.setContainer(v_container);
    sdkBean.setProgress(v_progress);
    sdkBean.setView(barBean.getView());
    if (barBean.getView() instanceof String) {
        sdkBean.setType("urlView");
        WXSDKList.put(barBean.getTabName(), sdkBean);
        addWXSDKView(barBean.getTabName());
    } else if (barBean.getView() instanceof TabbarPageView) {
        sdkBean.setType("pageView");
        WXSDKList.put(barBean.getTabName(), sdkBean);
        addWXPageView(barBean.getTabName());
    }
    // 
    if (getDomObject().getEvents().contains(weiuiConstants.Event.REFRESH_LISTENER)) {
        sdkBean.getSwipeRefresh().setColorSchemeResources(android.R.color.holo_blue_light, android.R.color.holo_red_light, android.R.color.holo_orange_light, android.R.color.holo_green_light);
        sdkBean.getSwipeRefresh().setOnRefreshListener(() -> {
            Map<String, Object> data = new HashMap<>();
            data.put("tabName", barBean.getTabName());
            data.put("position", getTabPosition(barBean.getTabName()));
            fireEvent(weiuiConstants.Event.REFRESH_LISTENER, data);
        });
        sdkBean.setSwipeRefreshEnable(true);
    } else {
        sdkBean.setSwipeRefreshEnable(false);
        sdkBean.getSwipeRefresh().setEnabled(false);
    }
    // 
    mTabEntity.add(new TabbarEntity(barBean));
    mViewList.add(view);
    mTabPagerAdapter.setListViews(mViewList);
    mTabPagerAdapter.notifyDataSetChanged();
}
Also used : WXSDKBean(vip.kuaifan.weiui.ui.component.tabbar.bean.WXSDKBean) HashMap(java.util.HashMap) FrameLayout(android.widget.FrameLayout) WXDomObject(com.taobao.weex.dom.WXDomObject) JSONObject(com.alibaba.fastjson.JSONObject) View(android.view.View) SwipeRefreshLayout(android.support.v4.widget.SwipeRefreshLayout) ProgressBar(android.widget.ProgressBar) TabbarEntity(vip.kuaifan.weiui.ui.component.tabbar.entity.TabbarEntity)

Aggregations

SwipeRefreshLayout (android.support.v4.widget.SwipeRefreshLayout)1 View (android.view.View)1 FrameLayout (android.widget.FrameLayout)1 ProgressBar (android.widget.ProgressBar)1 JSONObject (com.alibaba.fastjson.JSONObject)1 WXDomObject (com.taobao.weex.dom.WXDomObject)1 HashMap (java.util.HashMap)1 WXSDKBean (vip.kuaifan.weiui.ui.component.tabbar.bean.WXSDKBean)1 TabbarEntity (vip.kuaifan.weiui.ui.component.tabbar.entity.TabbarEntity)1