/** 初始化数据 */ private PictureData initData() { String json; if (isFirstData) { json = LocalFileUtils.getStringFormAsset(this, "picture.json"); } else { json = LocalFileUtils.getStringFormAsset(this, "picture1.json"); } isFirstData = !isFirstData; // 使用JsonTool工具将JSON数据封装到实例对象 return JsonTool.toBean(json, PictureData.class); }
/** * 添加头部View LoopView * * <p>这里使用的是LoopView开源项目,项目地址:https://github.com/xuehuayous/Android-LoopView * * @return void */ private void addFooterView() { LayoutInflater inflater = LayoutInflater.from(this); FrameLayout layout = (FrameLayout) inflater.inflate(R.layout.recycler_header, null); AdLoopView mAdLoopView = (AdLoopView) layout.findViewById(R.id.home_frag_rotate_vp); mWrapAdapter.addFooterView(layout); // 初始化LoopView数据 String json = LocalFileUtils.getStringFormAsset(this, "loopview.json"); mAdLoopView.refreshData(json); mAdLoopView.startAutoLoop(); }