onOffsetsChanged不调用的Touchwiz [英] onOffsetsChanged not called by Touchwiz

查看:276
本文介绍了onOffsetsChanged不调用的Touchwiz的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

注:因为它是特定于三星的问题,我也问在他们的<一个href="http://developer.samsung.com/forum/thread/onoffsetschanged-not-called-in-live-wallpaper/77/217103?boardName=GeneralB&startId=zzzzz~">developer董事会。

Note: since it is a question specific to Samsung, I also asked it on their developer board.

我目前正在实施的Andr​​oid动态壁纸,我听我的墙纸引擎更改壁纸的onOffsetsChanged()方法,当用户扫描通过他的homescreens。这在我的私人的Galaxy Tab的伟大工程具有CM9定制ROM。在我公司的设备,A股的Galaxy S3,这是行不通的。不知怎么的Touchwiz不调用onOffsetsChanged时,主屏幕被改变。

I am currently implementing a Live Wallpaper in Android and I'm listening to the onOffsetsChanged() method in my wallpaper engine to change the wallpaper when the user swipes through his homescreens. This works great on my private Galaxy Tab with a CM9 custom rom. On my company device, a stock Galaxy S3, it does not work. Somehow Touchwiz doesn't call onOffsetsChanged when the homescreen is changed.

谷歌搜索的话题并没有除的<一个描述产生任何显著结果href="https://play.google.com/store/apps/details?id=com.samsung.android.livewallpaper.parallaxspring">this应用,这里的开发状态:修正了滚动的最新的TouchWiz发射,其中onOffsetsChanged()不会被调用。现在,我只想联系dev的,但不幸的是这也是三星的应用程序。

Googling for the topic didn't yield any significant results besides the description of this app, where the dev states: "Fixed scrolling on latest TouchWiz launcher where onOffsetsChanged() doesn't get called." Now I would just contact the dev, but unfortunately it is also a Samsung app.

有谁知道一个解决方法,以获得当前的偏移量,而不依赖于onOffsetsChanged?有没有人碰到这个问题,在自己的壁纸?有谁知道这是故意的,或者如果我可以假设,未来的Touchwiz版本将使用的方法了吗?

Does anyone know a workaround to get the current offsets without relying on onOffsetsChanged? Has anyone run into this problem in their own wallpaper? Does anyone know if this is intentional or if I can assume that future Touchwiz versions will make use of the method again?

推荐答案

一些开发商采用触摸事件,而不是系统onOffsetsChanged()使用的TouchWiz工作。我认为,目前只有更好的方法是使用混合动力系统的情况下,这将工作在这样的方式:

Some developers are using touch events instead of system onOffsetsChanged() to work with TouchWiz. I think, currently the only better way is using the hybrid event system, which will work in such way:

1)始终认为onOffsetsChanged()消息不正确发送(使布尔属性默认为false)。
2)这意味着你应该实现onTouch()方法来作出适当的模仿onOffsetsChanged的()。听onTouch()只有在布尔属性仍然是假的。
3):当onOffsetsChanged()被调用,检查xOffset参数。如果是没有0.0也不是0.5F,然后更改布尔属性为true,只听onOffsetsChanged()。

1) Always assume that onOffsetsChanged() message is not sent correctly (make boolean property defaulting to false).
2) This means that you should implement onTouch() method to make the proper imitation of onOffsetsChanged(). Listen to onTouch() only if the boolean property is still false.
3) When onOffsetsChanged() is called, check the xOffset param. If it's neither 0.0f nor 0.5f, then change the boolean property to true and listen only to onOffsetsChanged().

code将某物,如:

Code will be sth like:

public class myEngine extends WallpaperService.Engine {
    private boolean offsetChangedWorking = false;

    public void onOffsetsChanged (float xOffset, float yOffset, float xOffsetStep, float yOffsetStep, int xPixelOffset, int yPixelOffset) {
        if (offsetChangedWorking == false && xOffset != 0.0f && xOffset != 0.5f) {
            offsetChangedWorking = true;
        }

        if (offsetChangedWorking == true) {
            // Do sth here
        }
    }

    public void onTouchEvent(MotionEvent paramMotionEvent) {
        if (offsetChangedWorking == false) {
            // Do sth else here
        }
    }
}

这code是唯一一个。请注意,如果你用==比较花车是不正确的,但它也可能在这种情况下。

This code is only an illustration. Note, that comparing floats with == is not correct, but it might work in this case.

此外,它看起来像三星视差轻量级进程正在以同样的方式。如果您拥有TouchWiz和其他一些正常工作的启动程序(它发送onOffsetsChanged()一​​般)的设备,你可以自己尝试一下:

Also, it looks like Samsung Parallax LWPs are working the same way. If you have a device with TouchWiz and some other properly working launcher (which sends onOffsetsChanged() normally), you can try it by yourself:

1)将视差LWP上的TouchWiz第一(重要!),看看它不仅取决于的onTouchEvent()
2)改变发射到另外一个。请参阅LWP现在取决于onOffsetsChanged()
3)重新更改启动器的TouchWiz,看到刷卡不适合这个LWP工作了。

1) Set parallax LWP on TouchWiz first (important!) and see that it depends only on onTouchEvent()
2) Change the launcher to the other one. See that LWP now depends on onOffsetsChanged()
3) Change the launcher to TouchWiz again and see that swiping doesn't work for this LWP anymore.

所以我建议补充的是,在每一个onResume()事件再次改变布尔offsetChangedWorking为false。这应该prevent这样的错误与发射器的变化。

So what i recommend to add is on every onResume() event change the boolean offsetChangedWorking to false again. This should prevent such bugs with launcher changes.

这篇关于onOffsetsChanged不调用的Touchwiz的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