Ejemplo n.º 1
0
        public override void Setup()
        {
            base.Setup();

            List <VideoComponent> videos = new List <VideoComponent>();
            var folderEnumerator         = Substitute.For <IFolderEnumerator>();

            folderEnumerator.Enumerate().Returns(videos);

            this._model = new VideoComponentsViewModel(folderEnumerator);
            Assert.That("There are no videos to view", Is.EqualTo(this._model.Title));
        }
Ejemplo n.º 2
0
        public bool Previous()
        {
            VideoComponentsViewModel vm = this.ViewModel as VideoComponentsViewModel;

            if (vm == null)
            {
                return(false);
            }

            string title = this.GetString(Resource.String.module_videos);

            this.FragmentLoadStateListener.TitleChanged(title);
            return(vm.NavigateUp());
        }
Ejemplo n.º 3
0
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle inState)
        {
            base.OnCreateView(inflater, container, inState);
            View view = this.BindingInflate(Resource.Layout.fragment_video_components, null);

            this._listView              = view.FindViewById <MvxListView>(Resource.Id.video_list);
            this._videoView             = view.FindViewById <VideoView>(Resource.Id.video_view);
            this._videoView.Completion += WatchingVideoComplete;

            MediaController controller = new MediaController(this.Activity);

            this._videoView.SetMediaController(controller);

            this._viewModel = new VideoComponentsViewModel(new AndroidFolderEnumerator());

            this._bindableVideoPlayer = new BindableVideoPlayer(this._videoView);

            var set = this.CreateBindingSet <VideoComponentFragment, VideoComponentsViewModel>();

            set.Bind(this._bindableVideoPlayer).For(obj => obj.VideoPath).To(x => x.CurrentVideoPath);
            set.Bind(this._bindableVideoPlayer).For(obj => obj.IsPlaying).To(x => x.Playing);
            set.Bind(this._bindableVideoPlayer).For(obj => obj.ScreenTitle).To(x => x.ScreenTitle);
            set.Apply();

            this.ViewModel = this._viewModel;

            var adapter = new VideoComponentAdapter(this.Activity, (IMvxAndroidBindingContext)this.BindingContext);

            this._listView.Adapter = adapter;

            if (inState != null)
            {
                string json      = inState.GetString(CurrentVideosBundleKey);
                string stackJson = inState.GetString(HistoryStackBundleKey);

                var settings = new JsonSerializerSettings
                {
                    TypeNameHandling = TypeNameHandling.All
                };

                ObservableCollection <VideoComponent> savedList = JsonConvert.DeserializeObject <ObservableCollection <VideoComponent> >(json, settings);
                var previousStack = JsonConvert.DeserializeObject <ObservableCollection <VideoComponent>[]>(stackJson, settings);

                this.RestoreHistory(previousStack);
                this._viewModel.VideoComponents = savedList;
                string title = inState.GetString(CurrentTitleBundleKey);
                this._viewModel.Title = title;

                if (inState.ContainsKey(CurrentScreenTitleBundleKey))
                {
                    this._viewModel.ScreenTitle = inState.GetString(CurrentScreenTitleBundleKey);
                }

                if (inState.ContainsKey(VideoPlayStateBundleKey))
                {
                    this.RestoreVideState(inState);
                }

                string category = Activity.GetString(Resource.String.module_videos);
                string video    = _bindableVideoPlayer.ScreenTitle;
                string watching = Activity.GetString(Resource.String.started_watching);
                StartedWatchingVideo(category, video, watching);
            }

            return(view);
        }