/** * 根据{@link ABaseTask} 的加载状态,刷新视图 * * @param state * @param tag */ protected void taskStateChanged(ABaseTaskState state, Serializable tag) { // 开始Task if (state == ABaseTaskState.prepare) { if (isContentEmpty()) { setViewVisiable(loadingLayout, View.VISIBLE); setViewVisiable(contentLayout, View.GONE); } else { setViewVisiable(loadingLayout, View.GONE); setViewVisiable(contentLayout, View.VISIBLE); } setViewVisiable(emptyLayout, View.GONE); setViewVisiable(loadFailureLayout, View.GONE); } // Task成功 else if (state == ABaseTaskState.success) { setViewVisiable(loadingLayout, View.GONE); if (isContentEmpty()) { setViewVisiable(emptyLayout, View.VISIBLE); } else { setViewVisiable(contentLayout, View.VISIBLE); } } // 取消Task else if (state == ABaseTaskState.canceled) { if (isContentEmpty()) { setViewVisiable(loadingLayout, View.GONE); setViewVisiable(emptyLayout, View.VISIBLE); } } // Task失败 else if (state == ABaseTaskState.falid) { if (isContentEmpty()) { setViewVisiable(emptyLayout, View.GONE); setViewVisiable(loadingLayout, View.GONE); setViewVisiable(loadFailureLayout, View.VISIBLE); if (tag != null && loadFailureLayout != null) ViewUtils.setTextViewValue(loadFailureLayout, R.id.txtLoadFailed, tag.toString()); } } // Task结束 else if (state == ABaseTaskState.finished) { } }
/** * 以Toast形式显示一个消息 * * @param msg */ protected void showMessage(CharSequence msg) { if (!TextUtils.isEmpty(msg)) ViewUtils.showMessage(msg.toString()); }