Note that there are some explanatory texts on larger screens.

plurals
  1. POTriggering event in Activity using MvvmCross
    primarykey
    data
    text
    <p>I have an MvxFragmentActivity which loads a google map and places markers on the map. The code to create the map and markers is very Droid specific so it is in the Activity. The markers are created based on objects in the ViewModel which each contain lat/long coordinates. This worked fine as long as I loaded the objects in my Init method. I have since moved the load objects method to a service and call it on a different thread. This way the UI is responsive. However, how do I call the method in the Activity when the load is completed?</p> <p>Here is my current code in the Activity (this code shouldn't change, just how it is called):</p> <pre><code> private void InitMapFragment() { foreach (var item in viewModel.Items) { var icon = BitmapDescriptorFactory.FromResource(Resource.Drawable.place_img); var markerOptions = new MarkerOptions() .SetPosition(new LatLng(item.Latitude, item.Longitude)) .InvokeIcon(icon) .SetSnippet(item.DistanceText) .SetTitle(item.Name); var marker = _map.AddMarker(markerOptions); _markerIds.Add(marker.Id, item.Id); } } </code></pre> <p>Code in my viewModel:</p> <pre><code> private void BeginLoadItems() { _loadItemsService.Load(); } // This is triggered by a message private void OnLoadItemsComplete(LoadCompleteMessage message) { Items = message.Items; } </code></pre> <p>Code in my Service:</p> <pre><code> public void Load() { ThreadPool.QueueUserWorkItem(state =&gt; { var results = _repository.Retrieve(); _messenger.Publish(new LoadCompleteMessage(this, results)); }); } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload