Esempio n. 1
0
        /*
         * (non-Javadoc)
         * @see android.support.v4.app.LoaderManager.LoaderCallbacks#onLoadFinished(android
         * .support.v4.content.Loader, java.lang.Object)
         */
        public void OnLoadFinished(Android.Content.Loader loader, Java.Lang.Object raw)
        {
            var data = Utils.GetDictionary(raw);

            mRowsAdapter = new ArrayObjectAdapter(new ListRowPresenter());
            var cardPresenter = new CardPresenter();

            int i = 0;

            foreach (var entry in  data)
            {
                var           listRowAdapter = new ArrayObjectAdapter(cardPresenter);
                IList <Movie> list           = entry.Value;
                foreach (Movie current in list)
                {
                    listRowAdapter.Add(current);
                }
                var header = new HeaderItem(i, entry.Key, null);
                i++;
                mRowsAdapter.Add(new ListRow(header, listRowAdapter));
            }

            var gridHeader     = new HeaderItem(i, Resources.GetString(Resource.String.preferences), null);
            var gridPresenter  = new GridItemPresenter(this);
            var gridRowAdapter = new ArrayObjectAdapter(gridPresenter);

            gridRowAdapter.Add(Resources.GetString(Resource.String.grid_view));
            gridRowAdapter.Add(Resources.GetString(Resource.String.send_feeback));
            gridRowAdapter.Add(Resources.GetString(Resource.String.personal_settings));
            mRowsAdapter.Add(new ListRow(gridHeader, gridRowAdapter));
            this.Adapter = mRowsAdapter;

            UpdateRecommendations();
        }
Esempio n. 2
0
        void buildAdapter()
        {
            var adapter = new ArrayObjectAdapter(new ListRowPresenter());

            var videos = Video.GetVideos(this.Activity);

            var categories = from m in videos
                             select m.Categories;

            foreach (var c in categories.Distinct())
            {
                var categoryVideos = videos.Where(m => m.Categories == c);

                var categoryAdapter = new ArrayObjectAdapter(new VideoPresenter());

                foreach (var v in categoryVideos)
                {
                    categoryAdapter.Add(v);
                }

                var header = new HeaderItem(c.ToLowerInvariant());
                adapter.Add(new ListRow(header, categoryAdapter));
            }

            Adapter = adapter;
        }
        private void SetupFragment()
        {
            var gridPresenter = new VerticalGridPresenter();

            gridPresenter.NumberOfColumns = NUM_COLUMNS;
            this.GridPresenter            = gridPresenter;
            mAdapter = new ArrayObjectAdapter(new CardPresenter());

            long seed   = System.Diagnostics.Stopwatch.GetTimestamp();           //a pseudorandom seed based on system time
            var  movies = VideoProvider.MovieList;

            foreach (var entry in movies)
            {
                //TODO may need to write Util.Shuffle method, will go in Utils.cs
                var list = (List <Object>)entry.Value;
                Collections.Shuffle(list, new Java.Util.Random(seed));
                foreach (var movie in list)
                {
                    mAdapter.Add((Movie)movie);
                }
            }

            this.Adapter = mAdapter;
            SetOnItemSelectedListener(this);
            OnItemClickedListener = this;

            SetOnItemSelectedListener(this);
        }
		public override void OnCreate (Bundle savedInstanceState)
		{
			base.OnCreate (savedInstanceState);
			mDelayedLoad = new SearchRunnable (this);
			mRowsAdapter = new ArrayObjectAdapter (new ListRowPresenter ());
			SetSearchResultProvider (this);
			SetOnItemClickedListener (this);
		}
