@Override public void handleMessage(Message msg) { switch (msg.what) { case LOADING: // mPbLoading.setVisibility(View.VISIBLE); mIvEmpty.setVisibility(View.GONE); mLvData.setVisibility(View.VISIBLE); break; case FINISH: mLvData.finishRefreshing(); mPbLoading.setVisibility(View.GONE); if (mDatas.isEmpty()) { mLvData.setVisibility(View.GONE); mIvEmpty.setVisibility(View.VISIBLE); } else { mLvData.setVisibility(View.VISIBLE); mIvEmpty.setVisibility(View.GONE); adapter.notifyDataSetChanged(); if (mIsFirst) { mLvData.smoothScrollToPosition(0); mIsFirst = false; } } break; } }
@Override public void setInfo(Object obj, int code) { // TODO Auto-generated method stub pd.dismiss(); JSONObject json = JsonUtils.parseJson((String) obj); if (json.getIntValue("code") == 1) { list.clear(); JSONArray jsonList = json.getJSONArray("list"); JSONObject jsonObject; for (int i = 0; i < jsonList.size(); i++) { jsonObject = jsonList.getJSONObject(i); WBModel wList = new WBModel(); wList.setWbName("普天小王子"); wList.setWbMac(jsonObject.getString("mac")); list.add(wList); } adapter.notifyDataSetChanged(); } else { Toast.makeText(context, "获取名单失败", Toast.LENGTH_SHORT).show(); } }