本文整理汇总了Java中com.github.angads25.filepicker.view.FilePickerDialog类的典型用法代码示例。如果您正苦于以下问题:Java FilePickerDialog类的具体用法?Java FilePickerDialog怎么用?Java FilePickerDialog使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
FilePickerDialog类属于com.github.angads25.filepicker.view包,在下文中一共展示了FilePickerDialog类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setSelectDialog
import com.github.angads25.filepicker.view.FilePickerDialog; //导入依赖的package包/类
private void setSelectDialog() {
DialogProperties properties = new DialogProperties();
properties.selection_mode = DialogConfigs.SINGLE_MODE;
properties.selection_type = DialogConfigs.FILE_SELECT;
properties.root = new File(DialogConfigs.DEFAULT_DIR);
properties.error_dir = new File(DialogConfigs.DEFAULT_DIR);
properties.offset = new File(DialogConfigs.DEFAULT_DIR);
properties.extensions = null;
dialog = new FilePickerDialog(MainActivity.this, properties);
dialog.setTitle("Select a File");
dialog.setDialogSelectionListener(new DialogSelectionListener() {
@Override
public void onSelectedFilePaths(String[] files) {
//files is the array of the paths of files selected by the Application User.
videoPath = files[0]; // test
String suffix = videoPath.substring(videoPath.lastIndexOf("."));
if(!SUPPORTED_TYPES.contains(suffix)) {
Toast.makeText(MainActivity.this, "不支持的格式!", Toast.LENGTH_SHORT).show();
return;
}
Log.d(TAG, "videoPath" + videoPath);
videoRenderer.changeVideoPathAndPlay(videoPath);
pause.setEnabled(true);
// Log.d(TAG, "clickable" + pause.isClickable());
pause.setBackgroundResource(R.drawable.pause);
videoRenderer.pausePlay(PLAY_PAUSE_FLAG);
}
});
}
示例2: onRequestPermissionsResult
import com.github.angads25.filepicker.view.FilePickerDialog; //导入依赖的package包/类
@Override
public void onRequestPermissionsResult(int requestCode,@NonNull String permissions[],@NonNull int[] grantResults) {
switch (requestCode) {
case FilePickerDialog.EXTERNAL_READ_PERMISSION_GRANT: {
if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
if(dialog!=null) {
//Show dialog if the read permission has been granted.
dialog.show();
}
}
else {
//Permission has not been granted. Notify the user.
Toast.makeText(MainActivity.this,"Permission is Required for getting list of files",Toast.LENGTH_SHORT).show();
}
}
}
}
示例3: onRequestPermissionsResult
import com.github.angads25.filepicker.view.FilePickerDialog; //导入依赖的package包/类
@Override
public void onRequestPermissionsResult(int requestCode,
@NonNull String permissions[], @NonNull int[] grantResults) {
switch (requestCode) {
case PERMISSIONS_REQUEST_CODE_STORAGE: {
// If request is cancelled, the result arrays are empty.
if (grantResults.length > 0
&& grantResults[0] == PackageManager.PERMISSION_GRANTED) {
UIUtils.toast("授权成功");
}
break;
}
case FilePickerDialog.EXTERNAL_READ_PERMISSION_GRANT: {
if (grantResults.length == 0
|| grantResults[0] != PackageManager.PERMISSION_GRANTED) {
UIUtils.askForStoragePermission(this);
}
break;
}
}
}
示例4: load
import com.github.angads25.filepicker.view.FilePickerDialog; //导入依赖的package包/类
/**
* Load a configuration. This method displays the file picker. this file picker get the selected file config.
* This file content is deserialized and given to the callback cbDone
* @param context
* @param cbDone
*/
public void load(@NonNull Context context, @NonNull final GollumCallbackGetGeneric<Configuration> cbDone) {
Logger.d(TAG, "load()");
DialogProperties dialogProperties = new DialogProperties();
dialogProperties.selection_type = DialogConfigs.FILE_SELECT;
dialogProperties.selection_mode = DialogConfigs.SINGLE_MODE;
dialogProperties.root = Environment.getExternalStorageDirectory();
dialogProperties.error_dir = new File(DialogConfigs.DEFAULT_DIR);
dialogProperties.offset = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOCUMENTS);
dialogProperties.extensions = new String[]{"json"};
FilePickerDialog filePickerDialog = new FilePickerDialog(context, dialogProperties);
filePickerDialog.setDialogSelectionListener(new DialogSelectionListener() {
@Override
public void onSelectedFilePaths(String[] files) {
if (files.length > 0) {
Logger.d(TAG, "file selected: " + files[0]);
Configuration configuration = load(files[0]);
if (configuration != null) {
Logger.d(TAG, "configuration NOT NULL");
cbDone.done(configuration, null);
} else {
Logger.d(TAG, "configuration IS NULL");
cbDone.done(null, null);
}
}
}
});
filePickerDialog.show();
}
示例5: openFilePickerDialog
import com.github.angads25.filepicker.view.FilePickerDialog; //导入依赖的package包/类
/**
* Open a file picker dialog to ease select a new image from external storage.
*/
public void openFilePickerDialog() {
DialogProperties properties = new DialogProperties();
properties.selection_mode = DialogConfigs.SINGLE_MODE;
properties.selection_type = DialogConfigs.FILE_SELECT;
// initial directory should be pictures directory
properties.offset = new File("/mnt/sdcard" + File.separator + Environment.DIRECTORY_PICTURES);
// show accepted image format only
properties.extensions = new String[]{"jpg","jpeg","png","gif","bmp","webp"};
FilePickerDialog dialog = new FilePickerDialog(getActivity(), properties);
dialog.setTitle(R.string.dialog_edit_doc_cover_image_select_title);
dialog.setPositiveBtnName(getString(R.string.dialog_edit_doc_cover_image_select_ok));
dialog.setNegativeBtnName(getString(android.R.string.cancel));
dialog.setDialogSelectionListener(new DialogSelectionListener() {
@Override
public void onSelectedFilePaths(String[] files) {
if (files.length > 0) {
mImagePath = files[0];
updateImage();
}
}
});
dialog.show();
// There is a problem with library dialog theme, it does not support a light
// primary color because header text color is always white.
// With this hack (we had to study library layout) it ensures that header background
// is ok.
dialog.findViewById(R.id.header).setBackgroundColor(
ContextCompat.getColor(getActivity(), R.color.colorAccent));
}
示例6: browseForLibrary
import com.github.angads25.filepicker.view.FilePickerDialog; //导入依赖的package包/类
private void browseForLibrary() {
fab.setEnabled(false);
String rootdir = "/storage/";
final DialogProperties properties = new DialogProperties();
properties.selection_mode = DialogConfigs.SINGLE_MODE;
properties.selection_type = DialogConfigs.DIR_SELECT;
properties.root = new File(DialogConfigs.DEFAULT_DIR);
properties.root = new File(rootdir);
properties.extensions = null;
final FilePickerDialog dialog = new FilePickerDialog(BookLibrary.this, properties);
dialog.setDialogSelectionListener(new DialogSelectionListener() {
@Override
public void onSelectedFilePaths(String[] files) {
if (files.length > 0) {
String[] fileBits = files[0].split("/");
String libraryName = fileBits[fileBits.length - 1];
progressBar.setMax(2500);
progressBar.setProgress(0);
progressBar.setVisibility(View.VISIBLE);
progressBarContainer.setVisibility(View.VISIBLE);
((BookLibApplication) getApplicationContext()).getLibManager().addLibrary(prgBrHandler, mHandler, libraryName, files[0]);
}
}
});
dialog.show();
}
示例7: onPreferenceSingleClick
import com.github.angads25.filepicker.view.FilePickerDialog; //导入依赖的package包/类
@Override
public boolean onPreferenceSingleClick(Preference preference) {
mPreference = preference;
File offset = null;
String current = HiSettingsHelper.getInstance().getStringValue(preference.getKey(), "");
if (!TextUtils.isEmpty(current)) {
File currentFile = new File(current);
if (currentFile.exists()) {
offset = currentFile.getParentFile();
}
}
DialogProperties properties = new DialogProperties();
properties.root = Environment.getExternalStorageDirectory();
properties.error_dir = Environment.getExternalStorageDirectory();
properties.selection_mode = DialogConfigs.SINGLE_MODE;
if (offset != null)
properties.offset = offset;
if (mType == FONT_FILE) {
properties.selection_type = DialogConfigs.FILE_SELECT;
properties.extensions = "ttf:otf".split(":");
properties.enable_clear_button = true;
} else if (mType == SAVE_DIR) {
properties.selection_type = DialogConfigs.DIR_SELECT;
}
FilePickerDialog mDialog = new FilePickerDialog(mActivity);
mDialog.setProperties(properties);
mDialog.setDialogSelectionListener(this);
mDialog.setTitle(preference.getTitle());
mDialog.show();
return false;
}
示例8: initPicturePanel
import com.github.angads25.filepicker.view.FilePickerDialog; //导入依赖的package包/类
private void initPicturePanel(final View root) {
((ImageView) root.findViewById(R.id.picture_preview)).setImageResource(R.drawable.pause_publish);
root.findViewById(R.id.picture_preview).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
DialogProperties properties = new DialogProperties();
properties.selection_mode = DialogConfigs.SINGLE_MODE;
properties.selection_type = DialogConfigs.FILE_SELECT;
properties.root = new File(DialogConfigs.STORAGE_DIR);
properties.error_dir = new File(DialogConfigs.DEFAULT_DIR);
properties.extensions = new String[]{"jpg", "png"};
FilePickerDialog dialog = new FilePickerDialog(getActivity(), properties);
dialog.setTitle("Select a File");
dialog.setDialogSelectionListener(new DialogSelectionListener() {
@Override
public void onSelectedFilePaths(String[] files) {
ImageView imageView = ((ImageView) getView().findViewById(R.id.picture_preview));
if (files != null && files.length > 0){
mPictureFilePath = files[0];
imageView.setImageBitmap(BitmapFactory.decodeFile(mPictureFilePath));
} else {
mPictureFilePath = null;
imageView.setImageResource(R.drawable.pause_publish);
}
}
});
dialog.show();
}
});
}
示例9: promptForFiles
import com.github.angads25.filepicker.view.FilePickerDialog; //导入依赖的package包/类
/**
* step 1, users selects files
*/
private void promptForFiles() {
DialogProperties properties = new DialogProperties();
properties.selection_mode = DialogConfigs.MULTI_MODE;
properties.selection_type = DialogConfigs.FILE_SELECT;
properties.root = new File(DialogConfigs.DEFAULT_DIR);
;//(Configuration.getInstance().getOsmdroidBasePath());
properties.error_dir = new File(DialogConfigs.DEFAULT_DIR);
properties.offset = new File(DialogConfigs.DEFAULT_DIR);
Set<String> registeredExtensions = ArchiveFileFactory.getRegisteredExtensions();
//api check
if (Build.VERSION.SDK_INT >= 14)
registeredExtensions.add("gpkg");
if (Build.VERSION.SDK_INT >= 10)
registeredExtensions.add("map");
String[] ret = new String[registeredExtensions.size()];
ret = registeredExtensions.toArray(ret);
properties.extensions = ret;
FilePickerDialog dialog = new FilePickerDialog(getContext(), properties);
dialog.setTitle("Select a File");
dialog.setDialogSelectionListener(new DialogSelectionListener() {
@Override
public void onSelectedFilePaths(String[] files) {
//files is the array of the paths of files selected by the Application User.
setProviderConfig(files);
}
});
dialog.show();
}
示例10: onCreate
import com.github.angads25.filepicker.view.FilePickerDialog; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_normal);
ListView messageTimeline = (ListView) this.findViewById(R.id.timeline);
fileChooseButton = (Button) this.findViewById(R.id.filebutton);
final DialogProperties properties = new DialogProperties();
properties.selection_mode = DialogConfigs.SINGLE_MODE;
properties.selection_type = DialogConfigs.FILE_SELECT;
properties.root = new File(DialogConfigs.DEFAULT_DIR);
properties.error_dir = new File(DialogConfigs.DEFAULT_DIR);
properties.extensions = null;
final FilePickerDialog dialog = new FilePickerDialog(NormalActivity.this, properties);
dialog.setTitle("File to send");
final Activity current = this;
fileChooseButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
dialog.show();
}
});
MsgBox = (EditText) this.findViewById(R.id.editText);
Messages = new MessageBoxAdapter(this);
messageTimeline.setTranscriptMode(ListView.TRANSCRIPT_MODE_ALWAYS_SCROLL);
messageTimeline.setStackFromBottom(true);
messageTimeline.setAdapter(Messages);
//messagebox handeling
Button sendButton = (Button) this.findViewById(R.id.send);
sendButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
updateList();
}
});
Intent bindIntent = new Intent(this, ScatterRoutingService.class);
bindService(bindIntent, mConnection, Context.BIND_AUTO_CREATE);
}