use of com.luck.picture.lib.weiui.library.entity.LocalMediaFolder in project weiui by kuaifan.
the class PictureBaseActivity method getImageFolder.
/**
* 将图片插入到相机文件夹中
*
* @param path
* @param imageFolders
* @return
*/
protected LocalMediaFolder getImageFolder(String path, List<LocalMediaFolder> imageFolders) {
File imageFile = new File(path);
File folderFile = imageFile.getParentFile();
for (LocalMediaFolder folder : imageFolders) {
if (folder.getName().equals(folderFile.getName())) {
return folder;
}
}
LocalMediaFolder newFolder = new LocalMediaFolder();
newFolder.setName(folderFile.getName());
newFolder.setPath(folderFile.getAbsolutePath());
newFolder.setFirstImagePath(path);
imageFolders.add(newFolder);
return newFolder;
}
use of com.luck.picture.lib.weiui.library.entity.LocalMediaFolder in project weiui by kuaifan.
the class FolderPopWindow method notifyDataCheckedStatus.
/**
* 设置选中状态
*/
public void notifyDataCheckedStatus(List<LocalMedia> medias) {
try {
// 获取选中图片
List<LocalMediaFolder> folders = adapter.getFolderData();
for (LocalMediaFolder folder : folders) {
folder.setCheckedNum(0);
}
if (medias.size() > 0) {
for (LocalMediaFolder folder : folders) {
// 记录当前相册下有多少张是选中的
int num = 0;
List<LocalMedia> images = folder.getImages();
for (LocalMedia media : images) {
String path = media.getPath();
for (LocalMedia m : medias) {
if (path.equals(m.getPath())) {
num++;
folder.setCheckedNum(num);
}
}
}
}
}
adapter.bindFolderData(folders);
} catch (Exception e) {
e.printStackTrace();
}
}
use of com.luck.picture.lib.weiui.library.entity.LocalMediaFolder in project weiui by kuaifan.
the class PictureBaseActivity method createNewFolder.
/**
* 如果没有任何相册,先创建一个最近相册出来
*
* @param folders
*/
protected void createNewFolder(List<LocalMediaFolder> folders) {
if (folders.size() == 0) {
// 没有相册 先创建一个最近相册出来
LocalMediaFolder newFolder = new LocalMediaFolder();
String folderName = config.mimeType == PictureMimeType.ofAudio() ? getString(R.string.picture_all_audio) : getString(R.string.picture_camera_roll);
newFolder.setName(folderName);
newFolder.setPath("");
newFolder.setFirstImagePath("");
folders.add(newFolder);
}
}
use of com.luck.picture.lib.weiui.library.entity.LocalMediaFolder in project weiui by kuaifan.
the class PictureSelectorActivity method manualSaveFolder.
/**
* 手动添加拍照后的相片到图片列表,并设为选中
*
* @param media
*/
private void manualSaveFolder(LocalMedia media) {
try {
createNewFolder(foldersList);
LocalMediaFolder folder = getImageFolder(media.getPath(), foldersList);
LocalMediaFolder cameraFolder = foldersList.size() > 0 ? foldersList.get(0) : null;
if (cameraFolder != null && folder != null) {
// 相机胶卷
cameraFolder.setFirstImagePath(media.getPath());
cameraFolder.setImages(images);
cameraFolder.setImageNum(cameraFolder.getImageNum() + 1);
// 拍照相册
int num = folder.getImageNum() + 1;
folder.setImageNum(num);
folder.getImages().add(0, media);
folder.setFirstImagePath(cameraPath);
folderWindow.bindFolder(foldersList);
}
} catch (Exception e) {
e.printStackTrace();
}
}
use of com.luck.picture.lib.weiui.library.entity.LocalMediaFolder in project weiui by kuaifan.
the class PictureAlbumDirectoryAdapter method onBindViewHolder.
@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.tv_sign.setVisibility(checkedNum > 0 ? View.VISIBLE : View.INVISIBLE);
holder.itemView.setSelected(isChecked);
if (mimeType == PictureMimeType.ofAudio()) {
holder.first_image.setImageResource(R.drawable.audio_placeholder);
} else {
RequestOptions options = new RequestOptions().placeholder(R.drawable.ic_placeholder).centerCrop().sizeMultiplier(0.5f).diskCacheStrategy(DiskCacheStrategy.ALL).override(160, 160);
Glide.with(holder.itemView.getContext()).asBitmap().load(imagePath).apply(options).into(new BitmapImageViewTarget(holder.first_image) {
@Override
protected void setResource(Bitmap resource) {
RoundedBitmapDrawable circularBitmapDrawable = RoundedBitmapDrawableFactory.create(mContext.getResources(), resource);
circularBitmapDrawable.setCornerRadius(8);
holder.first_image.setImageDrawable(circularBitmapDrawable);
}
});
}
holder.image_num.setText("(" + imageNum + ")");
holder.tv_folder_name.setText(name);
holder.itemView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (onItemClickListener != null) {
for (LocalMediaFolder mediaFolder : folders) {
mediaFolder.setChecked(false);
}
folder.setChecked(true);
notifyDataSetChanged();
onItemClickListener.onItemClick(folder.getName(), folder.getImages());
}
}
});
}
Aggregations