Unknown URI IllegalArgumentException when using menu in SME CollectionViewWindow

Bug #991884 reported by pjv
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Collectionista
Fix Released
Medium
Unassigned

Bug Description

second pass in FacadeContentProvider.getType() has a int overflow uri.

pjv (pjv)
Changed in collectionista:
importance: Undecided → Medium
Revision history for this message
pjv (pjv) wrote :

Apparently I had been using:

    if(ContentUris.parseId(uri)==-1){
     uri = ContentUris.withAppendedId(uri,
       mGrid.getSelectedItemId());
    }

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 onCreateOptionsMenu().

I also already had added in the past (to cope with some parsing bug?):

   } catch (NumberFormatException e1) {
    uri = ContentUris.withAppendedId(uri,
      mGrid.getSelectedItemId());
   }

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 FacadeContentProvider.getType().

So I added a filter to haveItems:

 && mGrid.getSelectedItemId()!=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.
            //BUG SOLVED Now certainly the latest id is used from onPrepareOptionsMenu() (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/3d4c7179c95e6422/1c05bf361b640548
            if(!(mGrid.getSelectedItemId()>=0)){
             menu.removeItem(menuItemDelete);
            }else{
             lastSelectedItemId = mGrid.getSelectedItemId();
            }

Is this check still required now?

Also update comments.

This is in every Activity almost, in onPrepareOptionsMenu (similar stuff, but not this, in onGridItemClick and onCreateContextMenu).

Changed in collectionista:
status: New → Fix Committed
pjv (pjv)
Changed in collectionista:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.