|
@@ -141,67 +141,7 @@ public class MainActivity extends AppCompatActivity {
|
|
|
if (!StringUtils.isNullOrEmpty(time)) {
|
|
|
LocalStorage.getInstance().getSession().setTime(Long.parseLong(time));
|
|
|
}
|
|
|
- String qrcode_url = configMap.get(SystemConfigConstant.cabinet_take_object_qrcode_url);
|
|
|
-
|
|
|
- try {
|
|
|
- ICSPClient.download(qrcode_url, new Callback() {
|
|
|
- @Override
|
|
|
- public void onFailure(@NotNull Call call, @NotNull IOException e) {
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException {
|
|
|
- InputStream is = null;
|
|
|
- byte[] buf = new byte[2048];
|
|
|
- int len = 0;
|
|
|
- FileOutputStream fos = null;
|
|
|
- final String destFileDir = "res/drawable/";
|
|
|
- String destFileName = "e_mp_qrcode_8x8.jpg";
|
|
|
- //储存下载文件的目录
|
|
|
- File dir = new File(getApplication().getFilesDir().getAbsolutePath() + "/" +destFileDir);
|
|
|
- if (!dir.exists()) {
|
|
|
- dir.mkdirs();
|
|
|
- }
|
|
|
-// destFileName = apk_url.substring(apk_url.lastIndexOf('/'), apk_url.length() - 1);
|
|
|
- File file = new File(dir, destFileName);
|
|
|
-
|
|
|
- try {
|
|
|
-
|
|
|
- is = response.body().byteStream();
|
|
|
- long total = response.body().contentLength();
|
|
|
- fos = new FileOutputStream(file);
|
|
|
- long sum = 0;
|
|
|
- while ((len = is.read(buf)) != -1) {
|
|
|
- fos.write(buf, 0, len);
|
|
|
- sum += len;
|
|
|
- int progress = (int) (sum * 1.0f / total * 100);
|
|
|
- //下载中更新进度条
|
|
|
- listener.onDownloading(progress);
|
|
|
- }
|
|
|
- fos.flush();
|
|
|
- //下载完成
|
|
|
- listener.onDownloadSuccess(file);
|
|
|
- } catch (Exception e) {
|
|
|
- listener.onDownloadFailed(e);
|
|
|
- }finally {
|
|
|
- try {
|
|
|
- if (is != null) {
|
|
|
- is.close();
|
|
|
- }
|
|
|
- if (fos != null) {
|
|
|
- fos.close();
|
|
|
- }
|
|
|
- } catch (IOException e) {
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
- }
|
|
|
- }, listener);
|
|
|
- } catch (Exception e) {
|
|
|
|
|
|
- }
|
|
|
Log.i(TAG, "onResponse: 获取系统配置成功! ");
|
|
|
} else {
|
|
|
Log.w(TAG, "onResponse: code==>" + readValue.getCode() + ", msg==>" + readValue.getMsg());
|
|
@@ -236,7 +176,7 @@ public class MainActivity extends AppCompatActivity {
|
|
|
try {
|
|
|
ShellVo shellVo = JacksonUtils.objectmapper.readValue(msg.getPayload(), ShellVo.class);
|
|
|
ShellVo result = shellVo;
|
|
|
- if (shellVo != null && shellVo.getScript() != null && "".equals(shellVo.getScript()) && shellVo.getScript().length() > 0) {
|
|
|
+ if (shellVo != null && shellVo.getScript() != null && !"".equals(shellVo.getScript()) && shellVo.getScript().length() > 0) {
|
|
|
BaseUtils.executeShell(shellVo);
|
|
|
} else {
|
|
|
result = new ShellVo();
|