Java 类com.afollestad.materialdialogs.folderselector.FileChooserDialog 实例源码

项目:Tapad    文件:PresetStoreActivity.java   
@Override
public void onFileSelection(@NonNull FileChooserDialog dialog, @NonNull File file) {
    Log.d(TAG, file.getAbsolutePath());
    final String presetName = getCustomFolderName();

    // install zip
    fileHelper.unzip(file.getAbsolutePath(),
            PROJECT_LOCATION_PRESETS,
            presetName,
            activity,
            new Runnable() {
                @Override
                public void run() {
                    Log.d(TAG, "installed " + presetName);
                    setViewPager();
                }
            }
    );
}
项目:Munch    文件:SettingsActivity.java   
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setActivityTheme();
    setContentView(R.layout.activity_settings);
    ButterKnife.bind(this);

    //bind progress bar
    mMaterialProgressBar = (MaterialProgressBar) findViewById(R.id.indeterminate_progress);
    if (!NetworkConnectionUtil.isNetworkAvailable(SettingsActivity.this)) {
        mMaterialProgressBar.setVisibility(View.GONE);
    }

    setToolBar();

    getFragmentManager().beginTransaction().replace(R.id.frame_layout_settings, new SettingsFragment()).commit();

    sFileChooserDialog = new FileChooserDialog.Builder(SettingsActivity.this)
            .cancelButton(R.string.cancel)
            .build();
}
项目:androidclient    文件:NumberValidation.java   
/** Opens import keys from another device wizard. */
private void importKey() {
    checkInput(true, new ParameterRunnable<Boolean>() {
        @Override
        public void run(Boolean result) {
            if (result) {
                // import keys -- number verification with server is still needed
                // though because of key rollback protection
                // TODO allow for manual validation too

                // do not wait for the generated key
                stopKeyReceiver();

                new FileChooserDialog.Builder(NumberValidation.this)
                    .initialPath(PersonalKeyPack.DEFAULT_KEYPACK.getParent())
                    .mimeType(PersonalKeyPack.KEYPACK_MIME)
                    .show(getSupportFragmentManager());
            }
        }
    });
}
项目:GitHub    文件:MainActivity.java   
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
@OnClick(R.id.file_chooser)
public void showFileChooser() {
    chooserDialog = R.id.file_chooser;
    if (ActivityCompat.checkSelfPermission(MainActivity.this, Manifest.permission.READ_EXTERNAL_STORAGE) !=
            PackageManager.PERMISSION_GRANTED) {
        ActivityCompat.requestPermissions(MainActivity.this, new String[]{Manifest.permission.READ_EXTERNAL_STORAGE}, STORAGE_PERMISSION_RC);
        return;
    }
    new FileChooserDialog.Builder(this)
            .show();
}
项目:TwistyTimer    文件:ExportImportDialog.java   
/**
 * Handles the selection of a file when solve times are being imported. If the "external" file
 * format is chosen, the user must be further prompted to select the puzzle type and category
 * to assign to the imported solve times. If the chosen file does not end with the expected
 * file extension
 *
 * @param dialog The file chooser dialog that reported the selection.
 * @param file   The file that was chosen.
 */
@Override
public void onFileSelection(@NonNull FileChooserDialog dialog, @NonNull File file) {
    if (ExportImportUtils.isFileExtensionOK(file)) {
        mImportFile = file;

        if (mFileFormat == EXIM_FORMAT_EXTERNAL) {
            // Need to get the puzzle type and category before importing the data. There will
            // be a call-back to "onPuzzleSelected" before returning to the activity.
            PuzzleChooserDialog.newInstance(
                    R.string.action_import, ExportImportDialog.this.getTag())
                    .show(getActivity().getSupportFragmentManager(), null);
        } else {
            // Importing from a back-up file. There is no need to know the puzzle type and
            // category, as those are in the file. Hand back to the activity to do the import.
            getExImActivity().onImportSolveTimes(mImportFile, mFileFormat, null, null);
            dismiss();
        }
    } else {
        // TODO: ADD HELP
        new MaterialDialog.Builder(getActivity())
            .title(R.string.file_selection_error_title)
            .content(R.string.file_selection_error_content, ".txt")
            .positiveText(R.string.action_ok)
            .show();
        dismiss();
    }
}
项目:TwistyTimer    文件:MainActivity.java   
/**
 * Handles the call-back from a file chooser dialog when a file is selected. This is used for
 * communication between the {@code FileChooserDialog} and the export/import fragments. The
 * originating fragment that opened the file chooser dialog should set the "tag" of the file
 * chooser dialog to the value of the fragment tag that this activity uses to identify that
 * originating fragment. This activity will then forward this notification to that fragment,
 * which is expected to implement this same interface method.
 *
 * @param dialog
 *     The file chooser dialog that has reported the file selection.
 * @param file
 *     The file that was chosen.
 */
