public async Task DownloadImageAsync(MessageGroupItem item)
        {
            IsLoading = true;
            var saved = true;

            try
            {
                var imageBytes =
                    await
                    _messageManager.GetMessageContent(SelectedMessageGroup.MessageGroupId,
                                                      item.Message.SentMessageId,
                                                      Shell.Instance.ViewModel.CurrentTokens,
                                                      Shell.Instance.ViewModel.CurrentUser.Region,
                                                      Shell.Instance.ViewModel.CurrentUser.Language);

                await FileAccessCommands.SaveStreamToCameraRoll(imageBytes, item.Message.SentMessageId + ".png");
            }
            catch (Exception ex)
            {
                //Insights.Report(ex);
                saved = false;
            }

            var loader = new ResourceLoader();

            if (!saved)
            {
                await ResultChecker.SendMessageDialogAsync(loader.GetString("ErrorSaveImage/Text"), false);
            }
            else
            {
                await ResultChecker.SendMessageDialogAsync(loader.GetString("ImageSaved/Text"), true);
            }
            IsLoading = false;
        }
Ejemplo n.º 2
0
        private async void GetAvatar(MessageGroupItem message, UserAccountEntity userAccountEntity)
        {
            UserEntity user = await UserManager.GetUserAvatar(message.Message.senderOnlineId, userAccountEntity);

            message.AvatarUrl = user.AvatarUrl;
            OnPropertyChanged("MessageGroupCollection");
        }
        public async void SetMessages(string userName, UserAccountEntity userAccountEntity)
        {
            MessageGroupCollection = new ObservableCollection <MessageGroupItem>();
            var messageManager = new MessageManager();

            _messageGroupEntity = await messageManager.GetMessageGroup(userName, userAccountEntity);

            foreach (MessageGroupEntity.MessageGroup message in _messageGroupEntity.MessageGroups)
            {
                var newMessage = new MessageGroupItem {
                    MessageGroup = message
                };
                GetAvatar(newMessage, userAccountEntity);
                MessageGroupCollection.Add(newMessage);
            }
        }
        public async Task LoadMessageImage(MessageGroupItem item)
        {
            IsLoading = true;
            await Shell.Instance.ViewModel.UpdateTokens();

            var imageBytes =
                await
                _messageManager.GetMessageContent(SelectedMessageGroup.MessageGroupId,
                                                  item.Message.SentMessageId,
                                                  Shell.Instance.ViewModel.CurrentTokens,
                                                  Shell.Instance.ViewModel.CurrentUser.Region,
                                                  Shell.Instance.ViewModel.CurrentUser.Language);

            item.Image = await DecodeImage(imageBytes);

            IsLoading = false;
        }
 private void MessagesVmOnPropertyChanged(object sender, PropertyChangedEventArgs propertyChangedEventArgs)
 {
     switch (propertyChangedEventArgs.PropertyName)
     {
     case "IsNewMessage":
         if (Locator.ViewModels.MessagesVm.IsNewMessage)
         {
             _lastSelectedItem        = null;
             MessageList.SelectedItem = null;
             Locator.ViewModels.MessagesVm.MessageCollection.Clear();
             if (AdaptiveStates.CurrentState == NarrowState)
             {
                 // Use "drill in" transition for navigating from master list to detail view
                 App.RootFrame.Navigate(typeof(MessageDetailPage), null, new DrillInNavigationTransitionInfo());
             }
         }
         break;
     }
 }
        private async void MessageGroup_OnClick(object sender, ItemClickEventArgs e)
        {
            var clickedItem = (MessageGroupItem)e.ClickedItem;

            _lastSelectedItem = clickedItem;
            await Locator.ViewModels.MessagesVm.GetMessages(clickedItem.MessageGroup);

            Locator.ViewModels.MessagesVm.IsNewMessage = false;

            if (AdaptiveStates.CurrentState == NarrowState)
            {
                // Use "drill in" transition for navigating from master list to detail view
                App.RootFrame.Navigate(typeof(MessageDetailPage), null, new DrillInNavigationTransitionInfo());
            }
            else
            {
                // Play a refresh animation when the user switches detail items.
                //EnableContentTransitions();
            }
        }