Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit fd0d6275 authored by Jeff Sharkey's avatar Jeff Sharkey
Browse files

Fix ExpandableListView context menus when has header views.

createContextMenuInfo() should have been subtracting any
header views, similar to performItemClick().  Previously,
this caused getUnflattenedPos() to return invalid positions.

This fixes http://b/issue?id=1778239
parent 7d68dae9
Loading
Loading
Loading
Loading
+9 −1
Original line number Original line Diff line number Diff line
@@ -33,6 +33,7 @@ import android.view.ContextMenu;
import android.view.SoundEffectConstants;
import android.view.SoundEffectConstants;
import android.view.View;
import android.view.View;
import android.view.ContextMenu.ContextMenuInfo;
import android.view.ContextMenu.ContextMenuInfo;
import android.widget.AdapterView.AdapterContextMenuInfo;
import android.widget.ExpandableListConnector.PositionMetadata;
import android.widget.ExpandableListConnector.PositionMetadata;


/**
/**
@@ -916,7 +917,14 @@ public class ExpandableListView extends ListView {


    @Override
    @Override
    ContextMenuInfo createContextMenuInfo(View view, int flatListPosition, long id) {
    ContextMenuInfo createContextMenuInfo(View view, int flatListPosition, long id) {
        PositionMetadata pm = mConnector.getUnflattenedPos(flatListPosition);
        // Adjust for and handle for header views
        final int adjustedPosition = flatListPosition - getHeaderViewsCount();
        if (adjustedPosition < 0) {
            // Return normal info for header view context menus
            return new AdapterContextMenuInfo(view, flatListPosition, id);
        }

        PositionMetadata pm = mConnector.getUnflattenedPos(adjustedPosition);
        ExpandableListPosition pos = pm.position;
        ExpandableListPosition pos = pm.position;
        pm.recycle();
        pm.recycle();