本文整理汇总了Java中com.netease.nim.uikit.common.util.file.FileUtil.getExtensionName方法的典型用法代码示例。如果您正苦于以下问题:Java FileUtil.getExtensionName方法的具体用法?Java FileUtil.getExtensionName怎么用?Java FileUtil.getExtensionName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.netease.nim.uikit.common.util.file.FileUtil
的用法示例。
在下文中一共展示了FileUtil.getExtensionName方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onGetLocalVideoResult
import com.netease.nim.uikit.common.util.file.FileUtil; //导入方法依赖的package包/类
/**
* 获取本地相册视频回调操作
*/
public void onGetLocalVideoResult(final Intent data) {
if (data == null) {
return;
}
String filePath = filePathFromIntent(data);
if (StringUtil.isEmpty(filePath) || !checkVideoFile(filePath)) {
return;
}
String md5 = MD5.getStreamMD5(filePath);
String filename = md5 + "." + FileUtil.getExtensionName(filePath);
String md5Path = StorageUtil.getWritePath(filename, StorageType.TYPE_VIDEO);
if (AttachmentStore.copy(filePath, md5Path) != -1) {
if (listener != null) {
listener.onVideoPicked(new File(md5Path), md5);
}
} else {
Toast.makeText(activity, R.string.video_exception, Toast.LENGTH_SHORT).show();
}
}
示例2: sendImageAfterPreviewPhotoActivityResult
import com.netease.nim.uikit.common.util.file.FileUtil; //导入方法依赖的package包/类
public static void sendImageAfterPreviewPhotoActivityResult(Intent data, Callback callback) {
final ArrayList<String> selectedImageFileList = data.getStringArrayListExtra(Extras.EXTRA_SCALED_IMAGE_LIST);
final ArrayList<String> origSelectedImageFileList = data.getStringArrayListExtra(Extras.EXTRA_ORIG_IMAGE_LIST);
boolean isOrig = data.getBooleanExtra(Extras.EXTRA_IS_ORIGINAL, false);
for (int i = 0; i < selectedImageFileList.size(); i++) {
String imageFilepath = selectedImageFileList.get(i);
File imageFile = new File(imageFilepath);
String origImageFilePath = origSelectedImageFileList.get(i);
if (isOrig) {
// 把原图按md5存放
String origMD5 = MD5.getStreamMD5(origImageFilePath);
String extension = FileUtil.getExtensionName(origImageFilePath);
String origMD5Path = StorageUtil.getWritePath(origMD5 + "." + extension,
StorageType.TYPE_IMAGE);
AttachmentStore.copy(origImageFilePath, origMD5Path);
// 把缩略图移到按原图计算的新md5目录下
String thumbFilename = FileUtil.getFileNameFromPath(imageFilepath);
String thumbMD5Path = StorageUtil.getReadPath(thumbFilename,
StorageType.TYPE_THUMB_IMAGE);
String origThumbMD5Path = StorageUtil.getWritePath(origMD5 + "." + extension,
StorageType.TYPE_THUMB_IMAGE);
AttachmentStore.move(thumbMD5Path, origThumbMD5Path);
if (callback != null) {
callback.sendImage(new File(origMD5Path), isOrig);
}
} else {
if (callback != null) {
callback.sendImage(imageFile, isOrig);
}
}
}
}
示例3: onGetLocalPictureResult
import com.netease.nim.uikit.common.util.file.FileUtil; //导入方法依赖的package包/类
public void onGetLocalPictureResult(int requestCode, int resultCode, final Intent data) {
if (data == null) {
return;
}
final String photoPath = data.getStringExtra(Extras.EXTRA_FILE_PATH);
if (TextUtils.isEmpty(photoPath)) {
return;
}
imageFile = new File(photoPath);
String mimeType = FileUtil.getExtensionName(photoPath);
imageFile = ImageUtil.getScaledImageFileWithMD5(imageFile, mimeType);
if (imageFile == null) {
Toast.makeText(this, R.string.picker_image_error, Toast.LENGTH_LONG).show();
return;
} else {
ImageUtil.makeThumbnail(PreviewImageFromLocalActivity.this,
imageFile);
}
origImageList.add(photoPath);
selectImageList.add(imageFile.getAbsolutePath());
imageViewPagerAdapter.notifyDataSetChanged();
final Handler handler = new Handler();
handler.postDelayed(new Runnable() {
@Override
public void run() {
imageViewPager.setCurrentItem(selectImageList.size() - 1);
}
}, 100);
//有可用的图片
if(selectImageList.size() >= 1){
sendButton.setEnabled(true);
}
}
示例4: onGetLocalPictureResult
import com.netease.nim.uikit.common.util.file.FileUtil; //导入方法依赖的package包/类
public void onGetLocalPictureResult(int requestCode, int resultCode, final Intent data) {
if (data == null) {
return;
}
final String photoPath = data.getStringExtra(Extras.EXTRA_FILE_PATH);
if (TextUtils.isEmpty(photoPath)) {
return;
}
imageFile = new File(photoPath);
String mimeType = FileUtil.getExtensionName(photoPath);
imageFile = ImageUtil.getScaledImageFileWithMD5(imageFile, mimeType);
if (imageFile == null) {
Toast.makeText(this, R.string.picker_image_error, Toast.LENGTH_LONG).show();
return;
} else {
ImageUtil.makeThumbnail(PreviewImageFromLocalActivity.this,
imageFile);
}
origImageList.add(photoPath);
selectImageList.add(imageFile.getAbsolutePath());
imageViewPagerAdapter.notifyDataSetChanged();
final Handler handler = new Handler();
handler.postDelayed(new Runnable() {
@Override
public void run() {
imageViewPager.setCurrentItem(selectImageList.size() - 1);
}
}, 100);
//有可用的图片
if (selectImageList.size() >= 1) {
sendButton.setEnabled(true);
}
}