parent
84e985e120
commit
02ebf78188
@ -1,37 +0,0 @@ |
|||||||
package net.pokeranalytics.android.ui.view |
|
||||||
|
|
||||||
import android.content.Context |
|
||||||
import android.util.AttributeSet |
|
||||||
import android.view.ContextMenu |
|
||||||
import android.view.View |
|
||||||
import androidx.recyclerview.widget.RecyclerView |
|
||||||
|
|
||||||
|
|
||||||
class ContextMenuRecyclerView : RecyclerView { |
|
||||||
|
|
||||||
constructor(context: Context, attributeSet: AttributeSet?, defStyle: Int) : super(context, attributeSet, defStyle) |
|
||||||
constructor(context: Context, attributeSet: AttributeSet?) : super(context, attributeSet) |
|
||||||
constructor(context: Context) : super(context) |
|
||||||
|
|
||||||
private var mContextMenuInfo: RecyclerViewContextMenuInfo? = null |
|
||||||
|
|
||||||
override fun getContextMenuInfo(): ContextMenu.ContextMenuInfo? { |
|
||||||
return mContextMenuInfo |
|
||||||
} |
|
||||||
|
|
||||||
override fun showContextMenuForChild(originalView: View): Boolean { |
|
||||||
|
|
||||||
val longPressPosition = getChildAdapterPosition(originalView) |
|
||||||
val longPressId = adapter?.getItemId(longPressPosition) |
|
||||||
|
|
||||||
if (longPressPosition >= 0 && longPressId != null) { |
|
||||||
mContextMenuInfo = RecyclerViewContextMenuInfo(longPressPosition, longPressId) |
|
||||||
return super.showContextMenuForChild(originalView) |
|
||||||
} |
|
||||||
return false |
|
||||||
} |
|
||||||
|
|
||||||
class RecyclerViewContextMenuInfo(val position: Int, val id: Long) : ContextMenu.ContextMenuInfo |
|
||||||
|
|
||||||
} |
|
||||||
|
|
||||||
Loading…
Reference in new issue