Esempio n. 5
0
 public override void OnCreate(Bundle savedInstanceState)
 {
     base.OnCreate(savedInstanceState);
     mDelayedLoad = new SearchRunnable(this);
     mRowsAdapter = new ArrayObjectAdapter(new ListRowPresenter());
     SetSearchResultProvider(this);
     SetOnItemViewClickedListener(this);
 }
		protected void LoadRows (String query)
		{
			Dictionary<string, IList<Movie>> movies = VideoProvider.MovieList;
			ArrayObjectAdapter listRowAdapter = new ArrayObjectAdapter (new CardPresenter ());
			foreach (var entry in movies) {
				foreach (Movie movie in entry.Value) {
					if (movie.Title.ToLower (unitedStates)
						.Contains (query.ToLower (unitedStates))
					    || movie.Description.ToLower (unitedStates)
						.Contains (query.ToLower (unitedStates))) {
						listRowAdapter.Add (movie);
					}
				}
			}
			HeaderItem header = new HeaderItem (0, Resources.GetString (Resource.String.search_results), (string)null);
			mRowsAdapter.Add (new ListRow (header, listRowAdapter));
		}
            protected override void OnPostExecute(Java.Lang.Object raw)
            {
                DetailsOverviewRow          detailrow    = (DetailsOverviewRow)raw;
                ClassPresenterSelector      ps           = new ClassPresenterSelector();
                DetailsOverviewRowPresenter dorPresenter =
                    new DetailsOverviewRowPresenter(new DetailsDescriptionPresenter());

                // set detail background and style
                dorPresenter.BackgroundColor         = owner.Resources.GetColor(Resource.Color.detail_background);
                dorPresenter.StyleLarge              = true;
                dorPresenter.OnActionClickedListener = (this);
                ps.AddClassPresenter(Utils.ToJavaClass(typeof(DetailsOverviewRow)), dorPresenter);
                ps.AddClassPresenter(Utils.ToJavaClass(typeof(ListRow)), new ListRowPresenter());
                ArrayObjectAdapter adapter = new ArrayObjectAdapter(ps);

                adapter.Add((Java.Lang.Object)detailrow);

                string[] subcategories =
                {
                    owner.GetString(Resource.String.related_movies)
                };
                var movies = VideoProvider.MovieList;

                ArrayObjectAdapter listRowAdapter = new ArrayObjectAdapter(new CardPresenter());

                foreach (var entry in movies)
                {
                    if (owner.selectedMovie.Category.IndexOf(entry.Key) >= 0)
                    {
                        foreach (var movie in entry.Value)
                        {
                            listRowAdapter.Add(movie);
                        }
                    }
                }
                HeaderItem header = new HeaderItem(0, subcategories [0]);

                adapter.Add(new ListRow(header, listRowAdapter));
                owner.Adapter = adapter;
            }
Esempio n. 8
0
        protected void LoadRows(String query)
        {
            Dictionary <string, IList <Movie> > movies = VideoProvider.MovieList;
            ArrayObjectAdapter listRowAdapter          = new ArrayObjectAdapter(new CardPresenter());

            foreach (var entry in movies)
            {
                foreach (Movie movie in entry.Value)
                {
                    if (movie.Title.ToLower(unitedStates)
                        .Contains(query.ToLower(unitedStates)) ||
                        movie.Description.ToLower(unitedStates)
                        .Contains(query.ToLower(unitedStates)))
                    {
                        listRowAdapter.Add(movie);
                    }
                }
            }
            HeaderItem header = new HeaderItem(0, Resources.GetString(Resource.String.search_results));

            mRowsAdapter.Add(new ListRow(header, listRowAdapter));
        }
Esempio n. 9
0
        void buildAdapter()
        {
            var adapter = new ArrayObjectAdapter (new ListRowPresenter ());

            var videos = Video.GetVideos (this.Activity);

            var categories = from m in videos
                select m.Categories;

            foreach (var c in categories.Distinct ()) {
                var categoryVideos = videos.Where (m => m.Categories == c);

                var categoryAdapter = new ArrayObjectAdapter (new VideoPresenter ());

                foreach (var v in categoryVideos)
                    categoryAdapter.Add (v);

                var header = new HeaderItem (c.ToLowerInvariant ());
                adapter.Add (new ListRow (header, categoryAdapter));
            }

            Adapter = adapter;
        }
        private void SetupFragment()
        {
            var gridPresenter = new VerticalGridPresenter();
            gridPresenter.NumberOfColumns = NUM_COLUMNS;
            this.GridPresenter = gridPresenter;
            mAdapter = new ArrayObjectAdapter (new CardPresenter ());

            long seed = System.Diagnostics.Stopwatch.GetTimestamp(); //a pseudorandom seed based on system time
            var movies = VideoProvider.MovieList;

            foreach (var entry in movies) {
                //TODO may need to write Util.Shuffle method, will go in Utils.cs
                var list = (List<Object>)entry.Value;
                Collections.Shuffle (list, new Java.Util.Random (seed));
                foreach (var movie in list)
                    mAdapter.Add ((Movie) movie);
            }

            this.Adapter = mAdapter;
            OnItemViewClickedListener = this;

            SetOnItemViewSelectedListener (this);
        }
