Search in sources :

Example 1 with LocalMediaFolder

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);
    }
}
Also used : LocalMediaFolder(com.ningcui.mylibrary.viewLib.Imagepicker.entity.LocalMediaFolder)

Example 2 with LocalMediaFolder

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;
}
Also used : LocalMediaFolder(com.ningcui.mylibrary.viewLib.Imagepicker.entity.LocalMediaFolder) File(java.io.File)

Example 3 with LocalMediaFolder

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();
    }
}
Also used : LocalMediaFolder(com.ningcui.mylibrary.viewLib.Imagepicker.entity.LocalMediaFolder)

Example 4 with LocalMediaFolder

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());
        }
    });
}
Also used : RoundedBitmapDrawable(android.support.v4.graphics.drawable.RoundedBitmapDrawable) LocalMediaFolder(com.ningcui.mylibrary.viewLib.Imagepicker.entity.LocalMediaFolder) Bitmap(android.graphics.Bitmap) BitmapImageViewTarget(com.bumptech.glide.request.target.BitmapImageViewTarget) ImageView(android.widget.ImageView) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView) View(android.view.View)

Example 5 with LocalMediaFolder

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;
}
Also used : LocalMediaFolder(com.ningcui.mylibrary.viewLib.Imagepicker.entity.LocalMediaFolder) File(java.io.File)

Aggregations

LocalMediaFolder (com.ningcui.mylibrary.viewLib.Imagepicker.entity.LocalMediaFolder)6 File (java.io.File)2 Bitmap (android.graphics.Bitmap)1 RoundedBitmapDrawable (android.support.v4.graphics.drawable.RoundedBitmapDrawable)1 RecyclerView (android.support.v7.widget.RecyclerView)1 View (android.view.View)1 ImageView (android.widget.ImageView)1 TextView (android.widget.TextView)1 BitmapImageViewTarget (com.bumptech.glide.request.target.BitmapImageViewTarget)1 LocalMedia (com.ningcui.mylibrary.viewLib.Imagepicker.entity.LocalMedia)1