Search in sources :

Example 1 with AxiosManager

use of com.eros.framework.manager.impl.AxiosManager in project WeexErosFramework by bmfe.

the class DefaultWXHttpAdapter method fetchUrl.

private void fetchUrl(final WXRequest request, final OnHttpListener listener) {
    AxiosManager axiosManager = ManagerFactory.getManagerService(AxiosManager.class);
    axiosManager.loadJSBundle(request, new JSBundleCallback() {

        @Override
        public void onFailure(WXResponse wxResponse) {
            if (listener != null) {
                listener.onHttpFinish(wxResponse);
            }
        }

        @Override
        public void onResponse(WXResponse wxResponse) {
            if (isInterceptor(request.url)) {
                if (listener != null) {
                    listener.onHttpFinish(wxResponse);
                }
            }
        }
    });
}
Also used : AxiosManager(com.eros.framework.manager.impl.AxiosManager) WXResponse(com.taobao.weex.common.WXResponse)

Example 2 with AxiosManager

use of com.eros.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").toUpperCase()) {
        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.eros.framework.manager.impl.AxiosManager) JSONObject(com.alibaba.fastjson.JSONObject) AxiosGet(com.eros.framework.model.AxiosGet) AxiosPost(com.eros.framework.model.AxiosPost) ParseManager(com.eros.framework.manager.impl.ParseManager)

Example 3 with AxiosManager

use of com.eros.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.eros.framework.manager.impl.AxiosManager) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) ImageItem(com.lzy.imagepicker.bean.ImageItem) ParseManager(com.eros.framework.manager.impl.ParseManager) File(java.io.File)

Example 4 with AxiosManager

use of com.eros.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.eros.framework.manager.impl.AxiosManager) FileCallBack(com.eros.framework.http.okhttp.callback.FileCallBack) File(java.io.File)

Aggregations

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