package com.epson.memcardacc;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;

import com.epson.memcardacc.MemcardTempAlertDialog;


public class MemcardPhotocopyTop extends MemcardTopSuper {
    protected static final int DIALOG_TYPE_NOT_READY = 101;

    protected int getStorageSetType() {
        return 2;
    }

    public void launchReaderActivity(int i) {
    }

    protected void onCreate(Bundle bundle) {
        mBitmapCache = MemcardBitmapCache.getInstance(this);
        if (mBitmapCache == null || !mBitmapCache.checkEnv()) {
            new MemcardTempAlertDialog().showAlertDialog(this, new MemcardTempAlertDialog.DialogCallback() {
                public void onPositiveCallback() {
                    MemcardPhotocopyTop.this.finish();
                }
            });
        }
        if (bundle == null) {
            CifsAccess.clearSmbAuthInfo();
        }
        super.onCreate(bundle);
        setContentView(R.layout.activity_mcphotocopy_top);
        setActionBar(R.string.FunctionName_iPrint_PhotoTransfer, true);
        mLaunchType = 0;
        findViewById(R.id.photocopy_button).setOnClickListener(new View.OnClickListener() {
            public void onClick(View view) {
                MemcardPhotocopyTop.this.launchWriter();
            }
        });
    }

    private void launchWriter() {
        if (mLaunchType == 0) {
            mLaunchType = 1;
            startMemcardStorageCheck();
        }
    }

    public void back_home_button_clicked(View view) {
        finish();
    }

    private void localShowDialog(int i) {
        if (!mActivityIsFinishing && mIsActivityForeground) {
            LocalAlertDialogFragment localAlertDialogFragment = null;
            if (i == 1) {
                localAlertDialogFragment = LocalAlertDialogFragment.newInstance(R.string.mcphotocopy_media_not_found_message, R.string.mcphotocopy_media_not_found_title, 101);
            }
            if (localAlertDialogFragment != null) {
                localAlertDialogFragment.show(getSupportFragmentManager(), "error_dialog");
            } else {
                super.localShowDialog(i);
            }
        }
    }

    public void launchWriterActivity() {
        startActivity(new Intent(this, PhotoCopyImageSelectActivity.class));
    }
}
