当前位置: 首页>>代码示例>>Java>>正文


Java FileUtils.getFile方法代码示例

本文整理汇总了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;
}
 
开发者ID:droidstealth,项目名称:droid-stealth,代码行数:30,代码来源:MorphingFragment.java

示例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();
		}
	}
}
 
开发者ID:BucketDevelopers,项目名称:AndroidFileBroadcast,代码行数:21,代码来源:File_Download.java

示例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);
			}
		}
	}
 
开发者ID:BucketDevelopers,项目名称:AndroidFileBroadcast,代码行数:20,代码来源:Listpage.java

示例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();
		}
	}
}
 
开发者ID:droidstealth,项目名称:droid-stealth,代码行数:13,代码来源:RecorderActivity.java

示例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);
}
 
开发者ID:feelinglucky,项目名称:iZhihu,代码行数:29,代码来源:PreferencesFragment.java

示例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;
	}
}
 
开发者ID:droidstealth,项目名称:droid-stealth,代码行数:66,代码来源:ContentFragment.java

示例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);
}
 
开发者ID:schul-cloud,项目名称:schulcloud-mobile-android,代码行数:9,代码来源:InternalFilesUtil.java


注:本文中的com.ipaulpro.afilechooser.utils.FileUtils.getFile方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。