Coder Social home page Coder Social logo

xutils3's Introduction

xUtils3简介

xUtils 包含了orm, http(s), image, view注解, 但依然很轻量级(251K), 并且特性强大, 方便扩展.

1. orm: 高效稳定的orm工具, 使得http接口实现时更方便的支持cookie和缓存.

  • 灵活的, 类似linq表达式的接口.
  • 和greenDao一致的性能.

2. http(s): 基于UrlConnection, Android4.4以后底层为okHttp实现.

  • 请求协议支持11种谓词: GET,POST,PUT,PATCH,HEAD,MOVE,COPY,DELETE,OPTIONS,TRACE,CONNECT
  • 支持超大文件(超过2G)上传
  • 支持断点下载(如果服务端支持Range参数,客户端自动处理断点下载)
  • 支持cookie(实现了domain, path, expiry等特性)
  • 支持缓存(实现了Cache-Control, Last-Modified, ETag等特性, 缓存内容过多时使用过期时间+LRU双重机制清理)
  • 支持异步和同步(可结合RxJava使用)调用

3. image: 有了http(s)及其下载缓存的支持, image模块的实现相当的简洁.

  • 支持内存缓存, 磁盘缓存(缩略图和原图), 并且支持回收被view持有, 但被MemCache移除的图片, 减少页面回退时的闪烁.
  • 支持在ListView滑动时, 自动停止被回收复用的item对应的下载任务(再次下载时断点续传)
  • 支持webp, gif(部分比较老的系统只展示静态图)
  • 支持圆角, 圆形, 方形等裁剪, 支持自动旋转...

4. view注解: view注解模块仅仅400多行代码却灵活的支持了各种View注入和事件绑定.

  • 事件注解支持且不受混淆影响...(参考混淆配置)
  • 支持绑定拥有多个方法的listener

使用Gradle构建时添加以下依赖即可:

implementation 'org.xutils:xutils:3.9.0'

混淆配置参考示例项目sample的配置

这里可以下载aar文件

常见问题:

  1. 更好的管理图片缓存: #149
  2. Cookie的使用: #125
  3. 关于query参数? http请求可以通过 header, url, body(请求体)传参; query参数是url中问号(?)后面的参数.
  4. 关于body参数? body参数只有PUT, POST, PATCH, DELETE(老版本RFC2616文档没有明确指出它是否支持, 所以暂时支持)请求支持.
  5. 自定义Http参数对象和结果解析: #191
  6. 设置了http超时时间为5s但任然等待15s左右: GET请求失败后默认会重试2次, 可以通过setMaxRetryCount(0)来防止请求自动重试.
  7. @Event注解同一个id子类的事件会覆盖父类, onClickListener和onItemClickListener默认屏蔽了双击这种手机上不常用操作, 如需要双击支持可以自己setOnClickListener.

使用前配置

需要的权限
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /><!-- 可选 -->
初始化
// 在application的onCreate中初始化
@Override
public void onCreate() {
    super.onCreate();
    x.Ext.init(this);
    x.Ext.setDebug(BuildConfig.DEBUG); // 是否输出debug日志, 开启debug会影响性能.
    ...
}

使用@Event事件注解(@ContentView, @ViewInject等更多示例参考sample项目)

/**
 * 1. 方法必须私有限定,
 * 2. 方法参数形式必须和type对应的Listener接口一致.
 * 3. 注解参数value支持数组: value={id1, id2, id3}
 * 4. 其它参数说明见{@link org.xutils.event.annotation.Event}类的说明.
 **/
@Event(value = R.id.btn_test1,
        type = View.OnClickListener.class/*可选参数, 默认是View.OnClickListener.class*/)
private void onTest1Click(View view) {
...
}

使用数据库(更多示例参考sample项目)

Parent test = db.selector(Parent.class)
                    .where("id", "in", new int[]{1, 3, 6})
                    .or("age", "<", 29)
                    .findFirst();
long count = db.selector(Parent.class)
                    .where("name", "LIKE", "w%")
                    .and("age", ">", 32)
                    .count();
List<Parent> testList = db.selector(Parent.class)
                    .where("id", "between", new String[]{"1", "5"})
                    .findAll();
