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);
}
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);
}
}
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);
}
}
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()));
}
}
}
}
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);
}
});
}
}
}
Aggregations