What to return from GetItem in an Adapter

StuartLodgeStuartLodge USBeta ✭✭✭

Back last year, I stubbed out the public override Object GetItem(int position) calls in my Adapters to return null.

This was to avoid GREF issues - see http://stackoverflow.com/questions/13842864/why-does-the-gref-go-too-high-when-i-put-a-mvxbindablespinner-in-a-mvxbindableli/13995199#comment19319057_13995199

However... the problem with this is it breaks the AutoCompleteTextView from working - see https://github.com/slodge/MvvmCross/issues/145

I think I'm about to enable the GetItem call again - just for those views... but, before I do, I thought I'd ask: does anyone have any different ideas? Extra bonus points for better ones!

Posts

  • GlennWilsonGlennWilson USUniversity ✭✭

    My rather naive thought (and I was not aware that there was an issue until I read this) is don't "new" an item in GetItem. Returning null does that. But, also...

    Depending on the use pattern, though, could you cache the items? Are you "new"ing the "same" items over and over for a fairly small list?

    Or, similar, maintain a Pool of your MvxJavaContainer wrapper class and instead of making new ones grab one from the pool and populate it with the proper SourceItem (or just give it enough information so that it could get the correct source item if it was actually needed)?

    In the Pool case I can see a challenge in knowing when you could release the instance back to the Pool...

Sign In or Register to comment.