public void setDrawMenuPosition(int drawMenuPosition) { if (mDrawMenuPosition != drawMenuPosition) { mDrawMenuPosition = drawMenuPosition; if (mUserChannelList != null) { mUserChannelList.clear(); } if (FlyingHttpTool.checkNetWorkStatus() == true) { loadChannelData(drawMenuPosition); } else { loadChannelData(drawMenuPosition); } } }
/** 此方法意思为fragment是否可见 ,可见时候加载数据 */ @Override public void setUserVisibleHint(boolean isVisibleToUser) { if (isVisibleToUser) { // fragment可见时加载数据 if (mShadeleft != null && mUserChannelList.size() != 0) { initAndShowView(); } else { if (FlyingHttpTool.checkNetWorkStatus() == true) { loadChannelData(mDrawMenuPosition); } else { loadChannelData(mDrawMenuPosition); } } } super.setUserVisibleHint(isVisibleToUser); }
/** 获取Column栏目 数据 */ public void loadChannelData(int drawMenuPosition) { mDrawMenuPosition = drawMenuPosition; String contentType = null; /* switch (drawMenuPosition) { case MainActivity.docMenuPostion: { contentType=ShareDefine.KContentTypeText; break; } case MainActivity.audioMenuPostion: { contentType=ShareDefine.KContentTypeAudio; break; } case MainActivity.vedioMenuPostion: { contentType=ShareDefine.KContentTypeVideo; break; } } */ FlyingHttpTool.getAlbumList( FlyingDataManager.getCurrentPassport(), FlyingDataManager.getBirdcopyAppID(), contentType, 1, true, false, new FlyingHttpTool.GetAlbumListListener() { @Override public void completion(final ArrayList<AlbumData> albumList, String allRecordCount) { if (albumList != null && albumList.size() != 0) { ArrayList<ChannelItem> channelList = new ArrayList<ChannelItem>(); for (int i = 0; i < albumList.size(); i++) { ChannelItem navigate = new ChannelItem(); navigate.setId(i); navigate.setName(albumList.get(i).getTagString()); navigate.setOrderId(i); navigate.setSelected(0); channelList.add(navigate); } mUserChannelList = channelList; } else { mUserChannelList = null; } getActivity() .runOnUiThread( new Runnable() { @Override public void run() { initAndShowView(); } }); } }); }