/** * Get a value. * * @param model The model. * @param width The width in pixels of the view the image is being loaded into. * @param height The height in pixels of the view the image is being loaded into. * @return The cached result, or null. */ @Nullable public B get(A model, int width, int height) { ModelKey<A> key = ModelKey.get(model, width, height); B result = cache.get(key); key.release(); return result; }
/** * Get a value. * * @param model The model. * @param width The width in pixels of the view the image is being loaded into. * @param height The height in pixels of the view the image is being loaded into. * @return The cached result, or null. */ @Nullable public B get(A model, int width, int height) { ModelKey<A> key = ModelKey.get(model, width, height); B result = cache.get(key); key.release(); return result; }
@Override protected void onItemEvicted(ModelKey<A> key, B item) { key.release(); } };
/** * Add a value. * * @param model The model. * @param width The width in pixels of the view the image is being loaded into. * @param height The height in pixels of the view the image is being loaded into. * @param value The value to store. */ public void put(A model, int width, int height, B value) { ModelKey<A> key = ModelKey.get(model, width, height); cache.put(key, value); }
/** * Get a value. * * @param model The model. * @param width The width in pixels of the view the image is being loaded into. * @param height The height in pixels of the view the image is being loaded into. * * @return The cached result, or null. */ public B get(A model, int width, int height) { ModelKey<A> key = ModelKey.get(model, width, height); B result = cache.get(key); key.release(); return result; }
/** * Add a value. * * @param model The model. * @param width The width in pixels of the view the image is being loaded into. * @param height The height in pixels of the view the image is being loaded into. * @param value The value to store. */ public void put(A model, int width, int height, B value) { ModelKey<A> key = ModelKey.get(model, width, height); cache.put(key, value); }
@Override protected void onItemEvicted(ModelKey<A> key, B item) { key.release(); } };
@Override protected void onItemEvicted(@NonNull ModelKey<A> key, @Nullable B item) { key.release(); } };
@Test public void testModelKeyEquivalence() { new EqualsTester().addEqualityGroup(ModelCache.ModelKey.get(14f, 100, 200), ModelCache.ModelKey.get(14f, 100, 200)) .addEqualityGroup(ModelCache.ModelKey.get(13f, 100, 200)) .addEqualityGroup(ModelCache.ModelKey.get(14f, 200, 200)) .addEqualityGroup(ModelCache.ModelKey.get(14f, 100, 300)).testEquals(); }
/** * Add a value. * * @param model The model. * @param width The width in pixels of the view the image is being loaded into. * @param height The height in pixels of the view the image is being loaded into. * @param value The value to store. */ public void put(A model, int width, int height, B value) { ModelKey<A> key = ModelKey.get(model, width, height); cache.put(key, value); }