List<DbModel> list = db.selector(Child.class)
                    .where("age", "<", 18)
                    .groupBy("parentId")
                    .having(WhereBuilder.b("COUNT(parentId)", ">", 1))
                    .select("parentId, COUNT(parentId) as childNum")
                    .findAll();

访问网络(更多示例参考sample项目)

如果你只需要一个简单的网络请求:

@Event(value = R.id.btn_test2)
private void onTest2Click(View view) {
    RequestParams params = new RequestParams("https://www.baidu.com/s");
    // params.setSslSocketFactory(...); // 如果需要自定义SSL
    params.addQueryStringParameter("wd", "xUtils");
    x.http().get(params, new Callback.CommonCallback<String>() {
        @Override
        public void onSuccess(String result) {
            Toast.makeText(x.app(), result, Toast.LENGTH_LONG).show();
        }

        @Override
        public void onError(Throwable ex, boolean isOnCallback) {
            Toast.makeText(x.app(), ex.getMessage(), Toast.LENGTH_LONG).show();
        }

        @Override
        public void onCancelled(CancelledException cex) {
            Toast.makeText(x.app(), "cancelled", Toast.LENGTH_LONG).show();
        }

        @Override
        public void onFinished() {

        }
    });
}

json或protobuf类型请求的处理

/**
 * 自定义实体参数类请参考:
 * 请求注解 {@link org.xutils.http.annotation.HttpRequest}
 * 请求注解处理模板接口 {@link org.xutils.http.app.ParamsBuilder}
 *
 * 需要自定义类型作为callback的泛型时, 参考:
 * 响应注解 {@link org.xutils.http.annotation.HttpResponse}
 * 响应注解处理模板接口 {@link org.xutils.http.app.ResponseParser}
 *
 * 示例: 查看 org.xutils.sample.http 包里的代码
 */
JsonDemoParams params = new JsonDemoParams();
params.wd = "xUtils";
// 有上传文件时使用multipart表单, 否则上传原始文件流.
// params.setMultipart(true);
// 上传文件方式 1
// params.uploadFile = new File("/sdcard/test.txt");
// 上传文件方式 2
// params.addBodyParameter("uploadFile", new File("/sdcard/test.txt"));
Callback.Cancelable cancelable
       = x.http().get(params,
       /**
       * 1. callback的泛型:
       * callback参数默认支持的泛型类型参见{@link org.xutils.http.loader.LoaderFactory},
       * 例如: 指定泛型为File则可实现文件下载, 使用params.setSaveFilePath(path)指定文件保存的全路径, 默认支持断点续传(采用了文件锁防止多线程/进程修改文件,及文件末端校验续传文件的一致性).
       * 
       * 自定义callback的泛型支持方案1, 自定义某一Class的转换(不够灵活): 
       * 结合PrepareCallback的两个泛型参数, 第一个泛型参数类型使用LoaderFactory已经支持的, 第二个泛型参数作为最终输出, 需要在prepare方法中自己实现.
       * 一个稍复杂的例子可以参考{@link org.xutils.image.ImageLoader}
       *
       * 自定义callback的泛型支持方案2, 自定义一类数据的自动转化: 
       * 将注解@HttpResponse加到自定义返回值类型上, 实现自定义ResponseParser接口来统一转换.
       * 如果返回值是json/xml/protobuf等数据格式, 那么利用第三方的json/xml/protobuf等工具将十分容易定义自己的ResponseParser.
       * 如示例代码{@link org.xutils.demo.http.JsonDemoResponse}, 可直接使用JsonDemoResponse作为callback的泛型.
       *
       * 2. callback的组合:
       * 可以用基类或接口组合个种类的Callback, 见{@link org.xutils.common.Callback}.
       * 例如:
       * a. 组合使用CacheCallback将使请求检测缓存或将结果存入缓存(仅GET和POST请求生效).
       * b. 组合使用PrepareCallback的prepare方法将为callback提供一次后台执行耗时任务的机会, 然后将结果给onCache或onSuccess.
       * c. 组合使用ProgressCallback将提供进度回调.
       * 可参考{@link org.xutils.image.ImageLoader} 或 示例代码中的 {@link org.xutils.demo.download.DownloadCallback}
       *
       * 3. 请求过程拦截或记录日志: 参考 {@link org.xutils.http.app.RequestTracker}
       *
       * 4. 请求Header获取: 参考 {@link org.xutils.demo.http.JsonResponseParser} 或 {@link org.xutils.http.app.RequestInterceptListener}
       *
       * 5. 其他(线程池, 超时, 重定向, 重试, 代理等): 参考 {@link org.xutils.http.RequestParams}
       *
       **/
       new Callback.CommonCallback<JsonDemoResponse>() {
           @Override
           public void onSuccess(JsonDemoResponse result) {
               Toast.makeText(x.app(), result.toString(), Toast.LENGTH_LONG).show();
           }

           @Override
           public void onError(Throwable ex, boolean isOnCallback) {
               //Toast.makeText(x.app(), ex.getMessage(), Toast.LENGTH_LONG).show();
               if (ex instanceof HttpException) { // 网络错误
                   HttpException httpEx = (HttpException) ex;
                   int responseCode = httpEx.getCode();
                   String responseMsg = httpEx.getMessage();
                   String errorResult = httpEx.getResult();
                   // ...
               } else { // 其他错误
                   // ...
               }
               Toast.makeText(x.app(), ex.getMessage(), Toast.LENGTH_LONG).show();
           }

           @Override
           public void onCancelled(CancelledException cex) {
               Toast.makeText(x.app(), "cancelled", Toast.LENGTH_LONG).show();
           }

           @Override
           public void onFinished() {

           }
       });