Esempio n. 11
0
		/*
	     * (non-Javadoc)
	     * @see android.support.v4.app.LoaderManager.LoaderCallbacks#onLoadFinished(android
	     * .support.v4.content.Loader, java.lang.Object)
	     */
		public void OnLoadFinished (Android.Content.Loader loader, Java.Lang.Object raw)
		{
			var data = Utils.GetDictionary (raw);
			mRowsAdapter = new ArrayObjectAdapter (new ListRowPresenter ());
			var cardPresenter = new CardPresenter ();

			int i = 0;
			foreach (var entry in  data) {
				var listRowAdapter = new ArrayObjectAdapter (cardPresenter);
				IList<Movie> list = entry.Value;
				foreach (Movie current in list) {
					listRowAdapter.Add (current);
				}
				var header = new HeaderItem (i, entry.Key, null);
				i++;
				mRowsAdapter.Add (new ListRow (header, listRowAdapter));
			}

			var gridHeader = new HeaderItem (i, Resources.GetString (Resource.String.preferences), null);
			var gridPresenter = new GridItemPresenter (this);
			var gridRowAdapter = new ArrayObjectAdapter (gridPresenter);

			gridRowAdapter.Add (Resources.GetString (Resource.String.grid_view));
			gridRowAdapter.Add (Resources.GetString (Resource.String.send_feeback));
			gridRowAdapter.Add (Resources.GetString (Resource.String.personal_settings));
			mRowsAdapter.Add (new ListRow (gridHeader, gridRowAdapter));
			this.Adapter = mRowsAdapter;

			UpdateRecommendations ();
		}
        private void BuildDetails()
        {
            var selector = new ClassPresenterSelector();
            var rowPresenter = new AgqrPlaybackControlsRowPresenter(new AgqrDetailsDescriptionPresenter());
            rowPresenter.SetSecondaryActionsHidden(true);
            rowPresenter.BackgroundColor = Resources.GetColor(Resource.Color.AccentDark);
            rowPresenter.ProgressColor = Resources.GetColor(Resource.Color.Accent);
            selector.AddClassPresenter<PlaybackControlsRow>(rowPresenter);
            selector.AddClassPresenter<ListRow>(new ListRowPresenter());
            this._rowsAdapter = new ArrayObjectAdapter(selector);

            var nowPlaying = ApplicationMain.ServiceLocator.GetInstance<NowPlaying>();
            var playbackPlayer = ((PlaybackPlayerFragmentBase)this.ParentFragment);

            var playbackControlsRow = new PlaybackControlsRow(new PlaybackControlsRowViewModel(playbackPlayer, nowPlaying));
            var controlPresenterSelector = new ControlButtonPresenterSelector();
            var primaryActions = new ArrayObjectAdapter(controlPresenterSelector);
            var primaryActionsDefinition = this.GetPrimaryActionDefinition();
            var secondaryActions = new ArrayObjectAdapter(controlPresenterSelector);
            var secondaryActionsDefinition = this.GetSecondaryActionDefinition();
            playbackControlsRow.PrimaryActionsAdapter = primaryActions;
            playbackControlsRow.SecondaryActionsAdapter = secondaryActions;
            primaryActions.AddAll(0, primaryActionsDefinition.Keys);
            secondaryActions.AddAll(0, secondaryActionsDefinition.Keys);
            this._rowsAdapter.Add(playbackControlsRow);

            Observable.FromEventPattern<ActionClickedEventArgs>(h => rowPresenter.ActionClicked += h, h => rowPresenter.ActionClicked -= h)
                .Select(x => x.EventArgs.Action)
                .Select(x => new { Action = primaryActionsDefinition.ContainsKey(x) ? primaryActionsDefinition[x] : secondaryActionsDefinition[x], Target = x })
                .Subscribe(x => x.Action(x.Target))
                .AddTo(this.LifetimeDisposables);

            playbackPlayer.IsPlaying
                .ObserveOnUIDispatcher()
                .Subscribe(x =>
                {
                    var playPauseAction = primaryActionsDefinition.Select(y => y.Key).OfType<PlaybackControlsRow.PlayPauseAction>().Single();
                    playPauseAction.Index = x
                        ? PlaybackControlsRow.PlayPauseAction.Pause
                        : PlaybackControlsRow.PlayPauseAction.Play;
                    this._rowsAdapter.NotifyArrayItemRangeChanged(0, 1);
                })
                .AddTo(this.LifetimeDisposables);

            playbackPlayer.ElapsedSeconds
                .ObserveOnUIDispatcher()
                .Subscribe(x =>
                {
                    playbackControlsRow.CurrentTime = x*1000;
                    //this._rowsAdapter.NotifyArrayItemRangeChanged(0, 1); // こっちは通知してはダメ(ガコガコする
                })
                .AddTo(this.LifetimeDisposables);

            nowPlaying.Program
                .Where(x => x != null)
                .ObserveOnUIDispatcher()
                .Subscribe(x =>
                {
                    playbackControlsRow.TotalTime = (int) (x.End - x.Start).TotalMilliseconds;
                    this._rowsAdapter.NotifyArrayItemRangeChanged(0, 1);
                })
                .AddTo(this.LifetimeDisposables);

            this.Adapter = this._rowsAdapter;
        }