"> 8
 import com.android.common.executors.ThreadExecutor;
9
-import com.android.common.utils.LogHelper;
10 9
 
11
-import ai.pai.lensman.bean.PhotoBean;
12
-import ai.pai.lensman.db.DBService;
10
+import java.util.HashMap;
13 11
 
14
-public class OrderDealService extends Service implements UploadTask.OnPhotoUploadListener{
12
+import ai.pai.lensman.bean.OrderBean;
13
+import ai.pai.lensman.db.Preferences;
14
+import ai.pai.lensman.utils.HttpPostTask;
15 15
 
16
-    private PhotoBean currentPhoto;
17
-    private PhotoUploadListener listener;
16
+public class OrderDealService extends Service{
18 17
 
19 18
     @Override
20 19
     public IBinder onBind(Intent intent) {
21
-        return new MyBinder();
20
+        return new OrderServiceBinder();
22 21
     }
23 22
 
24 23
     @Override
25 24
     public int onStartCommand(Intent intent, int flags, int startId) {
26
-        if(intent!=null && intent.getSerializableExtra("photo")!=null){
27
-            PhotoBean bean = (PhotoBean) intent.getSerializableExtra("photo");
28
-            bean.uploadStatus = PhotoBean.UploadStatus.STATUS_NO_BEGIN;
29
-            DBService.getInstance().updatePhotoBean(bean);
30
-        }
31
-            startUpload();
32
-        return super.onStartCommand(intent, flags, startId);
25
+        startQuery();
26
+        return START_STICKY;
33 27
     }
34 28
 
35
-    private synchronized void startUpload(){
36
-        if(currentPhoto!=null){
37
-            LogHelper.d("czy","当前有图片正在上传"+currentPhoto);
38
-            return;
39
-        }
40
-         currentPhoto = DBService.getInstance().getNextUploadPhoto();
41
-        if(currentPhoto==null){
42
-            LogHelper.d("czy","本地图片已全部上传");
43
-            return;
44
-        }
45
-        LogHelper.d("czy","即将上传的照片是"+currentPhoto);
46
-        new UploadTask(currentPhoto,this).executeOnExecutor(ThreadExecutor.getInstance().getExecutor());
47
-    }
29
+    private void startQuery(){
30
+        HashMap<String,String> params = new HashMap<>();
31
+        params.put("user_id", Preferences.getInstance().getLensManId());
32
+        new HttpPostTask(params){
33
+            OrderBean orderBean;
34
+            @Override
35
+            protected boolean parseResponse(String response) {
36
+                orderBean = new OrderBean();
48 37
 
49
-    @Override
50
-    public void onPhotoUploadSucceed(PhotoBean bean) {
51
-        if(bean.equals(currentPhoto)){
52
-            currentPhoto.uploadStatus =  PhotoBean.UploadStatus.STATUS_SUCCESS;
53
-            DBService.getInstance().updatePhotoBean(currentPhoto);
54
-            if(listener!=null){
55
-                listener.onPhotoUploaded(currentPhoto);
38
+                return super.parseResponse(response);
56 39
             }
57
-            currentPhoto = null;
58
-        }
59
-        startUpload();
60
-    }
61 40
 
62
-    @Override
63
-    public void onPhotoUploadFail(PhotoBean bean) {
64
-        if(bean.equals(currentPhoto)){
65
-            currentPhoto.uploadStatus =  PhotoBean.UploadStatus.STATUS_ERROR;
66
-            DBService.getInstance().updatePhotoBean(currentPhoto);
67
-            if(listener!=null){
68
-                listener.onPhotoUploadError(currentPhoto);
41
+            @Override
42
+            protected void onPostSuccess() {
43
+                super.onPostSuccess();
44
+                onNewOrderArrived(orderBean);
69 45
             }
70
-            currentPhoto = null;
71
-        }
72
-        startUpload();
73
-    }
74 46
 
75
-    public void setPhotoUploadListener(PhotoUploadListener listener){
76
-        this.listener = listener;
47
+            @Override
48
+            protected void onPostFail() {
49
+                super.onPostFail();
50
+            }
51
+        }.executeOnExecutor(ThreadExecutor.getInstance().getExecutor());
52
+
77 53
     }
78 54
 
79
-    public interface PhotoUploadListener{
80
-        void onPhotoUploaded(PhotoBean bean);
81
-        void onPhotoUploadError(PhotoBean bean);
55
+    private void onNewOrderArrived(OrderBean bean){
56
+
82 57
     }
83 58
 
84
-    public class MyBinder extends Binder {
59
+    public class OrderServiceBinder extends Binder {
85 60
 
86 61
         public OrderDealService getService(){
87 62
             return OrderDealService.this;

+ 1 - 0
app/src/main/java/ai/pai/lensman/utils/UrlContainer.java

@@ -37,6 +37,7 @@ public class UrlContainer {
37 37
 
38 38
     public static final String BRIEFS_URL = HOST_URL+"l/brief";
39 39
 
40
+    public static final String QUERY_ORDER_URL = HOST_URL+"l/query";
40 41
 
41 42
 
42 43
 }

kodo - Gogs: Go Git Service

Няма описание

Brightcells: 018d52f61d Update package django_xxx преди 8 години
..
migrations a7cbbf15a7 Update max_length for CharField преди 8 години
__init__.py 7a17d0fb90 add api wxpay & add redis relative преди 10 години
admin.py 018d52f61d Update package django_xxx преди 8 години
models.py 018d52f61d Update package django_xxx преди 8 години
tests.py fabef63211 set line_length=200 for isort преди 10 години
views.py 018d52f61d Update package django_xxx преди 8 години