项目添加到集群管理器和放大器;调用集群()没有影响,直到AsyncTask的完成 [英] Adding items to cluster manager & call to cluster() have no effect until AsyncTask finishes

查看:173
本文介绍了项目添加到集群管理器和放大器;调用集群()没有影响,直到AsyncTask的完成的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的情况:

我使用的AsyncTask 来prepare数据的谷歌地图。因为这项工作需要一些时间,我想显示的对象,因为他们已经准备好(并在完成不是一次)。 所以我用 publishProgress &安培; onProgressUpdate 更新地图
。 我用的是谷歌地图Android的API工具库标记添加到地图中。我称之为 ClusterManager.cluster()后数据的变化,迫使重装的标记。

I use an AsyncTask to prepare data for a google map. Because this task takes some time, I'd like to display the objects as they are ready (and not all at once when finished). So I use publishProgress&onProgressUpdate to update the map.
I use the Google Maps Android API utility library to add the markers to the map. I call ClusterManager.cluster() after data changes to force reloading of the markers.

问题:

什么也没有发生。更新进度 onProgressUpdate()完美的作品,但在地图上显示的标记没有。我可以看到,所有的都应该在方法被调用做得到打来电话,我测试过,这些方法做工精细从的AsyncTask 不叫时。 的的AsyncTask的结束,所有的指标得到神奇地显示,即使没有进一步的方法被调用。
如果我使用(将其添加到集群管理器即代替)同样的方法直接添加标记,通过标准的API地图标记显示为他们应该。

Nothing happens. Updating a ProgressBar from onProgressUpdate() works flawlessly but displaying the markers on the map does not. I can see that all the methods that are supposed to get called do get called and I've tested that these methods work fine when called not from an AsyncTask. After the AsyncTask finishes, all the markers get magically displayed, even though no further method gets called.
If I use the same method to add markers directly to the map through standard API (i.e. instead of adding them to the cluster manager) the markers appear as they are supposed to.

所以,问题是 - 没有任何理由群集管理器等的重新聚集,直到AsyncTask的结束?编辑:更多precisely,而不是之后 doInBackground 结束,但在 onPostExecute 完成

So the question is - is there any reason for the cluster manager to wait with the re-clustering until the AsyncTask finishes? More precisely, not after doInBackground finishes but after onPostExecute finishes.

我无法理解和调试这个问题,花了整整一天,它已经。
在此先感谢!

I'm having trouble understanding and debugging this problem, spent a whole day with it already.
Thanks in advance!

推荐答案

原来,问题是在混合muplitple 的AsyncTask 的S - 一矿,一个在群集管理器。此修复程序 - 不是一个非常好一个 - 就是让库的变化(我没有找到一种方法,能够很好地扩展,因为私有字段的话),并在执行不同任务的聚类任务集群()方法:

Turns out the problem was in mixing muplitple AsyncTasks - one mine and one in the clustering manager. The fix - not a very nice one - was to make a change in the library (I didn't find a way to nicely extend it because of the private fields) and execute the task clustering task differently in cluster() method:

if (Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.HONEYCOMB) {
    mClusterTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR,
            mMap.getCameraPosition().zoom);
} else {
    mClusterTask.execute(mMap.getCameraPosition().zoom);
}

找到的意见-rather coincitentally-在 GitHub的

希望它可能挽救别人头疼。

Hope it might save someone else a headache.

这篇关于项目添加到集群管理器和放大器;调用集群()没有影响,直到AsyncTask的完成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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