Java Code Examples for com.luck.picture.lib.config.PictureMimeType#ofAudio()
The following examples show how to use
com.luck.picture.lib.config.PictureMimeType#ofAudio() .
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: PictureBaseActivity.java From PictureSelector with Apache License 2.0 | 5 votes |
/** * If you don't have any albums, first create a camera film folder to come out * * @param folders */ protected void createNewFolder(List<LocalMediaFolder> folders) { if (folders.size() == 0) { // 没有相册 先创建一个最近相册出来 LocalMediaFolder newFolder = new LocalMediaFolder(); String folderName = config.chooseMode == PictureMimeType.ofAudio() ? getString(R.string.picture_all_audio) : getString(R.string.picture_camera_roll); newFolder.setName(folderName); newFolder.setFirstImagePath(""); newFolder.setCameraFolder(true); newFolder.setBucketId(-1); newFolder.setChecked(true); folders.add(newFolder); } }
Example 2
Source File: PictureBaseActivity.java From PictureSelector with Apache License 2.0 | 5 votes |
/** * get audio path * * @param data */ protected String getAudioPath(Intent data) { if (data != null && config.chooseMode == PictureMimeType.ofAudio()) { try { Uri uri = data.getData(); if (uri != null) { return Build.VERSION.SDK_INT <= Build.VERSION_CODES.KITKAT ? uri.getPath() : MediaUtils.getAudioFilePathFromUri(getContext(), uri); } } catch (Exception e) { e.printStackTrace(); } } return ""; }
Example 3
Source File: PictureBaseActivity.java From PictureSelector with Apache License 2.0 | 5 votes |
/** * start to camera audio */ public void startOpenCameraAudio() { if (PermissionChecker.checkSelfPermission(this, Manifest.permission.RECORD_AUDIO)) { Intent cameraIntent = new Intent(MediaStore.Audio.Media.RECORD_SOUND_ACTION); if (cameraIntent.resolveActivity(getPackageManager()) != null) { config.cameraMimeType = PictureMimeType.ofAudio(); startActivityForResult(cameraIntent, PictureConfig.REQUEST_CAMERA); } } else { PermissionChecker.requestPermissions(this, new String[]{Manifest.permission.RECORD_AUDIO}, PictureConfig.APPLY_AUDIO_PERMISSIONS_CODE); } }
Example 4
Source File: PictureSelectionModel.java From PictureSelector with Apache License 2.0 | 5 votes |
/** * @param isOriginalControl Whether the original image is displayed * @return */ public PictureSelectionModel isOriginalImageControl(boolean isOriginalControl) { selectionConfig.isOriginalControl = !selectionConfig.camera && selectionConfig.chooseMode != PictureMimeType.ofVideo() && selectionConfig.chooseMode != PictureMimeType.ofAudio() && isOriginalControl; return this; }
Example 5
Source File: PictureAlbumDirectoryAdapter.java From PictureSelector with Apache License 2.0 | 5 votes |
@Override public void onBindViewHolder(final ViewHolder holder, int position) { final LocalMediaFolder folder = folders.get(position); String name = folder.getName(); int imageNum = folder.getImageNum(); String imagePath = folder.getFirstImagePath(); boolean isChecked = folder.isChecked(); int checkedNum = folder.getCheckedNum(); holder.tvSign.setVisibility(checkedNum > 0 ? View.VISIBLE : View.INVISIBLE); holder.itemView.setSelected(isChecked); if (config.style != null && config.style.pictureAlbumStyle != 0) { holder.itemView.setBackgroundResource(config.style.pictureAlbumStyle); } if (chooseMode == PictureMimeType.ofAudio()) { holder.ivFirstImage.setImageResource(R.drawable.picture_audio_placeholder); } else { if (PictureSelectionConfig.imageEngine != null) { PictureSelectionConfig.imageEngine.loadFolderImage(holder.itemView.getContext(), imagePath, holder.ivFirstImage); } } Context context = holder.itemView.getContext(); String firstTitle = folder.getOfAllType() != -1 ? folder.getOfAllType() == PictureMimeType.ofAudio() ? context.getString(R.string.picture_all_audio) : context.getString(R.string.picture_camera_roll) : name; holder.tvFolderName.setText(context.getString(R.string.picture_camera_roll_num, firstTitle, imageNum)); holder.itemView.setOnClickListener(view -> { if (onAlbumItemClickListener != null) { int size = folders.size(); for (int i = 0; i < size; i++) { LocalMediaFolder mediaFolder = folders.get(i); mediaFolder.setChecked(false); } folder.setChecked(true); notifyDataSetChanged(); onAlbumItemClickListener.onItemClick(position, folder.isCameraFolder(), folder.getBucketId(), folder.getName(), folder.getData()); } }); }
Example 6
Source File: PictureImageGridAdapter.java From PictureSelector with Apache License 2.0 | 5 votes |
public CameraViewHolder(View itemView) { super(itemView); headerView = itemView; tvCamera = itemView.findViewById(R.id.tvCamera); String title = config.chooseMode == PictureMimeType.ofAudio() ? context.getString(R.string.picture_tape) : context.getString(R.string.picture_take_picture); tvCamera.setText(title); }
Example 7
Source File: StringUtils.java From PictureSelector with Apache License 2.0 | 5 votes |
public static void tempTextFont(TextView tv, int mimeType) { String text = tv.getText().toString().trim(); String str = mimeType == PictureMimeType.ofAudio() ? tv.getContext().getString(R.string.picture_empty_audio_title) : tv.getContext().getString(R.string.picture_empty_title); String sumText = str + text; Spannable placeSpan = new SpannableString(sumText); placeSpan.setSpan(new RelativeSizeSpan(0.8f), str.length(), sumText.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); tv.setText(placeSpan); }
Example 8
Source File: CloudActivity.java From tysq-android with GNU General Public License v3.0 | 4 votes |
@Override public void onModifyArticle(int type) { if (type == FileTypeDialog.OTHER) { new LFilePicker() .withActivity(this) .withRequestCode(REQUEST_FILE_CODE) .withStartPath(Environment.getExternalStorageDirectory().getAbsolutePath()) .withMutilyMode(true) .withMaxNum(9) .start(); // .withActivity(this) // .withRequestCode(REQUEST_FILE_CODE) // .withTitle("文件选择") // .withIconStyle(Constant.ICON_STYLE_YELLOW) // // //指定初始显示路径 // .withIsGreater(false)//过滤文件大小 小于指定大小的文件 // .withFileSize(1024 * 1024 * 1024)//指定文件大小为1G` // .withChooseMode(false)//文件夹选择模式 // //.withFileFilter(new String[]{"txt", "png", "docx"}) // .start(); return; } int mimeType; switch (type) { case FileTypeDialog.PIC: mimeType = PictureMimeType.ofImage(); break; case FileTypeDialog.VIDEO: mimeType = PictureMimeType.ofVideo(); break; case FileTypeDialog.AUDIO: mimeType = PictureMimeType.ofAudio(); break; default: mimeType = PictureMimeType.ofImage(); break; } int picWidth = UIUtils.dip2px(this, 50); PictureSelector.create(this) .openGallery(mimeType)// 全部.PictureMimeType.ofAll()、图片.ofImage()、视频.ofVideo()、音频.ofAudio() .maxSelectNum(9)// 最大图片选择数量 .minSelectNum(1)// 最小选择数量 .imageSpanCount(3)// 每行显示个数 .selectionMode(PictureConfig.MULTIPLE)// 多选 or 单选 .previewImage(mimeType == PictureMimeType.ofImage())// 是否可预览图片 true or false .previewVideo(mimeType == PictureMimeType.ofVideo())// 是否可预览视频 .enablePreviewAudio(mimeType == PictureMimeType.ofAudio())// 是否可播放音频 true or false .isZoomAnim(true)// 图片列表点击 缩放效果 默认true .synOrAsy(true)//同步true或异步false 压缩 默认同步 .glideOverride(picWidth, picWidth)// glide 加载宽高,越小图片列表越流畅,但会影响列表图片浏览的清晰度 .hideBottomControls(false)// 是否显示uCrop工具栏,默认不显示 .isGif(false)// 是否显示gif图片 .freeStyleCropEnabled(true)// 裁剪框是否可拖拽 .minimumCompressSize(100)// 小于100kb的图片不压缩 .forResult(REQUEST_MEDIA_CODE);//结果回调onActivityResult code }
Example 9
Source File: PictureSelectorActivity.java From PictureSelector with Apache License 2.0 | 4 votes |
@Override protected void initWidgets() { super.initWidgets(); container = findViewById(R.id.container); titleViewBg = findViewById(R.id.titleViewBg); mIvPictureLeftBack = findViewById(R.id.pictureLeftBack); mTvPictureTitle = findViewById(R.id.picture_title); mTvPictureRight = findViewById(R.id.picture_right); mTvPictureOk = findViewById(R.id.picture_tv_ok); mCbOriginal = findViewById(R.id.cb_original); mIvArrow = findViewById(R.id.ivArrow); mTvPicturePreview = findViewById(R.id.picture_id_preview); mTvPictureImgNum = findViewById(R.id.picture_tvMediaNum); mRecyclerView = findViewById(R.id.picture_recycler); mBottomLayout = findViewById(R.id.rl_bottom); mTvEmpty = findViewById(R.id.tv_empty); isNumComplete(numComplete); if (!numComplete) { animation = AnimationUtils.loadAnimation(this, R.anim.picture_anim_modal_in); } mTvPicturePreview.setOnClickListener(this); if (config.isAutomaticTitleRecyclerTop) { titleViewBg.setOnClickListener(this); } mTvPicturePreview.setVisibility(config.chooseMode != PictureMimeType.ofAudio() && config.enablePreview ? View.VISIBLE : View.GONE); mBottomLayout.setVisibility(config.selectionMode == PictureConfig.SINGLE && config.isSingleDirectReturn ? View.GONE : View.VISIBLE); mIvPictureLeftBack.setOnClickListener(this); mTvPictureRight.setOnClickListener(this); mTvPictureOk.setOnClickListener(this); mTvPictureImgNum.setOnClickListener(this); mTvPictureTitle.setOnClickListener(this); mIvArrow.setOnClickListener(this); String title = config.chooseMode == PictureMimeType.ofAudio() ? getString(R.string.picture_all_audio) : getString(R.string.picture_camera_roll); mTvPictureTitle.setText(title); mTvPictureTitle.setTag(R.id.view_tag, -1); folderWindow = new FolderPopWindow(this, config); folderWindow.setArrowImageView(mIvArrow); folderWindow.setOnAlbumItemClickListener(this); mRecyclerView.addItemDecoration(new GridSpacingItemDecoration(config.imageSpanCount, ScreenUtils.dip2px(this, 2), false)); mRecyclerView.setLayoutManager(new GridLayoutManager(getContext(), config.imageSpanCount)); if (!config.isPageStrategy) { mRecyclerView.setHasFixedSize(true); } else { mRecyclerView.setReachBottomRow(RecyclerPreloadView.BOTTOM_PRELOAD); mRecyclerView.setOnRecyclerViewPreloadListener(PictureSelectorActivity.this); } RecyclerView.ItemAnimator itemAnimator = mRecyclerView.getItemAnimator(); if (itemAnimator != null) { ((SimpleItemAnimator) itemAnimator).setSupportsChangeAnimations(false); mRecyclerView.setItemAnimator(null); } loadAllMediaData(); mTvEmpty.setText(config.chooseMode == PictureMimeType.ofAudio() ? getString(R.string.picture_audio_empty) : getString(R.string.picture_empty)); StringUtils.tempTextFont(mTvEmpty, config.chooseMode); mAdapter = new PictureImageGridAdapter(getContext(), config); mAdapter.setOnPhotoSelectChangedListener(this); switch (config.animationMode) { case AnimationType .ALPHA_IN_ANIMATION: mRecyclerView.setAdapter(new AlphaInAnimationAdapter(mAdapter)); break; case AnimationType .SLIDE_IN_BOTTOM_ANIMATION: mRecyclerView.setAdapter(new SlideInBottomAnimationAdapter(mAdapter)); break; default: mRecyclerView.setAdapter(mAdapter); break; } if (config.isOriginalControl) { mCbOriginal.setVisibility(View.VISIBLE); mCbOriginal.setChecked(config.isCheckOriginalImage); mCbOriginal.setOnCheckedChangeListener((buttonView, isChecked) -> { config.isCheckOriginalImage = isChecked; }); } }
Example 10
Source File: PictureSelectorUtils.java From DevUtils with Apache License 2.0 | 3 votes |
/** * 设置相册选择类型 * <pre> * 全部 PictureMimeType.ofAll() = 0 * 图片 ofImage() = 1 * 视频 ofVideo() = 2 * 音频 ofAudio() = 3 * </pre> * @param mimeType 相册选择类型 * @return {@link PicConfig} */ public PicConfig setMimeType(final int mimeType) { // 超过最大、最小值都默认为全部类型 if (mimeType > PictureMimeType.ofAudio() || mimeType < PictureMimeType.ofAll()) { this.mimeType = PictureMimeType.ofAll(); } else { this.mimeType = mimeType; } return this; }