Skip to content
This repository was archived by the owner on Nov 26, 2025. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@

package com.etsy.android.grid;

import java.util.ArrayList;

import android.content.Context;
import android.database.DataSetObserver;
import android.graphics.Rect;
Expand All @@ -28,14 +30,19 @@
import android.support.v4.view.ViewCompat;
import android.util.AttributeSet;
import android.util.Log;
import android.view.*;
import android.view.ContextMenu.ContextMenuInfo;
import android.view.HapticFeedbackConstants;
import android.view.MotionEvent;
import android.view.VelocityTracker;
import android.view.View;
import android.view.ViewConfiguration;
import android.view.ViewGroup;
import android.view.ViewParent;
import android.widget.AbsListView;
import android.widget.AdapterView;
import android.widget.ListAdapter;
import android.widget.Scroller;

import java.util.ArrayList;

/**
* An extendable implementation of the Android {@link android.widget.ListView}
* <p/>
Expand Down Expand Up @@ -2910,4 +2917,24 @@ public boolean sameWindow() {
return hasWindowFocus() && getWindowAttachCount() == mOriginalAttachCount;
}
}

@Override
protected ContextMenuInfo getContextMenuInfo(){ // added by v-b-r
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using Floating context menu with StaggeredGridView, menuInfo was null previously, I've added necessary method to get menuInfo properly. I've have not gone through full code, this method might need a review.

ContextMenuInfo menuInfo = super.getContextMenuInfo();
if(menuInfo==null){
final ListAdapter adapter = mAdapter;
final int motionPosition = mPerformClick.mClickMotionPosition;
if (adapter != null && mItemCount > 0 &&
motionPosition != INVALID_POSITION &&
motionPosition < adapter.getCount()) {
final View view = getChildAt(motionPosition); // a fix by @pboos

if (view != null) {
final int clickPosition = motionPosition + mFirstPosition;
menuInfo = new AdapterContextMenuInfo(view, clickPosition, adapter.getItemId(clickPosition));
}
}
}
return menuInfo;
}
}