本文整理汇总了Java中com.netease.nim.uikit.common.util.storage.StorageType类的典型用法代码示例。如果您正苦于以下问题:Java StorageType类的具体用法?Java StorageType怎么用?Java StorageType使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
StorageType类属于com.netease.nim.uikit.common.util.storage包,在下文中一共展示了StorageType类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onGetLocalVideoResult
import com.netease.nim.uikit.common.util.storage.StorageType; //导入依赖的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: onCaptureVideoResult
import com.netease.nim.uikit.common.util.storage.StorageType; //导入依赖的package包/类
/**
* 拍摄视频后回调操作
*/
public void onCaptureVideoResult(Intent data) {
if (videoFile == null || !videoFile.exists()) {
return;
}
//N930拍照取消也产生字节为0的文件
if (videoFile.length() <= 0) {
videoFile.delete();
return;
}
String videoPath = videoFile.getPath();
String md5 = MD5.getStreamMD5(videoPath);
String md5Path = StorageUtil.getWritePath(md5 + ".mp4", StorageType.TYPE_VIDEO);
if (AttachmentStore.move(videoPath, md5Path)) {
if (listener != null) {
listener.onVideoPicked(new File(md5Path), md5);
}
}
}
示例3: choosePictureFromLocal
import com.netease.nim.uikit.common.util.storage.StorageType; //导入依赖的package包/类
/**
* 获取本地图片
*/
protected void choosePictureFromLocal() {
if (!StorageUtil.hasEnoughSpaceForWrite(PreviewImageFromLocalActivity.this, StorageType.TYPE_IMAGE, true)) {
return;
}
new AsyncTask<String, Integer, Boolean>() {
@Override
protected void onPreExecute() {
Toast.makeText(PreviewImageFromLocalActivity.this, R.string.waitfor_image_local, Toast.LENGTH_LONG).show();
}
@Override
protected Boolean doInBackground(String... params) {
return true;
}
@Override
protected void onPostExecute(Boolean result) {
int from = PickImageActivity.FROM_LOCAL;
Activity thiz = PreviewImageFromLocalActivity.this;
PickImageActivity.start(thiz, RequestCode.GET_LOCAL_IMAGE, from, "");
}
}.execute();
}
示例4: makeThumbnail
import com.netease.nim.uikit.common.util.storage.StorageType; //导入依赖的package包/类
public static String makeThumbnail(Context context, File imageFile) {
String thumbFilePath = StorageUtil.getWritePath(imageFile.getName(),
StorageType.TYPE_THUMB_IMAGE);
File thumbFile = AttachmentStore.create(thumbFilePath);
if (thumbFile == null) {
return null;
}
boolean result = scaleThumbnail(
imageFile,
thumbFile,
MsgViewHolderThumbBase.getImageMaxEdge(),
MsgViewHolderThumbBase.getImageMinEdge(),
CompressFormat.JPEG,
60);
if (!result) {
AttachmentStore.delete(thumbFilePath);
return null;
}
return thumbFilePath;
}
示例5: init
import com.netease.nim.uikit.common.util.storage.StorageType; //导入依赖的package包/类
/**
* 初始化UIKit,须传入context以及用户信息提供者
*
* @param context 上下文
* @param userInfoProvider 用户信息提供者
* @param contactProvider 通讯录信息提供者
*/
public static void init(Context context, UserInfoProvider userInfoProvider, ContactProvider contactProvider) {
NimUIKit.context = context.getApplicationContext();
NimUIKit.userInfoProvider = userInfoProvider;
NimUIKit.contactProvider = contactProvider;
NimUIKit.imageLoaderKit = new ImageLoaderKit(context, null);
// init data cache
LoginSyncDataStatusObserver.getInstance().registerLoginSyncDataStatus(true); // 监听登录同步数据完成通知
DataCacheManager.observeSDKDataChanged(true);
if (!TextUtils.isEmpty(getAccount())) {
DataCacheManager.buildDataCache(); // build data cache on auto login
}
// init tools
StorageUtil.init(context, null);
ScreenUtil.init(context);
StickerManager.getInstance().init();
// init log
String path = StorageUtil.getDirectoryByDirType(StorageType.TYPE_LOG);
LogUtil.init(path, Log.DEBUG);
}
示例6: makeThumbnail
import com.netease.nim.uikit.common.util.storage.StorageType; //导入依赖的package包/类
public static String makeThumbnail(Context context, File imageFile) {
String thumbFilePath = StorageUtil.getWritePath(imageFile.getName(),
StorageType.TYPE_THUMB_IMAGE);
File thumbFile = AttachmentStore.create(thumbFilePath);
if (thumbFile == null) {
return null;
}
boolean result = scaleThumbnail(
imageFile,
thumbFile,
MsgViewHolderThumbBase.getImageMaxEdge(),
MsgViewHolderThumbBase.getImageMinEdge(),
CompressFormat.JPEG,
60);
if (!result) {
AttachmentStore.delete(thumbFilePath);
return null;
}
return thumbFilePath;
}
示例7: choosePictureFromLocal
import com.netease.nim.uikit.common.util.storage.StorageType; //导入依赖的package包/类
/**
* 获取本地图片
*/
protected void choosePictureFromLocal() {
if (!StorageUtil.hasEnoughSpaceForWrite(PreviewImageFromLocalActivity.this, StorageType.TYPE_IMAGE, true)) {
return;
}
new AsyncTask<String, Integer, Boolean>() {
@Override
protected void onPreExecute() {
Toast.makeText(PreviewImageFromLocalActivity.this, R.string.waitfor_image_local, Toast.LENGTH_LONG).show();
}
@Override
protected Boolean doInBackground(String... params) {
return true;
}
@Override
protected void onPostExecute(Boolean result) {
int from = PickImageActivity.FROM_LOCAL;
Activity thiz = PreviewImageFromLocalActivity.this;
PickImageActivity.start(thiz, RequestCode.GET_LOCAL_IMAGE, from, "");
}
}.execute();
}
示例8: init
import com.netease.nim.uikit.common.util.storage.StorageType; //导入依赖的package包/类
/**
* 初始化UIKit,须传入context以及用户信息提供者
*
* @param context 上下文
* @param userInfoProvider 用户信息提供者
* @param contactProvider 通讯录信息提供者
*/
public static void init(Context context, UserInfoProvider userInfoProvider, ContactProvider contactProvider) {
NimUIKit.context = context.getApplicationContext();
initUserInfoProvider(userInfoProvider);
initContactProvider(contactProvider);
initDefaultSessionCustomization();
initDefaultContactEventListener();
NimUIKit.imageLoaderKit = new ImageLoaderKit(context);
// init data cache
LoginSyncDataStatusObserver.getInstance().registerLoginSyncDataStatus(true); // 监听登录同步数据完成通知
DataCacheManager.observeSDKDataChanged(true);
if (!TextUtils.isEmpty(getAccount())) {
DataCacheManager.buildDataCache(); // build data cache on auto login
getImageLoaderKit().buildImageCache(); // build image cache on auto login
}
// init tools
StorageUtil.init(context, null);
ScreenUtil.init(context);
StickerManager.getInstance().init();
// init log
String path = StorageUtil.getDirectoryByDirType(StorageType.TYPE_LOG);
LogUtil.init(path, Log.DEBUG);
}
示例9: sendImageAfterPreviewPhotoActivityResult
import com.netease.nim.uikit.common.util.storage.StorageType; //导入依赖的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);
}
}
}
}
示例10: chooseVideoFromCamera
import com.netease.nim.uikit.common.util.storage.StorageType; //导入依赖的package包/类
/**
* 拍摄视频
*/
protected void chooseVideoFromCamera() {
if (!StorageUtil.hasEnoughSpaceForWrite(activity,
StorageType.TYPE_VIDEO, true)) {
return;
}
videoFilePath = StorageUtil.getWritePath(
activity, StringUtil.get36UUID()
+ C.FileSuffix.MP4, StorageType.TYPE_TEMP);
videoFile = new File(videoFilePath);
// 启动视频录制
CaptureVideoActivity.start(activity, videoFilePath, captureRequestCode);
}
示例11: onPreviewImageActivityResult
import com.netease.nim.uikit.common.util.storage.StorageType; //导入依赖的package包/类
/**
* 拍摄回调
*/
private void onPreviewImageActivityResult(int requestCode, Intent data) {
if (data.getBooleanExtra(PreviewImageFromCameraActivity.RESULT_SEND, false)) {
sendImageAfterPreviewPhotoActivityResult(data);
} else if (data.getBooleanExtra(PreviewImageFromCameraActivity.RESULT_RETAKE, false)) {
String filename = StringUtil.get32UUID() + JPG;
String path = StorageUtil.getWritePath(filename, StorageType.TYPE_TEMP);
if (requestCode == RequestCode.PREVIEW_IMAGE_FROM_CAMERA) {
PickImageActivity.start(getActivity(), makeRequestCode(RequestCode.PICK_IMAGE), PickImageActivity.FROM_CAMERA, path);
}
}
}
示例12: choosePictureFromLocal
import com.netease.nim.uikit.common.util.storage.StorageType; //导入依赖的package包/类
/**
* 获取本地图片
*/
protected void choosePictureFromLocal() {
if (!StorageUtil.hasEnoughSpaceForWrite(PreviewImageFromCameraActivity.this, StorageType.TYPE_IMAGE, true)) {
return;
}
new AsyncTask<String, Integer, Boolean>() {
@Override
protected void onPreExecute() {
Toast.makeText(PreviewImageFromCameraActivity.this, R.string.waitfor_image_local, Toast.LENGTH_LONG).show();
}
@Override
protected Boolean doInBackground(String... params) {
return true;
}
@Override
protected void onPostExecute(Boolean result) {
Intent intent = new Intent(Intent.ACTION_PICK, MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
if (Build.VERSION.SDK_INT >= 11) {
intent.putExtra(Intent.EXTRA_LOCAL_ONLY, true);
}
try {
PreviewImageFromCameraActivity.this.startActivityForResult(intent, RequestCode.GET_LOCAL_IMAGE);
} catch (ActivityNotFoundException e) {
Toast.makeText(PreviewImageFromCameraActivity.this, R.string.gallery_invalid, Toast.LENGTH_LONG).show();
}
}
}.execute();
}
示例13: init
import com.netease.nim.uikit.common.util.storage.StorageType; //导入依赖的package包/类
public static void init(Context context, UIKitOptions options, IUserInfoProvider userInfoProvider, ContactProvider contactProvider) {
NimUIKitImpl.context = context.getApplicationContext();
NimUIKitImpl.options = options;
// init tools
StorageUtil.init(context, options.appCacheDir);
ScreenUtil.init(context);
if (options.loadSticker) {
StickerManager.getInstance().init();
}
// init log
String path = StorageUtil.getDirectoryByDirType(StorageType.TYPE_LOG);
LogUtil.init(path, Log.DEBUG);
NimUIKitImpl.imageLoaderKit = new ImageLoaderKit(context);
if (!options.independentChatRoom) {
initUserInfoProvider(userInfoProvider);
initContactProvider(contactProvider);
initDefaultSessionCustomization();
initDefaultContactEventListener();
// init data cache
LoginSyncDataStatusObserver.getInstance().registerLoginSyncDataStatus(true); // 监听登录同步数据完成通知
DataCacheManager.observeSDKDataChanged(true);
}
ChatRoomCacheManager.initCache();
if (!TextUtils.isEmpty(getAccount())) {
if (options.initAsync) {
DataCacheManager.buildDataCacheAsync(); // build data cache on auto login
} else {
DataCacheManager.buildDataCache(); // build data cache on auto login
buildCacheComplete = true;
}
getImageLoaderKit().buildImageCache(); // build image cache on auto login
}
}
示例14: choosePictureFromLocal
import com.netease.nim.uikit.common.util.storage.StorageType; //导入依赖的package包/类
/**
* 获取本地图片
*/
protected void choosePictureFromLocal() {
if (!StorageUtil.hasEnoughSpaceForWrite(PreviewImageFromCameraActivity.this, StorageType.TYPE_IMAGE, true)) {
return;
}
new AsyncTask<String, Integer, Boolean>() {
@Override
protected void onPreExecute() {
Toast.makeText(PreviewImageFromCameraActivity.this, R.string.waitfor_image_local, Toast.LENGTH_LONG).show();
}
@Override
protected Boolean doInBackground(String... params) {
return true;
}
@Override
protected void onPostExecute(Boolean result) {
Intent intent = new Intent(Intent.ACTION_PICK, MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
if (Build.VERSION.SDK_INT >= 11) {
intent.putExtra(Intent.EXTRA_LOCAL_ONLY, true);
}
try {
PreviewImageFromCameraActivity.this.startActivityForResult(intent, RequestCode.GET_LOCAL_IMAGE);
} catch (ActivityNotFoundException e) {
Toast.makeText(PreviewImageFromCameraActivity.this, R.string.gallery_invalid, Toast.LENGTH_LONG).show();
}
}
}.execute();
}
示例15: tempFile
import com.netease.nim.uikit.common.util.storage.StorageType; //导入依赖的package包/类
private String tempFile() {
String filename = StringUtil.get32UUID() + JPG;
return StorageUtil.getWritePath(filename, StorageType.TYPE_TEMP);
}