Unknown URI IllegalArgumentException when using menu in SME CollectionViewWindow
Bug #991884 reported by
pjv
This bug affects 1 person
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Collectionista |
Fix Released
|
Medium
|
Unassigned |
Bug Description
second pass in FacadeContentPr
Changed in collectionista: | |
importance: | Undecided → Medium |
Changed in collectionista: | |
status: | Fix Committed → Fix Released |
To post a comment you must log in.
Apparently I had been using:
if( ContentUris. parseId( uri)==- 1){ withAppendedId( uri,
mGrid.getSelect edItemId( ));
uri = ContentUris.
}
with the following comment:
// If there are any items in the list (which implies that one of
// them is selected (either one is selected, then it's a one, or otherwise nothing is selected but at the same time the whole dir through the uri append, then it's a set, for alternatives this suitability will be looked up anyway)), then we need to generate the actions that
// can be performed on the current selection. This will be a combination
// of our own specific actions along with any extensions that can be
// found.
This comment is now probably wrong. Nothing can be selected, and this is what happens on ICS, and then we don't need to append anything. In fact we don't need to do this whole ALTERNATIVE stuff because nothing is selected. Things applicable to the collection will be generated in onCreateOptions Menu().
I also already had added in the past (to cope with some parsing bug?):
} catch (NumberFormatEx ception e1) { withAppendedId( uri, getSelectedItem Id());
uri = ContentUris.
mGrid.
}
This created an opening for appends when not appropriate.
When nothing is selected the selected item id is AdapterView. INVALID_ ROW_ID (=Long.MAX_VALUE ending in 808). This creates havoc in FacadeContentPr ovider. getType( ).
So I added a filter to haveItems:
&& mGrid.getSelect edItemId( )!=AdapterView. INVALID_ ROW_ID
Should I also be robust against other constants (INVALID_ POSITION) ??
Also, I already seem to have been fixing this partially:
// This is another action -- deleting an item, but only if there really is a selection of a (single) one. sMenu() (where it's validity is checked) because of the glitch there could be sometimes (with dialogs appearing?), the problem is also that context actions on a single item should not be in the options menu but only in the context menu (the docs don't mention yet that this is default Android behaviour and NotePad even does it wrong then), see this: http:// groups. google. com/group/ android- developers/ browse_ thread/ thread/ 3d4c7179c95e642 2/1c05bf361b640 548
if( !(mGrid. getSelectedItem Id()>=0) ){
menu. removeItem( menuItemDelete) ;
lastSelec tedItemId = mGrid.getSelect edItemId( );
//BUG SOLVED Now certainly the latest id is used from onPrepareOption
}else{
}
Is this check still required now?
Also update comments.
This is in every Activity almost, in onPrepareOption sMenu (similar stuff, but not this, in onGridItemClick and onCreateContext Menu).