下面列出了android.view.Window#peekDecorView ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
@Nullable
@Override
public Object getElementToHighlightAtPosition(Window element, int x, int y, Rect bounds) {
final Descriptor.Host host = getHost();
View view = null;
HighlightableDescriptor descriptor = null;
if (host instanceof AndroidDescriptorHost) {
view = element.peekDecorView();
descriptor = ((AndroidDescriptorHost) host).getHighlightableDescriptor(view);
}
return descriptor == null
? null
: descriptor.getElementToHighlightAtPosition(view, x, y, bounds);
}
@Override
protected void onGetChildren(Window element, Accumulator<Object> children) {
View decorView = element.peekDecorView();
if (decorView != null) {
children.store(decorView);
}
}
@Override
protected void onGetChildren(Window element, Accumulator<Object> children) {
View decorView = element.peekDecorView();
if (decorView != null) {
children.store(decorView);
}
}
/**
* Return the current window token, or null.
*/
@CalledByNative
private IBinder getWindowToken() {
Activity activity = activityFromContext(mContextRef.get());
if (activity == null) return null;
Window window = activity.getWindow();
if (window == null) return null;
View decorView = window.peekDecorView();
if (decorView == null) return null;
return decorView.getWindowToken();
}
public boolean onHasView() {
Window w = FragmentActivity.this.getWindow();
return (w == null || w.peekDecorView() == null) ? false : true;
}
@Override
@Nullable
public View getViewForHighlighting(Object element) {
Window window = (Window) element;
return window.peekDecorView();
}
@Override
@Nullable
public View getViewAndBoundsForHighlighting(Window element, Rect bounds) {
return element.peekDecorView();
}
@Override
public boolean hasView() {
Window window = FragmentActivity.this.getWindow();
return (window != null && window.peekDecorView() != null);
}