@@ -55,6 +55,9 @@ public class SessionPresenter implements SessionContract.Presenter, SessionInter |
||
| 55 | 55 |
|
| 56 | 56 |
@Override |
| 57 | 57 |
public void onSessionStartError(String session) {
|
| 58 |
+ if (!isWorking) {
|
|
| 59 |
+ return; |
|
| 60 |
+ } |
|
| 58 | 61 |
sessionView.showToast("session启动失败,自动重试中");
|
| 59 | 62 |
interactor.startSession(); |
| 60 | 63 |
} |
@@ -3,21 +3,27 @@ package ai.pai.lensman.settings; |
||
| 3 | 3 |
import android.os.Bundle; |
| 4 | 4 |
import android.support.annotation.Nullable; |
| 5 | 5 |
import android.support.v7.app.AppCompatActivity; |
| 6 |
+import android.widget.EditText; |
|
| 7 |
+import android.widget.Toast; |
|
| 6 | 8 |
|
| 7 | 9 |
import ai.pai.lensman.R; |
| 8 | 10 |
import ai.pai.lensman.base.BaseActivity; |
| 11 |
+import ai.pai.lensman.utils.BoxUrlContainer; |
|
| 12 |
+import butterknife.BindView; |
|
| 9 | 13 |
import butterknife.ButterKnife; |
| 10 | 14 |
import butterknife.OnClick; |
| 11 | 15 |
|
| 12 | 16 |
|
| 13 | 17 |
public class SettingsActivity extends BaseActivity {
|
| 14 | 18 |
|
| 19 |
+ @BindView(R.id.et_box_ip) EditText boxIPET; |
|
| 15 | 20 |
|
| 16 | 21 |
@Override |
| 17 | 22 |
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
| 18 | 23 |
super.onCreate(savedInstanceState); |
| 19 | 24 |
setContentView(R.layout.activity_settings); |
| 20 | 25 |
unbinder = ButterKnife.bind(this); |
| 26 |
+ boxIPET.setText(BoxUrlContainer.BOX_IP); |
|
| 21 | 27 |
} |
| 22 | 28 |
|
| 23 | 29 |
@OnClick(R.id.title_bar_back_layout) |
@@ -40,4 +46,10 @@ public class SettingsActivity extends BaseActivity {
|
||
| 40 | 46 |
|
| 41 | 47 |
} |
| 42 | 48 |
|
| 49 |
+ @OnClick(R.id.btn_confirm_ip) |
|
| 50 |
+ void resetIP(){
|
|
| 51 |
+ BoxUrlContainer.resetIPHost( boxIPET.getText().toString()); |
|
| 52 |
+ Toast.makeText(this,"IP已设置为"+BoxUrlContainer.BOX_IP,Toast.LENGTH_SHORT).show(); |
|
| 53 |
+ } |
|
| 54 |
+ |
|
| 43 | 55 |
} |
@@ -1,18 +1,36 @@ |
||
| 1 | 1 |
package ai.pai.lensman.utils; |
| 2 | 2 |
|
| 3 |
-public final class BoxUrlContainer {
|
|
| 3 |
+public class BoxUrlContainer {
|
|
| 4 | 4 |
|
| 5 |
- private static final String BASE_URL = "http://192.168.8.100:8002/"; |
|
| 5 |
+ public static String BOX_IP = "192.168.8.100"; |
|
| 6 | 6 |
|
| 7 |
- public static final String SESSION_START_URL = BASE_URL+"session_start"; |
|
| 7 |
+ private static String BASE_URL = "http://" + BOX_IP + ":8002/"; |
|
| 8 | 8 |
|
| 9 |
- public static final String SESSION_END_URL = BASE_URL+"session_end"; |
|
| 9 |
+ public static String SESSION_START_URL = BASE_URL + "session_start"; |
|
| 10 | 10 |
|
| 11 |
- public static final String DELETE_PHOTO_URL = BASE_URL+"delete_photo"; |
|
| 11 |
+ public static String SESSION_END_URL = BASE_URL + "session_end"; |
|
| 12 | 12 |
|
| 13 |
- public static final String FETCH_THUMBNAIL_URL = BASE_URL+"fetch_thumbnail"; |
|
| 13 |
+ public static String DELETE_PHOTO_URL = BASE_URL + "delete_photo"; |
|
| 14 | 14 |
|
| 15 |
- public static final String PHOTO_PATH_PREFIX_URL = BASE_URL+"static/"; |
|
| 15 |
+ public static String FETCH_THUMBNAIL_URL = BASE_URL + "fetch_thumbnail"; |
|
| 16 |
+ |
|
| 17 |
+ public static String PHOTO_PATH_PREFIX_URL = BASE_URL + "static/"; |
|
| 18 |
+ |
|
| 19 |
+ public static void resetIPHost(String ip) {
|
|
| 20 |
+ BOX_IP = ip; |
|
| 21 |
+ |
|
| 22 |
+ BASE_URL = "http://" + BOX_IP + ":8002/"; |
|
| 23 |
+ |
|
| 24 |
+ SESSION_START_URL = BASE_URL + "session_start"; |
|
| 25 |
+ |
|
| 26 |
+ SESSION_END_URL = BASE_URL + "session_end"; |
|
| 27 |
+ |
|
| 28 |
+ DELETE_PHOTO_URL = BASE_URL + "delete_photo"; |
|
| 29 |
+ |
|
| 30 |
+ FETCH_THUMBNAIL_URL = BASE_URL + "fetch_thumbnail"; |
|
| 31 |
+ |
|
| 32 |
+ PHOTO_PATH_PREFIX_URL = BASE_URL + "static/"; |
|
| 33 |
+ } |
|
| 16 | 34 |
|
| 17 | 35 |
|
| 18 | 36 |
} |
@@ -3,6 +3,7 @@ package ai.pai.lensman.utils; |
||
| 3 | 3 |
import android.os.AsyncTask; |
| 4 | 4 |
|
| 5 | 5 |
import com.android.common.http.HttpUtils; |
| 6 |
+import com.android.common.utils.LogHelper; |
|
| 6 | 7 |
|
| 7 | 8 |
import java.util.HashMap; |
| 8 | 9 |
|
@@ -21,6 +22,7 @@ public class HttpPostTask extends AsyncTask<String,Integer,Boolean> {
|
||
| 21 | 22 |
@Override |
| 22 | 23 |
protected Boolean doInBackground(String... params) {
|
| 23 | 24 |
String rootUrl = params[0]; |
| 25 |
+ LogHelper.d("czy","http url = "+rootUrl);
|
|
| 24 | 26 |
if(rootUrl.contains("?")){
|
| 25 | 27 |
rootUrl+="&platform=android"; |
| 26 | 28 |
}else{
|
@@ -60,9 +60,10 @@ |
||
| 60 | 60 |
</LinearLayout> |
| 61 | 61 |
|
| 62 | 62 |
<ScrollView |
| 63 |
- android:layout_below="@id/title_bar_with_back_btn" |
|
| 64 | 63 |
android:layout_width="match_parent" |
| 65 |
- android:layout_height="match_parent"> |
|
| 64 |
+ android:layout_height="match_parent" |
|
| 65 |
+ android:layout_below="@id/title_bar_with_back_btn" |
|
| 66 |
+ > |
|
| 66 | 67 |
|
| 67 | 68 |
<LinearLayout |
| 68 | 69 |
android:layout_marginTop="8dp" |
@@ -156,7 +157,64 @@ |
||
| 156 | 157 |
|
| 157 | 158 |
</LinearLayout> |
| 158 | 159 |
|
| 160 |
+ |
|
| 161 |
+ <View |
|
| 162 |
+ android:layout_width="match_parent" |
|
| 163 |
+ android:layout_height="1px" |
|
| 164 |
+ android:background="@color/text_hint_grey_color"/> |
|
| 165 |
+ |
|
| 166 |
+ <LinearLayout |
|
| 167 |
+ android:id="@+id/layout_box_ip" |
|
| 168 |
+ android:layout_width="match_parent" |
|
| 169 |
+ android:layout_height="wrap_content" |
|
| 170 |
+ android:paddingRight="6dp" |
|
| 171 |
+ android:orientation="vertical"> |
|
| 172 |
+ |
|
| 173 |
+ <TextView |
|
| 174 |
+ android:layout_width="match_parent" |
|
| 175 |
+ android:layout_height="44dp" |
|
| 176 |
+ android:gravity="center_vertical" |
|
| 177 |
+ android:text="@string/box_set_ip" |
|
| 178 |
+ android:paddingLeft="10dp" |
|
| 179 |
+ android:textColor="@color/dark_grey" |
|
| 180 |
+ android:textSize="16sp" /> |
|
| 181 |
+ |
|
| 182 |
+ <EditText |
|
| 183 |
+ android:id="@+id/et_box_ip" |
|
| 184 |
+ android:layout_width="match_parent" |
|
| 185 |
+ android:layout_height="44dp" |
|
| 186 |
+ android:layout_marginLeft="8dp" |
|
| 187 |
+ android:layout_marginRight="8dp" |
|
| 188 |
+ android:gravity="center" |
|
| 189 |
+ android:textSize="16sp" |
|
| 190 |
+ android:textColor="@color/dark_grey" |
|
| 191 |
+ /> |
|
| 192 |
+ |
|
| 193 |
+ <Button |
|
| 194 |
+ android:id="@+id/btn_confirm_ip" |
|
| 195 |
+ android:layout_width="wrap_content" |
|
| 196 |
+ android:layout_height="wrap_content" |
|
| 197 |
+ android:text="@string/ok" |
|
| 198 |
+ android:layout_gravity="center_horizontal" |
|
| 199 |
+ android:textSize="16sp" |
|
| 200 |
+ android:textColor="@color/white" |
|
| 201 |
+ android:background="@drawable/print_rounded_rect_bg" |
|
| 202 |
+ android:layout_marginTop="8dp" |
|
| 203 |
+ android:layout_marginBottom="8dp" |
|
| 204 |
+ android:paddingLeft="35dp" |
|
| 205 |
+ android:paddingRight="35dp" |
|
| 206 |
+ android:paddingBottom="5dp" |
|
| 207 |
+ android:paddingTop="5dp"/> |
|
| 208 |
+ |
|
| 209 |
+ |
|
| 210 |
+ </LinearLayout> |
|
| 211 |
+ |
|
| 159 | 212 |
</LinearLayout> |
| 213 |
+ |
|
| 214 |
+ |
|
| 215 |
+ |
|
| 216 |
+ |
|
| 217 |
+ |
|
| 160 | 218 |
</ScrollView> |
| 161 | 219 |
|
| 162 | 220 |
|
@@ -124,4 +124,7 @@ |
||
| 124 | 124 |
<string name="contact_us">联系我们</string> |
| 125 | 125 |
|
| 126 | 126 |
<string name="about_us">关于我们</string> |
| 127 |
+ |
|
| 128 |
+ <string name="box_set_ip">BOX IP设置</string> |
|
| 129 |
+ |
|
| 127 | 130 |
</resources> |