Search in sources :

Example 6 with LocalMedia

use of com.ningcui.mylibrary.viewLib.Imagepicker.entity.LocalMedia in project JustAndroid by chinaltz.

the class LuBanCompress method handleCompressCallBack.

private void handleCompressCallBack(List<File> files) {
    for (int i = 0, j = images.size(); i < j; i++) {
        // 压缩成功后的地址
        String path = files.get(i).getPath();
        LocalMedia image = images.get(i);
        // 如果是网络图片则不压缩
        if (path != null && path.startsWith("http")) {
            image.setCompressPath("");
        } else {
            image.setCompressed(true);
            image.setCompressPath(path);
        }
    }
    listener.onCompressSuccess(images);
}
Also used : LocalMedia(com.ningcui.mylibrary.viewLib.Imagepicker.entity.LocalMedia)

Example 7 with LocalMedia

use of com.ningcui.mylibrary.viewLib.Imagepicker.entity.LocalMedia in project JustAndroid by chinaltz.

the class PicturePreviewActivity method onImageChecked.

/**
 * 判断当前图片是否选中
 *
 * @param position
 */
public void onImageChecked(int position) {
    if (images != null && images.size() > 0) {
        LocalMedia media = images.get(position);
        check.setSelected(isSelected(media));
    } else {
        check.setSelected(false);
    }
}
Also used : LocalMedia(com.ningcui.mylibrary.viewLib.Imagepicker.entity.LocalMedia)

Example 8 with LocalMedia

use of com.ningcui.mylibrary.viewLib.Imagepicker.entity.LocalMedia in project JustAndroid by chinaltz.

the class PicturePreviewActivity method subSelectPosition.

/**
 * 更新选择的顺序
 */
private void subSelectPosition() {
    for (int index = 0, len = selectImages.size(); index < len; index++) {
        LocalMedia media = selectImages.get(index);
        media.setNum(index + 1);
    }
}
Also used : LocalMedia(com.ningcui.mylibrary.viewLib.Imagepicker.entity.LocalMedia)

Example 9 with LocalMedia

use of com.ningcui.mylibrary.viewLib.Imagepicker.entity.LocalMedia in project JustAndroid by chinaltz.

the class PicturePreviewActivity method notifyCheckChanged.

/**
 * 选择按钮更新
 */
private void notifyCheckChanged(LocalMedia imageBean) {
    if (checkNumMode) {
        check.setText("");
        for (LocalMedia media : selectImages) {
            if (media.getPath().equals(imageBean.getPath())) {
                imageBean.setNum(media.getNum());
                check.setText(String.valueOf(imageBean.getNum()));
            }
        }
    }
}
Also used : LocalMedia(com.ningcui.mylibrary.viewLib.Imagepicker.entity.LocalMedia)

Example 10 with LocalMedia

use of com.ningcui.mylibrary.viewLib.Imagepicker.entity.LocalMedia in project JustAndroid by chinaltz.

the class GridImageAdapter method onBindViewHolder.

/**
 * 设置值
 */
@Override
public void onBindViewHolder(final ViewHolder viewHolder, final int position) {
    // 少于8张,显示继续添加的图标
    if (getItemViewType(position) == TYPE_CAMERA) {
        viewHolder.mImg.setImageResource(R.drawable.addimg_1x);
        viewHolder.mImg.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                mOnAddPicClickListener.onAddPicClick();
            }
        });
        viewHolder.ll_del.setVisibility(View.INVISIBLE);
    } else {
        viewHolder.ll_del.setVisibility(View.VISIBLE);
        viewHolder.ll_del.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View view) {
                int index = viewHolder.getAdapterPosition();
                list.remove(index);
                notifyItemRemoved(index);
                notifyItemRangeChanged(index, list.size());
                DebugUtil.i("delete position:", index + "--->remove after:" + list.size());
            }
        });
        LocalMedia media = list.get(position);
        String path = "";
        if (media.isCompressed()) {
            // 压缩过,或者裁剪同时压缩过,以最终压缩过图片为准
            path = media.getCompressPath();
        } else {
            // 原图
            path = media.getPath();
        }
        // 图片
        if (media.isCompressed()) {
            Log.i("compress image result:", new File(media.getCompressPath()).length() / 1024 + "k");
            Log.i("压缩地址::", media.getCompressPath());
        }
        Log.i("原图地址::", media.getPath());
        Glide.with(viewHolder.itemView.getContext()).load(path).centerCrop().placeholder(R.color.color_f6).diskCacheStrategy(DiskCacheStrategy.RESULT).into(viewHolder.mImg);
        // itemView 的点击事件
        if (mItemClickListener != null) {
            viewHolder.itemView.setOnClickListener(new View.OnClickListener() {

                @Override
                public void onClick(View v) {
                    int adapterPosition = viewHolder.getAdapterPosition();
                    mItemClickListener.onItemClick(adapterPosition, v);
                }
            });
        }
    }
}
Also used : LocalMedia(com.ningcui.mylibrary.viewLib.Imagepicker.entity.LocalMedia) ImageView(android.widget.ImageView) RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View) File(java.io.File)

Aggregations

LocalMedia (com.ningcui.mylibrary.viewLib.Imagepicker.entity.LocalMedia)18 View (android.view.View)4 RecyclerView (android.support.v7.widget.RecyclerView)3 ImageView (android.widget.ImageView)3 TextView (android.widget.TextView)3 ArrayList (java.util.ArrayList)3 Bundle (android.os.Bundle)2 File (java.io.File)2 Intent (android.content.Intent)1 Bitmap (android.graphics.Bitmap)1 Nullable (android.support.annotation.Nullable)1 GridImageAdapter (com.litingzhe.justandroid.someOther.imagePicker.adapter.GridImageAdapter)1 FullyGridLayoutManager (com.litingzhe.justandroid.someOther.imagePicker.utils.FullyGridLayoutManager)1 LocalMediaFolder (com.ningcui.mylibrary.viewLib.Imagepicker.entity.LocalMediaFolder)1 RxPermissions (com.ningcui.mylibrary.viewLib.Imagepicker.permissions.RxPermissions)1 Disposable (io.reactivex.disposables.Disposable)1 PhotoView (uk.co.senab.photoview.PhotoView)1 PhotoViewAttacher (uk.co.senab.photoview.PhotoViewAttacher)1