xUtils3自己努力摸索中(二)

来源:互联网 发布:vue.js 2.0中文文档 编辑:程序博客网 时间:2024/05/16 06:55

xUitls3网络请求

昨天学了下xUtils3的图片显示,我最喜欢的是圆形图片了,哈哈

[ 0 ] 昨天有个地方 是讲错了的,哎,第一次用,没发现,有两个不同的回调接口,所以下面来弥补,看看是是否,昨天的结论有错不

是否有错:返回 cache为true时,是在 onCache回调,还是,在onSuccess有值?????                  @Override                public boolean onCache(String result) {                    return true;                }                  @Override                public void onSuccess(String result) {                }

一 . >get请求

 x.http().get(requestParams, new Callback.CacheCallback<String>() {                    @Override                    public boolean onCache(String result) {                        Log.e("自定义标签", "onCache() called with: " + "result = [" + result + "]");                        return true;                    }                    @Override                    public void onSuccess(String result) {                        Log.e("自定义标签", "onSuccess() called with: " + "result = [" + result + "]");                    }                    @Override                    public void onError(Throwable ex, boolean isOnCallback) {                        Log.e("自定义标签", "onError() called with: " + "ex = [" + ex + "], isOnCallback = [" + isOnCallback + "]");                    }                    @Override                    public void onCancelled(CancelledException cex) {                        Log.e("自定义标签", "onCancelled() called with: " + "cex = [" + cex + "]");                    }                    @Override                    public void onFinished() {                        Log.e("自定义标签", "onFinished() called with: " + "");                    }                });

我大概总结一下

1.get请求,中有两中回调,有个事缓存有个没有缓存,
其实有好几和Callback接口
具体看源码

public interface Callback {    public interface CommonCallback<ResultType> extends Callback {        void onSuccess(ResultType result);        void onError(Throwable ex, boolean isOnCallback);        void onCancelled(CancelledException cex);        void onFinished();    }    public interface TypedCallback<ResultType> extends CommonCallback<ResultType> {        Type getLoadType();    }    public interface CacheCallback<ResultType> extends CommonCallback<ResultType> {        boolean onCache(ResultType result);    }    public interface ProxyCacheCallback<ResultType> extends CacheCallback<ResultType> {        boolean onlyCache();    }    public interface PrepareCallback<PrepareType, ResultType> extends CommonCallback<ResultType> {        ResultType prepare(PrepareType rawData);    }    public interface ProgressCallback<ResultType> extends CommonCallback<ResultType> {        void onWaiting();        void onStarted();        void onLoading(long total, long current, boolean isDownloading);    }    public interface GroupCallback<ItemType> extends Callback {        void onSuccess(ItemType item);        void onError(ItemType item, Throwable ex, boolean isOnCallback);        void onCancelled(ItemType item, CancelledException cex);        void onFinished(ItemType item);        void onAllFinished();    }    public interface Callable<ResultType> {        void call(ResultType result);    }    public interface Cancelable {        void cancel();        boolean isCancelled();    }    public static class CancelledException extends RuntimeException {        public CancelledException(String detailMessage) {            super(detailMessage);        }    }}

2.post请求,下次写哈,最近玩的厉害,放了几天假,然后学了百度地图,和自定义控件,这个自学学的也够呛的,所以,先不写了,回头来补上,哈哈,算给自己挖个坑吧,xUtils,的数据库,等等,以后肯定学回来,但现在,我们今天学了自定义控件,所以先放着

0 0
原创粉丝点击