From 4f89fc5185ddbea01c0a10c7343fc386f62e2af7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=B6=9B=28tao281=2Ezhang=29?= Date: Mon, 27 Jun 2022 17:23:36 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8D=87=E7=BA=A7=E4=BE=9D=E8=B5=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Readme_zh.md | 2 +- app/build.gradle | 2 +- .../com/kymjs/rxvolley/demo/ImageLoadTestActivity.java | 8 +++----- .../main/java/com/kymjs/rxvolley/demo/MainActivity.java | 7 +++---- image/build.gradle | 4 ++-- rxvolley/build.gradle | 4 ++-- rxvolley/src/main/java/com/kymjs/rxvolley/RxVolley.java | 7 +++++-- 7 files changed, 17 insertions(+), 17 deletions(-) diff --git a/Readme_zh.md b/Readme_zh.md index 75b3b4b..cb6561b 100755 --- a/Readme_zh.md +++ b/Readme_zh.md @@ -427,7 +427,7 @@ keyStore.setCertificateEntry("trust", cer); SSLSocketFactory socketFactory = new SSLSocketFactory(keyStore); -RxVolley.setRequestQueue(RequestQueue.newRequestQueue(RxVolley.CACHE_FOLDER), new HttpConnectStack(null, sslSocketFactory)); +RxVolley.setRequestQueue(RequestQueue.newRequestQueue(RxVolley.cacheFolder()), new HttpConnectStack(null, sslSocketFactory)); ``` diff --git a/app/build.gradle b/app/build.gradle index d42d198..78cfd17 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -35,7 +35,7 @@ dependencies { implementation 'io.reactivex.rxjava3:rxandroid:3.0.0' implementation 'com.squareup.okhttp3:okhttp:3.14.9' implementation 'androidx.appcompat:appcompat:1.3.1' - implementation 'com.github.kymjs:common:2.0.0' + implementation 'com.github.kymjs:common:2.0.5' implementation 'com.google.code.gson:gson:2.8.8' implementation project(':image') implementation project(':okhttp3') diff --git a/app/src/main/java/com/kymjs/rxvolley/demo/ImageLoadTestActivity.java b/app/src/main/java/com/kymjs/rxvolley/demo/ImageLoadTestActivity.java index d7cc394..a84f112 100644 --- a/app/src/main/java/com/kymjs/rxvolley/demo/ImageLoadTestActivity.java +++ b/app/src/main/java/com/kymjs/rxvolley/demo/ImageLoadTestActivity.java @@ -6,7 +6,6 @@ import android.os.Looper; import android.widget.ImageView; -import com.kymjs.common.FileUtils; import com.kymjs.common.Log; import com.kymjs.core.bitmap.client.BitmapCore; import com.kymjs.okhttp3.OkHttpStack; @@ -14,7 +13,6 @@ import com.kymjs.rxvolley.client.HttpCallback; import com.kymjs.rxvolley.http.RequestQueue; -import java.io.File; import java.util.Map; import okhttp3.OkHttpClient; @@ -28,7 +26,7 @@ public class ImageLoadTestActivity extends Activity { public ImageView contentView; protected void setUp() { - RxVolley.setRequestQueue(RequestQueue.newRequestQueue(RxVolley.CACHE_FOLDER, + RxVolley.setRequestQueue(RequestQueue.newRequestQueue(RxVolley.cacheFolder(), new OkHttpStack(new OkHttpClient()))); callback = new HttpCallback() { @@ -117,7 +115,7 @@ public void testBitmapWithLoadImage() { */ public void testBitmapWithDiskLoader() { new BitmapCore.Builder() - .url(FileUtils.getSDCardPath() + File.separator + "request.png") + .url("/sdcard/" + "request.png") .callback(callback) .view(contentView) .loadResId(R.mipmap.ic_launcher) @@ -130,7 +128,7 @@ public void testBitmapWithDiskLoader() { */ public void testBitmapWithDiskLoader2() { new BitmapCore.Builder() - .url(FileUtils.getSDCardPath() + File.separator + "request.png") + .url("/sdcard/request.png") .callback(callback) .view(contentView) .loadResId(R.mipmap.ic_launcher) diff --git a/app/src/main/java/com/kymjs/rxvolley/demo/MainActivity.java b/app/src/main/java/com/kymjs/rxvolley/demo/MainActivity.java index 2b83fc2..4e4c57f 100644 --- a/app/src/main/java/com/kymjs/rxvolley/demo/MainActivity.java +++ b/app/src/main/java/com/kymjs/rxvolley/demo/MainActivity.java @@ -11,7 +11,6 @@ import androidx.appcompat.app.AppCompatActivity; import com.google.gson.Gson; -import com.kymjs.common.FileUtils; import com.kymjs.common.Log; import com.kymjs.okhttp3.OkHttpStack; import com.kymjs.rxvolley.RxVolley; @@ -39,7 +38,7 @@ protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); - RxVolley.setRequestQueue(RequestQueue.newRequestQueue(RxVolley.CACHE_FOLDER, + RxVolley.setRequestQueue(RequestQueue.newRequestQueue(RxVolley.cacheFolder(), new OkHttpStack(new OkHttpClient()))); @@ -61,7 +60,7 @@ private void testUploadProgress() { params.put("uid", 863548); params.put("msg", "睡会"); - params.put("img", new File(FileUtils.getSDCardPath() + "/request.png")); + params.put("img", new File("/sdcard/request.png")); Gson gson = new Gson(); RxVolley.post("http://192.168.1.11/action/api/software_tweet_pub", params, @@ -171,7 +170,7 @@ public void onError(Throwable e) { * 下载 */ private void download() { - RxVolley.download(FileUtils.getSDCardPath() + "/a.apk", + RxVolley.download("/sdcard/a.apk", "https://www.oschina.net/uploads/osc-android-app-2.4.apk", new ProgressListener() { @Override public void onProgress(long transferredBytes, long totalSize) { diff --git a/image/build.gradle b/image/build.gradle index 9b80bbd..d5f96ad 100644 --- a/image/build.gradle +++ b/image/build.gradle @@ -29,11 +29,11 @@ android { } dependencies { - implementation 'io.reactivex.rxjava3:rxjava:3.1.0' + implementation 'io.reactivex.rxjava3:rxjava:3.1.4' implementation 'io.reactivex.rxjava3:rxandroid:3.0.0' // compileOnly 'com.github.kymjs.rxvolley:rxvolley:3.0.0' compileOnly project(':rxvolley') - implementation 'com.github.kymjs:common:2.0.0' + implementation 'com.github.kymjs:common:2.0.5' } apply plugin: 'maven-publish' diff --git a/rxvolley/build.gradle b/rxvolley/build.gradle index d42625d..4f4fca0 100644 --- a/rxvolley/build.gradle +++ b/rxvolley/build.gradle @@ -29,9 +29,9 @@ android { } dependencies { - implementation 'io.reactivex.rxjava3:rxjava:3.1.0' + implementation 'io.reactivex.rxjava3:rxjava:3.1.4' implementation 'io.reactivex.rxjava3:rxandroid:3.0.0' - implementation 'com.github.kymjs:common:2.0.0' + implementation 'com.github.kymjs:common:2.0.5' implementation 'androidx.appcompat:appcompat:1.3.1' } diff --git a/rxvolley/src/main/java/com/kymjs/rxvolley/RxVolley.java b/rxvolley/src/main/java/com/kymjs/rxvolley/RxVolley.java index 47858b2..a5e4171 100644 --- a/rxvolley/src/main/java/com/kymjs/rxvolley/RxVolley.java +++ b/rxvolley/src/main/java/com/kymjs/rxvolley/RxVolley.java @@ -18,6 +18,7 @@ import android.text.TextUtils; +import com.kymjs.common.ContextTrojan; import com.kymjs.common.FileUtils; import com.kymjs.rxvolley.client.FileRequest; import com.kymjs.rxvolley.client.FormRequest; @@ -49,7 +50,9 @@ public class RxVolley { private RxVolley() { } - public final static File CACHE_FOLDER = FileUtils.getExternalCacheDir("RxVolley"); + public static File cacheFolder() { + return FileUtils.getExternalCacheDir(ContextTrojan.getApplicationContext(), "RxVolley"); + } private static RequestQueue sRequestQueue; @@ -58,7 +61,7 @@ private RxVolley() { */ public synchronized static RequestQueue getRequestQueue() { if (sRequestQueue == null) { - sRequestQueue = RequestQueue.newRequestQueue(CACHE_FOLDER); + sRequestQueue = RequestQueue.newRequestQueue(cacheFolder()); } return sRequestQueue; }