ConfirmReadMemcard.java 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609
  1. package com.epson.memcardacc;
  2. import android.content.Intent;
  3. import android.os.AsyncTask;
  4. import android.os.Bundle;
  5. import android.os.StatFs;
  6. import android.view.View;
  7. import android.widget.TextView;
  8. import com.epson.mobilephone.common.wifidirect.WiFiDirectManager;
  9. import epson.common.DialogProgress;
  10. import epson.common.DialogProgressViewModel;
  11. import epson.print.ActivityIACommon;
  12. import epson.print.CommonDefine;
  13. import epson.print.Util.EPLog;
  14. import java.io.File;
  15. import java.util.ArrayList;
  16. import java.util.Calendar;
  17. import java.util.Deque;
  18. import java.util.Iterator;
  19. import java.util.Locale;
  20. public class ConfirmReadMemcard extends ActivityIACommon implements DialogProgress.DialogButtonClick {
  21. private static final int ACTIVITY_DIRECTORY_SELECT = 2;
  22. private static final int ACTIVITY_TYPE_PROGRESS = 1;
  23. private static final String DIALOG_COMMUNICATION_ERROR = "dialog_communication_error";
  24. private static final String DIALOG_COPY_RESULT_CANCEL = "dialog_copy_result";
  25. private static final String DIALOG_COPY_RESULT_COMPLETE = "dialog_copy_result_complete";
  26. private static final String DIALOG_COPY_RESULT_ERROR = "dialog_copy_result_error";
  27. private static final String DIALOG_DISK_SPACE_SHORTAGE = "dialog_disk_space_shortage";
  28. private static final String DIALOG_PRINTER_BUSY = "dialog_printer_busy";
  29. private static final String DIALOG_PROGRESS = "dialog_progress";
  30. private static final String DIALOG_WRITE_LOCAL_DIR_CANNOT_GET = "dialog_write_local_dir_cannot_get";
  31. static final int ERROR_COMMUNICATION_ERROR = 11;
  32. static final int ERROR_MEMCARD_BUSY = 10;
  33. public static final String KEY_IMAGE_LIST = "imagelist";
  34. private static final String LOG_TAG = "ConfirmReadMemcard";
  35. public static final String MEMCARD_STORAGE_TYPE = "memcard_storage_type";
  36. public static final int RESULT_BACK_TO_MEMCARD_TOP = 1;
  37. boolean doTotalFileSizeCalc = false;
  38. boolean isKeepSimleApConnect = false;
  39. boolean isTryConnectSimpleAp = false;
  40. CheckAndNextActivityTask mCheckAndNextActivityTask;
  41. private String mCopyTargetFolderName;
  42. private TextView mCopyTargetPathText;
  43. private TextView mFileNumText;
  44. private TextView mFileSizeText;
  45. private ArrayList<String> mImageList;
  46. private int mMemcardStorageType;
  47. private DialogProgressViewModel mModelDialog;
  48. private long mTotalFileSize;
  49. private TotalFileSizeCalcTask mTotalFileSizeCalcTask;
  50. private String mWriteDirectory = MemcardConfig.DEFAULT_READER_LOCAL_DIRECTORY;
  51. public void onCancelDialog(String str) {
  52. }
  53. public void onNeutralClick(String str) {
  54. }
  55. public void onPositiveClick(String str) {
  56. }
  57. protected void onCreate(Bundle bundle) {
  58. super.onCreate(bundle);
  59. setContentView(R.layout.activity_confirm_read_memcard);
  60. mModelDialog = (DialogProgressViewModel) ViewModelProviders.m2of((FragmentActivity) this).get(DialogProgressViewModel.class);
  61. mModelDialog.getDialogJob().observe(this, new Observer() {
  62. public final void onChanged(Object obj) {
  63. ConfirmReadMemcard.lambda$onCreate$0(ConfirmReadMemcard.this, (Deque) obj);
  64. }
  65. });
  66. setActionBar(R.string.memcard_title_copy_confirm, true);
  67. mFileNumText = (TextView) findViewById(R.id.textFileNumber);
  68. mFileSizeText = (TextView) findViewById(R.id.textFileSize);
  69. mFileSizeText.setText(CommonDefine.QUESTION_MARK);
  70. mCopyTargetPathText = (TextView) findViewById(R.id.textWriteFolder);
  71. Intent intent = getIntent();
  72. mImageList = intent.getStringArrayListExtra(KEY_IMAGE_LIST);
  73. if (mImageList == null) {
  74. mImageList = new ArrayList<>();
  75. }
  76. mMemcardStorageType = intent.getIntExtra("memcard_storage_type", 1);
  77. int size = mImageList.size();
  78. mFileNumText.setText(String.format(getResources().getString(R.string.memcard_file_num_format), new Object[]{Integer.valueOf(size)}));
  79. setTargetDirectory(MemcardConfig.DEFAULT_READER_LOCAL_DIRECTORY);
  80. doTotalFileSizeCalc = true;
  81. }
  82. public static /* synthetic */ void lambda$onCreate$0(ConfirmReadMemcard confirmReadMemcard, Deque deque) {
  83. String[] checkQueue = confirmReadMemcard.mModelDialog.checkQueue();
  84. if (checkQueue != null) {
  85. String str = checkQueue[0];
  86. String str2 = checkQueue[1];
  87. if (str2.equals("do_show")) {
  88. confirmReadMemcard.showDialog(str);
  89. }
  90. if (str2.equals("do_dismiss")) {
  91. confirmReadMemcard.dismissDialog(str);
  92. }
  93. }
  94. }
  95. protected void onResume() {
  96. super.onResume();
  97. if (!WiFiDirectManager.isNeedConnect(this, WiFiDirectManager.DEVICE_TYPE_PRINTER)) {
  98. isTryConnectSimpleAp = false;
  99. } else if (!this.isTryConnectSimpleAp) {
  100. isTryConnectSimpleAp = true;
  101. if (WiFiDirectManager.reconnect(this, WiFiDirectManager.DEVICE_TYPE_PRINTER, -1)) {
  102. doTotalFileSizeCalc = true;
  103. return;
  104. }
  105. }
  106. isKeepSimleApConnect = false;
  107. if (this.doTotalFileSizeCalc) {
  108. mTotalFileSizeCalcTask = new TotalFileSizeCalcTask();
  109. mTotalFileSizeCalcTask.execute(new Void[0]);
  110. doTotalFileSizeCalc = false;
  111. }
  112. }
  113. protected void onPause() {
  114. EPLog.d(LOG_TAG, "onPause()");
  115. super.onPause();
  116. }
  117. protected void onStop() {
  118. EPLog.d(LOG_TAG, "onStop()");
  119. super.onStop();
  120. if (!this.isKeepSimleApConnect) {
  121. WiFiDirectManager.disconnect(this, WiFiDirectManager.DEVICE_TYPE_PRINTER, MemcardUtil.getPrinterIpAddress(this));
  122. }
  123. }
  124. protected void onDestroy() {
  125. mTotalFileSizeCalcTask.cancel(true);
  126. super.onDestroy();
  127. }
  128. public void onBackPressed() {
  129. super.onBackPressed();
  130. isKeepSimleApConnect = true;
  131. }
  132. private void localShowDialog(String str) {
  133. mModelDialog.doShow(str);
  134. }
  135. public void setTargetDirectory(String str) {
  136. mWriteDirectory = str;
  137. mCopyTargetFolderName = getTargetFolderName();
  138. String str2 = mCopyTargetFolderName;
  139. if (str2 == null) {
  140. localShowDialog(DIALOG_WRITE_LOCAL_DIR_CANNOT_GET);
  141. str2 = "";
  142. }
  143. EPLog.i(LOG_TAG, "outdir: " + mCopyTargetFolderName);
  144. mCopyTargetPathText.setText(String.format(getResources().getString(R.string.memcard_folder_save_to_format), new Object[]{str2}));
  145. }
  146. private String getTargetFolderName() {
  147. Calendar instance = Calendar.getInstance();
  148. for (int i = 0; i < 100; i++) {
  149. String format = String.format(Locale.US, "%s/%s/%04d%02d%02d%02d%02d%02d", new Object[]{MemcardConfig.BASE_DIRECTORY, mWriteDirectory, Integer.valueOf(instance.get(1)), Integer.valueOf(instance.get(2) + 1), Integer.valueOf(instance.get(5)), Integer.valueOf(instance.get(11)), Integer.valueOf(instance.get(12)), Integer.valueOf(i)});
  150. File file = new File(format);
  151. if (!file.exists()) {
  152. boolean mkdirs = file.mkdirs();
  153. file.delete();
  154. if (mkdirs) {
  155. return format;
  156. }
  157. }
  158. }
  159. return null;
  160. }
  161. static long getTotalFileSize(ArrayList<String> arrayList) {
  162. long j = 0;
  163. if (arrayList == null) {
  164. return 0;
  165. }
  166. Iterator<String> it = arrayList.iterator();
  167. while (it.hasNext()) {
  168. j += new File(it.next()).length();
  169. }
  170. return j;
  171. }
  172. private boolean checkFileSize() {
  173. StatFs statFs = new StatFs(new File(MemcardConfig.BASE_DIRECTORY, mWriteDirectory).toString());
  174. return (mTotalFileSize / statFs.getBlockSizeLong()) + ((long) mImageList.size()) <= statFs.getAvailableBlocksLong();
  175. }
  176. public void updateFileSize(long j) {
  177. mTotalFileSize = j;
  178. mFileSizeText.setText(String.format(getResources().getString(R.string.memcard_total_file_size_format), new Object[]{Double.valueOf((mTotalFileSize) / 1000000.0d)}));
  179. }
  180. private void startCopyActivity() {
  181. Intent intent = new Intent(this, MemcardReadProgress.class);
  182. intent.putStringArrayListExtra("imageList", mImageList);
  183. intent.putExtra("target_folder_name", mCopyTargetFolderName);
  184. intent.putExtra("memcard_storage_type", mMemcardStorageType);
  185. startActivityForResult(intent, 1);
  186. isKeepSimleApConnect = true;
  187. }
  188. public void copy_dest_button_clicked(View view) {
  189. Intent intent = new Intent(this, DirectorySelecterActivity.class);
  190. intent.putExtra(DirectorySelecterActivity.PARAM_BASE_DIRECTORY, MemcardConfig.BASE_DIRECTORY);
  191. intent.putExtra(DirectorySelecterActivity.PARAM_DEFAULT_DIR, MemcardConfig.DEFAULT_READER_LOCAL_DIRECTORY);
  192. startActivityForResult(intent, 2);
  193. }
  194. public void copy_button_clicked(View view) {
  195. mCheckAndNextActivityTask = new CheckAndNextActivityTask();
  196. mCheckAndNextActivityTask.execute(new Void[0]);
  197. }
  198. /* JADX WARNING: Can't fix incorrect switch cases order */
  199. /* Code decompiled incorrectly, please refer to instructions dump. */
  200. private void showDialog(java.lang.String r12) {
  201. /*
  202. r11 = this;
  203. int r0 = r12.hashCode()
  204. r1 = 0
  205. switch(r0) {
  206. case -2116590872: goto L_0x004f;
  207. case -2003975289: goto L_0x0045;
  208. case -508401744: goto L_0x003b;
  209. case -63760199: goto L_0x0031;
  210. case -21731516: goto L_0x0027;
  211. case 1079349783: goto L_0x001d;
  212. case 1194959080: goto L_0x0013;
  213. case 1429177493: goto L_0x0009;
  214. default: goto L_0x0008;
  215. }
  216. L_0x0008:
  217. goto L_0x0059
  218. L_0x0009:
  219. java.lang.String r0 = "dialog_printer_busy"
  220. boolean r0 = r12.equals(r0)
  221. if (r0 == 0) goto L_0x0059
  222. r0 = 6
  223. goto L_0x005a
  224. L_0x0013:
  225. java.lang.String r0 = "dialog_copy_result_complete"
  226. boolean r0 = r12.equals(r0)
  227. if (r0 == 0) goto L_0x0059
  228. r0 = 3
  229. goto L_0x005a
  230. L_0x001d:
  231. java.lang.String r0 = "dialog_write_local_dir_cannot_get"
  232. boolean r0 = r12.equals(r0)
  233. if (r0 == 0) goto L_0x0059
  234. r0 = 2
  235. goto L_0x005a
  236. L_0x0027:
  237. java.lang.String r0 = "dialog_progress"
  238. boolean r0 = r12.equals(r0)
  239. if (r0 == 0) goto L_0x0059
  240. r0 = 0
  241. goto L_0x005a
  242. L_0x0031:
  243. java.lang.String r0 = "dialog_copy_result_error"
  244. boolean r0 = r12.equals(r0)
  245. if (r0 == 0) goto L_0x0059
  246. r0 = 5
  247. goto L_0x005a
  248. L_0x003b:
  249. java.lang.String r0 = "dialog_copy_result"
  250. boolean r0 = r12.equals(r0)
  251. if (r0 == 0) goto L_0x0059
  252. r0 = 4
  253. goto L_0x005a
  254. L_0x0045:
  255. java.lang.String r0 = "dialog_disk_space_shortage"
  256. boolean r0 = r12.equals(r0)
  257. if (r0 == 0) goto L_0x0059
  258. r0 = 1
  259. goto L_0x005a
  260. L_0x004f:
  261. java.lang.String r0 = "dialog_communication_error"
  262. boolean r0 = r12.equals(r0)
  263. if (r0 == 0) goto L_0x0059
  264. r0 = 7
  265. goto L_0x005a
  266. L_0x0059:
  267. r0 = -1
  268. L_0x005a:
  269. r2 = 2131624893(0x7f0e03bd, float:1.8876979E38)
  270. r3 = 2131625202(0x7f0e04f2, float:1.8877605E38)
  271. switch(r0) {
  272. case 0: goto L_0x0107;
  273. case 1: goto L_0x00eb;
  274. case 2: goto L_0x00eb;
  275. case 3: goto L_0x00d5;
  276. case 4: goto L_0x00bd;
  277. case 5: goto L_0x009f;
  278. case 6: goto L_0x0082;
  279. case 7: goto L_0x0066;
  280. default: goto L_0x0063;
  281. }
  282. L_0x0063:
  283. r0 = 0
  284. goto L_0x0115
  285. L_0x0066:
  286. r5 = 2
  287. r0 = 2131624886(0x7f0e03b6, float:1.8876964E38)
  288. java.lang.String r6 = r11.getString(r0)
  289. r0 = 2131624887(0x7f0e03b7, float:1.8876966E38)
  290. java.lang.String r7 = r11.getString(r0)
  291. java.lang.String r8 = r11.getString(r3)
  292. r9 = 0
  293. r10 = 0
  294. r4 = r12
  295. epson.common.DialogProgress r0 = epson.common.DialogProgress.newInstance(r4, r5, r6, r7, r8, r9, r10)
  296. goto L_0x0115
  297. L_0x0082:
  298. r2 = 2
  299. r0 = 2131624471(0x7f0e0217, float:1.8876123E38)
  300. java.lang.String r0 = r11.getString(r0)
  301. r1 = 2131624472(0x7f0e0218, float:1.8876125E38)
  302. java.lang.String r4 = r11.getString(r1)
  303. java.lang.String r5 = r11.getString(r3)
  304. r6 = 0
  305. r7 = 0
  306. r1 = r12
  307. r3 = r0
  308. epson.common.DialogProgress r0 = epson.common.DialogProgress.newInstance(r1, r2, r3, r4, r5, r6, r7)
  309. goto L_0x0115
  310. L_0x009f:
  311. r0 = 2
  312. java.lang.String r4 = r11.getString(r2)
  313. r1 = 2131624894(0x7f0e03be, float:1.887698E38)
  314. java.lang.String r5 = r11.getString(r1)
  315. java.lang.String r6 = r11.getString(r3)
  316. r7 = 0
  317. r8 = 0
  318. r1 = r12
  319. r2 = r0
  320. r3 = r4
  321. r4 = r5
  322. r5 = r6
  323. r6 = r7
  324. r7 = r8
  325. epson.common.DialogProgress r0 = epson.common.DialogProgress.newInstance(r1, r2, r3, r4, r5, r6, r7)
  326. goto L_0x0115
  327. L_0x00bd:
  328. r0 = 2
  329. java.lang.String r4 = r11.getString(r2)
  330. r5 = 0
  331. r6 = 0
  332. r7 = 0
  333. java.lang.String r8 = r11.getString(r3)
  334. r1 = r12
  335. r2 = r0
  336. r3 = r4
  337. r4 = r5
  338. r5 = r6
  339. r6 = r7
  340. r7 = r8
  341. epson.common.DialogProgress r0 = epson.common.DialogProgress.newInstance(r1, r2, r3, r4, r5, r6, r7)
  342. goto L_0x0115
  343. L_0x00d5:
  344. r2 = 2
  345. r0 = 2131624890(0x7f0e03ba, float:1.8876972E38)
  346. java.lang.String r0 = r11.getString(r0)
  347. r4 = 0
  348. r5 = 0
  349. r6 = 0
  350. java.lang.String r7 = r11.getString(r3)
  351. r1 = r12
  352. r3 = r0
  353. epson.common.DialogProgress r0 = epson.common.DialogProgress.newInstance(r1, r2, r3, r4, r5, r6, r7)
  354. goto L_0x0115
  355. L_0x00eb:
  356. r2 = 2
  357. r0 = 2131624883(0x7f0e03b3, float:1.8876958E38)
  358. java.lang.String r0 = r11.getString(r0)
  359. r1 = 2131624884(0x7f0e03b4, float:1.887696E38)
  360. java.lang.String r4 = r11.getString(r1)
  361. java.lang.String r5 = r11.getString(r3)
  362. r6 = 0
  363. r7 = 0
  364. r1 = r12
  365. r3 = r0
  366. epson.common.DialogProgress r0 = epson.common.DialogProgress.newInstance(r1, r2, r3, r4, r5, r6, r7)
  367. goto L_0x0115
  368. L_0x0107:
  369. r0 = 2131624885(0x7f0e03b5, float:1.8876962E38)
  370. java.lang.String r0 = r11.getString(r0)
  371. epson.common.DialogProgress r0 = epson.common.DialogProgress.newInstance(r12, r1, r0)
  372. r0.setCancelable(r1)
  373. L_0x0115:
  374. if (r0 == 0) goto L_0x011e
  375. android.support.v4.app.FragmentManager r1 = r11.getSupportFragmentManager()
  376. r0.show(r1, r12)
  377. L_0x011e:
  378. return
  379. */
  380. throw new UnsupportedOperationException("Method not decompiled: com.epson.memcardacc.ConfirmReadMemcard.showDialog(java.lang.String):void");
  381. }
  382. private void dismissDialog(String str) {
  383. DialogFragment dialogFragment = (DialogFragment) getSupportFragmentManager().findFragmentByTag(String.valueOf(str));
  384. if (dialogFragment != null) {
  385. dialogFragment.dismiss();
  386. }
  387. }
  388. protected void onActivityResult(int i, int i2, Intent intent) {
  389. switch (i) {
  390. case 1:
  391. isKeepSimleApConnect = false;
  392. if (i2 == -2) {
  393. setResult(1);
  394. finish();
  395. return;
  396. } else if (i2 != 0) {
  397. localShowDialog(DIALOG_COPY_RESULT_ERROR);
  398. return;
  399. } else {
  400. return;
  401. }
  402. case 2:
  403. if (i2 == -1) {
  404. setTargetDirectory(intent.getStringExtra(DirectorySelecterActivity.RESULT_DIRECTORY));
  405. return;
  406. }
  407. return;
  408. default:
  409. return;
  410. }
  411. }
  412. /* JADX WARNING: Removed duplicated region for block: B:12:0x0029 */
  413. /* JADX WARNING: Removed duplicated region for block: B:13:0x002f */
  414. /* JADX WARNING: Removed duplicated region for block: B:16:? A[RETURN, SYNTHETIC] */
  415. /* Code decompiled incorrectly, please refer to instructions dump. */
  416. public void onNegativeClick(java.lang.String r4) {
  417. /*
  418. r3 = this;
  419. int r0 = r4.hashCode()
  420. r1 = -508401744(0xffffffffe1b267b0, float:-4.11374E20)
  421. r2 = 1
  422. if (r0 == r1) goto L_0x001a
  423. r1 = 1194959080(0x4739a0e8, float:47520.906)
  424. if (r0 == r1) goto L_0x0010
  425. goto L_0x0024
  426. L_0x0010:
  427. java.lang.String r0 = "dialog_copy_result_complete"
  428. boolean r4 = r4.equals(r0)
  429. if (r4 == 0) goto L_0x0024
  430. r4 = 0
  431. goto L_0x0025
  432. L_0x001a:
  433. java.lang.String r0 = "dialog_copy_result"
  434. boolean r4 = r4.equals(r0)
  435. if (r4 == 0) goto L_0x0024
  436. r4 = 1
  437. goto L_0x0025
  438. L_0x0024:
  439. r4 = -1
  440. L_0x0025:
  441. switch(r4) {
  442. case 0: goto L_0x002f;
  443. case 1: goto L_0x0029;
  444. default: goto L_0x0028;
  445. }
  446. L_0x0028:
  447. goto L_0x0035
  448. L_0x0029:
  449. java.lang.String r4 = r3.mWriteDirectory
  450. r3.setTargetDirectory(r4)
  451. goto L_0x0035
  452. L_0x002f:
  453. r3.setResult(r2)
  454. r3.finish()
  455. L_0x0035:
  456. return
  457. */
  458. throw new UnsupportedOperationException("Method not decompiled: com.epson.memcardacc.ConfirmReadMemcard.onNegativeClick(java.lang.String):void");
  459. }
  460. class TotalFileSizeCalcTask extends AsyncTask<Void, Void, Long> {
  461. CifsAccess mCifsAccess = CifsAccess.getInstance();
  462. TotalFileSizeCalcTask() {
  463. }
  464. protected synchronized Long doInBackground(Void... voidArr) {
  465. if (mCifsAccess.initDefault(ConfirmReadMemcard.this, 1) == 0) {
  466. return -1L;
  467. }
  468. if (mCifsAccess.connectDefaultStorageWidthDefaultAthInfo(ConfirmReadMemcard.mMemcardStorageType) == 0) {
  469. mCifsAccess.free();
  470. return -1L;
  471. }
  472. try {
  473. Iterator it = ConfirmReadMemcard.mImageList.iterator();
  474. long j = 0;
  475. while (it.hasNext()) {
  476. if (isCancelled()) {
  477. mCifsAccess.disconnectStorage();
  478. mCifsAccess.free();
  479. return 0L;
  480. }
  481. long fileSize = mCifsAccess.getFileSize((String) it.next());
  482. if (fileSize <= 0) {
  483. return -1L;
  484. }
  485. j += fileSize;
  486. }
  487. mCifsAccess.disconnectStorage();
  488. mCifsAccess.free();
  489. return Long.valueOf(j);
  490. } finally {
  491. mCifsAccess.disconnectStorage();
  492. mCifsAccess.free();
  493. }
  494. }
  495. protected void onPostExecute(Long l) {
  496. if (l != null) {
  497. if (l.longValue() == 0) {
  498. ConfirmReadMemcard.this.localShowDialog(ConfirmReadMemcard.DIALOG_COPY_RESULT_CANCEL);
  499. } else if (l.longValue() < 0) {
  500. ConfirmReadMemcard.this.localShowDialog(ConfirmReadMemcard.DIALOG_COMMUNICATION_ERROR);
  501. } else {
  502. ConfirmReadMemcard.this.updateFileSize(l.longValue());
  503. }
  504. }
  505. ConfirmReadMemcard.mModelDialog.doDismiss(ConfirmReadMemcard.DIALOG_PROGRESS);
  506. }
  507. protected void onPreExecute() {
  508. ConfirmReadMemcard.mModelDialog.doShow(ConfirmReadMemcard.DIALOG_PROGRESS);
  509. }
  510. }
  511. class CheckAndNextActivityTask extends AsyncTask<Void, Void, Integer> {
  512. CheckAndNextActivityTask() {
  513. }
  514. protected Integer doInBackground(Void... voidArr) {
  515. if (ConfirmReadMemcard.mCopyTargetFolderName == null) {
  516. return 100;
  517. }
  518. if (isCancelled()) {
  519. return -1;
  520. }
  521. if (!ConfirmReadMemcard.this.checkFileSize()) {
  522. return 1;
  523. }
  524. if (isCancelled()) {
  525. return -1;
  526. }
  527. switch (EscprLibPrinter.checkIdleOrError(ConfirmReadMemcard.this, 60)) {
  528. case 1:
  529. return 11;
  530. case 2:
  531. return 10;
  532. default:
  533. new File(ConfirmReadMemcard.mCopyTargetFolderName).mkdir();
  534. return 0;
  535. }
  536. }
  537. protected void onCancelled() {
  538. ConfirmReadMemcard.mModelDialog.doDismiss(ConfirmReadMemcard.DIALOG_PROGRESS);
  539. }
  540. protected void onPostExecute(Integer num) {
  541. ConfirmReadMemcard.mModelDialog.doDismiss(ConfirmReadMemcard.DIALOG_PROGRESS);
  542. switch (num.intValue()) {
  543. case 0:
  544. ConfirmReadMemcard.this.startCopyActivity();
  545. return;
  546. case 1:
  547. ConfirmReadMemcard.this.localShowDialog(ConfirmReadMemcard.DIALOG_DISK_SPACE_SHORTAGE);
  548. return;
  549. case 10:
  550. ConfirmReadMemcard.this.localShowDialog(ConfirmReadMemcard.DIALOG_PRINTER_BUSY);
  551. return;
  552. case 11:
  553. ConfirmReadMemcard.this.localShowDialog(ConfirmReadMemcard.DIALOG_COMMUNICATION_ERROR);
  554. return;
  555. default:
  556. return;
  557. }
  558. }
  559. protected void onPreExecute() {
  560. ConfirmReadMemcard.mModelDialog.doShow(ConfirmReadMemcard.DIALOG_PROGRESS);
  561. if (ConfirmReadMemcard.mCopyTargetFolderName == null) {
  562. ConfirmReadMemcard.this.setTargetDirectory(MemcardConfig.DEFAULT_READER_LOCAL_DIRECTORY);
  563. }
  564. }
  565. }
  566. }