@nativescript-community/ui-image 5.0.12 → 5.0.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +4 -0
- package/index-common.d.ts +30 -1
- package/index-common.js.map +1 -1
- package/index.android.d.ts +11 -4
- package/index.android.js +159 -71
- package/index.android.js.map +1 -1
- package/index.d.ts +2 -2
- package/index.ios.d.ts +3 -3
- package/index.ios.js +6 -18
- package/index.ios.js.map +1 -1
- package/package.json +2 -2
- package/platforms/android/java/com/nativescript/image/CacheKeyStore.java +15 -27
- package/platforms/android/java/com/nativescript/image/CustomGlideModule.java +35 -154
- package/platforms/android/java/com/nativescript/image/CustomGlideUrl.java +2 -2
- package/platforms/android/java/com/nativescript/image/EvictionManager.java +331 -333
- package/platforms/android/java/com/nativescript/image/GlideConfiguration.java +28 -0
- package/platforms/android/java/com/nativescript/image/ModelSignatureDiskLruCacheWrapper.java +321 -0
- package/platforms/android/java/com/nativescript/image/ModelSignatureMemoryCache.java +155 -0
- package/platforms/android/java/com/nativescript/image/SaveKeysRequestListener.java +69 -125
- package/platforms/android/java/com/nativescript/image/SharedPrefCacheKeyStore.java +75 -49
- package/typings/ui_image.android.d.ts +10 -17
- package/platforms/android/java/com/nativescript/image/CapturingEngineKeyFactory.java +0 -43
- package/platforms/android/java/com/nativescript/image/RecordingDigest.java +0 -48
- package/platforms/android/java/com/nativescript/image/RecreatedResourceKey.java +0 -95
|
@@ -1,145 +1,89 @@
|
|
|
1
1
|
package com.nativescript.image;
|
|
2
2
|
|
|
3
|
-
import android.graphics.drawable.Drawable;
|
|
4
|
-
import android.util.Log;
|
|
5
|
-
|
|
6
|
-
import androidx.annotation.Nullable;
|
|
7
|
-
|
|
8
3
|
import com.bumptech.glide.load.Key;
|
|
9
4
|
import com.bumptech.glide.load.Options;
|
|
10
5
|
import com.bumptech.glide.load.Transformation;
|
|
6
|
+
import com.bumptech.glide.load.model.GlideUrl;
|
|
11
7
|
import com.bumptech.glide.request.RequestListener;
|
|
12
|
-
import com.bumptech.glide.request.RequestOptions;
|
|
13
8
|
import com.bumptech.glide.request.target.Target;
|
|
14
|
-
import
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* RequestListener that records the disk & transformation key bytes used for a
|
|
18
|
-
* request
|
|
19
|
-
* and persists them via EvictionManager so later evictions / presence checks
|
|
20
|
-
* can recreate
|
|
21
|
-
* the exact disk keys without needing to recreate Transformation objects.
|
|
22
|
-
*
|
|
23
|
-
* Usage:
|
|
24
|
-
* - Preferred: pass a RequestOptions instance; this listener will extract the
|
|
25
|
-
* internal Options
|
|
26
|
-
* via ExtractRequestOptions (cached reflection) so your existing RequestOptions
|
|
27
|
-
* usage continues to work.
|
|
28
|
-
* - Alternative: pass an Options instance directly if you already have it.
|
|
29
|
-
*
|
|
30
|
-
* The listener returns false from callbacks so it does not short-circuit other
|
|
31
|
-
* listeners or Glide's handling.
|
|
32
|
-
*/
|
|
33
|
-
public final class SaveKeysRequestListener implements RequestListener<Drawable> {
|
|
34
|
-
private static final String TAG = "SaveKeysRequestListener";
|
|
35
|
-
|
|
36
|
-
private final String id; // canonical id you use to later evict (typically the URL string or normalized
|
|
37
|
-
// model id)
|
|
38
|
-
private final Object model; // the same model object you pass to Glide.load(...)
|
|
39
|
-
private final Key sourceKey;
|
|
40
|
-
private final Key signature;
|
|
41
|
-
private final int width;
|
|
42
|
-
private final int height;
|
|
43
|
-
@Nullable
|
|
44
|
-
private final Transformation<?> transformation;
|
|
45
|
-
private final Options options;
|
|
46
|
-
private final Class<?> decodedResourceClass;
|
|
9
|
+
import android.util.Log;
|
|
47
10
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
this.options = (options == null) ? new Options() : ExtractRequestOptions.getFrom(options);
|
|
69
|
-
this.decodedResourceClass = (decodedResourceClass == null) ? Drawable.class : decodedResourceClass;
|
|
70
|
-
}
|
|
11
|
+
public class SaveKeysRequestListener implements RequestListener<Object> {
|
|
12
|
+
private static final String TAG = "SaveKeysRequestListener";
|
|
13
|
+
|
|
14
|
+
private final String id;
|
|
15
|
+
private final Object model;
|
|
16
|
+
private final Key fallbackSourceKey;
|
|
17
|
+
private final Key signature;
|
|
18
|
+
/**
|
|
19
|
+
* Construct directly with an Options instance.
|
|
20
|
+
*/
|
|
21
|
+
public SaveKeysRequestListener(
|
|
22
|
+
String id,
|
|
23
|
+
Object model,
|
|
24
|
+
Key fallbackSourceKey,
|
|
25
|
+
Key signature) {
|
|
26
|
+
this.id = id;
|
|
27
|
+
this.model = model;
|
|
28
|
+
this.fallbackSourceKey = fallbackSourceKey;
|
|
29
|
+
this.signature = signature;
|
|
30
|
+
}
|
|
71
31
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
32
|
+
private static String normalizeIdFromModel(Object model, String fallback) {
|
|
33
|
+
if (model == null) {
|
|
34
|
+
return fallback;
|
|
35
|
+
}
|
|
36
|
+
if (model instanceof GlideUrl) {
|
|
37
|
+
try {
|
|
38
|
+
return ((GlideUrl) model).toStringUrl();
|
|
39
|
+
} catch (Throwable t) {
|
|
40
|
+
return String.valueOf(model);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
return String.valueOf(model);
|
|
44
|
+
}
|
|
78
45
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
46
|
+
private static Key sourceKeyFromModel(Object model, Key fallback) {
|
|
47
|
+
// GlideUrl (including CustomGlideUrl) implements Key
|
|
48
|
+
if (model instanceof Key) {
|
|
49
|
+
return (Key) model;
|
|
50
|
+
}
|
|
51
|
+
// For string models, fallback to ObjectKey
|
|
52
|
+
return fallback;
|
|
53
|
+
}
|
|
85
54
|
|
|
86
|
-
|
|
87
|
-
|
|
55
|
+
@Override
|
|
56
|
+
public boolean onResourceReady(Object resource, Object model, Target<Object> target,
|
|
57
|
+
com.bumptech.glide.load.DataSource dataSource,
|
|
58
|
+
boolean isFirst) {
|
|
88
59
|
try {
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
Log.w(TAG, "Failed to record transformation key bytes for id=" + id, t);
|
|
94
|
-
}
|
|
95
|
-
}
|
|
60
|
+
// CRITICAL: Use the actual model passed to onResourceReady, not constructor model
|
|
61
|
+
// This ensures we capture the exact key Glide used
|
|
62
|
+
final String normalizedId = normalizeIdFromModel(model, this.id);
|
|
63
|
+
final Key actualSourceKey = sourceKeyFromModel(model, this.fallbackSourceKey);
|
|
96
64
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
options.updateDiskCacheKey(rd2);
|
|
101
|
-
optionsBytes = rd2.digest();
|
|
102
|
-
} catch (Throwable t) {
|
|
103
|
-
Log.w(TAG, "Failed to record options key bytes for id=" + id, t);
|
|
104
|
-
}
|
|
65
|
+
// Log.i(TAG, "onResourceReady: id=" + normalizedId +
|
|
66
|
+
// " sourceKey=" + actualSourceKey +
|
|
67
|
+
// " model=" + model);
|
|
105
68
|
|
|
106
|
-
// Attempt to preserve existing engineKey if present
|
|
107
|
-
com.bumptech.glide.load.Key engineKeyToKeep = null;
|
|
108
69
|
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
70
|
+
CacheKeyStore.StoredKeys s = new CacheKeyStore.StoredKeys(
|
|
71
|
+
actualSourceKey,
|
|
72
|
+
this.signature
|
|
73
|
+
);
|
|
74
|
+
|
|
75
|
+
EvictionManager.get().saveKeys(normalizedId, s);
|
|
76
|
+
// Log.i(TAG, "Keys saved for: " + normalizedId + " s=" +s);
|
|
77
|
+
} catch (Throwable t) {
|
|
78
|
+
Log.e(TAG, "Failed to save keys", t);
|
|
118
79
|
}
|
|
119
|
-
} catch (Throwable t) {
|
|
120
|
-
Log.w(TAG, "Failed to read existing stored keys to preserve engineKey for id=" + id, t);
|
|
121
|
-
}
|
|
122
80
|
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
sourceKey,
|
|
126
|
-
signature,
|
|
127
|
-
width,
|
|
128
|
-
height,
|
|
129
|
-
transformation, // may be null; kept for in-process fallback
|
|
130
|
-
transformationBytes, // recorded transformation bytes (preferred)
|
|
131
|
-
decodedResourceClass,
|
|
132
|
-
options,
|
|
133
|
-
optionsBytes,
|
|
134
|
-
engineKeyToKeep // preserve any engineKey we found
|
|
135
|
-
);
|
|
81
|
+
return false; // Don't consume the event
|
|
82
|
+
}
|
|
136
83
|
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
84
|
+
@Override
|
|
85
|
+
public boolean onLoadFailed(com.bumptech.glide.load.engine.GlideException e,
|
|
86
|
+
Object model, Target<Object> target, boolean isFirstResource) {
|
|
87
|
+
return false; // Don't consume
|
|
140
88
|
}
|
|
141
|
-
// Do not consume the event; allow other listeners and Glide to continue normal
|
|
142
|
-
// handling.
|
|
143
|
-
return false;
|
|
144
|
-
}
|
|
145
89
|
}
|
|
@@ -5,27 +5,23 @@ import android.content.SharedPreferences;
|
|
|
5
5
|
import android.util.Base64;
|
|
6
6
|
import org.json.JSONException;
|
|
7
7
|
import org.json.JSONObject;
|
|
8
|
+
import org.json.JSONArray;
|
|
8
9
|
import com.bumptech.glide.load.Key;
|
|
10
|
+
import com.bumptech.glide.load.model.GlideUrl;
|
|
11
|
+
import com.bumptech.glide.load.model.LazyHeaders;
|
|
9
12
|
import com.bumptech.glide.signature.ObjectKey;
|
|
10
13
|
import com.bumptech.glide.load.Options;
|
|
11
|
-
import
|
|
14
|
+
import java.util.Map;
|
|
15
|
+
import java.util.HashMap;
|
|
16
|
+
import java.util.Iterator;
|
|
17
|
+
import android.util.Log;
|
|
12
18
|
|
|
13
19
|
/**
|
|
14
|
-
* SharedPreferences-backed
|
|
15
|
-
* Stores:
|
|
16
|
-
* - source (string)
|
|
17
|
-
* - signature (string)
|
|
18
|
-
* - width, height
|
|
19
|
-
* - decodedResourceClass (string)
|
|
20
|
-
* - transformationKeyBytes (base64)
|
|
21
|
-
* - optionsKeyBytes (base64)
|
|
22
|
-
*
|
|
23
|
-
* For transformations: we store recorded bytes (from RecordingDigest) rather
|
|
24
|
-
* than trying to
|
|
25
|
-
* re-create the Transformation object.
|
|
20
|
+
* SharedPreferences-backed persistent store.
|
|
26
21
|
*/
|
|
27
|
-
public class SharedPrefCacheKeyStore {
|
|
28
|
-
private static final String
|
|
22
|
+
public class SharedPrefCacheKeyStore extends CacheKeyStore {
|
|
23
|
+
private static final String TAG = "SharedPrefCacheKeyStore";
|
|
24
|
+
private static final String PREFS = "glide_cache_keys_v3"; // bump version
|
|
29
25
|
private final SharedPreferences prefs;
|
|
30
26
|
|
|
31
27
|
public SharedPrefCacheKeyStore(Context context) {
|
|
@@ -35,19 +31,26 @@ public class SharedPrefCacheKeyStore {
|
|
|
35
31
|
public void put(String id, CacheKeyStore.StoredKeys keys) {
|
|
36
32
|
try {
|
|
37
33
|
JSONObject j = new JSONObject();
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
34
|
+
// Log.d(TAG, "SharedPrefCacheKeyStore.put id=" + id + " sourceKey=" + keys.sourceKey);
|
|
35
|
+
|
|
36
|
+
if (keys.sourceKey instanceof GlideUrl) {
|
|
37
|
+
GlideUrl glideUrl = (GlideUrl) keys.sourceKey;
|
|
38
|
+
j.put("sourceType", "GlideUrl");
|
|
39
|
+
j.put("sourceUrl", glideUrl.toStringUrl());
|
|
40
|
+
|
|
41
|
+
} else if (keys.sourceKey != null) {
|
|
42
|
+
j.put("sourceType", "ObjectKey");
|
|
43
|
+
j.put("source", keys.sourceKey.toString());
|
|
44
|
+
} else {
|
|
45
|
+
j.put("sourceType", "null");
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
if ( keys.signature != null) {
|
|
49
|
+
j.put("signature", keys.signature.toString());
|
|
50
|
+
}
|
|
48
51
|
prefs.edit().putString(id, j.toString()).apply();
|
|
49
52
|
} catch (JSONException e) {
|
|
50
|
-
|
|
53
|
+
Log.e(TAG, "Failed to serialize keys for " + id, e);
|
|
51
54
|
}
|
|
52
55
|
}
|
|
53
56
|
|
|
@@ -57,31 +60,50 @@ public class SharedPrefCacheKeyStore {
|
|
|
57
60
|
return null;
|
|
58
61
|
try {
|
|
59
62
|
JSONObject j = new JSONObject(s);
|
|
60
|
-
String source = j.optString("source", null);
|
|
61
|
-
String signature = j.optString("signature", null);
|
|
62
|
-
int width = j.optInt("width", com.bumptech.glide.request.target.Target.SIZE_ORIGINAL);
|
|
63
|
-
int height = j.optInt("height", com.bumptech.glide.request.target.Target.SIZE_ORIGINAL);
|
|
64
|
-
String decodedName = j.optString("decodedResourceClass", android.graphics.Bitmap.class.getName());
|
|
65
|
-
String transformationBase64 = j.optString("transformationBytes", null);
|
|
66
|
-
String optionsBase64 = j.optString("optionsBytes", null);
|
|
67
|
-
|
|
68
|
-
Key sourceKey = source != null && !"null".equals(source) ? new ObjectKey(source) : new ObjectKey(id);
|
|
69
|
-
Key signatureKey = signature != null && !"null".equals(signature) ? new ObjectKey(signature)
|
|
70
|
-
: new ObjectKey("signature-none");
|
|
71
|
-
Class<?> decodedClass = Class.forName(decodedName);
|
|
72
|
-
byte[] transformationBytes = (transformationBase64 == null || "null".equals(transformationBase64)) ? null
|
|
73
|
-
: Base64.decode(transformationBase64, Base64.NO_WRAP);
|
|
74
|
-
byte[] optionsBytes = (optionsBase64 == null || "null".equals(optionsBase64)) ? null
|
|
75
|
-
: Base64.decode(optionsBase64, Base64.NO_WRAP);
|
|
76
63
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
64
|
+
Key sourceKey;
|
|
65
|
+
String sourceType = j.optString("sourceType", "ObjectKey");
|
|
66
|
+
|
|
67
|
+
if ("GlideUrl".equals(sourceType)) {
|
|
68
|
+
String url = j.optString("sourceUrl", null);
|
|
69
|
+
|
|
70
|
+
if (url != null) {
|
|
71
|
+
sourceKey = new CustomGlideUrl(url, null, null, null);
|
|
72
|
+
} else {
|
|
73
|
+
sourceKey = new ObjectKey(id);
|
|
74
|
+
}
|
|
75
|
+
} else{
|
|
76
|
+
String source = j.optString("source", null);
|
|
77
|
+
if (source != null && !"null".equals(source)) {
|
|
78
|
+
// Extract inner value from "ObjectKey{object=value}" format
|
|
79
|
+
String innerValue = source;
|
|
80
|
+
if (innerValue.startsWith("ObjectKey{object=") && innerValue.endsWith("}")) {
|
|
81
|
+
innerValue = innerValue.substring(17, innerValue.length() - 1);
|
|
82
|
+
}
|
|
83
|
+
sourceKey = new ObjectKey(innerValue);
|
|
84
|
+
} else {
|
|
85
|
+
sourceKey = new ObjectKey(id);
|
|
86
|
+
}
|
|
87
|
+
// Log.d(TAG, "SharedPrefCacheKeyStore.get id=" + id + " source=" + source + " sourceKey=" + sourceKey);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
String signatureStr = j.optString("signature", null);
|
|
91
|
+
|
|
92
|
+
Key signatureKey;
|
|
93
|
+
if (signatureStr != null && !"null".equals(signatureStr)) {
|
|
94
|
+
// Extract inner value from "ObjectKey{object=value}" format
|
|
95
|
+
String innerValue = signatureStr;
|
|
96
|
+
if (signatureStr.startsWith("ObjectKey{object=") && signatureStr.endsWith("}")) {
|
|
97
|
+
innerValue = signatureStr.substring(17, signatureStr.length() - 1);
|
|
98
|
+
}
|
|
99
|
+
signatureKey = new ObjectKey(innerValue);
|
|
100
|
+
} else {
|
|
101
|
+
signatureKey = new ObjectKey("signature-none");
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
return new CacheKeyStore.StoredKeys(sourceKey, signatureKey);
|
|
84
105
|
} catch (Exception e) {
|
|
106
|
+
Log.e(TAG, "Failed to deserialize keys for " + id, e);
|
|
85
107
|
return null;
|
|
86
108
|
}
|
|
87
109
|
}
|
|
@@ -89,4 +111,8 @@ public class SharedPrefCacheKeyStore {
|
|
|
89
111
|
public void remove(String id) {
|
|
90
112
|
prefs.edit().remove(id).apply();
|
|
91
113
|
}
|
|
114
|
+
|
|
115
|
+
public void clearAll() {
|
|
116
|
+
prefs.edit().clear().apply();
|
|
117
|
+
}
|
|
92
118
|
}
|
|
@@ -126,6 +126,7 @@ declare namespace com {
|
|
|
126
126
|
export class EvictionManager {
|
|
127
127
|
public static class: java.lang.Class<com.nativescript.image.EvictionManager>;
|
|
128
128
|
public clearAll(): void;
|
|
129
|
+
public setGlideInstance(glideInstance: com.bumptech.glide.Glide);
|
|
129
130
|
public static get(): com.nativescript.image.EvictionManager;
|
|
130
131
|
public clearMemory(callback: com.nativescript.image.EvictionManager.EvictionCallback): void;
|
|
131
132
|
public clearAll(callback: com.nativescript.image.EvictionManager.EvictionCallback): void;
|
|
@@ -136,7 +137,6 @@ declare namespace com {
|
|
|
136
137
|
public setDiskCache(diskCache: com.bumptech.glide.load.engine.cache.DiskCache): void;
|
|
137
138
|
public isInMemoryCache(this_: string): boolean;
|
|
138
139
|
public evictAllForId(id: string): void;
|
|
139
|
-
public evictSourceForId(id: string, callback: com.nativescript.image.EvictionManager.EvictionCallback): void;
|
|
140
140
|
public evictDiskForId(this_: string, id: com.nativescript.image.EvictionManager.EvictionCallback): void;
|
|
141
141
|
public isInDiskCacheBlocking(resourceKey: string): androidNative.Array<boolean>;
|
|
142
142
|
public clearDiskCache(): void;
|
|
@@ -173,6 +173,14 @@ declare namespace com {
|
|
|
173
173
|
public constructor();
|
|
174
174
|
public onComplete(param0: boolean, param1: java.lang.Exception): void;
|
|
175
175
|
}
|
|
176
|
+
|
|
177
|
+
export function setGlideInstance(glideInstance: bumptech.glide.Glide) {
|
|
178
|
+
throw new Error('Function not implemented.');
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
export function setGlideInstance(glideInstance: bumptech.glide.Glide) {
|
|
182
|
+
throw new Error('Function not implemented.');
|
|
183
|
+
}
|
|
176
184
|
}
|
|
177
185
|
export class ExtractRequestOptions {
|
|
178
186
|
public static class: java.lang.Class<com.nativescript.image.ExtractRequestOptions>;
|
|
@@ -488,24 +496,9 @@ declare namespace com {
|
|
|
488
496
|
public source(): okio.BufferedSource;
|
|
489
497
|
public contentType(): okhttp3.MediaType;
|
|
490
498
|
}
|
|
491
|
-
export class RecordingDigest {
|
|
492
|
-
public static class: java.lang.Class<com.nativescript.image.RecordingDigest>;
|
|
493
|
-
public engineUpdate(input: number): void;
|
|
494
|
-
public engineUpdate(input: androidNative.Array<number>, offset: number, len: number): void;
|
|
495
|
-
public engineDigest(): androidNative.Array<number>;
|
|
496
|
-
public engineReset(): void;
|
|
497
|
-
public constructor();
|
|
498
|
-
}
|
|
499
|
-
export class RecreatedResourceKey {
|
|
500
|
-
public static class: java.lang.Class<com.nativescript.image.RecreatedResourceKey>;
|
|
501
|
-
public hashCode(): number;
|
|
502
|
-
public constructor(sourceKey: com.bumptech.glide.load.Key, signature: com.bumptech.glide.load.Key, width: number, height: number, transformationKeyBytes: androidNative.Array<number>, decodedResourceClass: java.lang.Class<any>, optionsKeyBytes: androidNative.Array<number>);
|
|
503
|
-
public equals(o: any): boolean;
|
|
504
|
-
public updateDiskCacheKey(messageDigest: java.security.MessageDigest): void;
|
|
505
|
-
}
|
|
506
499
|
export class SaveKeysRequestListener extends com.bumptech.glide.request.RequestListener<globalAndroid.graphics.drawable.Drawable> {
|
|
507
500
|
public static class: java.lang.Class<com.nativescript.image.SaveKeysRequestListener>;
|
|
508
|
-
public constructor(id: string, model: any, sourceKey: com.bumptech.glide.load.Key, signature: com.bumptech.glide.load.Key
|
|
501
|
+
public constructor(id: string, model: any, sourceKey: com.bumptech.glide.load.Key, signature: com.bumptech.glide.load.Key);
|
|
509
502
|
public onLoadFailed(e: com.bumptech.glide.load.engine.GlideException, model: any, target: com.bumptech.glide.request.target.Target<globalAndroid.graphics.drawable.Drawable>, isFirstResource: boolean): boolean;
|
|
510
503
|
public onResourceReady(t: globalAndroid.graphics.drawable.Drawable, rd2: any, t_1: com.bumptech.glide.request.target.Target<globalAndroid.graphics.drawable.Drawable>, existing: com.bumptech.glide.load.DataSource, t_2: boolean): boolean;
|
|
511
504
|
}
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
package com.bumptech.glide.load.engine;
|
|
2
|
-
|
|
3
|
-
import com.bumptech.glide.load.Key;
|
|
4
|
-
import com.bumptech.glide.load.Options;
|
|
5
|
-
import com.bumptech.glide.load.Transformation;
|
|
6
|
-
import java.util.Map;
|
|
7
|
-
import android.util.Log;
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Public subclass of package-private EngineKeyFactory that notifies a listener
|
|
11
|
-
* when an
|
|
12
|
-
* EngineKey is created.
|
|
13
|
-
*/
|
|
14
|
-
public class CapturingEngineKeyFactory extends EngineKeyFactory {
|
|
15
|
-
public interface Listener {
|
|
16
|
-
void onEngineKeyCreated(Key engineKey, Object model);
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
private final Listener listener;
|
|
20
|
-
|
|
21
|
-
public CapturingEngineKeyFactory(Listener listener) {
|
|
22
|
-
this.listener = listener;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
@SuppressWarnings({ "rawtypes", "unchecked" })
|
|
26
|
-
@Override
|
|
27
|
-
com.bumptech.glide.load.engine.EngineKey buildKey(
|
|
28
|
-
Object model,
|
|
29
|
-
Key signature,
|
|
30
|
-
int width,
|
|
31
|
-
int height,
|
|
32
|
-
Map<Class<?>, Transformation<?>> transformations,
|
|
33
|
-
Class<?> resourceClass,
|
|
34
|
-
Class<?> transcodeClass,
|
|
35
|
-
Options options) {
|
|
36
|
-
com.bumptech.glide.load.engine.EngineKey engineKey = super.buildKey(model, signature, width, height,
|
|
37
|
-
transformations, resourceClass, transcodeClass, options);
|
|
38
|
-
if (listener != null) {
|
|
39
|
-
listener.onEngineKeyCreated(engineKey, model);
|
|
40
|
-
}
|
|
41
|
-
return engineKey;
|
|
42
|
-
}
|
|
43
|
-
}
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
package com.nativescript.image;
|
|
2
|
-
|
|
3
|
-
import java.io.ByteArrayOutputStream;
|
|
4
|
-
import java.security.MessageDigest;
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Small MessageDigest that records raw bytes passed to update(...).
|
|
8
|
-
* We don't compute a digest here: we simply capture the bytes that callers
|
|
9
|
-
* write by calling
|
|
10
|
-
* update(byte[]) so we can later replay them into another MessageDigest.
|
|
11
|
-
*
|
|
12
|
-
* Usage:
|
|
13
|
-
* RecordingDigest r = new RecordingDigest();
|
|
14
|
-
* transformation.updateDiskCacheKey(r);
|
|
15
|
-
* byte[] bytes = r.digest(); // returns the concatenated bytes that
|
|
16
|
-
* transformation wrote
|
|
17
|
-
*/
|
|
18
|
-
public final class RecordingDigest extends MessageDigest {
|
|
19
|
-
private final ByteArrayOutputStream out = new ByteArrayOutputStream();
|
|
20
|
-
|
|
21
|
-
public RecordingDigest() {
|
|
22
|
-
// algorithm name is arbitrary here; we do not rely on MessageDigest's actual
|
|
23
|
-
// hashing.
|
|
24
|
-
super("NONE");
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
@Override
|
|
28
|
-
protected void engineUpdate(byte input) {
|
|
29
|
-
out.write(input);
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
@Override
|
|
33
|
-
protected void engineUpdate(byte[] input, int offset, int len) {
|
|
34
|
-
out.write(input, offset, len);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
@Override
|
|
38
|
-
protected byte[] engineDigest() {
|
|
39
|
-
byte[] result = out.toByteArray();
|
|
40
|
-
out.reset();
|
|
41
|
-
return result;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
@Override
|
|
45
|
-
protected void engineReset() {
|
|
46
|
-
out.reset();
|
|
47
|
-
}
|
|
48
|
-
}
|
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
package com.nativescript.image;
|
|
2
|
-
|
|
3
|
-
import androidx.annotation.NonNull;
|
|
4
|
-
import com.bumptech.glide.load.Key;
|
|
5
|
-
import java.nio.ByteBuffer;
|
|
6
|
-
import java.security.MessageDigest;
|
|
7
|
-
import java.util.Objects;
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Recreates ResourceCacheKey updateDiskCacheKey ordering but accepts
|
|
11
|
-
* precomputed transformation
|
|
12
|
-
* and options key bytes. This avoids the need to reconstruct
|
|
13
|
-
* Transformation/Options objects.
|
|
14
|
-
*
|
|
15
|
-
* Ordering mirrors Glide's ResourceCacheKey:
|
|
16
|
-
* signature.updateDiskCacheKey(md)
|
|
17
|
-
* sourceKey.updateDiskCacheKey(md)
|
|
18
|
-
* md.update(dimensions)
|
|
19
|
-
* md.update(transformationKeyBytes) -- if present
|
|
20
|
-
* md.update(optionsKeyBytes) -- if present
|
|
21
|
-
* md.update(decodedResourceClass.getName().getBytes(...))
|
|
22
|
-
*/
|
|
23
|
-
public final class RecreatedResourceKey implements Key {
|
|
24
|
-
private final Key sourceKey;
|
|
25
|
-
private final Key signature;
|
|
26
|
-
private final int width;
|
|
27
|
-
private final int height;
|
|
28
|
-
private final byte[] transformationKeyBytes; // may be null
|
|
29
|
-
private final Class<?> decodedResourceClass;
|
|
30
|
-
private final byte[] optionsKeyBytes; // may be null
|
|
31
|
-
|
|
32
|
-
public RecreatedResourceKey(
|
|
33
|
-
Key sourceKey,
|
|
34
|
-
Key signature,
|
|
35
|
-
int width,
|
|
36
|
-
int height,
|
|
37
|
-
byte[] transformationKeyBytes,
|
|
38
|
-
Class<?> decodedResourceClass,
|
|
39
|
-
byte[] optionsKeyBytes) {
|
|
40
|
-
this.sourceKey = Objects.requireNonNull(sourceKey);
|
|
41
|
-
this.signature = Objects.requireNonNull(signature);
|
|
42
|
-
this.width = width;
|
|
43
|
-
this.height = height;
|
|
44
|
-
this.transformationKeyBytes = transformationKeyBytes;
|
|
45
|
-
this.decodedResourceClass = Objects.requireNonNull(decodedResourceClass);
|
|
46
|
-
this.optionsKeyBytes = optionsKeyBytes;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
@Override
|
|
50
|
-
public boolean equals(Object o) {
|
|
51
|
-
if (this == o)
|
|
52
|
-
return true;
|
|
53
|
-
if (!(o instanceof RecreatedResourceKey))
|
|
54
|
-
return false;
|
|
55
|
-
RecreatedResourceKey that = (RecreatedResourceKey) o;
|
|
56
|
-
return width == that.width
|
|
57
|
-
&& height == that.height
|
|
58
|
-
&& sourceKey.equals(that.sourceKey)
|
|
59
|
-
&& signature.equals(that.signature)
|
|
60
|
-
&& java.util.Arrays.equals(transformationKeyBytes, that.transformationKeyBytes)
|
|
61
|
-
&& decodedResourceClass.equals(that.decodedResourceClass)
|
|
62
|
-
&& java.util.Arrays.equals(optionsKeyBytes, that.optionsKeyBytes);
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
@Override
|
|
66
|
-
public int hashCode() {
|
|
67
|
-
int result = sourceKey.hashCode();
|
|
68
|
-
result = 31 * result + signature.hashCode();
|
|
69
|
-
result = 31 * result + width;
|
|
70
|
-
result = 31 * result + height;
|
|
71
|
-
result = 31 * result + java.util.Arrays.hashCode(transformationKeyBytes);
|
|
72
|
-
result = 31 * result + decodedResourceClass.hashCode();
|
|
73
|
-
result = 31 * result + java.util.Arrays.hashCode(optionsKeyBytes);
|
|
74
|
-
return result;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
@Override
|
|
78
|
-
public void updateDiskCacheKey(@NonNull MessageDigest messageDigest) {
|
|
79
|
-
byte[] dimensions = ByteBuffer.allocate(8).putInt(width).putInt(height).array();
|
|
80
|
-
|
|
81
|
-
signature.updateDiskCacheKey(messageDigest);
|
|
82
|
-
sourceKey.updateDiskCacheKey(messageDigest);
|
|
83
|
-
messageDigest.update(dimensions);
|
|
84
|
-
|
|
85
|
-
if (transformationKeyBytes != null) {
|
|
86
|
-
messageDigest.update(transformationKeyBytes);
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
if (optionsKeyBytes != null) {
|
|
90
|
-
messageDigest.update(optionsKeyBytes);
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
messageDigest.update(decodedResourceClass.getName().getBytes(CHARSET));
|
|
94
|
-
}
|
|
95
|
-
}
|