package com.epson.memcardacc;

import android.arch.lifecycle.Observer;
import android.arch.lifecycle.ViewModelProviders;
import android.content.Context;
import android.content.Intent;
import android.os.AsyncTask;
import android.os.Bundle;


import android.support.p000v4.app.DialogFragment;
import android.support.p000v4.app.FragmentActivity;
import android.view.View;
import android.widget.TextView;
import com.epson.memcardacc.MemCardWriteConvertViewModel;
import com.epson.mobilephone.common.wifidirect.WiFiDirectManager;
import epson.common.DialogProgress;
import epson.common.DialogProgressViewModel;
import epson.print.ActivityIACommon;

import epson.print.MyPrinter;
import epson.print.Util.EPLog;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Deque;
import java.util.Locale;

public class ConfirmWriteMemcard extends ActivityIACommon implements DialogProgress.DialogButtonClick {
    private static final int ACTIVITY_TYPE_PROGRESS = 1;
    private static final String DIALOG_CHECK_AND_NEXT = "dialog_check_and_next";
    private static final String DIALOG_COMMUNICATION_ERROR = "dialog_communication_error";
    private static final String DIALOG_COPY_RESULT_CANCEL = "dialog_copy_result_cancel";
    private static final String DIALOG_COPY_RESULT_COMPLETE = "dialog_copy_result_complete";
    private static final String DIALOG_COPY_RESULT_ERROR = "dialog_copy_result_error";
    private static final String DIALOG_DISK_SPACE_SHORTAGE = "dialog_disk_space_shortage";
    private static final String DIALOG_FILE_CONVERT = "dialog_file_convert";
    private static final String DIALOG_FILE_WRITE_ERROR = "dialog_file_write_error";
    private static final String DIALOG_PRINTER_BUSY = "dialog_printer_busy";
    private static final String DIALOG_STORAGE_CONNECT_ERROR = "dialog_storage_connect_error";
    private static final String DIALOG_TARGET_DIRECTORY_NAME_TASK = "dialog_target_directy_name_task";
    static final int ERROR_COMMUNICATION_ERROR = 11;
    static final int ERROR_FILE_WRITE_ERROR = 12;
    static final int ERROR_MEMCARD_BUSY = 10;
    private static final String KEY_IMAGE_LIST = "imagelist";
    private static final String LOG_TAG = "ConfirmWriteMemcard";
    public static final int RESULT_BACK_TO_MEMCARD_TOP = 1;
    boolean doDirectoryNameTask = false;
    boolean isKeepSimleApConnect = false;
    boolean isTryConnectSimpleAp = false;
    private CheckAndNextActivityTask mCheckAndNextActivity;
    private String mCopyTargetFolderName;
    private TextView mCopyTargetPathText;
    private TextView mCopyTargetPrinter;
    private DirectoryNameTask mDirectoryNameTask = null;
    private TextView mFileNumText;
    private TextView mFileSizeText;
    private ArrayList<String> mImageList;
    private int mMemcardStorageType;
    private DialogProgressViewModel mModelDialog;
    private long mTotalFileSize;

    public void onCancelDialog(String str) {
    }

    public void onNeutralClick(String str) {
    }

    public void onPositiveClick(String str) {
    }

    @NonNull
    public static Intent getStartIntent(@NonNull Context context, @NonNull ArrayList<String> arrayList) {
        Intent intent = new Intent(context, ConfirmWriteMemcard.class);
        intent.putStringArrayListExtra("imagelist", arrayList);
        return intent;
    }

