image processing - Resampling large bitmaps for lists in Android using MVVM Cross -


i have long list of cells each contain image.

the images large on disk, used other things in app wallpapers etc.

i familiar normal android process resampling large bitmaps , disposing of them when no longer needed.

however, feel trying resample images on fly in list adapter inefficient without caching them once decoded, otherwise fling spawn many threads , have manage cancelling unneeded images etc etc.

the app built making extensive use of fantastic mvvmcross framework. thinking using mvximageviews these can load images disk , cache them easily. thing is, need resample them before cached.

my question is, know of established pattern in mvvmcross, or have suggestions how might go achieving it? need customise download cache plugin? suggestions great :)

ok, think have found answer. had been accidentally looking @ old mvvmcross 3.1 version of downloadcache plugin / mvxlocalfileimageloader.

after cloning date (v3.5) repo found functionality has been added. local files cached , can resampled on first load :)

the mvximageview has max height / width setter method propagates out mvximagehelper, in turn sends mvxlocalfileimageloader.

one thing note resampling happens if loading file, not if using resource id.

source here: https://github.com/mvvmcross/mvvmcross/blob/3.5/plugins/cirrious/downloadcache/cirrious.mvvmcross.plugins.downloadcache.droid/mvxandroidlocalfileimageloader.cs

once again mvvmcross saves day ^_^

update: have working, here pointers:

  • as noted in comments, local image caching available on 3.5.2 alpha mvvmcross. incompatible project, using 3.5.1 created own copies of 3.5.2a mvximageview, mvximagehelper , mvxandroidlocalfileimageloader, along interfaces, , registered them in setup class.

  • i modified mvxandroidlocalfileimageloader resample resources, not files.

  • you have bind mvximageview's imageurl property using "res:" prefix documented here (struggling bind local images in mvximageview mvvmcross); if bind 'drawableid' assigns image directly underlying imageview , no caching / resampling happens.

  • i needed able set customised mvximageview's max height / width resampling after layout inflated/bound, before images retrieved (i wanted set them during 'onmeasure', images had been loaded then). there better way hacked in bool flag 'sizeset'. image url temporarily stored if false (i.e. during initial binding). once set true (after onmeasure), stored url passed underlying imagehelper loaded.

  • one section of app uses full screen images background of fragments in pager adapter. bitmaps not getting garbage collected quick enough, leading eventual ooms when trying load next large image. manually calling gc.collect() when fragments destroyed frees memory causes ui stutter , wipes cache uses weak refs.

  • i getting frequent sigsegv crashes on lollipop when moving between fragments in pager adapter (they never happened on kitkat). managed work around issue adding setimagebitmap(null) imageview's dispose method. call dispose() on imageview in containing fragment's ondestroyview().

hope helps someone, took me while!


Comments

Popular posts from this blog

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -