Explorar el Código

apiservice 部分修改

liujiangyao hace 8 años
padre
commit
d2a14032e0

+ 7 - 1
app/src/main/java/com/sheep/gamegroup/model/api/ApiService.java

@@ -95,9 +95,15 @@ public interface ApiService {
     Observable<BaseMessage> acceptedTask(@Query("page") int page, @Query("per_page") int per_page);
 
     /**
-     * 获取正在运行的任务
+     * 获取自己正在运行的任务
      */
     @GET(ConnectAddress.V1 + "/app/accepted_task/run_task/")
     Observable<BaseMessage> returnTask();
 
+    /**
+     * 获取正在运行的任务
+     */
+    @GET(ConnectAddress.V1 + "/app/release_task/")
+    Observable<BaseMessage> releaseTask();
+
 }

+ 100 - 0
app/src/main/java/com/sheep/gamegroup/model/entity/TaskAcceptedEty.java

@@ -0,0 +1,100 @@
+package com.sheep.gamegroup.model.entity;
+
+/**
+ * 已接受任务
+ * Created by ljy on 2018/3/20.
+ */
+
+public class TaskAcceptedEty {
+    private String create_time;// 0,
+    private String device_id;// "string",
+    private String id;// 0,
+    private String release_task_id;// 0,
+    private String remarks;// "string",
+    private String screenshots;// "string",
+    private String status;// 0,
+    private String uid;// 0,
+    private String update_time;// 0
+
+    private TaskReleaseEty release_task;
+
+    public String getCreate_time() {
+        return create_time;
+    }
+
+    public void setCreate_time(String create_time) {
+        this.create_time = create_time;
+    }
+
+    public String getDevice_id() {
+        return device_id;
+    }
+
+    public void setDevice_id(String device_id) {
+        this.device_id = device_id;
+    }
+
+    public String getId() {
+        return id;
+    }
+
+    public void setId(String id) {
+        this.id = id;
+    }
+
+    public String getRelease_task_id() {
+        return release_task_id;
+    }
+
+    public void setRelease_task_id(String release_task_id) {
+        this.release_task_id = release_task_id;
+    }
+
+    public String getRemarks() {
+        return remarks;
+    }
+
+    public void setRemarks(String remarks) {
+        this.remarks = remarks;
+    }
+
+    public String getScreenshots() {
+        return screenshots;
+    }
+
+    public void setScreenshots(String screenshots) {
+        this.screenshots = screenshots;
+    }
+
+    public String getStatus() {
+        return status;
+    }
+
+    public void setStatus(String status) {
+        this.status = status;
+    }
+
+    public String getUid() {
+        return uid;
+    }
+
+    public void setUid(String uid) {
+        this.uid = uid;
+    }
+
+    public String getUpdate_time() {
+        return update_time;
+    }
+
+    public void setUpdate_time(String update_time) {
+        this.update_time = update_time;
+    }
+
+    public TaskReleaseEty getRelease_task() {
+        return release_task;
+    }
+
+    public void setRelease_task(TaskReleaseEty release_task) {
+        this.release_task = release_task;
+    }
+}

+ 108 - 0
app/src/main/java/com/sheep/gamegroup/model/entity/TaskEty.java

@@ -0,0 +1,108 @@
+package com.sheep.gamegroup.model.entity;
+
+/**
+ * 任务
+ * Created by ljy on 2018/3/20.
+ */
+
+public class TaskEty {
+    private String boot_address;//private String string",
+    private String create_time;// 0,
+    private String download_link;//private String string",
+    private String id;// 0,
+    private String inspect_type;// 0,
+    private String package_names;//private String string",
+    private String remarks;//private String string",
+    private String screenshots;//private String string",
+    private String task_name;//private String string",
+    private String task_type;// 0,
+    private String update_time;// 0
+
+    public String getBoot_address() {
+        return boot_address;
+    }
+
+    public void setBoot_address(String boot_address) {
+        this.boot_address = boot_address;
+    }
+
+    public String getCreate_time() {
+        return create_time;
+    }
+
+    public void setCreate_time(String create_time) {
+        this.create_time = create_time;
+    }
+
+    public String getDownload_link() {
+        return download_link;
+    }
+
+    public void setDownload_link(String download_link) {
+        this.download_link = download_link;
+    }
+
+    public String getId() {
+        return id;
+    }
+
+    public void setId(String id) {
+        this.id = id;
+    }
+
+    public String getInspect_type() {
+        return inspect_type;
+    }
+
+    public void setInspect_type(String inspect_type) {
+        this.inspect_type = inspect_type;
+    }
+
+    public String getPackage_names() {
+        return package_names;
+    }
+
+    public void setPackage_names(String package_names) {
+        this.package_names = package_names;
+    }
+
+    public String getRemarks() {
+        return remarks;
+    }
+
+    public void setRemarks(String remarks) {
+        this.remarks = remarks;
+    }
+
+    public String getScreenshots() {
+        return screenshots;
+    }
+
+    public void setScreenshots(String screenshots) {
+        this.screenshots = screenshots;
+    }
+
+    public String getTask_name() {
+        return task_name;
+    }
+
+    public void setTask_name(String task_name) {
+        this.task_name = task_name;
+    }
+
+    public String getTask_type() {
+        return task_type;
+    }
+
+    public void setTask_type(String task_type) {
+        this.task_type = task_type;
+    }
+
+    public String getUpdate_time() {
+        return update_time;
+    }
+
+    public void setUpdate_time(String update_time) {
+        this.update_time = update_time;
+    }
+}