// cancelable.cancel(); // 取消请求

带有缓存的请求示例:

JsonDemoParams params = new JsonDemoParams();
params.wd = "xUtils";
// 默认缓存存活时间, 单位:毫秒.(如果服务没有返回有效的max-age或Expires)
params.setCacheMaxAge(1000 * 60);
Callback.Cancelable cancelable
    	// 使用CacheCallback, xUtils将为该请求缓存数据.
		= x.http().get(params, new Callback.CacheCallback<JsonDemoResponse>() {

	private boolean hasError = false;
	private String result = null;

	@Override
	public boolean onCache(JsonDemoResponse result) {
		// 得到缓存数据, 缓存过期后不会进入这个方法.
		// 如果服务端没有返回过期时间, 参考params.setCacheMaxAge(maxAge)方法.
        //
        // * 客户端会根据服务端返回的 header 中 max-age 或 expires 来确定本地缓存是否给 onCache 方法.
        //   如果服务端没有返回 max-age 或 expires, 那么缓存将一直保存, 除非这里自己定义了返回false的
        //   逻辑, 那么xUtils将请求新数据, 来覆盖它.
        //
        // * 如果信任该缓存返回 true, 将不再请求网络;
        //   返回 false 继续请求网络, 但会在请求头中加上ETag, Last-Modified等信息,
        //   如果服务端返回304, 则表示数据没有更新, 不继续加载数据.
        //
        this.result = result;
        return false; // true: 信任缓存数据, 不在发起网络请求; false不信任缓存数据.
	}

	@Override
	public void onSuccess(JsonDemoResponse result) {
		// 注意: 如果服务返回304 或 onCache 选择了信任缓存, 这时result为null.
        if (result != null) {
		    this.result = result;
		}
	}

	@Override
	public void onError(Throwable ex, boolean isOnCallback) {
		hasError = true;
		Toast.makeText(x.app(), ex.getMessage(), Toast.LENGTH_LONG).show();
		if (ex instanceof HttpException) { // 网络错误
			HttpException httpEx = (HttpException) ex;
			int responseCode = httpEx.getCode();
			String responseMsg = httpEx.getMessage();
			String errorResult = httpEx.getResult();
			// ...
		} else { // 其他错误
			// ...
		}
	}

	@Override
	public void onCancelled(CancelledException cex) {
		Toast.makeText(x.app(), "cancelled", Toast.LENGTH_LONG).show();
	}

	@Override
	public void onFinished() {
		if (!hasError && result != null) {
			// 成功获取数据
			Toast.makeText(x.app(), result, Toast.LENGTH_LONG).show();
		}
	}
});

