本文整理汇总了Java中com.nononsenseapps.filepicker.FilePickerActivity类的典型用法代码示例。如果您正苦于以下问题:Java FilePickerActivity类的具体用法?Java FilePickerActivity怎么用?Java FilePickerActivity使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
FilePickerActivity类属于com.nononsenseapps.filepicker包,在下文中一共展示了FilePickerActivity类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onOptionsItemSelected
import com.nononsenseapps.filepicker.FilePickerActivity; //导入依赖的package包/类
/**
* This method handles the action menu item selections.
*
* @param item the item which has been selected
* @return if the item was found in the menu
*/
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch(item.getItemId()) {
case R.id.action_switch_user:
startActivity(new Intent(getApplicationContext(), UserSelectionActivity.class));
return true;
case R.id.action_about:
startActivity(new Intent(getApplicationContext(), AboutActivity.class));
return true;
case R.id.action_settings:
startActivity(new Intent(getApplicationContext(), SettingsActivity.class));
return true;
case 0: // Only in debug mode: File Picker
Intent i = new Intent(getApplicationContext(), FilePickerActivity.class);
startActivityForResult(i, CODE_FILEPICKER);
default:
return super.onOptionsItemSelected(item);
}
}
示例2: launchPicker
import com.nononsenseapps.filepicker.FilePickerActivity; //导入依赖的package包/类
private void launchPicker() {
File path = null;
if (!Strings.isNullOrEmpty(startPath)) {
path = new File(startPath);
}
if (path == null || !path.exists()) {
if (Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState())) {
path = new File(Environment.getExternalStorageDirectory().toString());
} else {
path = Environment.getRootDirectory();
}
}
Intent i = new Intent(this, MyFilePickerActivity.class);
i.putExtra(FilePickerActivity.EXTRA_START_PATH, path.getAbsolutePath());
if (directoryMode) {
i.putExtra(FilePickerActivity.EXTRA_ALLOW_CREATE_DIR, true);
i.putExtra(FilePickerActivity.EXTRA_MODE, FilePickerActivity.MODE_DIR);
}
startActivityForResult(i, REQUEST_PICKER);
}
示例3: onOptionsItemSelected
import com.nononsenseapps.filepicker.FilePickerActivity; //导入依赖的package包/类
@Override
public boolean onOptionsItemSelected(MenuItem item) {
int id = item.getItemId();
switch (id) {
case R.id.newitem:
Intent intent = new Intent(this, NoticeTreeActivity.class);
intent.putExtra(ARG_NOTICE, new NoticeItem(ROOT_BRANCH_TITLE));
startActivity(intent);
break;
case R.id.openitem:
Intent intent1 = new Intent(this, FilePickerActivity.class);
intent1.putExtra(FilePickerActivity.EXTRA_ALLOW_MULTIPLE, false);
intent1.putExtra(FilePickerActivity.EXTRA_ALLOW_CREATE_DIR, false);
intent1.putExtra(FilePickerActivity.EXTRA_MODE, FilePickerActivity.MODE_FILE);
intent1.putExtra(FilePickerActivity.EXTRA_START_PATH, Environment.getExternalStorageDirectory().getPath());
startActivityForResult(intent1, FILE_CODE);
break;
}
return super.onOptionsItemSelected(item);
}
示例4: selectFodler
import com.nononsenseapps.filepicker.FilePickerActivity; //导入依赖的package包/类
private void selectFodler()
{
Intent i = new Intent(getActivity(), FilePickerActivity.class);
// This works if you defined the intent filter
// Intent i = new Intent(Intent.ACTION_GET_CONTENT);
// Set these depending on your use case. These are the defaults.
i.putExtra(FilePickerActivity.EXTRA_ALLOW_MULTIPLE, false);
i.putExtra(FilePickerActivity.EXTRA_ALLOW_CREATE_DIR, true);
i.putExtra(FilePickerActivity.EXTRA_MODE, FilePickerActivity.MODE_DIR);
// Configure initial directory by specifying a String.
// You could specify a String like "/storage/emulated/0/", but that can
// dangerous. Always use Android's API calls to get paths to the SD-card or
// internal memory.
String initialPath = App.getAdvancedCameraPrefHelper().getCustomStorage();
if( !(new File(initialPath).exists()) )
{
initialPath = Environment.getExternalStorageDirectory().getPath();
}
i.putExtra(FilePickerActivity.EXTRA_START_PATH, initialPath);
startActivityForResult(i, FILE_CODE);
}
示例5: onStartFilePicker
import com.nononsenseapps.filepicker.FilePickerActivity; //导入依赖的package包/类
public void onStartFilePicker(MenuItem menuItem) {
Intent i = new Intent(Intent.ACTION_GET_CONTENT);
// Set these depending on your use case. These are the defaults.
i.putExtra(FilePickerActivity.EXTRA_ALLOW_MULTIPLE, false);
i.putExtra(FilePickerActivity.EXTRA_ALLOW_CREATE_DIR, false);
i.putExtra(FilePickerActivity.EXTRA_MODE, FilePickerActivity.MODE_FILE);
// Configure initial directory by specifying a String.
// You could specify a String like "/storage/emulated/0/", but that can
// dangerous. Always use Android's API calls to get paths to the SD-card or
// internal memory.
i.putExtra(FilePickerActivity.EXTRA_START_PATH, Environment.getExternalStorageDirectory().getPath());
startActivityForResult(i, FILE_CODE);
}
示例6: onCreate
import com.nononsenseapps.filepicker.FilePickerActivity; //导入依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.preferences);
// Setup the file chooser for the To field.
Preference filePicker = findPreference(PreferencesActivity.PREFS_TO_FILE);
filePicker.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
intent.putExtra(FilePickerActivity.EXTRA_ALLOW_MULTIPLE, false);
intent.putExtra(FilePickerActivity.EXTRA_ALLOW_CREATE_DIR, false);
intent.putExtra(FilePickerActivity.EXTRA_MODE, FilePickerActivity.MODE_DIR);
intent.putExtra(FilePickerActivity.EXTRA_START_PATH, Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES).getPath());
startActivityForResult(intent, REQUEST_CODE_TO);
return true;
}
});
}
示例7: onPreferenceClick
import com.nononsenseapps.filepicker.FilePickerActivity; //导入依赖的package包/类
@Override
public boolean onPreferenceClick(Preference preference) {
if (preference == update) {
Updater.checkForUpdates(getActivity(), true);
} else if (preference == storagePath) {
Intent i = new Intent(context, FilePickerActivity.class);
i.putExtra(FilePickerActivity.EXTRA_ALLOW_MULTIPLE, false);
i.putExtra(FilePickerActivity.EXTRA_ALLOW_CREATE_DIR, true);
i.putExtra(FilePickerActivity.EXTRA_MODE, FilePickerActivity.MODE_DIR);
startActivityForResult(i, 69);
return true;
} else if (preference == facebook) {
Utils.viewURL(context, FACEBOOK_URL);
} else if (preference == googlePlus) {
Utils.viewURL(context, GOOGLE_PLUS_URL);
} else if (preference == privacy) {
Utils.viewURL(context, PRIVACY_URL);
} else if (preference == terms) {
Utils.viewURL(context, TOS_URL);
} else if (preference == about) {
Utils.viewURL(context, ABOUT_URL);
} else if (preference == madeWithLove) {
Utils.viewURL(context, MADE_WITH_LOVE_URL);
}
return false;
}
示例8: onActivityResult
import com.nononsenseapps.filepicker.FilePickerActivity; //导入依赖的package包/类
@Override
public void onActivityResult(int requestCode, int resultCode, Intent intent) {
if (requestCode == FILE_CODE && resultCode == Activity.RESULT_OK) {
if (!intent.getBooleanExtra(FilePickerActivity.EXTRA_ALLOW_MULTIPLE, false)) {
// The URI will now be something like content://PACKAGE-NAME/root/path/to/file
Uri uri = intent.getData();
// A utility method is provided to transform the URI to a File object
File file = com.nononsenseapps.filepicker.Utils.getFileForUri(uri);
if (S.INFO)
Log.i(S.TAG, "XML path Uri (" + file.toString() + ")");
try {
SharedPreferences.Editor editor = mPrefs.edit();
editor.putString("settingCatalogLocation", file.toString());
editor.apply();
updateSummary(mPrefs, KEY_PREF_CATALOG_LOCATION);
} catch (Exception e) {
if (S.ERROR)
Log.e(S.TAG, "File select error " + e.getLocalizedMessage());
}
}
}
}
示例9: pickFileDialog
import com.nononsenseapps.filepicker.FilePickerActivity; //导入依赖的package包/类
public static void pickFileDialog(Activity activity, String location, int requestCode) {
// This always works
Intent i = new Intent(activity, FilePickerActivity.class);
// This works if you defined the intent filter
// Intent i = new Intent(Intent.ACTION_GET_CONTENT);
// Set these depending on your use case. These are the defaults.
i.putExtra(FilePickerActivity.EXTRA_ALLOW_MULTIPLE, false);
i.putExtra(FilePickerActivity.EXTRA_ALLOW_CREATE_DIR, false);
i.putExtra(FilePickerActivity.EXTRA_MODE, FilePickerActivity.MODE_FILE);
// Configure initial directory by specifying a String.
// You could specify a String like "/storage/emulated/0/", but that can
// dangerous. Always use Android's API calls to get paths to the SD-card or
// internal memory.
i.putExtra(FilePickerActivity.EXTRA_START_PATH, location);
// Environment.getExternalStorageDirectory().getPath()
activity.startActivityForResult(i, requestCode);
}
示例10: onOptionsItemSelected
import com.nononsenseapps.filepicker.FilePickerActivity; //导入依赖的package包/类
@Override
public boolean onOptionsItemSelected(MenuItem menuItem) {
if (menuItem.getItemId() == android.R.id.home) {
onBackPressed();
}
else if (menuItem.getItemId() == R.id.action_find) {
// load custom image
Intent i = new Intent(this, FilePickerActivity.class);
i.putExtra(FilePickerActivity.EXTRA_ALLOW_MULTIPLE, false);
i.putExtra(FilePickerActivity.EXTRA_ALLOW_CREATE_DIR, true);
i.putExtra(FilePickerActivity.EXTRA_MODE, FilePickerActivity.MODE_FILE);
i.putExtra(FilePickerActivity.EXTRA_START_PATH,
GlobalConfig.pathPickedSave == null || GlobalConfig.pathPickedSave.length() == 0 ?
Environment.getExternalStorageDirectory().getPath() : GlobalConfig.pathPickedSave);
startActivityForResult(i, 0);
}
return super.onOptionsItemSelected(menuItem);
}
示例11: selectFile
import com.nononsenseapps.filepicker.FilePickerActivity; //导入依赖的package包/类
void selectFile(){
Intent i = new Intent(this, FilePickerActivity.class);
// This works if you defined the intent filter
// Intent i = new Intent(Intent.ACTION_GET_CONTENT);
// Set these depending on your use case. These are the defaults.
i.putExtra(FilePickerActivity.EXTRA_ALLOW_MULTIPLE, false);
i.putExtra(FilePickerActivity.EXTRA_ALLOW_CREATE_DIR, false);
i.putExtra(FilePickerActivity.EXTRA_MODE, FilePickerActivity.MODE_FILE);
i.putExtra(FilePickerActivity.EXTRA_START_PATH, Environment.getExternalStorageDirectory().getPath());
startActivityForResult(i, FILE_CODE);
}
示例12: importData
import com.nononsenseapps.filepicker.FilePickerActivity; //导入依赖的package包/类
public void importData()
{
Intent intent = new Intent(ClassDetailsActivity.this, FilePickerActivity.class);
intent.setAction(Intent.ACTION_GET_CONTENT);
intent.putExtra(FilePickerActivity.EXTRA_ALLOW_MULTIPLE, false);
intent.putExtra(FilePickerActivity.EXTRA_ALLOW_CREATE_DIR, false);
intent.putExtra(FilePickerActivity.EXTRA_MODE, FilePickerActivity.MODE_FILE);
startActivityForResult(intent, FILE_SELECT_CODE);
}
示例13: showUploadHereDialog
import com.nononsenseapps.filepicker.FilePickerActivity; //导入依赖的package包/类
private void showUploadHereDialog() {
if (indexBrowser == null) {
Log.w("showUploadHereDialog", "unable to open dialog, null index browser");
} else {
Intent i = new Intent(this, MIVFilePickerActivity.class);
String path = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS).getAbsolutePath();
Log.i("showUploadHereDialog", "path = " + path);
i.putExtra(FilePickerActivity.EXTRA_START_PATH, path);
startActivityForResult(i, 0);
}
}
示例14: pickRootDir
import com.nononsenseapps.filepicker.FilePickerActivity; //导入依赖的package包/类
public void pickRootDir(View v) {
// https://github.com/spacecowboy/NoNonsense-FilePicker
Intent i = new Intent(this, FilePickerActivity.class);
i.putExtra(FilePickerActivity.EXTRA_ALLOW_MULTIPLE, false);
i.putExtra(FilePickerActivity.EXTRA_ALLOW_CREATE_DIR, false);
i.putExtra(FilePickerActivity.EXTRA_MODE, FilePickerActivity.MODE_DIR);
i.putExtra(FilePickerActivity.EXTRA_START_PATH, "/");
startActivityForResult(i, ROOT_DIR_REQ_CODE);
}
示例15: selectBlockManually
import com.nononsenseapps.filepicker.FilePickerActivity; //导入依赖的package包/类
void selectBlockManually() {
Intent i = new Intent(this, FilePickerActivity.class);
i.putExtra(FilePickerActivity.EXTRA_ALLOW_MULTIPLE, false);
i.putExtra(FilePickerActivity.EXTRA_ALLOW_CREATE_DIR, false);
i.putExtra(FilePickerActivity.EXTRA_MODE, FilePickerActivity.MODE_FILE);
i.putExtra(FilePickerActivity.EXTRA_START_PATH, "/");
startActivityForResult(i, BLOCK_FILE_REQ_CODE);
}