@SuppressWarnings("unchecked") @Override public void networkCallback(Object jsonResult, int httpCode, int requestTag) { if (mActivity == null) return; JsonData<ListJsonData> jResult = (JsonData<ListJsonData>) jsonResult; if (httpCode == HttpStatus.SC_FORBIDDEN) { ((AppApplication) mActivity.getApplication()).userNotLogin(); return; } if (httpCode != HttpStatus.SC_OK) { Log.e("Volley", "HTTP Code " + httpCode + " catched in callback!!"); String toastString; if (httpCode == HttpStatus.SC_CONFLICT) { toastString = mActivity.getString(R.string.parse_data_failed); } else if (httpCode == HttpStatus.SC_INTERNAL_SERVER_ERROR) { toastString = getString(R.string.error_occur_retry_later); } else toastString = mActivity.getString(R.string.connect_to_server_failed); ToastTools.toastWithFrequencyLimited(mActivity, toastString, Toast.LENGTH_SHORT, true); return; } Log.d("Volley", "JsonData apiVersion: " + jResult.getApiVersion()); if (jResult.getCode() != Constants.CODE_SUCCESS) { Log.e("Volley", jResult.getMessage() == null ? "" : jResult.getMessage()); ToastTools.toastWithFrequencyLimited( mActivity, jResult.getMessage(), Toast.LENGTH_SHORT, true); return; } if (jResult.getData().size() == 0) { isNoMorePosts = true; // ToastTools.toast(getActivity(), getString(R.string.no_more_message_notice), // Toast.LENGTH_SHORT).show(); return; } if (requestTag == REQUEST_LATEST_COMMENTED_AND_LIKES) { List<PostMessage> msgs = jResult.getData().getPostMsgList(); mMsgAdapter.clearAllComments(); if (!Utils.isListEmpty(msgs)) msgPosts.addAll(msgs); handleMsgPost(); } else if (requestTag == REQUEST_PREVIOUS_COMMENTED_AND_LIKES) { List<PostMessage> msgs = jResult.getData().getPostMsgList(); if (!Utils.isListEmpty(msgs)) msgPosts.addAll(msgs); handleMsgPost(); } }
@SuppressWarnings("unchecked") @Override public void networkCallback(Object jsonResult, int httpCode, int requestTag) { JsonData<ListJsonData> jResult = (JsonData<ListJsonData>) jsonResult; dismissWaitDialog(); if (httpCode == HttpStatus.SC_FORBIDDEN) { ((AppApplication) getApplication()).userNotLogin(); return; } if (httpCode != HttpStatus.SC_OK) { Log.e("Volley", "HTTP Code " + httpCode + " catched in callback!!"); String toastString; if (httpCode == HttpStatus.SC_CONFLICT) { toastString = getString(R.string.parse_data_failed); } else if (httpCode == HttpStatus.SC_INTERNAL_SERVER_ERROR) { toastString = getString(R.string.error_occur_retry_later); } else toastString = getString(R.string.connect_to_server_failed); ToastTools.toastWithFrequencyLimited( SearchOnlineMusicActivity.this, toastString, Toast.LENGTH_SHORT, true); return; } if (jResult.getCode() != Constants.CODE_SUCCESS) { Log.e("Volley", jResult.getMessage() == null ? "" : jResult.getMessage()); ToastTools.toastWithFrequencyLimited( SearchOnlineMusicActivity.this, jResult.getMessage(), Toast.LENGTH_SHORT, true); return; } if (requestTag == REQUEST_SEARCH_MUSIC) { List<Music> musics = jResult.getData().getMusicList(); mChooseMusicLocalAdapter = new ChooseMusicOnlineAdapter(SearchOnlineMusicActivity.this, musics); mChooseMusicLocalAdapter.setMusicListener(this); mListView.setAdapter(mChooseMusicLocalAdapter); if (!Utils.isListEmpty(musics)) { noMusicLayout.setVisibility(View.GONE); mListView.setVisibility(View.VISIBLE); } else { noMusicLayout.setVisibility(View.VISIBLE); } mListView.requestFocus(); } else if (requestTag == REQUEST_GET_REMOTE_MUSIC_URL) { Log.d("MusicUrl", jResult.getData().getMusicList().get(0).getMusicUrl()); } }