绑定图片(更多示例参考sample项目)

x.image().bind(imageView, url, imageOptions);

// assets file
x.image().bind(imageView, "assets://test.gif", imageOptions);

// resources file
x.image().bind(imageView, "res://" + R.minimap.test, imageOptions);

// local file
x.image().bind(imageView, new File("/sdcard/test.gif").toURI().toString(), imageOptions);
x.image().bind(imageView, "/sdcard/test.gif", imageOptions);
x.image().bind(imageView, "file:///sdcard/test.gif", imageOptions);
x.image().bind(imageView, "file:/sdcard/test.gif", imageOptions);

x.image().bind(imageView, url, imageOptions, new Callback.CommonCallback<Drawable>() {...});
x.image().loadDrawable(url, imageOptions, new Callback.CommonCallback<Drawable>() {...});
// 用来获取缓存文件
x.image().loadFile(url, imageOptions, new Callback.CommonCallback<File>() {...});

关于作者

  • Email: [email protected], [email protected]
  • 有任何建议或者使用中遇到问题都可以给我发邮件, 你也可以加入QQ群:330445659(已满), 275967695, 257323060, 384426013, 176778777, 169852490, 261053948, 330108003, 技术交流,idea分享 _

xutils3's People

Contributors

ayaybob avatar liaolintao avatar wyouflf avatar yan96in avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

xutils3's Issues

http请求cancel问题

调用Cancelable的cancel后,CommonCallback.onCancelled没有调用,走到onError了

还是cancel问题

请问:
1.setCancelFast的作用是什么?
2.setCancelFast设为true,设置线程池的max size为1,当A下载任务在执行中,B下载任务等待中,cancel B任务时,并不会立即执行B任务回调,等到A任务执行完后或cancel A任务后才回调,如何优化?
补充:
取消下载时,cancel会调用两次
E/x_log:DownloadManager.stopDownload(L:156): stopDownload
E/x_log:DownloadCallback.cancel(L:106): cancel
E/x_log:DownloadCallback.cancel(L:106): cancel

DbUtil

dbutils是否支持类嵌套?

class A{
  int a1
 String stra
}

class B{
A a
int b
String strb
}

这样直接保存B的对象可以吗?

使用xUtils3 get数据的问题

11-24 19:43:28.230 24229-24446/? W/dalvikvm: Exception Ljava/lang/RuntimeException; thrown while initializing Lorg/xutils/http/cookie/DbCookieStore;
11-24 19:43:28.230 24229-24446/? W/dalvikvm: Exception Ljava/lang/ExceptionInInitializerError; thrown while initializing Lorg/xutils/http/request/HttpRequest;
11-24 19:43:28.255 24229-24229/? I/hehe: onErrornull
11-24 19:43:28.255 24229-24229/? I/hehe: onFinished

加载图片 异常信息

