问题和排球的贡献 [英] Issues and contribution for Volley

查看:148
本文介绍了问题和排球的贡献的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

由于有这真棒presentation上凌空我试图把它列入项目我的工作。我发现自己纠正了一些错误,我发现在被公布的源$ C ​​$ C

Since there was this awesome presentation on Volley I tried to include it in a project I am working on. I found myself correcting some bugs I found in the source code that was published.

有谁知道是否有会是一些GitHub的项目中,人们可以向项目或有另一种方式来缺陷和功能要求传达给开发人员?

Does anybody know if there is gonna be some GitHub project where one could contribute to the project or is there another way to communicate bugs and feature requests to the developer?

至于我与排球的问题:

1。看来,重定向不会因为它应该工作: 凌空返回一个错误,$ C $的C 302 ,而不是重定向到的响应头给定的位置。

1. It seems that redirection does not work as it should: Volley returns an error code 302 instead of redirecting to the location given in the response header.

2。获取缓存目录不上我的模拟器运行4.2.2工作:

2. Getting the cache directory does not work on my emulator running 4.2.2:

cacheDir = new File(context.getCacheDir(), DEFAULT_CACHE_DIR);  
final String cacheDir1 = "/Android/data/cache/";
cacheDir = new File(Environment.getExternalStorageDirectory().getPath() + cacheDir1);

这解决方法是特定的平台,虽然。只是想增加它的完成的缘故。

This workaround is platform specific, though. Just wanted to add it for completions sake.

另外,我觉得排球是一个真正的真棒一块code和正是我一直在寻找的东西,直到我做我自己;)

Besides that I think Volley is really an awesome piece of code and exactly what I was looking for until I did it myself ;)

更新1

下面另一个链接<一个href="https://android-review.googlesource.com/#/admin/projects/platform/frameworks/volley">contribution页面AOSP 。我认为它更多的是独立的库。我会检查出来,虽然我还是AP preciate更多的相关信息和教程乱射。 该人士$ ​​C $ C,我建议仅仅是一个快速和肮脏的修复,这在我的示范项目,并获得成功。

Here another link to the contribution page AOSP. I thought its more a standalone library. I will check that out, although I still appreciate more infos and tutorials on Volley. The source code I suggested is just a quick and dirty fix, which did the trick in my demo project.

更新2

我发现了另一个有趣的博客帖子提及到响应另外一个问题,这可能是有帮助的。

I found another interesting blog post by Ognyan Bankov mentioned as a response to another question, which could be helpful.

推荐答案

好像很多已经回答了评论,但我会尽量覆盖休息,或者更确切地说,我会尽量满足您的具体问题。

Seems like a lot has been answered in the comments but I'll try to cover the rest, or rather, I'll try to cover your specific questions.

1)排球不处理重定向它自己。它由基础HttpStack处理。例如,我目前使用OkHttp(从广场)作为我对排球的HTTP客户端。请参见 https://plus.google.com/108284392618554783657/posts/eJJxhkTQ4yU https://gist.github.com/JakeWharton/5616899 OkHttp是伟大的,因为它具有优良的默认处理SPDY,重定向,以及其他HTTP服务。你也可以使用这个交给它之前实现自己的缺省值HttpURLConnection的平台(调用followRedirects()的连接抽射例如--- <一个href="https://developer.android.com/reference/java/net/HttpURLConnection.html#setFollowRedirects(boolean)" rel="nofollow">https://developer.android.com/reference/java/net/HttpURLConnection.html#setFollowRedirects(boolean))

1) Volley does not handle redirection on it's own. It's handled by the underlying HttpStack. For example, I currently use OkHttp (from Square) as my HTTP client for Volley. See https://plus.google.com/108284392618554783657/posts/eJJxhkTQ4yU https://gist.github.com/JakeWharton/5616899 OkHttp is great, as it has excellent defaults for handling SPDY, redirects, and other HTTP conveniences. You could also use this to implement your own defaults for the platform HttpUrlConnection (calling followRedirects() on the connection before handing it to Volley for example --- https://developer.android.com/reference/java/net/HttpURLConnection.html#setFollowRedirects(boolean))

2)我什至不知道我会用getCacheDir()的凌空缓存。根据文档(的https://developer.android.com/reference/android/content/Context.html#getCacheDir()),高速缓存目录应该不能超过1 MB。然而,大多数的客户倾向于使用10 MB作为默认的HTTP缓存(1 MB是非常小的一个HTTP缓存!)。还有,你为什么要使用这么深的缓存目录?世界上没有其他原因,cacheDir1应该是多个目录很深,只要它的文件名。getCacheDir()将返回反正自己的文件夹。初始化排球时,我建议你这样做(通常推荐的地方就是应用类)

2) I'm not even sure that I'd use getCacheDir() for a Volley cache. According to the docs (https://developer.android.com/reference/android/content/Context.html#getCacheDir()), that cache directory should never exceed 1 mb. Whereas, most clients tend to use 10 mb as a default for an http cache (1 mb is really small for an Http cache!!). Also, why are you using such a deep cache directory? Theres no reason that "cacheDir1" should be multiple directories deep. Just make it a file name. getCacheDir() would return your own folder anyways. I'd recommend doing this when initializing Volley (usually the recommended place is the Application class):

File volleyCacheFile = new File(getExternalCacheDir(), "volleyCache.tmp");

当然,这没有任何错误处理(如果外部存储器不可用什么呢?)。另外,不要忘记,你需要适当的权限来写外部存储。

Of course, this lacks any error handling (what if the external storage is unavailable?). Also, don't forget that you need the appropriate permission to write the external storage.

希望有所帮助。

这篇关于问题和排球的贡献的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