コード例 #1
0
        public async Task Update()
        {
            var wc = new WebClient();

            string json;

            try
            {
                var downloadTask = wc.DownloadStringTaskAsync("https://raw.githubusercontent.com/selmaohneh/DdfGuide/master/dtos.json");
                var timeoutTask  = Task.Delay(TimeSpan.FromSeconds(7));

                var completedTask = await Task.WhenAny(downloadTask, timeoutTask);

                if (completedTask == timeoutTask)
                {
                    _notifier.Notify("Aktualisierung abgebrochen. Schlechte Internetverbindung");
                    return;
                }

                json = downloadTask.Result;
            }
            catch (WebException)
            {
                _notifier.Notify("Aktualisierung fehlgeschlagen. Keine Intertverbindung.");
                return;
            }

            var dtos = JsonConvert.DeserializeObject <IEnumerable <AudioDramaDto> >(json);

            _dtoCache.Save(dtos);

            _notifier.Notify("Aktualisierung erfolgreich.");
        }
コード例 #2
0
 public void Execute(TranslateSubtitlesFileToNewFile command)
 {
     try
     {
         decoratee.Execute(command);
     }
     catch (AuthenticationException e)
     {
         notifier.Notify($"The authentication key \"{e.Key}\" is not valid. Please check your key in your DeepL Pro dashboard.");
     }
     catch (InternalErrorException)
     {
         notifier.Notify("An internal error occured. Please try again later.");
     }
     catch (FileNotFoundException e)
     {
         notifier.Notify($"The file \"{e.FileName}\" does not exist. Please give a correct srt file to translate.");
     }
     catch (SubtitlesParsingException e)
     {
         notifier.Notify($"Unable to parse the file \"{command.ToTranslate}\" because of a problem in the subtitle number {e.IncorrectSubtitleId}.");
     }
     catch (InternetAccessException)
     {
         notifier.Notify("Unable to reach the DeepL API. Please check your internet access.");
     }
 }
コード例 #3
0
 private EventHandler SaveClipboardText()
 {
     return((sender, args) =>
     {
         _clipboardService.SetClipboardText(_jsonForSavingToClipboard);
         _userNotifier.Notify("Daten erfolgreich in Zwischenablage kopiert.");
         _yesNoDialog.YesClicked -= SaveClipboardText();
     });
 }
コード例 #4
0
        private void SetupListView()
        {
            _listView = _view.FindViewById <ListView>(Resource.Id.listViewAudioDramas);

            _listViewAdapter = new AudioDramaListAdapter(Activity, _imageViewFiller, _releaseDateService);

            _listView.ItemClick += (sender, args) =>
            {
                var audioDrama = _listViewAdapter[args.Position];
                AudioDramaClicked?.Invoke(this, audioDrama.AudioDramaDto.Id);
            };

            var swipeActionAdapter = new SwipeActionAdapter(_listViewAdapter);

            swipeActionAdapter.SetListView(_listView);

            _listView.Adapter = swipeActionAdapter;

            swipeActionAdapter
            .AddBackground(SwipeDirection.DirectionFarLeft, Resource.Layout.swipebackgroundleft)
            .AddBackground(SwipeDirection.DirectionFarRight, Resource.Layout.swipebackgroundright)
            .AddBackground(SwipeDirection.DirectionNormalLeft, Resource.Layout.swipebackgroundleft)
            .AddBackground(SwipeDirection.DirectionNormalRight, Resource.Layout.swipebackgroundright);

            _swipeActionListener = new SwipeActionListener();

            _swipeActionListener.LeftSwiped += (sender, i) =>
            {
                try
                {
                    var audioDrama = _listViewAdapter[i];
                    HeardClicked?.Invoke(this, audioDrama.AudioDramaDto.Id);
                }
                catch (ArgumentOutOfRangeException)
                {
                    _userNotifier.Notify("Fehler beim Markieren als gehört. Bitte erneut versuchen.");
                }
            };

            _swipeActionListener.RightSwiped += (sender, i) =>
            {
                try
                {
                    var audioDrama = _listViewAdapter[i];
                    IsFavoriteClicked?.Invoke(this, audioDrama.AudioDramaDto.Id);
                }
                catch (ArgumentOutOfRangeException)
                {
                    _userNotifier.Notify("Fehler beim Markieren als Favorit. Bitte erneut versuchen.");
                }
            };


            swipeActionAdapter.SetSwipeActionListener(_swipeActionListener);
        }
コード例 #5
0
        public async Task Start()
        {
            var builder = new AudioDramaBuilder();

            var saver = new OnUserDataChangedInCacheSaver(_userDataCache);

            var source = new AudioDramaSource(
                _dtoCache,
                _userDataCache,
                builder,
                saver,
                _userNotifier);

            var audioDramaPresenter = new AudioDramaPresenter(_audioDramaView, _uriInvoker);

            var filterFactory = new AudioDramaFilterFactory();
            var sorterFactory = new AudioDramaSorterFactory();
            var searcher      = new AudioDramaSearcher();

            var explorer = new AudioDramaExplorer(source, searcher, filterFactory, sorterFactory);
            var picker   = new RandomAudioDramaPicker();

            var importExport = new UserDataImportExport(_userDataCache, _clipboardService, _yesNoDialog, _userNotifier,
                                                        _okDialog);

            var audioDramaListPresenter = new AudioDramaListPresenter(
                _audioDramaListView,
                explorer,
                _uriInvoker,
                importExport,
                source
                );

            var navigator = new Navigator(
                _rootView,
                audioDramaPresenter,
                audioDramaListPresenter,
                explorer,
                picker,
                source,
                _shutdown,
                _updatingView);

            navigator.ShowUpdateView();

            try
            {
                await source.Update();
            }
            catch (Exception)
            {
                // needed due to using async void. Otherwise
                // all exception will bubble up until here and crash the app.
                _userNotifier.Notify("Aktualisierung aus unbekannten Grund fehlgeschlagen.");
            }

            navigator.ShowStartView();
        }
 public void Handle(SubtitlesFileSuccessfullyTranslated e)
 {
     notifier.Notify($"Subtitles successfully translated to \"{e.OutputFile}\".");
 }
コード例 #7
0
        }                                             //<- 'true' here indicates that all these events should be invoked only after the transaction is committed

        public void Handle(OrderPaidEvent domainEvent)
        {
            System.Console.WriteLine("[Event] - NotificationsHandler.Handle(domainEvent)");
            _notifier.Notify("Yay! Your payment has been processed.");
        }