Пример #1
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            SetContentView(Resource.Layout.Video);
            Console.WriteLine("VideoActivity");

            TextView title = FindViewById <TextView> (Resource.Id.ActionBarTitle);

            title.Visibility = ViewStates.Invisible;

            Button back = FindViewById <Button> (Resource.Id.ActionBarBack);

            back.Visibility = ViewStates.Invisible;

            listView = FindViewById <ListView> (Resource.Id.ListVideo);
            menuList = FindViewById <ListView> (Resource.Id.MenuMenu);

            this.returnMenu            = FindViewById <RelativeLayout> (Resource.Id.returnMenu);
            this.returnMenu.Visibility = ViewStates.Invisible;

            this.returnMenu.Click += (s, arg) => {
                RestoreMainViewObject();
            };

            //----------------------------------------------------------------------------------------------
            getData(0, 0, true, true);
            this.page     = 1;
            this.category = 0;
            //----------------------------------------------------------------------------------------------

            listView.ItemClick += (s, arg) => {
                if (!_menuLeftOut)
                {
                    var videoDetail = new Intent(this, typeof(VideoDetailActivity));
                    videoDetail.PutExtra("MyData", string.Format(RequestConfig.Video, model.News[arg.Position].Id));
                    videoDetail.PutExtra("MyTitle", model.News[arg.Position].Category);
                    StartActivity(videoDetail);
                }
                else
                {
                    RestoreMainViewObject();
                }
            };

            menuList.ItemClick += (s, arg) => {
                getData(categories[arg.Position].Link, 0, true, true);
                this.category = categories[arg.Position].Link;
                this.page     = 1;
            };

            listView.Scroll += (object sender, AbsListView.ScrollEventArgs e) => {
                Console.WriteLine("{0}....", listView.FirstVisiblePosition);
                if (loader)
                {
                    return;
                }
                if (listView.FirstVisiblePosition == this.pagingPosition)
                {
                    //load new data here
                    getPagedData(this.category, this.page);
                    this.page++;
                    this.pagingPosition += 25;
                }
            };

            _context = ApplicationContext;

            /*TextView menuName = FindViewById<TextView> (Resource.Id.MenuName);
             * menuName.Text = string.Format("{0} {1}",Globals.firstName ,Globals.lastName);
             *
             * ImageView menuImage = FindViewById<ImageView> (Resource.Id.menuImage);
             *
             * Button settings = FindViewById<Button> (Resource.Id.Settings);
             * settings.Click += delegate {
             *      var accSettings = new Intent (this, typeof(AccountSettingsActivity));
             *      StartActivity (accSettings);
             * };
             *
             *
             * if (!Globals.IsLoggedIn ()) {
             *      addContent.Visibility = ViewStates.Visible;
             *
             * } else {
             *      addContent.Visibility = ViewStates.Invisible;
             * }*/
            Globals.SetUserInfo(this);

            Button addContent = FindViewById <Button> (Resource.Id.AddContent);

            addContent.Click += delegate {
                var customizingSelection = new Intent(this, typeof(CustomizingSelectionActivity));
                StartActivity(customizingSelection);
            };

            DefineGui();
        }
Пример #2
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            SetContentView(Resource.Layout.NewsScreen);
            Console.WriteLine("NewsActivity");

            TextView title = FindViewById <TextView> (Resource.Id.ActionBarTitle);

            title.Visibility = ViewStates.Invisible;
            title.Text       = Intent.GetStringExtra("SportName") ?? "SportNet";


            ImageView logo = FindViewById <ImageView> (Resource.Id.ActionBarLogo);

            logo.Visibility = ViewStates.Visible;

            Button back = FindViewById <Button> (Resource.Id.ActionBarBack);

            back.Click += (sender, args) => {
                var parent = (NewsGroupActivity)Parent;
                parent.OnBackPressed();
                //Finish();
            };

            newsList = FindViewById <ListView>(Resource.Id.NewsList);
            menuList = FindViewById <ListView> (Resource.Id.MenuMenu);

            ImageButton menu = FindViewById <ImageButton> (Resource.Id.ActionBarMenu);

            if (Globals.IsLoggedIn())
            {
                menu.Visibility  = ViewStates.Invisible;
                back.Visibility  = ViewStates.Visible;
                logo.Visibility  = ViewStates.Invisible;
                title.Visibility = ViewStates.Visible;
            }
            else
            {
                menu.Visibility  = ViewStates.Visible;
                back.Visibility  = ViewStates.Invisible;
                logo.Visibility  = ViewStates.Visible;
                title.Visibility = ViewStates.Invisible;
            }

            this.returnMenu            = FindViewById <RelativeLayout> (Resource.Id.returnMenu);
            this.returnMenu.Visibility = ViewStates.Invisible;

            this.returnMenu.Click += (s, arg) => {
                RestoreMainViewObject();
            };


            //----------------------------------------------------------------------------------------------
            this.category = Intent.GetIntExtra("Category", 0);
            getData(this.category, 0, true, true);
            this.page = 1;
            //----------------------------------------------------------------------------------------------

            newsList.ItemClick += (s, arg) => {
                if (!_menuLeftOut)
                {
                    var    newsDetail = new Intent(this, typeof(NewsDetailActivity));
                    string url        = string.Format(RequestConfig.Article, model.News[arg.Position + 3].SmallId);
                    newsDetail.PutExtra("MyCategory", model.News[arg.Position + 3].Category);
                    newsDetail.PutExtra("MySource", url);
                    StartActivity(newsDetail);
                }
                else
                {
                    RestoreMainViewObject();
                }
            };

            menuList.ItemClick += (s, arg) => {
                getData(categories[arg.Position].Link, 0, true, true);
                this.category = categories[arg.Position].Link;
                this.page     = 1;
            };

            newsList.Scroll += (object sender, AbsListView.ScrollEventArgs e) => {
                Console.WriteLine("{0}....", newsList.FirstVisiblePosition);
                if (loader)
                {
                    return;
                }
                if (newsList.FirstVisiblePosition == this.pagingPosition)
                {
                    //load new data here
                    getPagedData(this.category, this.page);
                    this.page++;
                    this.pagingPosition += 25;
                }
            };

            _context = ApplicationContext;

            Globals.SetUserInfo(this);

            /*TextView menuName = FindViewById<TextView> (Resource.Id.MenuName);
             * menuName.Text = string.Format("{0} {1}",Globals.firstName ,Globals.lastName);
             *
             * ImageView menuImage = FindViewById<ImageView> (Resource.Id.menuImage);
             *
             * Button settings = FindViewById<Button> (Resource.Id.Settings);
             * settings.Click += delegate {
             *      var accSettings = new Intent (this, typeof(AccountSettingsActivity));
             *      StartActivity (accSettings);
             * };
             *
             *
             * if (!Globals.IsLoggedIn ()) {
             *      addContent.Visibility = ViewStates.Visible;
             *
             * } else {
             *      addContent.Visibility = ViewStates.Invisible;
             *
             * }*/

            Button addContent = FindViewById <Button> (Resource.Id.AddContent);

            addContent.Click += delegate {
                var customizingSelection = new Intent(this, typeof(CustomizingSelectionActivity));
                StartActivity(customizingSelection);
            };

            DefineGui();
        }