/** 停止刷新 */ private void stopRefresh() { home_Xlistview.stopLoadMore(); home_Xlistview.stopRefresh(); SimpleDateFormat simpleDateFormat = new SimpleDateFormat("MM/dd/yyyy HH:mm", Locale.getDefault()); home_Xlistview.setRefreshTime(simpleDateFormat.format(new Date(System.currentTimeMillis()))); }
private void fillData(String result) { DealData dealData = null; try { dealData = GsonUtil.json2bean(result, DealData.class); ArrayList<Deal> deals = dealData.getData().getDeals(); if (isRefresh) { mAllDeals.clear(); convenientBanner.setcurrentitem(0); } mAllDeals.addAll(deals); if (newsListAdapter == null) { newsListAdapter = new TabListAdapter(mContext, mAllDeals); home_Xlistview.setAdapter(newsListAdapter); } else { newsListAdapter.setData(mAllDeals); newsListAdapter.notifyDataSetChanged(); } mHandler.sendEmptyMessage(MSG_STOP_REFRESH); home_Xlistview.setVisibility(View.VISIBLE); hideBaseLoading(); } catch (Exception e) { hideBaseLoading(); if (mAllDeals.size() == 0 && !isRefresh) { showLoadingError(); } else { mHandler.sendEmptyMessage(MSG_STOP_REFRESH); ToastUtil.showToast(mContext, "亲,加载错误啦,请重试."); } e.printStackTrace(); } }
@Override public void onDestroyView() { super.onDestroyView(); Log.i("abc", "tab--onDestroyView>" + mType); mAllDeals.clear(); if (convenientBanner != null) { boolean result = home_Xlistview.removeHeaderView(convenientBanner); } home_Xlistview.setVisibility(View.GONE); // 停止翻页 convenientBanner.stopTurning(); }
private void initXListViewHeader() { View headView = LayoutInflater.from(mContext).inflate(R.layout.home_xgridview_header, null); convenientBanner = (ConvenientBanner) headView.findViewById(R.id.convenientBanner); convenientBanner.setLayoutParams( new XListView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 600)); convenientBanner .setPages( new CBViewHolderCreator<NetworkImageHolderView>() { @Override public NetworkImageHolderView createHolder() { return new NetworkImageHolderView(); } }, networkImages) .setPageIndicator( new int[] {R.drawable.ic_page_indicator, R.drawable.ic_page_indicator_focused}); convenientBanner.setOnItemClickListener( new OnItemClickListener() { @Override public void onItemClick(int position) { ToastUtil.showToast(mContext, "点击了--position" + position + "---type" + mType); } }); home_Xlistview.addHeaderView(convenientBanner); // 开始自动翻页 convenientBanner.startTurning(3000); }
@Override protected void setListensers() { home_Xlistview.setPullLoadEnable(true); home_Xlistview.setSelector(android.R.color.transparent); home_Xlistview.setOnItemClickListener(new MyOnItemClickListener()); home_Xlistview.setXListViewListener(new MyIXListViewListener()); ObserverManager mObserverManager = ObserverManager.getInstance(); mObserverManager.addCityChangedObserver( new ObserverManager.OnCityChangedListener() { @Override public void onCityChanged() { home_Xlistview.setVisibility(View.GONE); isShowAnim(true); showBaseLoading(); getDealData(); } }); }
@Override public void handleMessage(Message msg) { super.handleMessage(msg); switch (msg.what) { case MSG_STOP_REFRESH: stopRefresh(); break; case MSG_GET_DATA_OVER: ToastUtil.showToast(mContext, "亲,没有更多数据了哦."); stopRefresh(); home_Xlistview.setPullLoadEnable(false); break; default: break; } }