@Override
public void onFileSelection(@NonNull FileChooserDialog dialog, @NonNull File file) {
    // This "relay" scheme ensures that this activity is not embroiled in the gory details of
    // what the "destinationFrag" wanted with the file.
    final Fragment destinationFrag = fragmentManager.findFragmentByTag(FRAG_TAG_EXIM_DIALOG);

    if (destinationFrag instanceof FileChooserDialog.FileCallback) {
        ((FileChooserDialog.FileCallback) destinationFrag).onFileSelection(dialog, file);
    } else {
        // This is not expected unless there is a bug to be fixed.
        Log.e(TAG, "onFileSelection(): Unknown or incompatible fragment: " + destinationFrag.getTag());
    }
}
项目:Tapad    文件:PresetStoreActivity.java   
private void openPreset() {
    new FileChooserDialog.Builder(this)
            .initialPath(Environment.getExternalStorageDirectory().getPath())
            .mimeType("application/zip")
            .tag("optional-identifier")
            .show(this);
    Toast.makeText(activity, R.string.preset_store_open_preset, Toast.LENGTH_LONG).show();
}
项目:androidclient    文件:NumberValidation.java   
@Override
public void onFileSelection(@NonNull FileChooserDialog fileChooserDialog, @NonNull File file) {
    try {
        startImport(new FileInputStream(file));
    }
    catch (FileNotFoundException e) {
        Log.e(TAG, "error importing keys", e);
        Toast.makeText(this,
            R.string.err_import_keypair_read,
            Toast.LENGTH_LONG).show();
    }
}
项目:material-dialogs    文件:MainActivity.java   
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
@OnClick(R.id.file_chooser)
public void showFileChooser() {
  chooserDialog = R.id.file_chooser;
  if (ActivityCompat.checkSelfPermission(
          MainActivity.this, Manifest.permission.READ_EXTERNAL_STORAGE)
      != PackageManager.PERMISSION_GRANTED) {
    ActivityCompat.requestPermissions(
        MainActivity.this,
        new String[] {Manifest.permission.READ_EXTERNAL_STORAGE},
        STORAGE_PERMISSION_RC);
    return;
  }
  new FileChooserDialog.Builder(this).show();
}
项目:GitHub    文件:MainActivity.java   
@Override public void onFileSelection(@NonNull FileChooserDialog dialog, @NonNull File file) {
    showToast(file.getAbsolutePath());
}
项目:mapbox-plugins-android    文件:GeoJsonActivity.java   
private void showFileChooserDialog() {
  new FileChooserDialog.Builder(this)
    .extensionsFilter(".geojson", ".json", ".js", ".txt")
    .goUpLabel("Up")
    .show(getSupportFragmentManager());
}
项目:mapbox-plugins-android    文件:GeoJsonActivity.java   
@Override
public void onFileSelection(@NonNull FileChooserDialog dialog, @NonNull File file) {
  drawFromPath(file);
}
项目:TwistyTimer    文件:ExportImportDialog.java   
@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;
    }
}
项目:Tapad    文件:PresetStoreActivity.java   
@Override
public void onFileChooserDismissed(@NonNull FileChooserDialog dialog) {
}
项目:MockLocations    文件:MainActivity.java   
@Override
public void initView() {
    //设置标题
    setActionBarWithTitle(toolbar, getResources().getString(R.string.app_name));

    //设置地图
    mainPresenter.configBaiduMap();

    //绑定轨迹绘制工具
    drawTool = new DrawTool(mBaiduMap, this);

    //设置初始位置
    mBaiduMap.setMapStatus(MapStatusUpdateFactory.newLatLng(new LatLng(32.129927, 118.913191)));

    //绑定位置模拟显示当前位置,控制模拟线程
    mockLocationHelper = new MockLocationHelper(this, mBaiduMap);

    RxBus.getDefault().toObserverable(EmulatorPanelView.EmulatorPanelEvent.class)
            .subscribe(
                    new Action1<EmulatorPanelView.EmulatorPanelEvent>() {
                        @Override
                        public void call(EmulatorPanelView.EmulatorPanelEvent emulatorPanelEvent) {
                            if (emulatorPanelEvent.getState() == EmulatorPanelView.EmulatorPanelState.OPEN_FILE) {
                                new FileChooserDialog.Builder(MainActivity.this)
                                        .chooseButton(R.string.choose_file)  // changes label of the choose button
                                        .cancelButton(R.string.cancel)
                                        .initialPath(GpsJsonFileHelper.sAppFolder)  // changes initial path, defaults to external storage directory
                                        .mimeType("text/plain") // Optional MIME type filter

                                        .tag("choose-location-file-id")
                                        .show();

                                //startActivityForResult(new Intent(MainActivity.this, LocationFilesActivity.class), MLConstant.ACTIVITY_REQUEST_CODE.JSON_FILES);
                            } else {
                                // ignore , mocklocation helper will take these
                            }
                        }
                    },
                    new Action1<Throwable>() {
                        @Override
                        public void call(Throwable throwable) {
                            Logger.e(throwable, "on EmulatorPanelEvent Error in MainAc");
                        }
                    }
            );
}
项目:MockLocations    文件:MainActivity.java   
@Override
public void onFileSelection(@NonNull FileChooserDialog dialog, @NonNull File file) {
    dialog.dismiss();
    mainPresenter.processJson(file.getAbsolutePath());
}
项目:Munch    文件:SettingsActivity.java   
@Override
public void onFileSelection(FileChooserDialog dialog, File file) {
    ImportOpmlPresenter.onFileSelected(file);
}
项目:androidclient    文件:NumberValidation.java   
@Override
public void onFileChooserDismissed(@NonNull FileChooserDialog dialog) {
}
项目:mapbox-android-demo    文件:GeoJsonPluginActivity.java   
private void showFileChooserDialog() {
  new FileChooserDialog.Builder(this)
    .extensionsFilter(".geojson", ".json", ".js", ".txt")
    .goUpLabel("Up")
    .show();
}
项目:mapbox-android-demo    文件:GeoJsonPluginActivity.java   
@Override
public void onFileSelection(@NonNull FileChooserDialog dialog, @NonNull File file) {
  drawFromPath(file);
}
项目:material-dialogs    文件:MainActivity.java   
@Override
public void onFileSelection(FileChooserDialog dialog, File file) {
  showToast(file.getAbsolutePath());
}
项目:material-dialogs    文件:MainActivity.java   
@Override
public void onFileChooserDismissed(FileChooserDialog dialog) {
  showToast("File chooser dismissed!");
}
项目:GitHub    文件:MainActivity.java   
@Override public void onFileChooserDismissed(@NonNull FileChooserDialog dialog) {

    }
项目:mapbox-plugins-android    文件:GeoJsonActivity.java   
@Override
public void onFileChooserDismissed(@NonNull FileChooserDialog dialog) {

}
项目:TwistyTimer    文件:ExportImportDialog.java   
/**
 * Gets the activity reference type cast to support the required interfaces and base classes
 * for export/import operations.
 *
 * @return The attached activity, or {@code null} if no activity is attached.
 */
private <A extends AppCompatActivity & FileChooserDialog.FileCallback & ExportImportCallbacks>
A getExImActivity() {
    //noinspection unchecked
    return (A) getActivity();
}
项目:mapbox-android-demo    文件:GeoJsonPluginActivity.java   
@Override
public void onFileChooserDismissed(@NonNull FileChooserDialog dialog) {

}