use of com.ningcui.mylibrary.viewLib.Imagepicker.entity.LocalMediaFolder in project JustAndroid by chinaltz.
the class PictureBaseActivity method createNewFolder.
/**
* 如果没有任何相册,先创建一个最近相册出来
*
* @param folders
*/
protected void createNewFolder(List<LocalMediaFolder> folders) {
if (folders.size() == 0) {
// 没有相册 先创建一个最近相册出来
LocalMediaFolder newFolder = new LocalMediaFolder();
String folderName = getString(R.string.picture_camera_roll);
newFolder.setName(folderName);
newFolder.setPath("");
newFolder.setFirstImagePath("");
folders.add(newFolder);
}
}
use of com.ningcui.mylibrary.viewLib.Imagepicker.entity.LocalMediaFolder in project JustAndroid by chinaltz.
the class LocalMediaLoader method getImageFolder.
private 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.ningcui.mylibrary.viewLib.Imagepicker.entity.LocalMediaFolder in project JustAndroid by chinaltz.
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.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.ningcui.mylibrary.viewLib.Imagepicker.entity.LocalMediaFolder in project JustAndroid by chinaltz.
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);
Glide.with(holder.itemView.getContext()).load(imagePath).asBitmap().error(R.drawable.ic_placeholder).centerCrop().override(150, 150).diskCacheStrategy(DiskCacheStrategy.RESULT).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());
}
});
}
use of com.ningcui.mylibrary.viewLib.Imagepicker.entity.LocalMediaFolder in project JustAndroid by chinaltz.
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;
}
Aggregations