@@ -20,8 +20,8 @@ android { |
||
20 | 20 |
applicationId "ai.pai.lensman" |
21 | 21 |
minSdkVersion MIN_SDK_VERSION as int |
22 | 22 |
targetSdkVersion TARGET_SDK_VERSION as int |
23 |
- versionCode 1021 |
|
24 |
- versionName "1.0.21" |
|
23 |
+ versionCode 1022 |
|
24 |
+ versionName "1.0.22" |
|
25 | 25 |
buildConfigField "boolean", "isTestMode", "true" |
26 | 26 |
manifestPlaceholders = [CHANNEL_NAME: "guanwang"] |
27 | 27 |
} |
@@ -53,6 +53,7 @@ class MainPresenter implements MainContract.Presenter,SyncTimeInteractor.SyncTim |
||
53 | 53 |
if (ConnectivityManager.CONNECTIVITY_ACTION.equals(intent.getAction())) { |
54 | 54 |
if(NetworkUtil.isWifiConnected(context)){ |
55 | 55 |
view.showBoxConnectedView(); |
56 |
+ App.getAppContext().startService(new Intent(App.getAppContext(), UploadService.class)); |
|
56 | 57 |
}else{ |
57 | 58 |
isBoxConnected = false; |
58 | 59 |
view.showBoxDisconnectedView(); |
@@ -9,6 +9,7 @@ import android.os.Message; |
||
9 | 9 |
|
10 | 10 |
import com.android.common.executors.ThreadExecutor; |
11 | 11 |
import com.android.common.utils.LogHelper; |
12 |
+import com.android.common.utils.NetworkUtil; |
|
12 | 13 |
|
13 | 14 |
import ai.pai.lensman.bean.PhotoBean; |
14 | 15 |
import ai.pai.lensman.db.DBService; |
@@ -45,6 +46,9 @@ public class UploadService extends Service implements UploadTask.OnPhotoUploadLi |
||
45 | 46 |
} |
46 | 47 |
|
47 | 48 |
private synchronized void startUpload(){ |
49 |
+ if(!NetworkUtil.isWifiConnected(this)){ |
|
50 |
+ return; |
|
51 |
+ } |
|
48 | 52 |
if(currentPhoto!=null){ |
49 | 53 |
LogHelper.d(TAG,"当前有图片正在上传"+currentPhoto); |
50 | 54 |
return; |
@@ -1,8 +1,13 @@ |
||
1 | 1 |
package ai.pai.lensman.session; |
2 | 2 |
|
3 |
+import android.content.BroadcastReceiver; |
|
4 |
+import android.content.Context; |
|
3 | 5 |
import android.content.Intent; |
6 |
+import android.content.IntentFilter; |
|
7 |
+import android.net.ConnectivityManager; |
|
4 | 8 |
|
5 | 9 |
import com.android.common.utils.LogHelper; |
10 |
+import com.android.common.utils.NetworkUtil; |
|
6 | 11 |
|
7 | 12 |
import java.util.ArrayList; |
8 | 13 |
import java.util.Timer; |
@@ -32,6 +37,17 @@ public class SessionPresenter implements SessionContract.Presenter, SessionInter |
||
32 | 37 |
|
33 | 38 |
private static final String TAG = "SessionPresenter"; |
34 | 39 |
|
40 |
+ private BroadcastReceiver wifiReceiver = new BroadcastReceiver() { |
|
41 |
+ @Override |
|
42 |
+ public void onReceive(Context context, Intent intent) { |
|
43 |
+ if (ConnectivityManager.CONNECTIVITY_ACTION.equals(intent.getAction())) { |
|
44 |
+ if(NetworkUtil.isWifiConnected(context)){ |
|
45 |
+ App.getAppContext().startService(new Intent(App.getAppContext(), UploadService.class)); |
|
46 |
+ } |
|
47 |
+ } |
|
48 |
+ } |
|
49 |
+ }; |
|
50 |
+ |
|
35 | 51 |
public SessionPresenter(SessionBean sessionBean, SessionContract.View view) { |
36 | 52 |
this.sessionView = view; |
37 | 53 |
this.sessionBean = sessionBean; |
@@ -63,10 +79,12 @@ public class SessionPresenter implements SessionContract.Presenter, SessionInter |
||
63 | 79 |
} |
64 | 80 |
},1000,1000); |
65 | 81 |
Preferences.getInstance().setCurrentSession(sessionBean.sessionId); |
82 |
+ registerWifiChangeReceiver(); |
|
66 | 83 |
} |
67 | 84 |
|
68 | 85 |
@Override |
69 | 86 |
public void stop() { |
87 |
+ App.getAppContext().unregisterReceiver(wifiReceiver); |
|
70 | 88 |
boxStatusInteractor.cancelJob(); |
71 | 89 |
interactor.endSession(); |
72 | 90 |
refreshTimer.cancel(); |
@@ -150,4 +168,10 @@ public class SessionPresenter implements SessionContract.Presenter, SessionInter |
||
150 | 168 |
sessionView.showBoxDisconnectedView(boxStatusCode,boxStatus); |
151 | 169 |
} |
152 | 170 |
} |
171 |
+ |
|
172 |
+ private void registerWifiChangeReceiver() { |
|
173 |
+ IntentFilter filter = new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION); |
|
174 |
+ App.getAppContext().registerReceiver(wifiReceiver,filter); |
|
175 |
+ } |
|
176 |
+ |
|
153 | 177 |
} |