    protected void onCreate(Bundle bundle) {
        super.onCreate(bundle);
        setContentView((int) R.layout.activity_confirm_write_memcard);
        mModelDialog = (DialogProgressViewModel) ViewModelProviders.m2of((FragmentActivity) this).get(DialogProgressViewModel.class);
        mModelDialog.getDialogJob().observe(this, new Observer() {
            public final void onChanged(Object obj) {
                ConfirmWriteMemcard.lambda$onCreate$0(ConfirmWriteMemcard.this, (Deque) obj);
            }
        });
        setActionBar((int) R.string.memcard_title_copy_confirm, true);
        mFileNumText = (TextView) findViewById(R.id.textFileNumber);
        mFileSizeText = (TextView) findViewById(R.id.textFileSize);
        mCopyTargetPrinter = (TextView) findViewById(R.id.textWritePrt);
        mCopyTargetPathText = (TextView) findViewById(R.id.textWriteFolder);
        mCopyTargetPathText.setText("");
        mImageList = null;
        mCopyTargetPrinter.setText(String.format(getResources().getString(R.string.memcard_printer_save_to_format), new Object[]{MyPrinter.getCurPrinter(this).getName()}));
        doDirectoryNameTask = true;
        observeImageConvertFromIntent(getIntent());
    }

    public static /* synthetic */ void lambda$onCreate$0(ConfirmWriteMemcard confirmWriteMemcard, Deque deque) {
        String[] checkQueue = confirmWriteMemcard.mModelDialog.checkQueue();
        if (checkQueue != null) {
            String str = checkQueue[0];
            String str2 = checkQueue[1];
            if (str2.equals("do_show")) {
                confirmWriteMemcard.showDialog(str);
            }
            if (str2.equals("do_dismiss")) {
                confirmWriteMemcard.dismissDialog(str);
            }
        }
    }

    private void observeImageConvertFromIntent(@Nullable Intent intent) {
        if (intent == null) {
            finish();
            return;
        }
        ArrayList<String> startArgumentFileList = getStartArgumentFileList(intent);
        if (startArgumentFileList == null) {
            finish();
            return;
        }
        updateFileInfo(startArgumentFileList);
        observeImageConvert(startArgumentFileList);
    }

    private ArrayList<String> getStartArgumentFileList(@Nullable Intent intent) {
        if (intent == null) {
            return null;
        }
        return intent.getStringArrayListExtra("imagelist");
    }

    private void observeImageConvert(@NonNull ArrayList<String> arrayList) {
        mModelDialog.doShow(DIALOG_FILE_CONVERT);
        MemCardWriteConvertViewModel memCardWriteConvertViewModel = (MemCardWriteConvertViewModel) ViewModelProviders.m2of((FragmentActivity) this).get(MemCardWriteConvertViewModel.class);
        memCardWriteConvertViewModel.setOrigFileList(arrayList);
        memCardWriteConvertViewModel.getData().observe(this, new Observer<MemCardWriteConvertViewModel.ConvertResult>() {
            public void onChanged(@Nullable MemCardWriteConvertViewModel.ConvertResult convertResult) {
                ConfirmWriteMemcard.this.onUpdateViewModelData(convertResult);
            }
        });
    }

    private void onUpdateViewModelData(MemCardWriteConvertViewModel.ConvertResult convertResult) {
        if (convertResult == null) {
            finish();
            return;
        }
        mModelDialog.doDismiss(DIALOG_FILE_CONVERT);
        mTotalFileSize = convertResult.totalFileSize;
        mImageList = new ArrayList<>(convertResult.filenameList);
        updateFileInfo(mImageList);
    }

    private void updateFileInfo(@Nullable ArrayList<String> arrayList) {
        mFileNumText.setText(String.format(getResources().getString(R.string.memcard_file_num_format), new Object[]{Integer.valueOf(arrayList != null ? arrayList.size() : 0)}));
        mFileSizeText.setText(String.format(getResources().getString(R.string.memcard_total_file_size_format), new Object[]{Double.valueOf(((double) mTotalFileSize) / 1000000.0d)}));
    }

    protected void onResume() {
        EPLog.m305d(LOG_TAG, "onResume()");
        super.onResume();
        if (!WiFiDirectManager.isNeedConnect(this, WiFiDirectManager.DEVICE_TYPE_PRINTER)) {
            isTryConnectSimpleAp = false;
        } else if (!this.isTryConnectSimpleAp) {
            isTryConnectSimpleAp = true;
            if (WiFiDirectManager.reconnect(this, WiFiDirectManager.DEVICE_TYPE_PRINTER, -1)) {
                doDirectoryNameTask = true;
                return;
            }
        }
        isKeepSimleApConnect = false;
        if (this.doDirectoryNameTask) {
            mDirectoryNameTask = new DirectoryNameTask();
            mDirectoryNameTask.execute(new Void[0]);
            doDirectoryNameTask = false;
        }
    }

