Coder Social home page Coder Social logo

Comments (1)

vincentbrison avatar vincentbrison commented on May 29, 2024

Hi,
If you use default serializer, it means you are using serialization of your
bitmaps into Json format, which I doubt you really want. With bitmaps you
should write your own custom serializer (at least for disk, in RAM you
should keep references) with examples like this
http://stackoverflow.com/questions/13562429/how-many-ways-to-convert-bitmap-to-string-and-vice-versa

2015-11-24 10:43 GMT+01:00 Andreas Gohr [email protected]:

I use the following to to cache Bitmaps:

DualCacheLogUtils.enableLog();DualCacheContextUtils.setContext(RadioApplication.getAppContext());
cache = new DualCacheBuilder(CACHE_NAME, CACHE_VERSION, Bitmap.class)
.useReferenceInRam(CACHE_RAM, new SizeOfBitmap())
.useDefaultSerializerInDisk(CACHE_DISK, true);

Storing seems to work fine, but when trying to retrieve an entry from
cache, I get the following:

I/dualcache: Entry for e5429ada18f6df2de9c9870c379b7eb4 is on disk.
E/dualcache: error :
com.fasterxml.jackson.databind.JsonMappingException: No suitable constructor found for type [simple type, class android.graphics.Bitmap]: can not instantiate from JSON object (need to add/enable type information?)
at [Source: {"mStackTrace":null,"mBuffer":null,"mRestorePolicyInfo":null,"mFinalizer":["android.graphics.Bitmap$BitmapFinalizer",{"mStackTrace":null,"mIsPreloaded":false,"mNativeBitmap":2140966016,"mPixelsIsAllocated":true,"mRecycled":false,"mBitmapSize":878000}],"mNinePatchChunk":null,"mLayoutBounds":null,"mIsMutable":false,"mIsPreloading":false,"mIsPremultiplied":true,"mIsRestorable":false,"mInUse":false,"mNativeBitmap":2140966016,"mNativeBitmapFreed":false,"mHeight":439,"mPixelsIsAllocated":true,"mRecycled":false,"mDensity":480,"mBitmapSize":878000,"mWidth":500}; line: 1, column: 2]
at com.fasterxml.jackson.databind.deser.BeanDeserializerBase.deserializeFromObjectUsingNonDefault(BeanDeserializerBase.java:1063)
at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserializeFromObject(BeanDeserializer.java:264)
at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:124)
at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:3051)
at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:2146)
at com.vincentbrison.openlibraries.android.dualcache.lib.DualCache.get(DualCache.java:410)


Reply to this email directly or view it on GitHub
#21.

Android enthusiast : vincentbrison.com

from dualcache.

Related Issues (20)

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.