11-26 09:57:12.436: W/x_log:ImageDecoder.saveThumbCache(L:508)(7486): Unsupported Bitmap configuration. Currently only RGBA_8888 and RGB_565 are supported
11-26 09:57:12.436: W/x_log:ImageDecoder.saveThumbCache(L:508)(7486): java.lang.RuntimeException: Unsupported Bitmap configuration. Currently only RGBA_8888 and RGB_565 are supported
11-26 09:57:12.436: W/x_log:ImageDecoder.saveThumbCache(L:508)(7486): at android.backport.webp.WebPFactory.nativeEncodeBitmap(Native Method)
11-26 09:57:12.436: W/x_log:ImageDecoder.saveThumbCache(L:508)(7486): at org.xutils.image.ImageDecoder.saveThumbCache(ImageDecoder.java:501)
11-26 09:57:12.436: W/x_log:ImageDecoder.saveThumbCache(L:508)(7486): at org.xutils.image.ImageDecoder.access$0(ImageDecoder.java:491)
11-26 09:57:12.436: W/x_log:ImageDecoder.saveThumbCache(L:508)(7486): at org.xutils.image.ImageDecoder$1.run(ImageDecoder.java:131)
11-26 09:57:12.436: W/x_log:ImageDecoder.saveThumbCache(L:508)(7486): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
11-26 09:57:12.436: W/x_log:ImageDecoder.saveThumbCache(L:508)(7486): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
11-26 09:57:12.436: W/x_log:ImageDecoder.saveThumbCache(L:508)(7486): at java.lang.Thread.run(Thread.java:818)
11-26 09:57:12.501: W/x_log:ImageDecoder.saveThumbCache(L:508)(7486): Unsupported Bitmap configuration. Currently only RGBA_8888 and RGB_565 are supported
11-26 09:57:12.501: W/x_log:ImageDecoder.saveThumbCache(L:508)(7486): java.lang.RuntimeException: Unsupported Bitmap configuration. Currently only RGBA_8888 and RGB_565 are supported
11-26 09:57:12.501: W/x_log:ImageDecoder.saveThumbCache(L:508)(7486): at android.backport.webp.WebPFactory.nativeEncodeBitmap(Native Method)
11-26 09:57:12.501: W/x_log:ImageDecoder.saveThumbCache(L:508)(7486): at org.xutils.image.ImageDecoder.saveThumbCache(ImageDecoder.java:501)
11-26 09:57:12.501: W/x_log:ImageDecoder.saveThumbCache(L:508)(7486): at org.xutils.image.ImageDecoder.access$0(ImageDecoder.java:491)
11-26 09:57:12.501: W/x_log:ImageDecoder.saveThumbCache(L:508)(7486): at org.xutils.image.ImageDecoder$1.run(ImageDecoder.java:131)
11-26 09:57:12.501: W/x_log:ImageDecoder.saveThumbCache(L:508)(7486): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
11-26 09:57:12.501: W/x_log:ImageDecoder.saveThumbCache(L:508)(7486): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
11-26 09:57:12.501: W/x_log:ImageDecoder.saveThumbCache(L:508)(7486): at java.lang.Thread.run(Thread.java:818)

org.xutils.ex.FileLockedException 异常信息

11-29 15:33:43.449 7130-7130/com.tigeroid E/x_log:ImageLoader.onError(L:409): org.xutils.ex.FileLockedException: /storage/emulated/0/Android/data/com.tigeroid/cache/xUtils_img/8ce22f4362f505df8535f7e3110519f9
11-29 15:33:43.449 7130-7130/com.tigeroid E/x_log:ImageLoader.onError(L:409): at org.xutils.cache.LruDiskCache.createDiskCacheFile(LruDiskCache.java:164)
11-29 15:33:43.449 7130-7130/com.tigeroid E/x_log:ImageLoader.onError(L:409): at org.xutils.http.loader.FileLoader.initDiskCacheFile(FileLoader.java:263)
11-29 15:33:43.449 7130-7130/com.tigeroid E/x_log:ImageLoader.onError(L:409): at org.xutils.http.loader.FileLoader.load(FileLoader.java:176)
11-29 15:33:43.449 7130-7130/com.tigeroid E/x_log:ImageLoader.onError(L:409): at org.xutils.http.loader.FileLoader.load(FileLoader.java:41)
11-29 15:33:43.449 7130-7130/com.tigeroid E/x_log:ImageLoader.onError(L:409): at org.xutils.http.request.UriRequest.loadResult(UriRequest.java:81)
11-29 15:33:43.449 7130-7130/com.tigeroid E/x_log:ImageLoader.onError(L:409): at org.xutils.http.request.HttpRequest.loadResult(HttpRequest.java:222)
11-29 15:33:43.449 7130-7130/com.tigeroid E/x_log:ImageLoader.onError(L:409): at org.xutils.http.HttpTask$RequestWorker.run(HttpTask.java:506)

断点续传策略

断点续传策略需要服务器配合吗?比如上传一半失败了,下次可以继续上传?

点击事件问题

例如有个button,我要在代码里动态的设置OnClickListener,但是现在点击事件的方法必须是private的,和View.OnClickListener public不一致,必须要搞两套。有什么办法能解决这个问题么?最好是能像xutils之前版本一样,能公用一个点击方法

按README的提示无法初始化

Hello,
我在gradle中添加依赖后,按照README的提示进行初始化,找不到x所在的包,是人品问题么。。。

同步请求会失败

