@@ -49,7 +49,7 @@ android {
|
||
| 49 | 49 |
zipAlignEnabled false |
| 50 | 50 |
minifyEnabled false |
| 51 | 51 |
shrinkResources false |
| 52 |
- buildConfigField "boolean", "isTestMode", "true" |
|
| 52 |
+ buildConfigField "boolean", "isTestMode", "false" |
|
| 53 | 53 |
signingConfig signingConfigs.releaseConfig |
| 54 | 54 |
} |
| 55 | 55 |
} |
@@ -71,8 +71,8 @@ public class MainActivity extends BaseActivity implements MainContract.View {
|
||
| 71 | 71 |
} |
| 72 | 72 |
|
| 73 | 73 |
@Override |
| 74 |
- public void showSnackBar(String msg) {
|
|
| 75 |
- |
|
| 74 |
+ public void showSnackBar(int stringId) {
|
|
| 75 |
+ Toast.makeText(this,stringId,Toast.LENGTH_SHORT).show(); |
|
| 76 | 76 |
} |
| 77 | 77 |
|
| 78 | 78 |
@Override |
@@ -10,7 +10,7 @@ public class MainContract {
|
||
| 10 | 10 |
|
| 11 | 11 |
interface View extends BaseView {
|
| 12 | 12 |
|
| 13 |
- void showSnackBar(String msg); |
|
| 13 |
+ void showSnackBar(int stringId); |
|
| 14 | 14 |
void showBoxDisconnectedView(); |
| 15 | 15 |
void showBoxConnectedView(); |
| 16 | 16 |
void showEmptyView(); |
@@ -17,6 +17,7 @@ import java.util.ArrayList; |
||
| 17 | 17 |
import java.util.Date; |
| 18 | 18 |
|
| 19 | 19 |
import ai.pai.lensman.App; |
| 20 |
+import ai.pai.lensman.R; |
|
| 20 | 21 |
import ai.pai.lensman.base.BaseInteractor; |
| 21 | 22 |
import ai.pai.lensman.bean.PhotoBean; |
| 22 | 23 |
import ai.pai.lensman.bean.SessionBean; |
@@ -26,7 +27,7 @@ import ai.pai.lensman.service.OrderDealService; |
||
| 26 | 27 |
import ai.pai.lensman.service.UploadService; |
| 27 | 28 |
|
| 28 | 29 |
class MainPresenter implements MainContract.Presenter,BaseInteractor.InteractorListener<ArrayList<String>>, |
| 29 |
- UploadService.PhotoUploadListener, QueryBoxStatusInteractor.BoxStatusListener {
|
|
| 30 |
+ UploadService.PhotoUploadListener, QueryBoxStatusInteractor.BoxStatusListener,OrderDealService.OrderServiceListener {
|
|
| 30 | 31 |
|
| 31 | 32 |
private int sessionSeq; |
| 32 | 33 |
private String lensmanId; |
@@ -38,7 +39,11 @@ class MainPresenter implements MainContract.Presenter,BaseInteractor.InteractorL |
||
| 38 | 39 |
private FetchSessionIdsInteractor interactor; |
| 39 | 40 |
private QueryBoxStatusInteractor boxStatusInteractor; |
| 40 | 41 |
|
| 41 |
- private ServiceConnection serviceConnection; |
|
| 42 |
+ private ServiceConnection uploadServiceConnection; |
|
| 43 |
+ private ServiceConnection orderServiceConnection; |
|
| 44 |
+ |
|
| 45 |
+ private boolean isBoxConnected = true; |
|
| 46 |
+ |
|
| 42 | 47 |
|
| 43 | 48 |
private BroadcastReceiver wifiReceiver = new BroadcastReceiver() {
|
| 44 | 49 |
@Override |
@@ -47,6 +52,7 @@ class MainPresenter implements MainContract.Presenter,BaseInteractor.InteractorL |
||
| 47 | 52 |
if(NetworkUtil.isWifiConnected(context)){
|
| 48 | 53 |
view.showBoxConnectedView(); |
| 49 | 54 |
}else{
|
| 55 |
+ isBoxConnected = false; |
|
| 50 | 56 |
view.showBoxDisconnectedView(); |
| 51 | 57 |
} |
| 52 | 58 |
} |
@@ -59,7 +65,7 @@ class MainPresenter implements MainContract.Presenter,BaseInteractor.InteractorL |
||
| 59 | 65 |
sessionIds = new ArrayList<>(); |
| 60 | 66 |
interactor = new FetchSessionIdsInteractor(lensmanId,100,this); |
| 61 | 67 |
boxStatusInteractor = new QueryBoxStatusInteractor(this); |
| 62 |
- serviceConnection = new ServiceConnection() {
|
|
| 68 |
+ uploadServiceConnection = new ServiceConnection() {
|
|
| 63 | 69 |
@Override |
| 64 | 70 |
public void onServiceConnected(ComponentName componentName, IBinder iBinder) {
|
| 65 | 71 |
((UploadService.MyBinder) iBinder).getService().setPhotoUploadListener(MainPresenter.this); |
@@ -70,6 +76,18 @@ class MainPresenter implements MainContract.Presenter,BaseInteractor.InteractorL |
||
| 70 | 76 |
|
| 71 | 77 |
} |
| 72 | 78 |
}; |
| 79 |
+ |
|
| 80 |
+ orderServiceConnection = new ServiceConnection() {
|
|
| 81 |
+ @Override |
|
| 82 |
+ public void onServiceConnected(ComponentName componentName, IBinder iBinder) {
|
|
| 83 |
+ ((OrderDealService.OrderServiceBinder) iBinder).getService().setOrderServiceListener(MainPresenter.this); |
|
| 84 |
+ } |
|
| 85 |
+ |
|
| 86 |
+ @Override |
|
| 87 |
+ public void onServiceDisconnected(ComponentName componentName) {
|
|
| 88 |
+ |
|
| 89 |
+ } |
|
| 90 |
+ }; |
|
| 73 | 91 |
} |
| 74 | 92 |
|
| 75 | 93 |
|
@@ -86,6 +104,7 @@ class MainPresenter implements MainContract.Presenter,BaseInteractor.InteractorL |
||
| 86 | 104 |
} |
| 87 | 105 |
if(sessionIds==null || sessionIds.size()<1){
|
| 88 | 106 |
view.setNewSessionBtnEnabled(false); |
| 107 |
+ view.showSnackBar(R.string.prepare_in_processing); |
|
| 89 | 108 |
}else{
|
| 90 | 109 |
view.setNewSessionBtnEnabled(true); |
| 91 | 110 |
} |
@@ -100,14 +119,18 @@ class MainPresenter implements MainContract.Presenter,BaseInteractor.InteractorL |
||
| 100 | 119 |
registerWifiChangeReceiver(); |
| 101 | 120 |
boxStatusInteractor.startJob(); |
| 102 | 121 |
App.getAppContext().startService(new Intent(App.getAppContext(), OrderDealService.class)); |
| 122 |
+ App.getAppContext().bindService(new Intent(App.getAppContext(),OrderDealService.class), |
|
| 123 |
+ orderServiceConnection, Context.BIND_AUTO_CREATE); |
|
| 103 | 124 |
App.getAppContext().startService(new Intent(App.getAppContext(), UploadService.class)); |
| 104 |
- App.getAppContext().bindService(new Intent(App.getAppContext(),UploadService.class),serviceConnection, Context.BIND_AUTO_CREATE); |
|
| 125 |
+ App.getAppContext().bindService(new Intent(App.getAppContext(),UploadService.class), |
|
| 126 |
+ uploadServiceConnection, Context.BIND_AUTO_CREATE); |
|
| 105 | 127 |
} |
| 106 | 128 |
|
| 107 | 129 |
@Override |
| 108 | 130 |
public void stop() {
|
| 109 | 131 |
boxStatusInteractor.cancelJob(); |
| 110 |
- App.getAppContext().unbindService(serviceConnection); |
|
| 132 |
+ App.getAppContext().unbindService(uploadServiceConnection); |
|
| 133 |
+ App.getAppContext().unbindService(orderServiceConnection); |
|
| 111 | 134 |
App.getAppContext().unregisterReceiver(wifiReceiver); |
| 112 | 135 |
} |
| 113 | 136 |
|
@@ -207,9 +230,24 @@ class MainPresenter implements MainContract.Presenter,BaseInteractor.InteractorL |
||
| 207 | 230 |
@Override |
| 208 | 231 |
public void onBoxStatusFetched(String boxNo, String boxStatus, String boxStatusCode) {
|
| 209 | 232 |
if("0".equals(boxStatusCode)){
|
| 233 |
+ isBoxConnected = true; |
|
| 210 | 234 |
view.showBoxConnectedView(); |
| 211 | 235 |
}else{
|
| 236 |
+ isBoxConnected = false; |
|
| 212 | 237 |
view.showBoxDisconnectedView(); |
| 238 |
+ boxStatusInteractor.startJob(); |
|
| 213 | 239 |
} |
| 214 | 240 |
} |
| 241 |
+ |
|
| 242 |
+ @Override |
|
| 243 |
+ public void onOrderArrived() {
|
|
| 244 |
+ if(!isBoxConnected){
|
|
| 245 |
+ view.showSnackBar(R.string.new_order_and_check_box); |
|
| 246 |
+ } |
|
| 247 |
+ } |
|
| 248 |
+ |
|
| 249 |
+ @Override |
|
| 250 |
+ public void onOrderCompleted() {
|
|
| 251 |
+ |
|
| 252 |
+ } |
|
| 215 | 253 |
} |
@@ -11,6 +11,7 @@ import android.text.TextUtils; |
||
| 11 | 11 |
|
| 12 | 12 |
import com.android.common.executors.ThreadExecutor; |
| 13 | 13 |
import com.android.common.utils.LogHelper; |
| 14 |
+import com.android.common.utils.NetworkUtil; |
|
| 14 | 15 |
|
| 15 | 16 |
import org.json.JSONArray; |
| 16 | 17 |
import org.json.JSONObject; |
@@ -36,6 +37,8 @@ public class OrderDealService extends Service implements Handler.Callback{
|
||
| 36 | 37 |
|
| 37 | 38 |
private ArrayList<OrderBean> orderList; |
| 38 | 39 |
private Handler handler; |
| 40 |
+ private OrderServiceListener listener; |
|
| 41 |
+ |
|
| 39 | 42 |
private static final int MSG_QUERY_ORDER = 2001; |
| 40 | 43 |
|
| 41 | 44 |
@Override |
@@ -98,6 +101,13 @@ public class OrderDealService extends Service implements Handler.Callback{
|
||
| 98 | 101 |
@Override |
| 99 | 102 |
protected void onPostSuccess() {
|
| 100 | 103 |
super.onPostSuccess(); |
| 104 |
+ if(listener!= null) {
|
|
| 105 |
+ if (orderList != null && orderList.size() > 0) {
|
|
| 106 |
+ listener.onOrderArrived(); |
|
| 107 |
+ }else{
|
|
| 108 |
+ listener.onOrderCompleted(); |
|
| 109 |
+ } |
|
| 110 |
+ } |
|
| 101 | 111 |
dealOrder(); |
| 102 | 112 |
} |
| 103 | 113 |
|
@@ -372,4 +382,13 @@ public class OrderDealService extends Service implements Handler.Callback{
|
||
| 372 | 382 |
} |
| 373 | 383 |
} |
| 374 | 384 |
|
| 385 |
+ public void setOrderServiceListener(OrderServiceListener listener){
|
|
| 386 |
+ this.listener = listener; |
|
| 387 |
+ } |
|
| 388 |
+ |
|
| 389 |
+ public interface OrderServiceListener{
|
|
| 390 |
+ void onOrderArrived(); |
|
| 391 |
+ void onOrderCompleted(); |
|
| 392 |
+ } |
|
| 393 |
+ |
|
| 375 | 394 |
} |
@@ -148,5 +148,7 @@ |
||
| 148 | 148 |
|
| 149 | 149 |
<string name="input_no_water_print_price">请设定去水印照片价格(单位 分)</string> |
| 150 | 150 |
|
| 151 |
+ <string name="prepare_in_processing">正在准备中,请稍后进行拍摄</string> |
|
| 151 | 152 |
|
| 153 |
+ <string name="new_order_and_check_box">您后台有新的订单,请检查box是否连接</string> |
|
| 152 | 154 |
</resources> |