ConfirmReadMemcard.java 23 KB

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