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


Java FileUtil类代码示例

本文整理汇总了Java中com.netease.nim.uikit.common.util.file.FileUtil的典型用法代码示例。如果您正苦于以下问题:Java FileUtil类的具体用法?Java FileUtil怎么用?Java FileUtil使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


FileUtil类属于com.netease.nim.uikit.common.util.file包,在下文中一共展示了FileUtil类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: updateFileStatusLabel

import com.netease.nim.uikit.common.util.file.FileUtil; //导入依赖的package包/类
private void updateFileStatusLabel() {
    fileStatusLabel.setVisibility(View.VISIBLE);
    progressBar.setVisibility(View.GONE);

    // 文件长度
    StringBuilder sb = new StringBuilder();
    sb.append(FileUtil.formatFileSize(msgAttachment.getSize()));
    sb.append("  ");
    // 下载状态
    String path = msgAttachment.getPathForSave();
    if (AttachmentStore.isFileExist(path)) {
        sb.append(context.getString(R.string.file_transfer_state_downloaded));
    } else {
        sb.append(context.getString(R.string.file_transfer_state_undownload));
    }
    fileStatusLabel.setText(sb.toString());
}
 
开发者ID:newDeepLearing,项目名称:decoy,代码行数:18,代码来源:MsgViewHolderFile.java

示例2: 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();
    }
}
 
开发者ID:newDeepLearing,项目名称:decoy,代码行数:26,代码来源:VideoMessageHelper.java

示例3: loadStickerCategory

import com.netease.nim.uikit.common.util.file.FileUtil; //导入依赖的package包/类
private void loadStickerCategory() {
    AssetManager assetManager = NimUIKit.getContext().getResources().getAssets();
    try {
        String[] files = assetManager.list("sticker");
        StickerCategory category;
        for (String name : files) {
            if (!FileUtil.hasExtentsion(name)) {
                category = new StickerCategory(name, name, true, getStickerOrder(name));
                stickerCategories.add(category);
                stickerCategoryMap.put(name, category);
            }
        }
        // 排序
        Collections.sort(stickerCategories, new Comparator<StickerCategory>() {
            @Override
            public int compare(StickerCategory l, StickerCategory r) {
                return l.getOrder() - r.getOrder();
            }
        });
    } catch (IOException e) {
        e.printStackTrace();
    }
}
 
开发者ID:newDeepLearing,项目名称:decoy,代码行数:24,代码来源:StickerManager.java

示例4: updateOriImageSizeTip

import com.netease.nim.uikit.common.util.file.FileUtil; //导入依赖的package包/类
private void updateOriImageSizeTip(boolean isOrig){
	if(origImageList == null)
		return;
	if(isOrig){
		long totalSize = 0;
		
		for (String filepath : origImageList) {
			totalSize += AttachmentStore.getFileLength(filepath);
		}
		originalImageSizeTip.setText(String.format(this.getResources().getString(
				R.string.picker_image_preview_original_select), FileUtil.formatFileSize(totalSize)));
		originalImage.setImageResource(R.drawable.nim_picker_orignal_checked);
	}else{
		originalImageSizeTip.setText(R.string.picker_image_preview_original);
		originalImage.setImageResource(R.drawable.nim_picker_orignal_normal);
	}
}
 
开发者ID:newDeepLearing,项目名称:decoy,代码行数:18,代码来源:PreviewImageFromLocalActivity.java

示例5: getScaledImageFileWithMD5

import com.netease.nim.uikit.common.util.file.FileUtil; //导入依赖的package包/类
public static File getScaledImageFileWithMD5(File imageFile, String mimeType) {
    String filePath = imageFile.getPath();

    if (!isInvalidPictureFile(mimeType)) {
        LogUtil.i("ImageUtil", "is invalid picture file");
        return null;
    }

    String tempFilePath = getTempFilePath(FileUtil.getExtensionName(filePath));
    File tempImageFile = AttachmentStore.create(tempFilePath);
    if (tempImageFile == null) {
        return null;
    }

    CompressFormat compressFormat = CompressFormat.JPEG;
    // 压缩数值由第三方开发者自行决定
    int maxWidth = 720;
    int quality = 60;

    if (ImageUtil.scaleImage(imageFile, tempImageFile, maxWidth, compressFormat, quality)) {
        return tempImageFile;
    } else {
        return null;
    }
}
 
开发者ID:newDeepLearing,项目名称:decoy,代码行数:26,代码来源:ImageUtil.java

示例6: updateOriImageSizeTip

import com.netease.nim.uikit.common.util.file.FileUtil; //导入依赖的package包/类
private void updateOriImageSizeTip(boolean isOrig) {
    if (origImageList == null)
        return;
    if (isOrig) {
        long totalSize = 0;

        for (String filepath : origImageList) {
            totalSize += AttachmentStore.getFileLength(filepath);
        }
        originalImageSizeTip.setText(String.format(this.getResources().getString(
                R.string.picker_image_preview_original_select), FileUtil.formatFileSize(totalSize)));
        originalImage.setImageResource(R.drawable.nim_picker_orignal_checked);
    } else {
        originalImageSizeTip.setText(R.string.picker_image_preview_original);
        originalImage.setImageResource(R.drawable.nim_picker_orignal_normal);
    }
}
 
