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();
        }
Exemple #2
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            SetContentView(Resource.Layout.UserCategory);
            Console.WriteLine("UserCategoryActivity");

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

            title.Visibility = ViewStates.Invisible;

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

            back.Visibility = ViewStates.Invisible;

            Display display = WindowManager.DefaultDisplay;
            int     width   = display.Width;

            newsList = FindViewById <ListView>(Resource.Id.UserNewsList);
            listView = FindViewById <ListView>(Resource.Id.UserCustomizingCategory);
            menuList = FindViewById <ListView> (Resource.Id.MenuMenu);

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

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

            var request = new RestRequest();

            request.RequestFinished += (object sender, RequestEndedArgs e) => {
                Console.WriteLine("KOR v newsActivity 1");
                var data = (CategoryModel)JsonConvert.DeserializeObject(e.Result, typeof(CategoryModel));
                model = data;
                // invoke it on the main thread
                this.news = new List <NewsModelItem> {
                    model.News[0],
                    model.News[1],
                    model.News[2],
                    model.News[3]
                };
                RunOnUiThread(delegate {
                    newsList.Adapter = new NewsScreenAdapter(this, news);
                    listView.Adapter = new CustomizingSelectionCategoryAdapter(this, model.Categories, true);
                    menuList.Adapter = new MainMenuListAdapter(this, model.Categories);
                });
            };
            request.Send(string.Format(RequestConfig.News(), 0, 0), "GET");


            newsList.ItemClick += (s, arg) => {
                var    newsDetail = new Intent(this, typeof(NewsDetailActivity));
                string url        = string.Format("{0}{1}", RequestConfig.Article, news[arg.Position].SmallId);
                Console.WriteLine(url);
                newsDetail.PutExtra("MyCategory", url);
                StartActivity(newsDetail);
            };



            listView.ItemClick += (sender, e) => {
                var intent = new Intent(this, typeof(NewsActivity));
                intent.PutExtra("Category", model.Categories[e.Position].Link);
                intent.PutExtra("SportName", model.Categories[e.Position].Name);
                intent.AddFlags(ActivityFlags.ClearTop);
                var parent = (NewsGroupActivity)Parent;
                parent.StartChildActivity("newsActivity", intent);
            };

            menuList.ItemClick += (sender, e) => {
                var news = new Intent(this, typeof(NewsActivity));
                news.PutExtra("Category", model.Categories[e.Position].Link);
                news.PutExtra("SportName", model.Categories[e.Position].Name);
                news.AddFlags(ActivityFlags.ClearTop);
                var parent = (NewsGroupActivity)Parent;
                parent.StartChildActivity("newsActivity", news);
            };

            _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);
             * };*/

            Globals.SetUserInfo(this);

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

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

            DefineGui();
        }
        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();
        }