本文整理汇总了Java中com.ipaulpro.afilechooser.utils.FileUtils.getFile方法的典型用法代码示例。如果您正苦于以下问题:Java FileUtils.getFile方法的具体用法?Java FileUtils.getFile怎么用?Java FileUtils.getFile使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.ipaulpro.afilechooser.utils.FileUtils
的用法示例。
在下文中一共展示了FileUtils.getFile方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: loadCroppedBitmapFromUri
import com.ipaulpro.afilechooser.utils.FileUtils; //导入方法依赖的package包/类
/**
* Loads a Bitmap from the given URI and scales and crops it to the given size
*
* @param uri The URI to load the Bitmap from
* @param size The size the final Bitmap should be
* @return
*/
private Bitmap loadCroppedBitmapFromUri(Uri uri, int size) {
File bitmapFile = FileUtils.getFile(getActivity(), uri);
BitmapFactory.Options options = new BitmapFactory.Options();
options.inJustDecodeBounds = true;
BitmapFactory.decodeFile(bitmapFile.getPath(), options); // TODO: Handle null pointers.
options.inSampleSize = calculateSampleSize(options, size, size);
options.inJustDecodeBounds = false;
Bitmap bitmap = BitmapFactory.decodeFile(bitmapFile.getPath(), options);
if (bitmap == null) {
Utils.d("Bitmap loading failed!");
return null;
}
if (bitmap.getHeight() > size || bitmap.getWidth() > size) {
bitmap = Utils.crop(bitmap, size, size);
}
return bitmap;
}
示例2: onActivityResult
import com.ipaulpro.afilechooser.utils.FileUtils; //导入方法依赖的package包/类
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
switch (requestCode) {
case REQUEST_CODE:
if (resultCode == RESULT_OK) {
String tempFilePath, tempFileName;
final Uri uri = data.getData();
File file = FileUtils.getFile(getApplicationContext(),uri);
tempFilePath = file.toString();
tempFileName = tempFilePath.substring(tempFilePath
.lastIndexOf('/') + 1);
Log.d("msg1", tempFileName);
XmlParser t_xml = new XmlParser(getFilesDir());
t_xml.addFile(tempFileName, tempFilePath);
Log.d("msg2", tempFilePath);
filearray.add(tempFileName);
arrayadapter.notifyDataSetChanged();
}
}
}
示例3: onActivityResult
import com.ipaulpro.afilechooser.utils.FileUtils; //导入方法依赖的package包/类
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
switch (requestCode) {
case REQUEST_CODE:
if (resultCode == Activity.RESULT_OK) {
String tempFilePath, tempFileName;
final Uri uri = data.getData();
File file = FileUtils.getFile(ab,uri);
tempFilePath = file.toString();
tempFileName = tempFilePath.substring(tempFilePath
.lastIndexOf('/') + 1);
Log.d("msg1", tempFileName);
XmlParser t_xml = new XmlParser(ab.getFilesDir());
t_xml.addFile(tempFileName, tempFilePath);
Log.d("msg2", tempFilePath);
arrayadapter.add(tempFileName);
}
}
}
示例4: removeRecording
import com.ipaulpro.afilechooser.utils.FileUtils; //导入方法依赖的package包/类
/**
* Clears the recording if any was made
*/
private void removeRecording() {
if (mOutputUri != null) {
File recording = FileUtils.getFile(this, mOutputUri);
if (recording != null && recording.exists()) {
//noinspection ResultOfMethodCallIgnored
recording.delete();
}
}
}
示例5: onActivityResult
import com.ipaulpro.afilechooser.utils.FileUtils; //导入方法依赖的package包/类
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
if (data != null) {
// Get the URI of the selected file
final Uri uri = data.getData();
try {
// Create a file instance from the URI
final File file = FileUtils.getFile(uri);
switch (requestCode) {
case R.string.key_custom_fonts:
case R.string.key_custom_fonts_bold:
SharedPreferences.Editor editor = mSharedPreferences.edit();
editor.putString(getString(requestCode), file.getAbsolutePath());
editor.commit();
break;
}
} catch (Exception e) {
Log.e("FileSelectorTestActivity", "File select error", e);
}
}
updateAndMarkFontsPath();
super.onActivityResult(requestCode, resultCode, data);
}
示例6: onActivityResult
import com.ipaulpro.afilechooser.utils.FileUtils; //导入方法依赖的package包/类
/**
* Listens for the return of the get content intent. Adds the items if successful
*
* @param requestCode
* @param resultCode
* @param data
*/
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
switch (requestCode) {
case CONTENT_REQUEST:
case REQUEST_CHOOSER:
if (resultCode == Activity.RESULT_OK) {
File dataFile = null;
if (data == null) {
//In this case, we can retrieve the url from temp image pos
Utils.d("Oops... Result was OK, but intent was null. That's just great.");
dataFile = mTempResultFile;
}
else {
Uri uri = data.getData();
//In this case, we can find file in Uri path
dataFile = FileUtils.getFile(getActivity(), uri);
}
//Something failed somewhere
if (dataFile == null) {
Utils.d("Empty result was found!");
return;
}
if (!dataFile.exists()) {
Utils.d("File with result does not exist...!");
return;
}
IndexedFolder dir = mContentManager.getCurrentFolder();
mContentManager.addFile(dir, dataFile, new IOnResult<IndexedFile>() {
@Override
public void onResult(IndexedFile result) {
if (result != null) {
ArrayList<IndexedItem> itemList = new ArrayList<IndexedItem>();
itemList.add(result);
mActionManager.actionLock(itemList, null); // lock right now
result.getOriginalFile().delete();
Utils.toast(R.string.content_success_add);
}
else {
Utils.toast(R.string.content_fail_add);
}
}
});
}
break;
case REQUEST_DIRECTORY:
if (resultCode == DirectoryChooserActivity.RESULT_CODE_DIR_SELECTED) {
File exportDir = new File(data.getStringExtra(DirectoryChooserActivity.RESULT_SELECTED_DIR));
mActionManager.actionRestore(getSelectedItems(), null, exportDir);
}
break;
}
}
示例7: getFileFromContentPath
import com.ipaulpro.afilechooser.utils.FileUtils; //导入方法依赖的package包/类
/**
* Gets a file from a given uri to the devices content db
* @param contentPath {Uri} - the contentUri which references the file in the content db
* @return a file representing the file on the device
*/
public File getFileFromContentPath(Uri contentPath) {
return FileUtils.getFile(context, contentPath);
}