本文整理汇总了Java中net.rdrei.android.dirchooser.DirectoryChooserFragment类的典型用法代码示例。如果您正苦于以下问题:Java DirectoryChooserFragment类的具体用法?Java DirectoryChooserFragment怎么用?Java DirectoryChooserFragment使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DirectoryChooserFragment类属于net.rdrei.android.dirchooser包,在下文中一共展示了DirectoryChooserFragment类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onCreate
import net.rdrei.android.dirchooser.DirectoryChooserFragment; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_select_folder);
mDialog = DirectoryChooserFragment.newInstance("DialogSample", null);
prefs = PreferenceManager
.getDefaultSharedPreferences(this);
editor = prefs.edit();
String settingDir = prefs.getString(Constants.SETTINGS_FAKKUDROID_FOLDER, "");
if (!settingDir.isEmpty()) {
EditText editText = (EditText) findViewById(R.id.etFolder);
editText.setText(settingDir);
} else {
selectDefault(null);
}
}
示例2: onCreate
import net.rdrei.android.dirchooser.DirectoryChooserFragment; //导入依赖的package包/类
@Override
protected void onCreate(@Nullable final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.dialog);
final DirectoryChooserConfig config = DirectoryChooserConfig.builder()
.newDirectoryName("DialogSample")
.build();
mDialog = DirectoryChooserFragment.newInstance(config);
mDirectoryTextView = (TextView) findViewById(R.id.textDirectory);
findViewById(R.id.btnChoose)
.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mDialog.show(getFragmentManager(), null);
}
});
}
示例3: setupPrefs
import net.rdrei.android.dirchooser.DirectoryChooserFragment; //导入依赖的package包/类
private void setupPrefs() {
final Preference saveLocation = findPreference(getString(R.string.image_file_location_pref));
saveLocation.setSummary(MimiUtil.getSaveDir(getActivity()).getAbsolutePath());
saveLocation.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
final DirectoryChooserConfig.Builder configBuilder = DirectoryChooserConfig.builder();
configBuilder.initialDirectory(MimiUtil.getSaveDir(getActivity()).getAbsolutePath())
.newDirectoryName("Mimi")
.allowNewDirectoryNameModification(true);
final DirectoryChooserFragment chooserDialog = DirectoryChooserFragment.newInstance(configBuilder.build());
chooserDialog.setDirectoryChooserListener(new DirectoryChooserFragment.OnFragmentInteractionListener() {
@Override
public void onSelectDirectory(@NonNull String path) {
MimiUtil.getInstance().setSaveDir(getActivity(), path);
saveLocation.setSummary(path);
chooserDialog.dismiss();
}
@Override
public void onCancelChooser() {
chooserDialog.dismiss();
}
});
chooserDialog.show(getActivity().getFragmentManager(), DIR_CHOOSER_TAG);
return true;
}
});
}
示例4: onCreate
import net.rdrei.android.dirchooser.DirectoryChooserFragment; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
final DirectoryChooserConfig config = DirectoryChooserConfig.builder()
.newDirectoryName("DialogSample")
.build();
mDialog = DirectoryChooserFragment.newInstance(config);
mDialog.show(getFragmentManager(), null);
}
示例5: showSaveLocation
import net.rdrei.android.dirchooser.DirectoryChooserFragment; //导入依赖的package包/类
private void showSaveLocation() {
if (dirChooser == null) {
dirChooser = DirectoryChooserFragment.newInstance(DirectoryChooserConfig.builder().initialDirectory(PREF_SAVE_LOCATION_VALUE)
.newDirectoryName(getApplicationContext().getString(getApplicationContext().getApplicationInfo().labelRes))
.build());
dirChooser.setStyle(DialogFragment.STYLE_NO_TITLE, R.style.AppTheme_DialogTheme);
}
dirChooser.show(getFragmentManager(), null);
}
示例6: openDirectChooserDialog
import net.rdrei.android.dirchooser.DirectoryChooserFragment; //导入依赖的package包/类
public void openDirectChooserDialog() {
DirectoryChooserConfig config = DirectoryChooserConfig.builder()
.newDirectoryName("HHComicDownload")
.allowNewDirectoryNameModification(true)
.initialDirectory(mDownloadPath)
.build();
mDialog = DirectoryChooserFragment.newInstance(config);
mDialog.setTargetFragment(this, 0);
mDialog.show(getFragmentManager(), null);
}
示例7: onCreate
import net.rdrei.android.dirchooser.DirectoryChooserFragment; //导入依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_export);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
mAssetsFiles = Arrays.asList(getIntent().getStringArrayExtra(EXTRA_SELECTED_ITEMS));
View colorButton = findViewById(R.id.color_button);
colorButton.setOnClickListener(mColorClickListener);
mColorPreview = findViewById(R.id.color_preview);
mColorPreview.setBackgroundColor(mColor);
View pathButton = findViewById(R.id.path_button);
pathButton.setOnClickListener(mPathClickListener);
mPathTextView = (TextView) findViewById(R.id.path_text);
mPathTextView.setText(Environment.getExternalStorageDirectory().getPath());
ListView listView = (ListView) findViewById(R.id.list_view);
listView.setOnItemClickListener(mOnItemClickListener);
listView.setOnItemLongClickListener(mOnItemLongClickListener);
listView.setAdapter(mListAdapter);
findViewById(R.id.start_export_button).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
startExport();
}
});
mDialog = DirectoryChooserFragment.newInstance(getString(R.string.app_name), null);
}
示例8: onCreate
import net.rdrei.android.dirchooser.DirectoryChooserFragment; //导入依赖的package包/类
@Override
protected void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.dialog);
//Pass the previously selected path.
mDialog = DirectoryChooserFragment.newInstance("AudioRecorder", Environment.getExternalStorageDirectory() + "/AudioRecorder");
mDirectoryTextView = (TextView) findViewById(R.id.textDirectory);
findViewById(R.id.btnChoose)
.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mDialog.show(getFragmentManager(), null);
}
});
}
示例9: onCreate
import net.rdrei.android.dirchooser.DirectoryChooserFragment; //导入依赖的package包/类
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
ThemeInitializer.init(this);
File workingDir = AppDirs.root(this);
directoryChooserDialog = DirectoryChooserFragment.newInstance(workingDir.getName(), workingDir.getParent());
// Display the fragment as the main content.
settingsFragment = new SettingsFragment();
getFragmentManager().beginTransaction()
.replace(android.R.id.content, settingsFragment)
.commit();
}
示例10: onCreate
import net.rdrei.android.dirchooser.DirectoryChooserFragment; //导入依赖的package包/类
@Override
public void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getPreferenceManager().setSharedPreferencesName(SharedPreferencesUtil.FILE_NAME);
addPreferencesFromResource(R.xml.preferences);
String downloadPath = DownloadManager.getDownloadPath();
if (downloadPath != null) {
String displayPath = Uri.decode(downloadPath);
getPreferenceManager().findPreference(KEY_PREF_DOWNLOAD_PATH).setSummary(displayPath);
}
ListPreference listPreference = (ListPreference) getPreferenceManager().findPreference(KEY_PREF_VIEW_DIRECTION);
CharSequence[] entries = listPreference.getEntries();
int i = listPreference.findIndexOfValue(listPreference.getValue());
i = (i <= 0) ? 0 : i;
listPreference.setSummary(entries[i]);
listPreference.setOnPreferenceChangeListener(this);
listPreference = (ListPreference) getPreferenceManager().findPreference(KEY_PREF_VIEW_VIDEO_PLAYER);
entries = listPreference.getEntries();
i = listPreference.findIndexOfValue(listPreference.getValue());
i = (i <= 0) ? 0 : i;
listPreference.setSummary(entries[i]);
listPreference.setOnPreferenceChangeListener(this);
getPreferenceScreen().setOnPreferenceChangeListener(this);
final DirectoryChooserConfig config = DirectoryChooserConfig.builder()
.initialDirectory((downloadPath.startsWith("/")) ? downloadPath : DownloadManager.DEFAULT_PATH)
.newDirectoryName("download")
.allowNewDirectoryNameModification(true)
.build();
mDialog = DirectoryChooserFragment.newInstance(config);
mDialog.setTargetFragment(this, 0);
float size = (float) Fresco.getImagePipelineFactory().getMainFileCache().getSize() / ByteConstants.MB;
Preference cacheCleanPreference = getPreferenceManager().findPreference(KEY_PREF_CACHE_CLEAN);
cacheCleanPreference.setSummary(String.format("已使用 %.2f MB", size));
LongClickPreference prefDownloadPath = (LongClickPreference) getPreferenceManager().findPreference(KEY_PREF_DOWNLOAD_PATH);
prefDownloadPath.setOnLongClickListener(v -> {
new AlertDialog.Builder(activity)
.setTitle("选择路径方式")
.setItems(new String[]{"系统文档(新)", "路径选择框(旧)"}, (dialogInterface, pos) -> {
if (pos == 0 && Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT_TREE);
intent.addFlags(Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION);
try {
startActivityForResult(intent, RESULT_CHOOSE_DIRECTORY);
} catch (ActivityNotFoundException e) {
e.printStackTrace();
mDialog.show(getFragmentManager(), null);
}
new Handler().postDelayed(() -> {
if (!opened)
activity.showSnackBar("如无法开启系统文档,长按使用旧工具");
}, 1000);
} else if (pos == 1) {
mDialog.show(getFragmentManager(), null);
} else
activity.showSnackBar("当前系统版本不支持");
})
.setNegativeButton(getString(R.string.cancel), null)
.show();
return true;
});
}
示例11: onItemLongClick
import net.rdrei.android.dirchooser.DirectoryChooserFragment; //导入依赖的package包/类
@Override
public boolean onItemLongClick(View view, int position) {
if (!(position >= 0 && position < pictures.size()))
return false;
pictureToBeSaved = pictures.get(position);
new AlertDialog.Builder(PictureViewerActivity.this)
.setTitle("操作")
.setItems(new String[]{"保存", "分享"}, (dialogInterface, i) -> {
if (i == 0) {
new AlertDialog.Builder(PictureViewerActivity.this).setTitle("是否直接保存到下载目录?")
.setMessage("或者另存到其他目录")
.setPositiveButton("保存", (dialog1, which1) ->
onSelectDirectory(Uri.parse(DownloadManager.getDownloadPath())))
.setNegativeButton("选择目录", (dialog12, which12) -> {
final DirectoryChooserConfig config = DirectoryChooserConfig.builder()
.initialDirectory(lastPath)
.newDirectoryName("download")
.allowNewDirectoryNameModification(true)
.build();
mDialog = DirectoryChooserFragment.newInstance(config);
mDialog.setDirectoryChooserListener(onFragmentInteractionListener);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT_TREE);
intent.addFlags(Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION);
try {
startActivityForResult(intent, PictureViewerActivity.RESULT_CHOOSE_DIRECTORY);
} catch (ActivityNotFoundException e) {
e.printStackTrace();
mDialog.show(getFragmentManager(), null);
}
} else {
mDialog.show(getFragmentManager(), null);
}
}).show();
} else if (i == 1) {
loadPicture(pictureToBeSaved, DownloadManager.getDownloadPath(), ACTION_SHARE);
}
})
.setNegativeButton("取消", null)
.show();
return true;
}