示例代码

 RequestParams params=new RequestParams("http://www.baidu.com");

        try {
           String response= x.http().getSync(params,String.class);
            System.out.println(response);
        } catch (Throwable throwable) {
            throwable.printStackTrace();
        }

异步就不会!

 java.lang.NullPointerException
11-28 22:17:22.738 22125-22125/org.xutils.sample W/System.err:     at com.android.okhttp.internal.http.HttpEngine.readResponse(HttpEngine.java:632)
11-28 22:17:22.738 22125-22125/org.xutils.sample W/System.err:     at com.android.okhttp.internal.http.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:347)
11-28 22:17:22.738 22125-22125/org.xutils.sample W/System.err:     at com.android.okhttp.internal.http.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:296)
11-28 22:17:22.738 22125-22125/org.xutils.sample W/System.err:     at com.android.okhttp.internal.http.HttpURLConnectionImpl.getResponseCode(HttpURLConnectionImpl.java:503)
11-28 22:17:22.738 22125-22125/org.xutils.sample W/System.err:     at org.xutils.http.request.HttpRequest.getResponseCode(HttpRequest.java:307)
11-28 22:17:22.738 22125-22125/org.xutils.sample W/System.err:     at org.xutils.http.HttpTask.doBackground(HttpTask.java:271)
11-28 22:17:22.738 22125-22125/org.xutils.sample W/System.err:     at org.xutils.common.task.TaskControllerImpl.startSync(TaskControllerImpl.java:63)
11-28 22:17:22.742 22125-22125/org.xutils.sample W/System.err:     at org.xutils.http.HttpManagerImpl.requestSync(HttpManagerImpl.java:109)
11-28 22:17:22.742 22125-22125/org.xutils.sample W/System.err:     at org.xutils.http.HttpManagerImpl.getSync(HttpManagerImpl.java:96)

怎么用保存cookie呢?

记得2.6版本中是通过configCookieStore来处理cookie的,新版中的cookie持久化是需要自己做吗?谢谢!

4.0.3的机器请求网络时报错

Could not find method java.net.HttpURLConnection.setFixedLengthStreamingMode, referenced from method org.xutils.http.request.HttpRequest.sendRequest

VFY: unable to resolve virtual method 35050: Ljava/net/HttpURLConnection;.setFixedLengthStreamingMode (J)V

VFY: replacing opcode 0x6e at 0x0219

Fatal signal 11 (SIGSEGV) at 0x00000000 (code=1)

然后app就挂掉了,但是却没有任何其他的错误输出,app闪退时也不弹窗提示“很抱歉,xx已停止运行”,反正app界面就突然消失了

性能问题

这个和OKHttp相比,应该没有优势吧!

快速加载本地缓存文件会出现问题

http://material-design.storage.googleapis.com/publish/material_v_4/material_ext_publish/0B6Okdz75tqQsQ0l4MWpTMmJCTm8/style_imagery_integration_hero1.png
org.xutils.ex.FileLockedException: /storage/emulated/0/Android/data/com.xhl.windowofword/cache/xUtils_img/7590aef6920e0732bf7526b5afc18c15
at org.xutils.cache.LruDiskCache.createDiskCacheFile(LruDiskCache.java:164)
at org.xutils.http.loader.FileLoader.initDiskCacheFile(FileLoader.java:263)
at org.xutils.http.loader.FileLoader.load(FileLoader.java:176)
at org.xutils.http.loader.FileLoader.load(FileLoader.java:41)
at org.xutils.http.request.UriRequest.loadResult(UriRequest.java:81)
at org.xutils.http.request.HttpRequest.loadResult(HttpRequest.java:222)
at org.xutils.http.HttpTask$RequestWorker.run(HttpTask.java:506)

Http问题

Http请求怎样设置超时?读超时这类的?还是默认已经设置好了? catch (Throwable throwable)我要怎么来严格区分哪些错误是服务器错误,哪些错误是网络错误?

百度地图不能用

为什么用了xutil3之后,百度地图在有的机子上运行不了啊,百度地图初始化就报错,我的机子是5.0系统的,在4.X系统的机子没有问题。

downloadcallback 弱引用带来的问题