+ 163 - 0
app/src/main/java/com/sheep/gamegroup/model/entity/TaskReleaseEty.java

@@ -0,0 +1,163 @@
+package com.sheep.gamegroup.model.entity;
+
+/**
+ * 获取已经发布任务
+ * Created by ljy on 2018/3/20.
+ */
+
+public class TaskReleaseEty {
+    private String bonus;// 0,
+    private String create_time;// 0,
+    private String deadline;// 0,
+    private String duration;// 0,
+    private String id;// 0,
+    private String last_num;// 0,
+    private String name;//private String string",
+    private String online_time;// 0,
+    private String online_type;// 0,
+    private String release_num;// 0,
+    private String remarks;//private String string",
+    private String status;// 0,
+    private String submit_num;// 0,
+    private String task_id;// 0,
+    private String unaudited_num;// 0,
+    private String update_time;// 0
+
+    private TaskEty task;
+
+    public String getBonus() {
+        return bonus;
+    }
+
+    public void setBonus(String bonus) {
+        this.bonus = bonus;
+    }
+
+    public String getCreate_time() {
+        return create_time;
+    }
+
+    public void setCreate_time(String create_time) {
+        this.create_time = create_time;
+    }
+
+    public String getDeadline() {
+        return deadline;
+    }
+
+    public void setDeadline(String deadline) {
+        this.deadline = deadline;
+    }
+
+    public String getDuration() {
+        return duration;
+    }
+
+    public void setDuration(String duration) {
+        this.duration = duration;
+    }
+
+    public String getId() {
+        return id;
+    }
+
+    public void setId(String id) {
+        this.id = id;
+    }
+
+    public String getLast_num() {
+        return last_num;
+    }
+
+    public void setLast_num(String last_num) {
+        this.last_num = last_num;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public String getOnline_time() {
+        return online_time;
+    }
+
+    public void setOnline_time(String online_time) {
+        this.online_time = online_time;
+    }
+
+    public String getOnline_type() {
+        return online_type;
+    }
+
+    public void setOnline_type(String online_type) {
+        this.online_type = online_type;
+    }
+
+    public String getRelease_num() {
+        return release_num;
+    }
+
+    public void setRelease_num(String release_num) {
+        this.release_num = release_num;
+    }
+
+    public String getRemarks() {
+        return remarks;
+    }
+
+    public void setRemarks(String remarks) {
+        this.remarks = remarks;
+    }
+
+    public String getStatus() {
+        return status;
+    }
+
+    public void setStatus(String status) {
+        this.status = status;
+    }
+
+    public String getSubmit_num() {
+        return submit_num;
+    }
+
+    public void setSubmit_num(String submit_num) {
+        this.submit_num = submit_num;
+    }
+
+    public String getTask_id() {
+        return task_id;
+    }
+
+    public void setTask_id(String task_id) {
+        this.task_id = task_id;
+    }
+
+    public String getUnaudited_num() {
+        return unaudited_num;
+    }
+
+    public void setUnaudited_num(String unaudited_num) {
+        this.unaudited_num = unaudited_num;
+    }
+
+    public String getUpdate_time() {
+        return update_time;
+    }
+
+    public void setUpdate_time(String update_time) {
+        this.update_time = update_time;
+    }
+
+    public TaskEty getTask() {
+        return task;
+    }
+
+    public void setTask(TaskEty task) {
+        this.task = task;
+    }
+}

+ 7 - 1
app/src/main/java/com/sheep/gamegroup/presenter/TryMakeMoneyContract.java

@@ -11,11 +11,17 @@ public interface TryMakeMoneyContract {
     interface Presenter{
         void getData(Object o);
         void acceptedTask(RequestParameEty o);//获取已接受的任务
-        void returnTask(RequestParameEty o);//获取正在运行的任务
+        void returnTask(RequestParameEty o);//获取我正在运行的任务
+        void releaseTask(RequestParameEty o);//获取正在运行的任务
     }
     interface View{
 
         void updateData2View(Object o);
         void failData2View(Object o);
+        void acceptedTaskUpdataView(Object o);
+        void failAcceptedTask2View(Object o);
+
+        void returnTaskTaskUpdataView(Object o);
+        void failReturnTask2View(Object o);
     }
 }

+ 25 - 13
app/src/main/java/com/sheep/gamegroup/presenter/TryMakeMoneyPresenter.java

@@ -3,6 +3,9 @@ package com.sheep.gamegroup.presenter;
 import com.sheep.gamegroup.model.api.ApiService;
 import com.sheep.gamegroup.model.entity.BaseMessage;
 import com.sheep.gamegroup.model.entity.RequestParameEty;
+import com.sheep.gamegroup.model.util.ExceptionHandle;
+import com.sheep.gamegroup.model.util.MySubscriber;
+import com.sheep.jiuyan.samllsheep.SheepApp;
 
 import javax.inject.Inject;
 
@@ -32,20 +35,16 @@ public class TryMakeMoneyPresenter implements TryMakeMoneyContract.Presenter {
     public void acceptedTask(RequestParameEty o) {
         apiService.acceptedTask(o.getPage(), o.getPer_page())
                 .subscribeOn(Schedulers.io())
-                .subscribe(new Observer<BaseMessage>() {
+                .subscribe(new MySubscriber<BaseMessage>(SheepApp.mContext) {
                     @Override
-                    public void onCompleted() {
-
-                    }
-
-                    @Override
-                    public void onError(Throwable throwable) {
-                        view.failData2View(throwable);
+                    public void onError(ExceptionHandle.ResponeThrowable responeThrowable) {
+                        view.failData2View(responeThrowable.getMessage());
                     }
 
                     @Override
                     public void onNext(BaseMessage baseMessage) {
                         view.updateData2View(baseMessage);
+
                     }
                 });
 
@@ -56,17 +55,30 @@ public class TryMakeMoneyPresenter implements TryMakeMoneyContract.Presenter {
 
         apiService.returnTask()
                 .subscribeOn(Schedulers.io())
-                .subscribe(new Observer<BaseMessage>() {
+                .subscribe(new MySubscriber<BaseMessage>(SheepApp.mContext) {
                     @Override
-                    public void onCompleted() {
-
+                    public void onError(ExceptionHandle.ResponeThrowable responeThrowable) {
+                        view.failData2View(responeThrowable);
                     }
 
                     @Override
-                    public void onError(Throwable throwable) {
-                        view.failData2View(throwable);
+                    public void onNext(BaseMessage baseMessage) {
+                        view.updateData2View(baseMessage);
 
                     }
+                });
+    }
+
+    @Override
+    public void releaseTask(RequestParameEty o) {
+
+        apiService.releaseTask()
+                .subscribeOn(Schedulers.io())
+                .subscribe(new MySubscriber<BaseMessage>(SheepApp.mContext) {
+                    @Override
+                    public void onError(ExceptionHandle.ResponeThrowable responeThrowable) {
+                        view.failData2View(responeThrowable);
+                    }
 
                     @Override
                     public void onNext(BaseMessage baseMessage) {

+ 52 - 1
app/src/main/java/com/sheep/gamegroup/view/activity/TryMakeMoneyact.java

@@ -7,12 +7,15 @@ import android.support.v7.widget.RecyclerView;
 
 import com.sheep.gamegroup.di.components.DaggerTryMakeMoneyComponent;
 import com.sheep.gamegroup.di.modules.TryMakeMoneyModule;
+import com.sheep.gamegroup.model.entity.BaseMessage;
 import com.sheep.gamegroup.model.entity.RequestParameEty;
 import com.sheep.gamegroup.presenter.TryMakeMoneyContract;
 import com.sheep.gamegroup.presenter.TryMakeMoneyPresenter;
+import com.sheep.gamegroup.util.Jump2View;
 import com.sheep.jiuyan.samllsheep.R;
 import com.sheep.jiuyan.samllsheep.SheepApp;
 import com.sheep.jiuyan.samllsheep.base.BaseActivity;
+import com.sheep.jiuyan.samllsheep.utils.G;
 
 import javax.inject.Inject;
 
@@ -64,7 +67,7 @@ public class TryMakeMoneyact extends BaseActivity implements TryMakeMoneyContrac
     public void initData() {
 
         presenter.acceptedTask(new RequestParameEty(1, 10));
-        presenter.returnTask(null);
+        presenter.releaseTask(null);
     }
 
     @Override
@@ -76,4 +79,52 @@ public class TryMakeMoneyact extends BaseActivity implements TryMakeMoneyContrac
     public void failData2View(Object o) {
 
     }
+
+    @Override
+    public void acceptedTaskUpdataView(Object o) {
+
+    }
+
+    @Override
+    public void failAcceptedTask2View(Object o) {
+        hideProgress();
+        try {
+            BaseMessage baseMessage = (BaseMessage) o;
+            switch (baseMessage.getCode()){
+                case 300://未查询到数据
+                    G.showToast(" 未查询到数据!");
+                    break;
+                default:
+                    G.showToast(" 网络错误!");
+                    break;
+            }
+        }catch (Exception e){
+            e.printStackTrace();
+            G.showToast(" 网络错误!");
+        }
+    }
+
+    @Override
+    public void returnTaskTaskUpdataView(Object o) {
+
+    }
+
+    @Override
+    public void failReturnTask2View(Object o) {
+        hideProgress();
+        try {
+            BaseMessage baseMessage = (BaseMessage) o;
+            switch (baseMessage.getCode()){
+                case 300://未查询到正在运行的任务
+                    G.showToast(" 未查询到正在运行的任务!");
+                    break;
+                default:
+                    G.showToast(" 网络错误!");
+                    break;
+            }
+        }catch (Exception e){
+            e.printStackTrace();
+            G.showToast(" 网络错误!");
+        }
+    }
 }