use of com.lzy.imagepicker.bean.ImageItem in project ImagePicker by jeasonlzy.
the class ImageGridAdapter method getView.
@Override
public View getView(final int position, View convertView, ViewGroup parent) {
int itemViewType = getItemViewType(position);
if (itemViewType == ITEM_TYPE_CAMERA) {
convertView = LayoutInflater.from(mActivity).inflate(R.layout.adapter_camera_item, parent, false);
//让图片是个正方形
convertView.setLayoutParams(new AbsListView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, mImageSize));
convertView.setTag(null);
convertView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (!((ImageBaseActivity) mActivity).checkPermission(Manifest.permission.CAMERA)) {
ActivityCompat.requestPermissions(mActivity, new String[] { Manifest.permission.CAMERA }, ImageGridActivity.REQUEST_PERMISSION_CAMERA);
} else {
imagePicker.takePicture(mActivity, ImagePicker.REQUEST_CODE_TAKE);
}
}
});
} else {
final ViewHolder holder;
if (convertView == null) {
convertView = LayoutInflater.from(mActivity).inflate(R.layout.adapter_image_list_item, parent, false);
//让图片是个正方形
convertView.setLayoutParams(new AbsListView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, mImageSize));
holder = new ViewHolder(convertView);
convertView.setTag(holder);
} else {
holder = (ViewHolder) convertView.getTag();
}
final ImageItem imageItem = getItem(position);
holder.ivThumb.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (listener != null)
listener.onImageItemClick(holder.rootView, imageItem, position);
}
});
holder.cbCheck.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
int selectLimit = imagePicker.getSelectLimit();
if (holder.cbCheck.isChecked() && mSelectedImages.size() >= selectLimit) {
Toast.makeText(mActivity.getApplicationContext(), mActivity.getString(R.string.select_limit, selectLimit), Toast.LENGTH_SHORT).show();
holder.cbCheck.setChecked(false);
holder.mask.setVisibility(View.GONE);
} else {
imagePicker.addSelectedImageItem(position, imageItem, holder.cbCheck.isChecked());
holder.mask.setVisibility(View.VISIBLE);
}
}
});
//根据是否多选,显示或隐藏checkbox
if (imagePicker.isMultiMode()) {
holder.cbCheck.setVisibility(View.VISIBLE);
boolean checked = mSelectedImages.contains(imageItem);
if (checked) {
holder.mask.setVisibility(View.VISIBLE);
holder.cbCheck.setChecked(true);
} else {
holder.mask.setVisibility(View.GONE);
holder.cbCheck.setChecked(false);
}
} else {
holder.cbCheck.setVisibility(View.GONE);
}
//显示图片
imagePicker.getImageLoader().displayImage(mActivity, imageItem.path, holder.ivThumb, mImageSize, mImageSize);
}
return convertView;
}
use of com.lzy.imagepicker.bean.ImageItem in project WeexErosFramework by bmfe.
the class DefaultImageAdapter method UpMultipleImageData.
public void UpMultipleImageData(Context context, ArrayList<ImageItem> items, UploadImageBean bean) {
ModalManager.BmLoading.showLoading(context, null, false);
ArrayList imagesFilrUrl = new ArrayList();
if (items != null && items.size() > 0) {
for (ImageItem item : items) {
Bitmap bitmap = ImageUtil.getBitmap(item.path, context);
// TODO 图片改为全路径
String path = new File(FileManager.getTempFilePath(context), String.valueOf(SystemClock.currentThreadTimeMillis())).getAbsolutePath();
String imageFileUrl = ImageUtil.zoomImage(context, bitmap, bean == null ? 0 : (int) bean.imageWidth, Constant.ImageConstants.BIGGESTWIDTH, path);
imagesFilrUrl.add(imageFileUrl);
bitmap.recycle();
}
}
HashMap<String, String> uploadParams = null;
HashMap<String, String> heads = null;
if (bean != null) {
String params = bean.params;
ParseManager parseManager = ManagerFactory.getManagerService(ParseManager.class);
uploadParams = parseManager.parseObject(params, HashMap.class);
heads = parseManager.parseObject(bean.header, HashMap.class);
}
AxiosManager axiosManager = ManagerFactory.getManagerService(AxiosManager.class);
String url = TextUtils.isEmpty(bean.url) ? Api.UPLOAD_URL : bean.url;
axiosManager.upload(url, imagesFilrUrl, uploadParams, heads);
}
use of com.lzy.imagepicker.bean.ImageItem in project WeexErosFramework by bmfe.
the class EventFetch method uploadImage.
public void uploadImage(String json, Context context, JSCallback jsCallback) {
mUploadAvatar = jsCallback;
mUploadContext = context;
UploadImageBean bean = ManagerFactory.getManagerService(ParseManager.class).parseObject(json, UploadImageBean.class);
ManagerFactory.getManagerService(DispatchEventManager.class).getBus().register(this);
ImageManager imageManager = ManagerFactory.getManagerService(ImageManager.class);
ArrayList<ImageItem> items = new ArrayList<>();
if (bean.images == null || bean.images.size() == 0) {
Toast.makeText(context, "没传递上传的图片~", Toast.LENGTH_SHORT).show();
return;
}
for (String path : bean.images) {
ImageItem item = new ImageItem();
item.path = path;
items.add(item);
}
imageManager.UpMultipleImageData(context, items, bean);
}
use of com.lzy.imagepicker.bean.ImageItem in project WeexErosFramework by bmfe.
the class AbstractWeexActivity method pickReturn.
/**
* 选择图片结果返回。
*/
private void pickReturn(ArrayList<ImageItem> items) {
UploadResultBean bean = new UploadResultBean();
List<String> data = new ArrayList<>();
for (ImageItem path : items) {
data.add(path.path);
}
bean.data = data;
ManagerFactory.getManagerService(DispatchEventManager.class).getBus().post(bean);
}
use of com.lzy.imagepicker.bean.ImageItem in project okhttp-OkGo by jeasonlzy.
the class UploadAdapter method updateData.
public List<UploadTask<?>> updateData(List<ImageItem> images) {
this.type = -1;
this.images = images;
values = new ArrayList<>();
if (images != null) {
Random random = new Random();
for (int i = 0; i < images.size(); i++) {
ImageItem imageItem = images.get(i);
// 这里是演示可以传递任何数据
PostRequest<String> postRequest = //
OkGo.<String>post(Urls.URL_FORM_UPLOAD).headers("aaa", //
"111").params("bbb", //
"222").params("fileKey" + i, //
new File(imageItem.path)).converter(new StringConvert());
UploadTask<String> task = //
OkUpload.request(imageItem.path, postRequest).priority(//
random.nextInt(100)).extra1(//
imageItem).save();
values.add(task);
}
}
notifyDataSetChanged();
return values;
}
Aggregations