|
|
@@ -27,11 +27,21 @@ public class BaseViewModel extends ViewModel {
|
|
|
return liveData;
|
|
|
}
|
|
|
|
|
|
+ private volatile int mLoadingTime;
|
|
|
+ public synchronized int onLoadTimeMinus() {
|
|
|
+ mLoadingTime = mLoadingTime-1;
|
|
|
+ return mLoadingTime;
|
|
|
+ }
|
|
|
+ public synchronized int onLoadTimeAdd() {
|
|
|
+ mLoadingTime = mLoadingTime+1;
|
|
|
+ return mLoadingTime;
|
|
|
+ }
|
|
|
/**
|
|
|
- * todo 对弹出对话框此时进行计数,归零才dismiss
|
|
|
+ * 这个方法名不能改动
|
|
|
+ * 对弹出对话框此时进行计数,归零才dismiss
|
|
|
*/
|
|
|
public void showLoading() {
|
|
|
- Log.e("log", "Loading");
|
|
|
+ onLoadTimeAdd();
|
|
|
}
|
|
|
|
|
|
public void post(int responseCode, String msg, Object dataBean, int sourceCode) {
|
|
|
@@ -43,27 +53,15 @@ public class BaseViewModel extends ViewModel {
|
|
|
}
|
|
|
|
|
|
public void post(int responseCode, String msg, Object dataBean) {
|
|
|
- if (liveData == null) {
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- liveData.postValue(new DataResult(responseCode, msg, dataBean, BaseMvpSource.COMMON));
|
|
|
+ post(responseCode, msg, dataBean, BaseMvpSource.COMMON);
|
|
|
}
|
|
|
|
|
|
public void post(int responseCode, Object dataBean) {
|
|
|
- if (liveData == null) {
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- liveData.postValue(new DataResult(responseCode, "", dataBean, BaseMvpSource.COMMON));
|
|
|
+ post(responseCode, "", dataBean, BaseMvpSource.COMMON);
|
|
|
}
|
|
|
|
|
|
public void post(int responseCode, Object dataBean, int sourceCode) {
|
|
|
- if (liveData == null) {
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- liveData.postValue(new DataResult(responseCode, "", dataBean, sourceCode));
|
|
|
+ post(responseCode, "", dataBean, sourceCode);
|
|
|
}
|
|
|
|
|
|
public void postSuccess(Object dataBean) {
|