private void PlayMessage(MessageDB message) { voiceFiles.Clear (); contentPackItems.Clear (); pollSteps.Clear (); MessageInfo messageInfo = this.MessageItems [message.MessageID]; ContentState dlState = new ContentState (message); contentPackItems = getLocalContentPackItems (dlState.ContentPackIDQ.ToList ()) .ToDictionary (s => s.ContentPackItemID, s => ContentPackItemDB.ConvertFromContentPackItemDB (s)); if (messageInfo.HasContentInfo) { RunOnUiThread (delegate { if (progress != null) progress.Dismiss (); this.PlayUnsentMessage (messageInfo.ContentInfo); }); } else { Dictionary<Guid, Dictionary<int, string>> localVoiceFiles = getLocalVoiceFiles (new List<Pair<Guid, List<int>>> () { new Pair<Guid, List<int>>(dlState.Message.MessageID, dlState.VoiceIDQ.ToList()) }); if (!localVoiceFiles.TryGetValue (dlState.Message.MessageID, out voiceFiles)) voiceFiles = new Dictionary<int, string> (); pollSteps = getLocalPollingStepsForMessage (dlState.Message.MessageGuid) .ToDictionary (s => s.StepNumber, s => PollingStepDB.ConvertFromPollingStepDB (s)); dlState.RemoveExistingItems (contentPackItems.Keys.ToList (), voiceFiles.Keys.ToList (), pollSteps.Keys.ToList ()); if (dlState.HasContentForDownload) { #if DEBUG System.Diagnostics.Debug.WriteLine ("dlState has content for download"); #endif if (dlState.HasContentPackItems) { #if DEBUG System.Diagnostics.Debug.WriteLine ("dlState has contentpackitems for download"); #endif LOLConnectClient service = new LOLConnectClient (LOLConstants.DefaultHttpBinding, LOLConstants.LOLConnectEndpoint); service.ContentPackGetItemCompleted += Service_ContentPackGetItemCompleted; service.ContentPackGetItemAsync (dlState.ContentPackIDQ.Peek (), ContentPackItem.ItemSize.Small, AndroidData.CurrentUser.AccountID, new Guid (AndroidData.ServiceAuthToken), dlState); } else if (dlState.HasVoiceRecordings) { #if DEBUG System.Diagnostics.Debug.WriteLine ("dlState has voicerecordings for download"); #endif LOLMessageClient service = new LOLMessageClient (LOLConstants.DefaultHttpBinding, LOLConstants.LOLMessageEndpoint); service.MessageGetStepDataCompleted += Service_MessageGetStepData; service.MessageGetStepDataAsync (dlState.Message.MessageID, dlState.VoiceIDQ.Peek (), new Guid (AndroidData.ServiceAuthToken), dlState); } else if (dlState.HasPollingSteps) { RunOnUiThread (delegate { #if DEBUG System.Diagnostics.Debug.WriteLine ("dlState has pollingsteps for download"); #endif LOLMessageClient service = new LOLMessageClient (LOLConstants.DefaultHttpBinding, LOLConstants.LOLMessageEndpoint); service.PollingStepGetCompleted += Service_PollingStepGetCompleted; service.PollingStepGetAsync (dlState.Message.MessageID, dlState.PollingIDQ.Peek (), AndroidData.CurrentUser.AccountID, new Guid (AndroidData.ServiceAuthToken), dlState); }); } } else RunOnUiThread (delegate { StartPlayMessage (message); }); } }