use of com.benmu.framework.manager.impl.AxiosManager 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.benmu.framework.manager.impl.AxiosManager in project WeexErosFramework by bmfe.
the class EventFetch method fetch.
public void fetch(String params, final Context context, final JSCallback jscallback) {
ParseManager parseManager = ManagerFactory.getManagerService(ParseManager.class);
AxiosManager axiosManager = ManagerFactory.getManagerService(AxiosManager.class);
JSONObject object = parseManager.parseObject(params);
final String mUrl = object.getString("url");
Boolean noRepeat = object.getBoolean("noRepeat");
if (noRepeat != null && noRepeat) {
axiosManager.cancel(mUrl);
}
switch(object.getString("method")) {
case OkHttpUtils.METHOD.GET:
AxiosGet axiosGet = parseManager.parseObject(params, AxiosGet.class);
get(context, axiosManager, axiosGet, jscallback);
break;
case OkHttpUtils.METHOD.POST:
AxiosPost axiosPost = parseManager.parseObject(params, AxiosPost.class);
post(context, axiosManager, axiosPost, jscallback);
break;
case OkHttpUtils.METHOD.HEAD:
AxiosGet axiosHead = parseManager.parseObject(params, AxiosGet.class);
head(context, axiosManager, axiosHead, jscallback);
break;
case OkHttpUtils.METHOD.DELETE:
AxiosPost axiosDelete = parseManager.parseObject(params, AxiosPost.class);
delete(context, axiosManager, axiosDelete, jscallback);
break;
case OkHttpUtils.METHOD.PUT:
AxiosPost axiosPut = parseManager.parseObject(params, AxiosPost.class);
put(context, axiosManager, axiosPut, jscallback);
break;
case OkHttpUtils.METHOD.PATCH:
AxiosPost axiosPatch = parseManager.parseObject(params, AxiosPost.class);
patch(context, axiosManager, axiosPatch, jscallback);
break;
}
}
use of com.benmu.framework.manager.impl.AxiosManager in project WeexErosFramework by bmfe.
the class MultipleFileDownloader method execute.
public void execute() {
if (mList == null)
return;
AxiosManager axiosManager = ManagerFactory.getManagerService(AxiosManager.class);
for (final String url : mList) {
final String fileName = createFileName(url);
axiosManager.download(url, new FileCallBack(mPath, fileName) {
@Override
public void onError(Call call, Exception e, int id) {
mSize++;
Log.e("url", "error" + url);
erros.add(new FileItem(new File(mPath, fileName).getAbsolutePath(), fileName));
postResult(mSize);
}
@Override
public void onResponse(File response, int id) {
mSize++;
Log.e("url", url);
paths.add(new FileItem(new File(mPath, fileName).getAbsolutePath(), fileName));
postResult(mSize);
}
});
}
}
Aggregations