Quellcode durchsuchen

apiservice 接口更新返回类型

liujiangyao vor 8 Jahren
Ursprung
Commit
c7c383a1d0

+ 0 - 21
.idea/gradle.xml

@@ -1,21 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project version="4">
-  <component name="GradleSettings">
-    <option name="linkedExternalProjectsSettings">
-      <GradleProjectSettings>
-        <option name="distributionType" value="DEFAULT_WRAPPED" />
-        <option name="externalProjectPath" value="$PROJECT_DIR$" />
-        <option name="modules">
-          <set>
-            <option value="$PROJECT_DIR$" />
-            <option value="$PROJECT_DIR$/app" />
-            <option value="$PROJECT_DIR$/datashare" />
-            <option value="$PROJECT_DIR$/ucrop" />
-            <option value="$PROJECT_DIR$/view" />
-          </set>
-        </option>
-        <option name="resolveModulePerSourceSet" value="false" />
-      </GradleProjectSettings>
-    </option>
-  </component>
-</project>

+ 7 - 18
app/src/main/java/com/sheep/gamegroup/presenter/AccountAndSecuritPresenter.java

@@ -4,13 +4,14 @@ import com.alibaba.fastjson.JSONObject;
 import com.sheep.gamegroup.model.api.ApiService;
 import com.sheep.gamegroup.model.entity.BaseMessage;
 import com.sheep.gamegroup.model.entity.UserInfoEntity;
+import com.sheep.gamegroup.model.util.SheepSubscriber;
 import com.sheep.gamegroup.util.FastJsonUtils;
+import com.sheep.jiuyan.samllsheep.SheepApp;
 
 import java.util.HashMap;
 
 import javax.inject.Inject;
 
-import rx.Observer;
 import rx.android.schedulers.AndroidSchedulers;
 import rx.schedulers.Schedulers;
 
@@ -36,32 +37,20 @@ public class AccountAndSecuritPresenter implements  AccountAndSecuritContract.Pr
 
         apiService.getInfo().subscribeOn(Schedulers.io())
                 .observeOn(AndroidSchedulers.mainThread())
-                .subscribe(new Observer<BaseMessage>() {
+                .subscribe(new SheepSubscriber<BaseMessage>(SheepApp.mContext) {
                     @Override
-                    public void onCompleted() {
-
-                    }
-
-                    @Override
-                    public void onError(Throwable throwable) {
+                    public void onError(BaseMessage baseMessage) {
                         view.NetError(-1,"请求网络异常");
                     }
 
                     @Override
                     public void onNext(BaseMessage baseMessage) {
-
                         if(baseMessage!=null){
 
 
-                            UserInfoEntity loginEty = FastJsonUtils.toBean( JSONObject.toJSONString(baseMessage.getData()),UserInfoEntity.class);
-                            view.showTask(loginEty);
+                        UserInfoEntity loginEty = FastJsonUtils.toBean( JSONObject.toJSONString(baseMessage.getData()),UserInfoEntity.class);
+                        view.showTask(loginEty);
 
                         }
-
-
-
                     }
-                });
-
-    }
-}
+                }); } }

+ 6 - 10
app/src/main/java/com/sheep/gamegroup/presenter/AskGetMoneyPresenter.java

@@ -8,8 +8,10 @@ import com.sheep.gamegroup.model.api.ApiService;
 import com.sheep.gamegroup.model.entity.BaseMessage;
 import com.sheep.gamegroup.model.entity.FriendAndAwardEntity;
 import com.sheep.gamegroup.model.entity.LoginEntity;
+import com.sheep.gamegroup.model.util.SheepSubscriber;
 import com.sheep.gamegroup.util.FastJsonUtils;
 import com.sheep.gamegroup.util.MyDbManager;
+import com.sheep.jiuyan.samllsheep.SheepApp;
 
 import org.xutils.ex.DbException;
 