我看源码里面,将回调设置成了弱引用,而弱引用随时可能被gc回收,所以可能导致接收不到回调信息?在下载大文件时,下载一段时间前台就接受不到回调信息了。小文件还好,我改成强引用就行了,请问为啥设计成弱引用呢?新人求教
private WeakReference viewHolderRef;

能不能根据作用把工具分开呢

能不能根据作用把工具分开呢
例如我已经使用了一个图片框架
不需要里面的图片框架了
但是你这里面还引入了一些so文件,并且文件还蛮大的

下载时有几率出现HTTP 400

同一个下载任务 点了开始下载 等一下再点停止下载 然后再点开始 有几率出来 HTTP 400
Bad request
code: 400, msg: Bad request, result: null

加载图片报错

11-25 03:49:30.706 6798-6798/org.xutils.sample E/x_log:ImageLoader.onError(L:409): http://wap.baidu.com/static/img/r/image/2014-04-18/a250be0f0af4d9dd116b4bf1f37dc5c6.jpg
java.io.EOFException
at libcore.io.Streams.readAsciiLine(Streams.java:203)
at libcore.net.http.HttpEngine.readResponseHeaders(HttpEngine.java:573)
at libcore.net.http.HttpEngine.readResponse(HttpEngine.java:821)
at libcore.net.http.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:283)
at libcore.net.http.HttpURLConnectionImpl.getResponseCode(HttpURLConnectionImpl.java:495)
at org.xutils.http.request.HttpRequest.sendRequest(HttpRequest.java:187)
at org.xutils.http.loader.FileLoader.load(FileLoader.java:212)
at org.xutils.http.loader.FileLoader.load(FileLoader.java:40)
at org.xutils.http.request.UriRequest.loadResult(UriRequest.java:81)
at org.xutils.http.request.HttpRequest.loadResult(HttpRequest.java:222)
at org.xutils.http.HttpTask$RequestWorker.run(HttpTask.java:503)

上传文件顺序

fileParams现在是hashmap,会导致顺序错乱,和上传顺序不一致,建议改为LinkedHashMap

每次请求网络结束后,UI都会卡顿

I/Choreographer: Skipped 42 frames! The application may be doing too much work on its main thread.

列表中上拉加载更多时,更是卡得不行,这次使用的机器是nexus4,5.1.1的系统,3.1.8版本

在Library项目中使用的问题

在Library项目中,R.id.XXX已经不是final修饰,所以在Library项目中似乎使用不了这个工具。这个问题有解吗?

x.Ext.init

建议参数类型改为context,现在是application,感觉不方便

建议修改一下ViewUtils的注入异常检测

因为用ViewUtils注入的时候,加入注入内容有误,或者找不到。他的提示很不友好,很不容易定位到有问题的某个属性。
下面是我自己修改的代码,望有帮助。
View findView = finder.findViewById(viewInject.value());
if (findView != null) {
field.setAccessible(true);
try {
field.set(object, findView);
} catch (Throwable e) {
String modifier = Modifier.toString(field.getModifiers());
String genericString[] = field.toGenericString().split(" ");
String type = genericString[1];
String name = field.getName();
String injectViewName = findView.getClass().toString().replaceFirst("class", "");
LogUtils.e(modifier + " " + type + " " + name + " 将要注入" + injectViewName);
}
} else {
String modifier = Modifier.toString(field.getModifiers());
String genericString[] = field.toGenericString().split(" ");
String type = genericString[1];
String name = field.getName();
LogUtils.e(modifier + " " + type + " " + name + " 注入id无效");
}

当加载图片过多时,存在图片无法加载的情况

1)如加载一个有分页的列表,每个item最多有5张或者6张图片
2)当加载20页或者30页后发现图片不能加载,重启应用也不能加载图片,只有清楚数据或者重新安装应用才能正常恢复。图片加载这个模块感觉就失去功能了,难道有设置了限制导致的?

java.lang.NoClassDefFoundError:

x.http().get(requestParams, new Callback.CommonCallback() ,使用这个方法时会报错:
java.lang.NoClassDefFoundError: org/xutils/http/request/HttpRequest

maven

能否添加到maven仓库。

数据库加密

希望数据库能进行加密处理,保证数据安全

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.