开发者ID:netease-im,项目名称:NIM_Android_UIKit,代码行数:18,代码来源:PreviewImageFromLocalActivity.java

示例7: loadImageView

import com.netease.nim.uikit.common.util.file.FileUtil; //导入依赖的package包/类
private void loadImageView() {
    fileStatusLabel.setVisibility(View.VISIBLE);
    // 文件长度
    StringBuilder sb = new StringBuilder();
    sb.append(FileUtil.formatFileSize(msgAttachment.getSize()));
    fileStatusLabel.setText(sb.toString());

    progressBar.setVisibility(View.GONE);
}
 
开发者ID:newDeepLearing,项目名称:decoy,代码行数:10,代码来源:MsgViewHolderFile.java

示例8: smallIcon

import com.netease.nim.uikit.common.util.file.FileUtil; //导入依赖的package包/类
public static int smallIcon(String fileName) {
    String ext = FileUtil.getExtensionName(fileName).toLowerCase();
    Integer resId = smallIconMap.get(ext);
    if (resId == null) {
        return R.drawable.file_ic_session_unknow;
    }

    return resId.intValue();
}
 
开发者ID:newDeepLearing,项目名称:decoy,代码行数:10,代码来源:FileIcons.java

示例9: bigIcon

import com.netease.nim.uikit.common.util.file.FileUtil; //导入依赖的package包/类
public static int bigIcon(String fileName) {
    String ext = FileUtil.getExtensionName(fileName).toLowerCase();
    Integer resId = bigIconMap.get(ext);
    if (resId == null) {
        return R.drawable.file_ic_detail_unknow;
    }

    return resId.intValue();
}
 
开发者ID:newDeepLearing,项目名称:decoy,代码行数:10,代码来源:FileIcons.java

示例10: 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);
            }
        }
    }
}
 
开发者ID:newDeepLearing,项目名称:decoy,代码行数:37,代码来源:SendImageHelper.java

示例11: onPostExecute

import com.netease.nim.uikit.common.util.file.FileUtil; //导入依赖的package包/类
@Override
protected void onPostExecute(File result) {
	super.onPostExecute(result);

	if (result != null) {
		if (callback != null) {
			String imageFilepath = result.getAbsolutePath();
			String md5 = FileUtil.getFileNameNoEx(FileUtil.getFileNameFromPath(imageFilepath));

			if (callback != null) {
				callback.sendImage(result, isOrig);
			}
		}
	}
}
 
开发者ID:newDeepLearing,项目名称:decoy,代码行数:16,代码来源:SendImageHelper.java

示例12: showVideoInfo

import com.netease.nim.uikit.common.util.file.FileUtil; //导入依赖的package包/类
/**
 * **************************** 下载视频 *********************************
 */
private void showVideoInfo() {
    long duration = ((VideoAttachment) message.getAttachment()).getDuration();
    long fileSize = ((VideoAttachment) message.getAttachment()).getSize();

    if (duration <= 0) {
        fileInfoTextView.setText("大小: " + FileUtil.formatFileSize(fileSize));
    } else {
        long seconds = TimeUtil.getSecondsByMilliseconds(duration);
        fileInfoTextView.setText("大小: " + FileUtil.formatFileSize(fileSize) + ",时长: "
                + String.valueOf(seconds) + " 秒");
        videoLength = seconds;
    }
}
 
开发者ID:newDeepLearing,项目名称:decoy,代码行数:17,代码来源:WatchVideoActivity.java

示例13: setDownloadProgress

import com.netease.nim.uikit.common.util.file.FileUtil; //导入依赖的package包/类
private void setDownloadProgress(final String label, final long progress, final long total) {
    final float percent = (float) ((double) progress / total);

    runOnUiThread(new Runnable() {
        @Override
        public void run() {
            LayoutParams fgLayoutParams = downloadProgressForeground.getLayoutParams();
            fgLayoutParams.width = (int) (downloadProgressBackground.getWidth() * percent);
            downloadProgressForeground.setLayoutParams(fgLayoutParams);

            downloadProgressText.setText(String.format(getString(R.string.download_progress_description), label,
                    FileUtil.formatFileSize(progress), FileUtil.formatFileSize(total)));
        }
    });
}
 
开发者ID:newDeepLearing,项目名称:decoy,代码行数:16,代码来源:WatchVideoActivity.java

示例14: 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);
       }
}
 
开发者ID:newDeepLearing,项目名称:decoy,代码行数:37,代码来源:PreviewImageFromLocalActivity.java

示例15: onPostExecute

import com.netease.nim.uikit.common.util.file.FileUtil; //导入依赖的package包/类
@Override
protected void onPostExecute(File result) {
    super.onPostExecute(result);

    if (result != null) {
        if (callback != null) {
            String imageFilepath = result.getAbsolutePath();
            String md5 = FileUtil.getFileNameNoEx(FileUtil.getFileNameFromPath(imageFilepath));

            if (callback != null) {
                callback.sendImage(result, isOrig);
            }
        }
    }
}
 
开发者ID:netease-im,项目名称:NIM_Android_UIKit,代码行数:16,代码来源:SendImageHelper.java


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