Search in sources :

Example 1 with AxiosManager

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);
}
Also used : Bitmap(android.graphics.Bitmap) AxiosManager(com.benmu.framework.manager.impl.AxiosManager) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) ImageItem(com.lzy.imagepicker.bean.ImageItem) ParseManager(com.benmu.framework.manager.impl.ParseManager) File(java.io.File)

Example 2 with AxiosManager

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;
    }
}
Also used : AxiosManager(com.benmu.framework.manager.impl.AxiosManager) JSONObject(com.alibaba.fastjson.JSONObject) AxiosGet(com.benmu.framework.model.AxiosGet) AxiosPost(com.benmu.framework.model.AxiosPost) ParseManager(com.benmu.framework.manager.impl.ParseManager)

Example 3 with AxiosManager

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);
            }
        });
    }
}
Also used : Call(okhttp3.Call) AxiosManager(com.benmu.framework.manager.impl.AxiosManager) FileCallBack(com.benmu.framework.http.okhttp.callback.FileCallBack) File(java.io.File)

Aggregations

AxiosManager (com.benmu.framework.manager.impl.AxiosManager)3 ParseManager (com.benmu.framework.manager.impl.ParseManager)2 File (java.io.File)2 Bitmap (android.graphics.Bitmap)1 JSONObject (com.alibaba.fastjson.JSONObject)1 FileCallBack (com.benmu.framework.http.okhttp.callback.FileCallBack)1 AxiosGet (com.benmu.framework.model.AxiosGet)1 AxiosPost (com.benmu.framework.model.AxiosPost)1 ImageItem (com.lzy.imagepicker.bean.ImageItem)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 Call (okhttp3.Call)1