예제 #1
0
        void OpenMesageInputWindow(string token, Model.Group group)
        {
            var dialog = new Android.App.AlertDialog.Builder(this);

            dialog.SetTitle($"Отправка сообщения в группу {group?.Name}:");
            View viewInflated = LayoutInflater.From(this).Inflate(Resource.Layout.MessageLayout, null);
            var  headerText   = viewInflated.FindViewById <EditText>(Resource.Id.header);
            var  contentText  = viewInflated.FindViewById <EditText>(Resource.Id.input);

            dialog.SetView(viewInflated);
            dialog.SetPositiveButton("Отправить", delegate { SendPost(token, group, headerText.Text, contentText.Text); });
            dialog.SetNegativeButton("Отмена", delegate { });
            dialog.Show();
        }
예제 #2
0
        async void SendPost(string token, Model.Group group, string theme, string content)
        {
            if (CheckConnection())
            {
                var dialog = new Android.App.AlertDialog.Builder(this);

                try
                {
                    await _manager.SendMessage(token, theme, content, group.Id);

                    string message = "Сообщение было отправленно";
                    dialog.SetMessage(message);
                    dialog.SetPositiveButton("Ок", delegate { });
                    dialog.Show();
                }
                catch (UnauthorizedAccessException)
                {
                    string message = "Ваши параметры авторизации устарели." +
                                     "\nВы будете возвращены на страницу авторизации, чтобы пройти процедуру авторизации заново";
                    dialog.SetMessage(message);
                    dialog.SetCancelable(false);
                    dialog.SetPositiveButton("Ок", delegate
                    {
                        LogOut();
                    });
                    dialog.Show();
                }
                catch (System.Exception ex)
                {
                    string message = ex.Message;
                    dialog.SetMessage(message);
                    dialog.SetPositiveButton("Ок", delegate { });
                    dialog.Show();
                }
            }
            ShowFeed();
        }