xUtils3自己努力摸索中(二)

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
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值