예제 #1
0
        public override async void OnViewCreated(View view, Bundle savedInstanceState)
        {
            await InitializeSpinner(_spinner);

            _spinner.ItemSelected += (sender, args) =>
                                     _preferencesManager.PutValue("selected_culture", (String)_spinner.SelectedItem);
        }
예제 #2
0
        public async void OnHandled(Object sender, HandlerResultEventArgs args)
        {
            if (args.HandlerResult.IsStatusUpdated())
            {
                _chatFrag.SetStatus(args.Status);
            }

            if (args.HandlerResult.IsMessageAppeared())
            {
                var selected = _shared.GetValue <String>("selected_culture");
                var lang     = LanguageProvider.GetInstance.GetLanguageByName(selected);

                if (args.IsInput)
                {
                    var result = await _translator.Translate(args.Message, lang.Key);

                    args.Message = result.Translated;
                }

                _chatFrag.ConversationArrayAdapter.Add(new BluetoothMessage
                {
                    Message = args.Message, Sender = _shared.GetValue <String>("connected_device")
                });
            }

            if (args.HandlerResult.IsAlertRaised())
            {
                Toast.MakeText(_chatFrag.Activity, args.Alert,
                               ToastLength.Short).Show();
            }

            if (args.HandlerResult.NewDeviceConnected())
            {
                _shared.PutValue("connected_device", args.ConnectedDeviceName);
            }

            if (args.HandlerResult.ClearChat())
            {
                _chatFrag.ConversationArrayAdapter.Clear();
            }
        }