@@ -42,27 +44,21 @@ public class AskGetMoneyPresenter implements AskGetMoneyContract.Presenter {
         apiService.FriendCountAndAward()
                 .subscribeOn(Schedulers.io())
                 .observeOn(AndroidSchedulers.mainThread())
-                .subscribe(new Observer<BaseMessage>() {
+                .subscribe(new SheepSubscriber<BaseMessage>(SheepApp.mContext) {
                     @Override
-                    public void onCompleted() {
-                        Log.e("onCompleted--------","onCompleted");
-                    }
-
-                    @Override
-                    public void onError(Throwable throwable) {
-                        Log.e("onError--------","onError:"+throwable);
-                         view.NetError(-1,ExceptionEngine.handleException(throwable).getMessage());
+                    public void onError(BaseMessage baseMessage) {
+                        view.NetError(-1, baseMessage.getMsg());
                     }
 
                     @Override
                     public void onNext(BaseMessage baseMessage) {
-
                         if(baseMessage!=null){
                             FriendAndAwardEntity Ety = FastJsonUtils.toBean( JSONObject.toJSONString(baseMessage.getData()),FriendAndAwardEntity.class);
                             view.showTask(Ety);
                         }else{
                             view.NetError(-1,"数据解析出错");
                         }
+
                     }
                 });
 

+ 3 - 8
app/src/main/java/com/sheep/gamegroup/presenter/LoginPresenter.java

@@ -10,6 +10,7 @@ import com.googlecode.protobuf.format.util.TextUtils;
 import com.sheep.gamegroup.exception.ExceptionEngine;
 import com.sheep.gamegroup.model.api.ApiService;
 import com.sheep.gamegroup.model.entity.BaseMessage;
+import com.sheep.gamegroup.model.entity.FriendAndAwardEntity;
 import com.sheep.gamegroup.model.entity.LoginEntity;
 import com.sheep.gamegroup.model.entity.UserEntity;
 import com.sheep.gamegroup.model.util.SheepSubscriber;
@@ -55,14 +56,9 @@ public class LoginPresenter implements LoginContract.Presenter {
         if(type==1){
             apiService.LoginByWX(j).subscribeOn(Schedulers.io())
                     .observeOn(AndroidSchedulers.mainThread())
-                    .subscribe(new Observer<BaseMessage>() {
-                        @Override
-                        public void onCompleted() {
-
-                        }
-
+                    .subscribe(new SheepSubscriber<BaseMessage>(SheepApp.mContext) {
                         @Override
-                        public void onError(Throwable throwable) {
+                        public void onError(BaseMessage baseMessage) {
                             view.NetError(-1, "微信登录失败  请检查网络是否正常");
                         }
 
@@ -83,7 +79,6 @@ public class LoginPresenter implements LoginContract.Presenter {
 
                             view.NetSuccess(1,"登录成功");
 
-
                         }
                     });
 

+ 7 - 15
app/src/main/java/com/sheep/gamegroup/presenter/ReNamePresenter.java

@@ -6,6 +6,8 @@ import com.alibaba.fastjson.JSONObject;
 import com.sheep.gamegroup.exception.ExceptionEngine;
 import com.sheep.gamegroup.model.api.ApiService;
 import com.sheep.gamegroup.model.entity.BaseMessage;
+import com.sheep.gamegroup.model.util.SheepSubscriber;
+import com.sheep.jiuyan.samllsheep.SheepApp;
 
 import java.util.HashMap;
 
@@ -39,32 +41,22 @@ public class ReNamePresenter implements  ReNameContract.Presenter  {
         apiService.changeBaseInfo(j)
                 .subscribeOn(Schedulers.io())
                 .observeOn(AndroidSchedulers.mainThread())
-                .subscribe(new Observer<BaseMessage>() {
+                .subscribe(new SheepSubscriber<BaseMessage>(SheepApp.mContext) {
                     @Override
-                    public void onCompleted() {
-                        Log.e("onCompleted--------","onCompleted");
+                    public void onError(BaseMessage baseMessage) {
 
-                    }
-
-                    @Override
-                    public void onError(Throwable throwable) {
-                        Log.e("onError--------","onError:"+throwable);
-                        view.NetError(-1, ExceptionEngine.handleException(throwable).getMessage());
+                        view.NetError(-1, baseMessage.getMsg()+"");
                     }
 
                     @Override
                     public void onNext(BaseMessage baseMessage) {
-
                         if(baseMessage!=null){
-                          view.NetSuccess(1,"修改昵称成功");
+                            view.NetSuccess(1,"修改昵称成功");
                         }else{
                             view.NetError(-1,"数据解析出错");
                         }
+
                     }
                 });
-
-
-
-
     }
 }

+ 11 - 8
app/src/main/java/com/sheep/gamegroup/presenter/RealNameAutherPresenter.java

@@ -6,8 +6,15 @@ import com.alibaba.fastjson.JSONObject;
 import com.sheep.gamegroup.exception.ExceptionEngine;
 import com.sheep.gamegroup.model.api.ApiService;
 import com.sheep.gamegroup.model.entity.BaseMessage;
+import com.sheep.gamegroup.model.entity.LoginEntity;
 import com.sheep.gamegroup.model.entity.UserInfoEntity;
+import com.sheep.gamegroup.model.util.SheepSubscriber;
 import com.sheep.gamegroup.util.FastJsonUtils;
+import com.sheep.gamegroup.util.MyDbManager;
+import com.sheep.jiuyan.samllsheep.SheepApp;
+import com.sheep.jiuyan.samllsheep.utils.SpUtils;
+
+import org.xutils.ex.DbException;
 
 import java.util.HashMap;
 import java.util.Iterator;
@@ -45,21 +52,17 @@ public class RealNameAutherPresenter implements  RealNameAutherContract.Presente
         view.showGoProgress();
         apiService.bindALl(jsonObject).subscribeOn(Schedulers.io())
                 .observeOn(AndroidSchedulers.mainThread())
-                .subscribe(new Observer<BaseMessage>() {
-                    @Override
-                    public void onCompleted() {
-
-                    }
-
+                .subscribe(new SheepSubscriber<BaseMessage>(SheepApp.mContext) {
                     @Override
-                    public void onError(Throwable throwable) {
+                    public void onError(BaseMessage baseMessage) {
 
                         view.NetError(-1,"绑定信息失败");
                     }
 
                     @Override
                     public void onNext(BaseMessage baseMessage) {
-                         view.NetSuccess(0,"修改成功");
+                        view.NetSuccess(0,"修改成功");
+
                     }
                 });