Java Code Examples for com.luck.picture.lib.config.PictureMimeType#isContent()
The following examples show how to use
com.luck.picture.lib.config.PictureMimeType#isContent() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PicassoEngine.java From PictureSelector with Apache License 2.0 | 6 votes |
/** * 加载图片 * * @param context * @param url * @param imageView */ @Override public void loadImage(@NonNull Context context, @NonNull String url, @NonNull ImageView imageView) { VideoRequestHandler videoRequestHandler = new VideoRequestHandler(); if (PictureMimeType.isContent(url)) { Picasso.get() .load(Uri.parse(url)) .into(imageView); } else { if (PictureMimeType.isUrlHasVideo(url)) { Picasso picasso = new Picasso.Builder(context.getApplicationContext()) .addRequestHandler(videoRequestHandler) .build(); picasso.load(videoRequestHandler.SCHEME_VIDEO + ":" + url) .into(imageView); } else { Picasso.get() .load(new File(url)) .into(imageView); } } }
Example 2
Source File: PictureSelectorActivity.java From PictureSelector with Apache License 2.0 | 6 votes |
/** * isSame * * @param newMedia * @return */ private boolean isLocalMediaSame(LocalMedia newMedia) { LocalMedia oldMedia = mAdapter.getItem(0); if (oldMedia == null || newMedia == null) { return false; } if (oldMedia.getPath().equals(newMedia.getPath())) { return true; } // if Content:// type,determines whether the suffix id is consistent, mainly to solve the following two types of problems // content://media/external/images/media/5844 // content://media/external/file/5844 if (PictureMimeType.isContent(newMedia.getPath()) && PictureMimeType.isContent(oldMedia.getPath())) { if (!TextUtils.isEmpty(newMedia.getPath()) && !TextUtils.isEmpty(oldMedia.getPath())) { String newId = newMedia.getPath().substring(newMedia.getPath().lastIndexOf("/") + 1); String oldId = oldMedia.getPath().substring(oldMedia.getPath().lastIndexOf("/") + 1); if (newId.equals(oldId)) { return true; } } } return false; }
Example 3
Source File: PicassoEngine.java From PictureSelector with Apache License 2.0 | 5 votes |
/** * 加载相册目录 * * @param context 上下文 * @param url 图片路径 * @param imageView 承载图片ImageView */ @Override public void loadFolderImage(@NonNull Context context, @NonNull String url, @NonNull ImageView imageView) { VideoRequestHandler videoRequestHandler = new VideoRequestHandler(); if (PictureMimeType.isContent(url)) { Picasso.get() .load(Uri.parse(url)) .resize(180, 180) .centerCrop() .placeholder(R.drawable.picture_image_placeholder) .into(imageView); } else { if (PictureMimeType.isUrlHasVideo(url)) { Picasso picasso = new Picasso.Builder(context.getApplicationContext()) .addRequestHandler(videoRequestHandler) .build(); picasso.load(videoRequestHandler.SCHEME_VIDEO + ":" + url) .resize(180, 180) .centerCrop() .placeholder(R.drawable.picture_image_placeholder) .into(imageView); } else { Picasso.get() .load(new File(url)) .resize(180, 180) .centerCrop() .placeholder(R.drawable.picture_image_placeholder) .into(imageView); } } }
Example 4
Source File: PicassoEngine.java From PictureSelector with Apache License 2.0 | 5 votes |
/** * 加载gif * * @param context 上下文 * @param url 图片路径 * @param imageView 承载图片ImageView */ @Override public void loadAsGifImage(@NonNull Context context, @NonNull String url, @NonNull ImageView imageView) { if (PictureMimeType.isContent(url)) { Picasso.get() .load(Uri.parse(url)) .into(imageView); } else { Picasso.get() .load(new File(url)) .into(imageView); } }
Example 5
Source File: PicassoEngine.java From PictureSelector with Apache License 2.0 | 5 votes |
/** * 加载图片列表图片 * * @param context 上下文 * @param url 图片路径 * @param imageView 承载图片ImageView */ @Override public void loadGridImage(@NonNull Context context, @NonNull String url, @NonNull ImageView imageView) { VideoRequestHandler videoRequestHandler = new VideoRequestHandler(); if (PictureMimeType.isContent(url)) { Picasso.get() .load(Uri.parse(url)) .resize(200, 200) .centerCrop() .placeholder(R.drawable.picture_image_placeholder) .into(imageView); } else { if (PictureMimeType.isUrlHasVideo(url)) { Picasso picasso = new Picasso.Builder(context.getApplicationContext()) .addRequestHandler(videoRequestHandler) .build(); picasso.load(videoRequestHandler.SCHEME_VIDEO + ":" + url) .resize(200, 200) .centerCrop() .placeholder(R.drawable.picture_image_placeholder) .into(imageView); } else { Picasso.get() .load(new File(url)) .resize(200, 200) .centerCrop() .placeholder(R.drawable.picture_image_placeholder) .into(imageView); } } }
Example 6
Source File: CustomCameraView.java From PictureSelector with Apache License 2.0 | 5 votes |
@Override public void onImageSaved(@NonNull ImageCapture.OutputFileResults outputFileResults) { if (mConfigReference.get() != null) { if (SdkVersionUtils.checkedAndroid_Q() && PictureMimeType.isContent(mConfigReference.get().cameraPath)) { PictureThreadUtils.executeByIo(new PictureThreadUtils.SimpleTask<Boolean>() { @Override public Boolean doInBackground() { return AndroidQTransformUtils.copyPathToDCIM(mContextReference.get(), mFileReference.get(), Uri.parse(mConfigReference.get().cameraPath)); } @Override public void onSuccess(Boolean result) { PictureThreadUtils.cancel(PictureThreadUtils.getIoPool()); } }); } } if (mImageCallbackListenerReference.get() != null && mFileReference.get() != null && mImagePreviewReference.get() != null) { mImageCallbackListenerReference.get().onLoadImage(mFileReference.get(), mImagePreviewReference.get()); } if (mImagePreviewReference.get() != null) { mImagePreviewReference.get().setVisibility(View.VISIBLE); } if (mCaptureLayoutReference.get() != null) { mCaptureLayoutReference.get().startTypeBtnAnimator(); } }
Example 7
Source File: CustomCameraView.java From PictureSelector with Apache License 2.0 | 5 votes |
/** * 重置状态 */ private void resetState() { if (mCameraView.getCaptureMode() == androidx.camera.view.CameraView.CaptureMode.VIDEO) { if (mCameraView.isRecording()) { mCameraView.stopRecording(); } if (mVideoFile != null && mVideoFile.exists()) { mVideoFile.delete(); if (SdkVersionUtils.checkedAndroid_Q() && PictureMimeType.isContent(mConfig.cameraPath)) { getContext().getContentResolver().delete(Uri.parse(mConfig.cameraPath), null, null); } else { new PictureMediaScannerConnection(getContext(), mVideoFile.getAbsolutePath()); } } } else { mImagePreview.setVisibility(INVISIBLE); if (mPhotoFile != null && mPhotoFile.exists()) { mPhotoFile.delete(); if (SdkVersionUtils.checkedAndroid_Q() && PictureMimeType.isContent(mConfig.cameraPath)) { getContext().getContentResolver().delete(Uri.parse(mConfig.cameraPath), null, null); } else { new PictureMediaScannerConnection(getContext(), mPhotoFile.getAbsolutePath()); } } } mSwitchCamera.setVisibility(VISIBLE); mFlashLamp.setVisibility(VISIBLE); mCameraView.setVisibility(View.VISIBLE); mCaptureLayout.resetCaptureLayout(); }
Example 8
Source File: PictureBaseActivity.java From PictureSelector with Apache License 2.0 | 5 votes |
/** * Insert the image into the camera folder * * @param path * @param imageFolders * @return */ protected LocalMediaFolder getImageFolder(String path, String realPath, List<LocalMediaFolder> imageFolders) { File imageFile = new File(PictureMimeType.isContent(path) ? realPath : path); File folderFile = imageFile.getParentFile(); for (LocalMediaFolder folder : imageFolders) { if (folderFile != null && folder.getName().equals(folderFile.getName())) { return folder; } } LocalMediaFolder newFolder = new LocalMediaFolder(); newFolder.setName(folderFile != null ? folderFile.getName() : ""); newFolder.setFirstImagePath(path); imageFolders.add(newFolder); return newFolder; }
Example 9
Source File: PictureVideoPlayActivity.java From PictureSelector with Apache License 2.0 | 5 votes |
@Override public void onStart() { // Play Video if (SdkVersionUtils.checkedAndroid_Q() && PictureMimeType.isContent(videoPath)) { mVideoView.setVideoURI(Uri.parse(videoPath)); } else { mVideoView.setVideoPath(videoPath); } mVideoView.start(); super.onStart(); }
Example 10
Source File: MediaUtils.java From PictureSelector with Apache License 2.0 | 5 votes |
/** * 设置LocalMedia旋转信息 * * @param context * @param media * @param isAndroidQChangeWH * @return */ public static void setOrientationSynchronous(Context context, LocalMedia media, boolean isAndroidQChangeWH, boolean isAndroidQChangeVideoWH) { if (PictureMimeType.isHasImage(media.getMimeType())) { if (!isAndroidQChangeWH) { return; } } if (PictureMimeType.isHasVideo(media.getMimeType())) { if (!isAndroidQChangeVideoWH) { return; } } // 如果有旋转信息图片宽高则是相反 int orientation = 0; if (PictureMimeType.isHasImage(media.getMimeType())) { orientation = MediaUtils.getImageOrientationForUrl(context, media.getPath()); } else if (PictureMimeType.isHasVideo(media.getMimeType())) { if (PictureMimeType.isContent(media.getPath())) { orientation = MediaUtils.getVideoOrientationForUri(context, Uri.parse(media.getPath())); } else { orientation = MediaUtils.getVideoOrientationForUrl(media.getPath()); } } if (orientation == ExifInterface.ORIENTATION_ROTATE_90 || orientation == ExifInterface.ORIENTATION_ROTATE_270) { int width = media.getWidth(); int height = media.getHeight(); media.setWidth(height); media.setHeight(width); } media.setOrientation(orientation); }