简体   繁体   English

开发人员指南中的Google Glass LiveCard示例代码是否有错误?

[英]Is there an error on the Google Glass LiveCard sample code on the Developer Guides?

I was going through the GDK docs on LiveCards (high frequency) and I came across this line of code: 我正在浏览LiveCards上的GDK文档(高频率),我遇到了这行代码:

mLiveCard.getSurfaceHolder().addCallback(new RenderThread());

RenderThread is a Class that extends Thread and does not implement any SurfaceHolder.Callback . RenderThread是一个extends ThreadClass ,并没有实现任何SurfaceHolder.Callback In the other hand, in the same sample code they define LiveCardRenderer which implements DirectRenderingCallback which in turn extends SurfaceHolder.Callback . 另一方面,在相同的示例代码中,他们定义了LiveCardRenderer ,它实现了DirectRenderingCallback ,而DirectRenderingCallbackextends SurfaceHolder.Callback Shouldn't LiveCardRenderer be used instead of RenderThread ? 不宜LiveCardRenderer被用来代替RenderThread

Thanks for catching that. 谢谢你抓住了。 You're right, it should be new LiveCardRenderer() . 你是对的,它应该是new LiveCardRenderer() The documentation has now been fixed. 文档现已修复。

This does look a lot like a mistake, as you rightly say, instead of new RenderThread() , you should have new LiveCardRenderer() . 这看起来很像一个错误,正如你正确地说,而不是new RenderThread() ,你应该有new LiveCardRenderer()

If you take a look and any of the sample apps in the GDK, for example the compass app you can see they have something like 如果您看一下GDK中的任何示例应用程序,例如罗盘应用程序,您可以看到它们有类似的东西

mRenderer = new CompassRenderer(this, mOrientationManager, mLandmarks);
mLiveCard.setDirectRenderingEnabled(true).getSurfaceHolder().addCallback(mRenderer);

Where CompassRenderer extends SurfaceHolder.Callback as you would expect and the code is similar in principle to that given for LiveCardRenderer . CompassRenderer延伸SurfaceHolder.Callback你所期望的,代码类似,原则上,对于给定的LiveCardRenderer

I hope that helps. 我希望有所帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM