ExportImportDialog.java 文件源码

java
阅读 21 收藏 0 点赞 0 评论 0

项目:TwistyTimer 作者:
@Override
public void onClick(View view) {
    // NOTE: The call-backs from the "FileChooserDialog" and "PuzzleChooserDialog"
    //
    switch (view.getId()) {
        case R.id.export_backup:
            // All puzzle types and categories are exported to a single back-up file.
            // There is no need to identify the export file or the puzzle type/category.
            // Just invoke the activity and dismiss this dialog.
            getExImActivity().onExportSolveTimes(EXIM_FORMAT_BACKUP, null, null);
            dismiss();
            break;

        case R.id.export_external:
            mFileFormat = EXIM_FORMAT_EXTERNAL;
            // Select the single puzzle type and category that will be exported. When the
            // call-back from this puzzle chooser is received ("onPuzzleTypeSelected"),
            // this dialog will exit and hand control back to the activity to perform the
            // export. The call-back uses "getTag()" to tell the chooser to tell the
            // activity that the chosen puzzle type/category should be relayed back to this
            // dialog fragment.
            PuzzleChooserDialog.newInstance(
                    R.string.action_export, ExportImportDialog.this.getTag())
                    .show(getActivity().getSupportFragmentManager(), null);
            break;

        case R.id.import_backup:
            mFileFormat = EXIM_FORMAT_BACKUP;
            // Select the file to import. When the call-back from this file chooser is
            // received ("onFileSelection"), this dialog will exit and hand control back
            // to the activity to perform the export. The call-back uses "getTag()" to tell
            // the chooser to tell the activity that the chosen puzzle type/category should
            // be relayed back to this dialog fragment.
            new FileChooserDialog.Builder(getExImActivity())
                    .chooseButton(R.string.action_choose)
                    .tag(FRAG_TAG_EXIM_FILECHOOSER)
                    .show();
            break;

        case R.id.import_external:
            // Show a dialog that explains the required text format, then, when that is
            // closed, select the file to import. When the call-back from this file chooser
            // is received ("onFileSelection"), this dialog will check that the file name
            // is valid. If valid, the puzzle chooser will be shown.  When the call-back
            // from that puzzle chooser is received ("onPuzzleTypeSelected"), this dialog
            // will exit and hand control back to the activity to perform the import.
            mFileFormat = EXIM_FORMAT_EXTERNAL;
            new MaterialDialog.Builder(getContext())
                    .title(R.string.import_external_title)
                    .content(R.string.import_external_content_first)
                    .positiveText(R.string.action_ok)
                    .onPositive(new MaterialDialog.SingleButtonCallback() {
                        @Override
                        public void onClick(@NonNull MaterialDialog dialog,
                                            @NonNull DialogAction which) {
                            new FileChooserDialog.Builder(getExImActivity())
                                    .chooseButton(R.string.action_choose)
                                    .tag(FRAG_TAG_EXIM_FILECHOOSER)
                                    .show();
                        }
                    })
                    .show();
            break;

        case R.id.export_button:
            AnimUtils.toggleContentVisibility(exportBackup, exportExternal);
            break;

        case R.id.import_button:
            AnimUtils.toggleContentVisibility(importBackup, importExternal);
            break;

        //case R.id.help_button:
        //    break;
    }
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号