@Override public void onSuccess(int statusCode, Header[] headers, byte[] responseBody) { String content = new String(responseBody); try { boolean success = new JSONObject(content).optBoolean("success", false); String message = new JSONObject(content).optString("message"); String data = new JSONObject(content).optString("data"); if (!success) { MsgTools.toast(getActivity(), message, ResourceMap.LENGTH_SHORT); } else { List<MessageBean> messageList = new ArrayList<MessageBean>(); messageList.addAll( (List<MessageBean>) new Gson().fromJson(data, new TypeToken<List<MessageBean>>() {}.getType())); // 数据从未读数开始排序 // ComparatorNoRead comparator = new ComparatorNoRead(); // Collections.sort(messageList, comparator); kzxMessageAdapter.setDataForLoader(messageList); if (kzxMessageAdapter.isEmpty()) { dateCustomList.setEmptyView(img_empty_feed); } } } catch (Exception e) { e.printStackTrace(); MsgTools.toast( getActivity(), getString(R.string.request_error), ResourceMap.LENGTH_SHORT); } }
@Override public void onStart() { super.onStart(); if (kzxMessageAdapter.getCount() > 0) { swipeLayout.setRefreshing(true); } else { default_load_view.setVisibility(View.VISIBLE); } }