android - CursorLoader Sort Order and updates -
i have gallery app using cursorloader
allows sorting of images metadata. sort defined when cursorloader
created.
// returns new cursorloader return new cursorloader( this, // parent activity context meta.data.content_uri, // table query projection, // projection return selection, // no selection clause selectionargs, // no selection arguments sort // default sort order );
if user selects images taken viewer. have opportunity manipulate metadata. causes automatic resort, can confusing. selected image may move middle end based on sorting , user won't realize this, they'll unable swipe when thought could.
is there way sort cursorloader
initially, have maintain _id
order, henceforth, if data sort based on changes?
edit: possible solution
only thing can think of maintain 'order' column viewer activity sort on , 'select' column handle selection.
before launching viewer i'll iterate through cursor inserting 'order' counter. i'll bulk insert. viewer activity should maintain previous ordering regardless of changes metadata within viewer.
two columns feels bit of hack, should work. other thing can think of manage separate custom datasource viewer, has it's own issues.
hopefully there's better way this.
the main reason using cursorloader
leverage base activity ensure same dataset used between activities without additional coding. however, since second activity needed "lock" onto dataset of prior realized poor use of cursorloader
it's main strength staying in sync changes database. wanted ignore these changes in second activity. instead created custom dataset manager second app.
(not sure relevant question longer, since up-voted it, i'll share final conclusion)
Comments
Post a Comment