    protected void onPause() {
        super.onPause();
        if (isFinishing()) {
            deleteTemporallyFile();
        }
    }

    protected void onStop() {
        EPLog.m305d(LOG_TAG, "onStop()");
        super.onStop();
        if (!this.isKeepSimleApConnect) {
            WiFiDirectManager.disconnect(this, WiFiDirectManager.DEVICE_TYPE_PRINTER, MemcardUtil.getPrinterIpAddress(this));
        }
    }

    private void setWriteDirName(String str) {
        mCopyTargetFolderName = str;
        if (str != null && mCopyTargetFolderName != null) {
            runOnUiThread(new Runnable() {
                public void run() {
                    ConfirmWriteMemcard.mCopyTargetPathText.setText(String.format(ConfirmWriteMemcard.this.getResources().getString(R.string.memcard_folder_save_to_format), new Object[]{ConfirmWriteMemcard.mCopyTargetFolderName}));
                }
            });
        }
    }

    private boolean isWirteDirNameDetermined() {
        String str = mCopyTargetFolderName;
        return str != null && str.length() > 0;
    }

    public void add_button_clicked(View view) {
        LocalImageSelectActivity.startAddImageList(this, getStartArgumentFileList(getIntent()));
        finish();
    }

    public void copy_button_clicked(View view) {
        mCheckAndNextActivity = new CheckAndNextActivityTask();
        mCheckAndNextActivity.execute(new Void[0]);
    }

    public void onBackPressed() {
        setResult(1);
        finish();
    }

    private void deleteTemporallyFile() {
        ((MemCardWriteConvertViewModel) ViewModelProviders.m2of((FragmentActivity) this).get(MemCardWriteConvertViewModel.class)).deleteTempFile();
    }

    private int capacityCheck() {
        EPLog.m313i(LOG_TAG, "in capacityCheck()");
        CifsAccess instance = CifsAccess.getInstance();
        try {
            if (instance.initDefault(this, 1) == 0) {
                return 2;
            }
            if (instance.connectDefaultStorageWidthDefaultAthInfo(mMemcardStorageType) == 0) {
                instance.free();
                return 2;
            }
            int unitSize = instance.getUnitSize();
            long freeUnit = instance.getFreeUnit();
            instance.disconnectStorage();
            instance.free();
            EPLog.m313i(LOG_TAG, "unit :<" + unitSize + "> free: <" + freeUnit + ">");
            if ((mTotalFileSize / ((long) unitSize)) + ((long) mImageList.size()) > freeUnit) {
                return 1;
            }
            return 0;
        } finally {
            instance.free();
        }
    }

    private String cifsGetTargetFoldername() {
        CifsAccess instance = CifsAccess.getInstance();
        try {
            if (instance.initDefault(this, 1) == 0) {
                return null;
            }
            int checkStorage = instance.checkStorage();
            if (checkStorage == 0) {
                instance.free();
                return null;
            }
            mMemcardStorageType = checkStorage;
            if (instance.connectDefaultStorageWidthDefaultAthInfo(checkStorage) == 0) {
                instance.free();
                return null;
            }
            String targetFolderName = getTargetFolderName(instance);
            instance.disconnectStorage();
            instance.free();
            return targetFolderName;
        } finally {
            instance.free();
        }
    }

