opt 事件面板按钮不出现问题
This commit is contained in:
@@ -2,6 +2,8 @@ package com.mogo.module.extensions.bean;
|
||||
|
||||
import android.view.View;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* 底层view封装
|
||||
*
|
||||
@@ -12,7 +14,8 @@ public class BottomLayerViewWrapper {
|
||||
private int x;
|
||||
private int y;
|
||||
|
||||
public BottomLayerViewWrapper(){}
|
||||
public BottomLayerViewWrapper() {
|
||||
}
|
||||
|
||||
public BottomLayerViewWrapper(View view, int x, int y) {
|
||||
this.view = view;
|
||||
@@ -20,6 +23,25 @@ public class BottomLayerViewWrapper {
|
||||
this.y = y;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
BottomLayerViewWrapper wrapper = (BottomLayerViewWrapper) o;
|
||||
return x == wrapper.x &&
|
||||
y == wrapper.y &&
|
||||
view.equals(wrapper.view);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(view);
|
||||
}
|
||||
|
||||
public View getView() {
|
||||
return view;
|
||||
}
|
||||
|
||||
@@ -58,12 +58,26 @@ public class EntranceViewHolder {
|
||||
"\n x: " + x + ", y: " + y);
|
||||
BottomLayerViewWrapper wrapper = new BottomLayerViewWrapper(view, x, y);
|
||||
if(rootViewGroup == null) {
|
||||
preAddView.add(wrapper);
|
||||
if(!preAddView.contains(wrapper)) {
|
||||
preAddView.add(wrapper);
|
||||
}
|
||||
}else{
|
||||
realAddView(wrapper);
|
||||
if(!containView(view)) {
|
||||
realAddView(wrapper);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private boolean containView(View view) {
|
||||
int count = rootViewGroup.getChildCount();
|
||||
for (int i = 0; i < count; i++) {
|
||||
if(rootViewGroup.getChildAt(i).equals(view)){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 使用的时候需要预先判断rootViewGroup是否为空,本方法默认rootViewGroup不为空
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user