/**
* 显示删除浮窗
*
* @param view itemView对象
* @param pos 位置
*/
private fun showPopWindow(view: View, pos: Int) {
val popHeight = DeviceUtils.dip2px(this, 35f)
val popWidth = DeviceUtils.dip2px(this, 52f)
if (mPopupMenu == null) {
mPopupMenu = PopupWindow(
View.inflate(this, R.layout.bbj_rv_userfavorite_popwindow, null),
popWidth,
popHeight
)
mPopupMenu!!.isTouchable = true
mPopupMenu!!.setBackgroundDrawable(ColorDrawable())
}
mPopupMenu?.let {
if (it.isShowing) it.dismiss()
val offsetX = (popWidth + view.height) / 2
var offsetY = (popHeight + view.height)
var itemLocation = IntArray(1)
view.getLocationInWindow(itemLocation)
var recyclerLocation = IntArray(1)
recyclerView.getLocationInWindow(recyclerLocation)
//上方不足显示
if (itemLocation[2] - recyclerLocation[2] < offsetY) {
it.showAsDropDown(view, offsetX, 0)
} else {
it.showAsDropDown(view, offsetX, -offsetY)
}
}
}
网友评论