    private String getTargetFolderName(CifsAccess cifsAccess) {
        Calendar instance = Calendar.getInstance();
        int createDirectory = cifsAccess.createDirectory(MemcardConfig.CIFS_WRITE_FOLDER);
        if (createDirectory != -1203 && createDirectory != 0) {
            return null;
        }
        for (int i = 0; i < 100; i++) {
            String format = String.format(Locale.US, "\\EPIMG\\%04d%02d%02d%02d%02d%02d", new Object[]{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)});
            if (cifsAccess.createDirectory(format) == 0) {
                cifsAccess.deleteDirectory(format);
                return format;
            }
            EPLog.m313i(LOG_TAG, "CifsAccess.createDirectory() return <" + createDirectory + ">");
        }
        return null;
    }

    private void startCopyActivity() {
        Intent intent = new Intent(this, MemcardWriteProgress.class);
        intent.putStringArrayListExtra("imageList", mImageList);
        intent.putExtra("target_folder_name", mCopyTargetFolderName);
        intent.putExtra("memcard_storage_type", mMemcardStorageType);
        startActivityForResult(intent, 1);
        isKeepSimleApConnect = true;
    }

    protected void onActivityResult(int i, int i2, Intent intent) {
        if (i == 1) {
            isKeepSimleApConnect = false;
            if (i2 == -2) {
                loggerCountUp();
                setResult(1);
                deleteTemporallyFile();
                finish();
            } else if (i2 != 0) {
                localShowDialog(DIALOG_COPY_RESULT_ERROR);
            }
        }
    }

    private void loggerCountUp() {
        mImageList.size();
    }

    private void localShowDialog(String str) {
        mModelDialog.doShow(str);
    }

    /* JADX WARNING: Can't fix incorrect switch cases order */
    /* Code decompiled incorrectly, please refer to instructions dump. */
    private void showDialog(java.lang.String r11) {
        /*
            r10 = this;
            int r0 = r11.hashCode()
            r1 = 0
            switch(r0) {
                case -2116590872: goto L_0x0066;
                case -2049655319: goto L_0x005b;
                case -2003975289: goto L_0x0051;
                case -1628437111: goto L_0x0047;
                case -797044744: goto L_0x003d;
                case 976257404: goto L_0x0033;
                case 1194959080: goto L_0x0028;
                case 1429177493: goto L_0x001e;
                case 1442112211: goto L_0x0014;
                case 2132918151: goto L_0x000a;
                default: goto L_0x0008;
            }
        L_0x0008:
            goto L_0x0070
        L_0x000a:
            java.lang.String r0 = "dialog_file_convert"
            boolean r0 = r11.equals(r0)
            if (r0 == 0) goto L_0x0070
            r0 = 0
            goto L_0x0071
        L_0x0014:
            java.lang.String r0 = "dialog_target_directy_name_task"
            boolean r0 = r11.equals(r0)
            if (r0 == 0) goto L_0x0070
            r0 = 1
            goto L_0x0071
        L_0x001e:
            java.lang.String r0 = "dialog_printer_busy"
            boolean r0 = r11.equals(r0)
            if (r0 == 0) goto L_0x0070
            r0 = 5
            goto L_0x0071
        L_0x0028:
            java.lang.String r0 = "dialog_copy_result_complete"
            boolean r0 = r11.equals(r0)
            if (r0 == 0) goto L_0x0070
            r0 = 8
            goto L_0x0071
        L_0x0033:
            java.lang.String r0 = "dialog_file_write_error"
            boolean r0 = r11.equals(r0)
            if (r0 == 0) goto L_0x0070
            r0 = 6
            goto L_0x0071
        L_0x003d:
            java.lang.String r0 = "dialog_storage_connect_error"
            boolean r0 = r11.equals(r0)
            if (r0 == 0) goto L_0x0070
            r0 = 4
            goto L_0x0071
        L_0x0047:
            java.lang.String r0 = "dialog_check_and_next"
            boolean r0 = r11.equals(r0)
            if (r0 == 0) goto L_0x0070
            r0 = 2
            goto L_0x0071
        L_0x0051:
            java.lang.String r0 = "dialog_disk_space_shortage"
            boolean r0 = r11.equals(r0)
            if (r0 == 0) goto L_0x0070
            r0 = 3
            goto L_0x0071
        L_0x005b:
            java.lang.String r0 = "dialog_copy_result_cancel"
            boolean r0 = r11.equals(r0)
            if (r0 == 0) goto L_0x0070
            r0 = 9
            goto L_0x0071
        L_0x0066:
            java.lang.String r0 = "dialog_communication_error"
            boolean r0 = r11.equals(r0)
            if (r0 == 0) goto L_0x0070
            r0 = 7
            goto L_0x0071
        L_0x0070:
            r0 = -1
        L_0x0071:
            r2 = 2131625202(0x7f0e04f2, float:1.8877605E38)
            switch(r0) {
                case 0: goto L_0x0154;
                case 1: goto L_0x0145;
                case 2: goto L_0x0136;
                case 3: goto L_0x011a;
                case 4: goto L_0x00fe;
                case 5: goto L_0x00e2;
                case 6: goto L_0x00c5;
                case 7: goto L_0x00a9;
                case 8: goto L_0x0090;
                case 9: goto L_0x007a;
                default: goto L_0x0077;
            }
        L_0x0077:
            r0 = 0
            goto L_0x015d
        L_0x007a:
            r4 = 2
            r0 = 2131624893(0x7f0e03bd, float:1.8876979E38)
            java.lang.String r5 = r10.getString(r0)
            r6 = 0
            java.lang.String r7 = r10.getString(r2)
            r8 = 0
            r9 = 0
            r3 = r11
            epson.common.DialogProgress r0 = epson.common.DialogProgress.newInstance(r3, r4, r5, r6, r7, r8, r9)
            goto L_0x015d
        L_0x0090:
            r3 = 2
            r0 = 2131624890(0x7f0e03ba, float:1.8876972E38)
            java.lang.String r4 = r10.getString(r0)
            r5 = 0
            r6 = 0
            r7 = 0
            java.lang.String r8 = r10.getString(r2)
            r2 = r11
            epson.common.DialogProgress r0 = epson.common.DialogProgress.newInstance(r2, r3, r4, r5, r6, r7, r8)
            r0.setCancelable(r1)
            goto L_0x015d
        L_0x00a9:
            r3 = 2
            r0 = 2131624886(0x7f0e03b6, float:1.8876964E38)
            java.lang.String r4 = r10.getString(r0)
            r0 = 2131624887(0x7f0e03b7, float:1.8876966E38)
            java.lang.String r5 = r10.getString(r0)
            java.lang.String r6 = r10.getString(r2)
            r7 = 0
            r8 = 0
            r2 = r11
            epson.common.DialogProgress r0 = epson.common.DialogProgress.newInstance(r2, r3, r4, r5, r6, r7, r8)
            goto L_0x015d
        L_0x00c5:
            r0 = 2
            r1 = 2131624896(0x7f0e03c0, float:1.8876985E38)
            java.lang.String r3 = r10.getString(r1)
            r1 = 2131624897(0x7f0e03c1, float:1.8876987E38)
            java.lang.String r4 = r10.getString(r1)
            java.lang.String r5 = r10.getString(r2)
            r6 = 0
            r7 = 0
            r1 = r11
            r2 = r0
            epson.common.DialogProgress r0 = epson.common.DialogProgress.newInstance(r1, r2, r3, r4, r5, r6, r7)
            goto L_0x015d
        L_0x00e2:
            r0 = 2
            r1 = 2131624471(0x7f0e0217, float:1.8876123E38)
            java.lang.String r3 = r10.getString(r1)
            r1 = 2131624472(0x7f0e0218, float:1.8876125E38)
            java.lang.String r4 = r10.getString(r1)
            java.lang.String r5 = r10.getString(r2)
            r6 = 0
            r7 = 0
            r1 = r11
            r2 = r0
            epson.common.DialogProgress r0 = epson.common.DialogProgress.newInstance(r1, r2, r3, r4, r5, r6, r7)
            goto L_0x015d
        L_0x00fe:
            r0 = 2
            r1 = 2131624902(0x7f0e03c6, float:1.8876997E38)
            java.lang.String r3 = r10.getString(r1)
            r1 = 2131624903(0x7f0e03c7, float:1.8876999E38)
            java.lang.String r4 = r10.getString(r1)
            java.lang.String r5 = r10.getString(r2)
            r6 = 0
            r7 = 0
            r1 = r11
            r2 = r0
            epson.common.DialogProgress r0 = epson.common.DialogProgress.newInstance(r1, r2, r3, r4, r5, r6, r7)
            goto L_0x015d
        L_0x011a:
            r0 = 2
            r1 = 2131624883(0x7f0e03b3, float:1.8876958E38)
            java.lang.String r3 = r10.getString(r1)
            r1 = 2131624884(0x7f0e03b4, float:1.887696E38)
            java.lang.String r4 = r10.getString(r1)
            java.lang.String r5 = r10.getString(r2)
            r6 = 0
            r7 = 0
            r1 = r11
            r2 = r0
            epson.common.DialogProgress r0 = epson.common.DialogProgress.newInstance(r1, r2, r3, r4, r5, r6, r7)
            goto L_0x015d
        L_0x0136:
            r0 = 2131624885(0x7f0e03b5, float:1.8876962E38)
            java.lang.String r0 = r10.getString(r0)
            epson.common.DialogProgress r0 = epson.common.DialogProgress.newInstance(r11, r1, r0)
            r0.setCancelable(r1)
            goto L_0x015d
        L_0x0145:
            r0 = 2131624888(0x7f0e03b8, float:1.8876968E38)
            java.lang.String r0 = r10.getString(r0)
            epson.common.DialogProgress r0 = epson.common.DialogProgress.newInstance(r11, r1, r0)
            r0.setCancelable(r1)
            goto L_0x015d
        L_0x0154:
            java.lang.String r0 = ""
            epson.common.DialogProgress r0 = epson.common.DialogProgress.newInstance(r11, r1, r0)
            r0.setCancelable(r1)
        L_0x015d:
            if (r0 == 0) goto L_0x0166
            android.support.v4.app.FragmentManager r1 = r10.getSupportFragmentManager()
            r0.show(r1, r11)
        L_0x0166:
            return
        */
        throw new UnsupportedOperationException("Method not decompiled: com.epson.memcardacc.ConfirmWriteMemcard.showDialog(java.lang.String):void");
    }

    private void dismissDialog(String str) {
        DialogFragment dialogFragment = (DialogFragment) getSupportFragmentManager().findFragmentByTag(str);
        if (dialogFragment != null) {
            dialogFragment.dismiss();
        }
    }

    /* JADX WARNING: Removed duplicated region for block: B:12:0x002a  */
    /* JADX WARNING: Removed duplicated region for block: B:13:0x0039  */
    /* JADX WARNING: Removed duplicated region for block: B:16:? A[RETURN, SYNTHETIC] */
    /* Code decompiled incorrectly, please refer to instructions dump. */
    public void onNegativeClick(java.lang.String r5) {
        /*
            r4 = this;
            int r0 = r5.hashCode()
            r1 = -2049655319(0xffffffff85d4bde9, float:-2.0006146E-35)
            r2 = 0
            r3 = 1
            if (r0 == r1) goto L_0x001b
            r1 = 1194959080(0x4739a0e8, float:47520.906)
            if (r0 == r1) goto L_0x0011
            goto L_0x0025
        L_0x0011:
            java.lang.String r0 = "dialog_copy_result_complete"
            boolean r5 = r5.equals(r0)
            if (r5 == 0) goto L_0x0025
            r5 = 0
            goto L_0x0026
        L_0x001b:
            java.lang.String r0 = "dialog_copy_result_cancel"
            boolean r5 = r5.equals(r0)
            if (r5 == 0) goto L_0x0025
            r5 = 1
            goto L_0x0026
        L_0x0025:
            r5 = -1
        L_0x0026:
            switch(r5) {
                case 0: goto L_0x0039;
                case 1: goto L_0x002a;
                default: goto L_0x0029;
            }
        L_0x0029:
            goto L_0x003f
        L_0x002a:
            com.epson.memcardacc.ConfirmWriteMemcard$DirectoryNameTask r5 = new com.epson.memcardacc.ConfirmWriteMemcard$DirectoryNameTask
            r5.<init>()
            r4.mDirectoryNameTask = r5
            com.epson.memcardacc.ConfirmWriteMemcard$DirectoryNameTask r5 = r4.mDirectoryNameTask
            java.lang.Void[] r0 = new java.lang.Void[r2]
            r5.execute(r0)
            goto L_0x003f
        L_0x0039:
            r4.setResult(r3)
            r4.finish()
        L_0x003f:
            return
        */
        throw new UnsupportedOperationException("Method not decompiled: com.epson.memcardacc.ConfirmWriteMemcard.onNegativeClick(java.lang.String):void");
    }

    class DirectoryNameTask extends AsyncTask<Void, Integer, String> {
        protected void onProgressUpdate(Integer... numArr) {
        }

        DirectoryNameTask() {
        }

        protected void onPostExecute(String str) {
            if (str == null) {
                ConfirmWriteMemcard.this.setWriteDirName("");
            } else {
                ConfirmWriteMemcard.this.setWriteDirName(str);
            }
            ConfirmWriteMemcard.mModelDialog.doDismiss(ConfirmWriteMemcard.DIALOG_TARGET_DIRECTORY_NAME_TASK);
        }

        protected void onPreExecute() {
            ConfirmWriteMemcard.mModelDialog.doShow(ConfirmWriteMemcard.DIALOG_TARGET_DIRECTORY_NAME_TASK);
        }

        protected String doInBackground(Void... voidArr) {
            return ConfirmWriteMemcard.this.cifsGetTargetFoldername();
        }
    }

    class CheckAndNextActivityTask extends AsyncTask<Void, Void, Integer> {
        CheckAndNextActivityTask() {
        }

        protected Integer doInBackground(Void... voidArr) {
            if (isCancelled()) {
                return -1;
            }
            switch (EscprLibPrinter.checkIdleOrError(ConfirmWriteMemcard.this, 60)) {
                case 1:
                    return 11;
                case 2:
                    return 10;
                default:
                    if (!ConfirmWriteMemcard.this.isWirteDirNameDetermined()) {
                        String cifsGetTargetFoldername = ConfirmWriteMemcard.this.cifsGetTargetFoldername();
                        if (cifsGetTargetFoldername == null || cifsGetTargetFoldername.length() <= 0) {
                            return 12;
                        }
                        ConfirmWriteMemcard.this.setWriteDirName(cifsGetTargetFoldername);
                    }
                    int access$400 = ConfirmWriteMemcard.this.capacityCheck();
                    if (access$400 != 0) {
                        return Integer.valueOf(access$400);
                    }
                    return 0;
            }
        }

        protected void onCancelled() {
            ConfirmWriteMemcard.mModelDialog.doDismiss(ConfirmWriteMemcard.DIALOG_CHECK_AND_NEXT);
        }

        protected void onPostExecute(Integer num) {
            ConfirmWriteMemcard.mModelDialog.doDismiss(ConfirmWriteMemcard.DIALOG_CHECK_AND_NEXT);
            int intValue = num.intValue();
            switch (intValue) {
                case 0:
                    ConfirmWriteMemcard.this.startCopyActivity();
                    return;
                case 1:
                    ConfirmWriteMemcard.this.localShowDialog(ConfirmWriteMemcard.DIALOG_DISK_SPACE_SHORTAGE);
                    return;
                case 2:
                    ConfirmWriteMemcard.this.localShowDialog(ConfirmWriteMemcard.DIALOG_STORAGE_CONNECT_ERROR);
                    return;
                default:
                    switch (intValue) {
                        case 10:
                            ConfirmWriteMemcard.this.localShowDialog(ConfirmWriteMemcard.DIALOG_PRINTER_BUSY);
                            return;
                        case 11:
                            ConfirmWriteMemcard.this.localShowDialog(ConfirmWriteMemcard.DIALOG_COMMUNICATION_ERROR);
                            return;
                        case 12:
                            ConfirmWriteMemcard.this.localShowDialog(ConfirmWriteMemcard.DIALOG_FILE_WRITE_ERROR);
                            return;
                        default:
                            return;
                    }
            }
        }

        protected void onPreExecute() {
            ConfirmWriteMemcard.mModelDialog.doShow(ConfirmWriteMemcard.DIALOG_CHECK_AND_NEXT);
        }
    }
}
