Exemplo n.º 1
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad ();

            this.ForgotPassword.TouchUpInside += (object sender, EventArgs e) => {
                var board = UIStoryboard.FromName ("MainStoryboard", null);
                var password = (ForgotPasswordController)board.InstantiateViewController ("forgotpassword");
                this.NavigationController.PushViewController(password, true);
            };

            this.Login.TouchUpInside += (object sender, EventArgs e) => {
                //((UIWindow)UIApplication.SharedApplication.Delegate.Window).RootViewController =
                //	new MainTabController();
                var request = new RestRequest();
                var model = new LoginModel { Email = this.Email.Text, Password = this.Password.Text, RememberMe = true };
                request.Send(RequestConfig.Login, "POST", model);
                request.RequestFinished += (object send, RequestEndedArgs ev) => {
                    var jsonId = (int)JsonConvert.DeserializeObject (ev.Result, typeof(int));
                    InvokeOnMainThread (delegate {
                        AppDelegate.SaveProfileId(jsonId);
                        var tabbar = new MainTabController();
                        UIApplication.SharedApplication.Delegate.Window.RootViewController = tabbar;
                    });
                };
            };
        }
Exemplo n.º 2
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad ();

            this.CreateAccount.TouchUpInside += (object sender, EventArgs e) => {
                //UIStoryboard board = UIStoryboard.FromName ("MainStoryboard", null);
                //PreferencesController welcome = (PreferencesController)board.InstantiateViewController ("preferencescontroller");
                //welcome.ImageSources = new string[] { "aaa", "a", "a", "a", "a", "a", "a", "a", "a" };

                //this.NavigationController.PushViewController(welcome, true);
                model = new RegisterModel { Email = this.Email.Text, FirstName = this.FirstName.Text, LastName = this.LastName.Text, Password = this.Password.Text };
                var request = new RestRequest();
                request.Send("http://www.sport.net/api/content/register", "POST", model);
            };

            this.ImagePicker.TouchUpInside += (s, e) => {
                // create a new picker controller
                imagePicker = new UIImagePickerController ();

                // set our source to the photo library
                imagePicker.SourceType = UIImagePickerControllerSourceType.PhotoLibrary;

                // set what media types
                imagePicker.MediaTypes = UIImagePickerController.AvailableMediaTypes (UIImagePickerControllerSourceType.PhotoLibrary);

                imagePicker.FinishedPickingMedia += Handle_FinishedPickingMedia;
                imagePicker.Canceled += Handle_Canceled;

                // show the picker
                NavigationController.PresentViewController (imagePicker, true, null);

            };
        }
Exemplo n.º 3
0
        void getData(int category, int page, bool isVideoUpdated, bool isMenuUpdated)
        {
            //----------------------------------------------------------------------------------------------
            var request = new RestRequest();

            request.RequestFinished += (object sender, RequestEndedArgs e) => {
                var data = (CategoryVideoModel)JsonConvert.DeserializeObject(e.Result, typeof(CategoryVideoModel));
                model = data;
                // invoke it on the main thread
                RunOnUiThread(delegate {
                    if (isVideoUpdated)
                    {
                        this.listView.Adapter = new VideoAdapter(this, model.News);
                        this.pagingPosition   = ((VideoAdapter)this.listView.Adapter).VideoModel.Count - 9;
                        loader = false;
                    }
                    if (isMenuUpdated)
                    {
                        this.menuList.Adapter = new MainMenuListAdapter(this, model.Categories);
                        this.categories       = model.Categories;
                        if (model.CategoryId != 0)
                        {
                            this.categories.Insert(0, new CategoriesMenuModelItem {
                                Name = "All Sports", Link = model.Parent.Link
                            });
                        }
                    }
                });
            };
            request.Send(string.Format(RequestConfig.Videos, category, page), "GET");
            //----------------------------------------------------------------------------------------------
        }
Exemplo n.º 4
0
        public override void RowSelected(UITableView tableView, NSIndexPath indexPath)
        {
            var request = new RestRequest ();
            var tab = (MainTabController)UIApplication.SharedApplication.Delegate.Window.RootViewController;

            if (indexPath.Row == 0 && !root) {
                request.RequestFinished += (object sender, RequestEndedArgs e) => {
                    InvokeOnMainThread(delegate {
                        var data = (List<LiveScoreSportModel>)JsonConvert.DeserializeObject(e.Result, typeof(List<LiveScoreSportModel>));
                        tableView.Source = new SwitchCategorySource(data, target);
                        tableView.ReloadData();
                    });
                };
                request.Send (RequestConfig.LiveScoreSports, "GET");

                var request2 = new RestRequest ();
                request2.RequestFinished += (object sender, RequestEndedArgs e) => {
                    InvokeOnMainThread(delegate {
                        var data = (LiveScoreViewModel)JsonConvert.DeserializeObject(e.Result, typeof(LiveScoreViewModel));
                        this.target.Source = new TodayTableSource(data);
                        this.target.ReloadData();
                    });
                };
                request2.Send (string.Format (RequestConfig.LiveScore, categories [indexPath.Row].Id, 0), "GET");
                //tab.LiveScore.SportToday.Text = "All Sports";
            }
            else {
                request.RequestFinished += (object sender, RequestEndedArgs e) => {
                    InvokeOnMainThread(delegate {
                        var data = (List<LiveScoreCategoryModel>)JsonConvert.DeserializeObject(e.Result, typeof(List<LiveScoreCategoryModel>));
                        data.Insert(0, new LiveScoreCategoryModel { Name = "Back" });
                        tableView.Source = new SwitchCategorySource(data, target, currentSport);
                        tableView.ReloadData();
                    });
                };

                var request2 = new RestRequest ();
                request2.RequestFinished += (object sender, RequestEndedArgs e) => {
                    InvokeOnMainThread(delegate {
                        var data = (LiveScoreViewModel)JsonConvert.DeserializeObject(e.Result, typeof(LiveScoreViewModel));
                        this.target.Source = new TodayTableSource(data);
                        this.target.ReloadData();
                    });
                };

                if (root) {
                    request.Send (string.Format (RequestConfig.LiveScoreCategories, items [indexPath.Row].Id), "GET");
                    request2.Send (string.Format (RequestConfig.LiveScore, items[indexPath.Row].Id, 0), "GET");
                    //tab.LiveScore.SportToday.Text = items [indexPath.Row].Name;
                }
                else {
                    request2.Send (string.Format (RequestConfig.LiveScore, currentSport, categories [indexPath.Row].Id), "GET");
                }
            }
        }
Exemplo n.º 5
0
        void getPagedData(int category, int page)
        {
            var request = new RestRequest();

            request.RequestFinished += (object sender, RequestEndedArgs e) => {
                var data = (List <VideoModelItem>)JsonConvert.DeserializeObject(e.Result, typeof(List <VideoModelItem>));
                RunOnUiThread(delegate {
                    var adapter = this.listView.Adapter as VideoAdapter;
                    adapter.VideoModel.AddRange(data);
                    adapter.NotifyDataSetChanged();
                });
            };
            request.Send(string.Format(RequestConfig.VideosPaged, category, page), "GET");
        }
Exemplo n.º 6
0
        private void getAdView()
        {
            var request = new RestRequest();

            request.RequestFinished += (object sender, RequestEndedArgs e) => {
                var data = (AdModel)JsonConvert.DeserializeObject(e.Result, typeof(AdModel));
                this.model = data;
                RunOnUiThread(delegate {
                    localWebView.SetUrlDrawable(model.Image, Resource.Drawable.SportNetNoPicBig);
                    //var requestAdPressed = new RestRequest ();
                    //requestAdPressed.Send (this.model.Impression,"GET");
                    //Console.WriteLine("Sent");
                });
            };
            request.Send(RequestConfig.Ads, "GET");
        }
        private void saveChange(int position, IParcelable state)
        {
            var current = ((CustomizingSelectionCategoryAdapter)this.listView.Adapter).Model[position];

            current.Checked = !current.Checked;

            listView.Adapter = new CustomizingSelectionCategoryAdapter(this, ((CustomizingSelectionCategoryAdapter)this.listView.Adapter).Model, false);
            listView.OnRestoreInstanceState(state);

            var req = new RestRequest();

            req.Send(RequestConfig.AddContent, "POST", current);
            req.RequestFinished += (object sender, RequestEndedArgs e) => {
                RunOnUiThread(delegate {
                    Console.WriteLine(e.Result);
                });
            };
        }
        public override void ViewWillAppear(bool animated)
        {
            spinner = new UIActivityIndicatorView (UIActivityIndicatorViewStyle.WhiteLarge);
            spinner.Center = new PointF (160, 160);
            spinner.HidesWhenStopped = true;
            View.AddSubview (spinner);
            spinner.StartAnimating ();
            TableView.Hidden = true;

            var button = new UIBarButtonItem ("Back", UIBarButtonItemStyle.Plain, null);
            var custom = new UIButton (new RectangleF (0, 0, 26, 15));
            custom.SetBackgroundImage(UIImage.FromFile("./Assets/back.png"), UIControlState.Normal);
            custom.TouchUpInside += (sender, e) => NavigationController.PopViewControllerAnimated (true);
            button.CustomView = custom;

            this.NavigationItem.LeftBarButtonItem = button;

            var request = new RestRequest ();
            request.RequestFinished += (object sender, RequestEndedArgs e) => {
                var data = (AddContentModel)JsonConvert.DeserializeObject(e.Result, typeof(AddContentModel));
                InvokeOnMainThread(delegate {
                    AppDelegate.SubCategories = data;
                    var all = new AddContentItem();
                    all.Name = "All from " + data.ParentCategory.Name;
                    all.HasChildren = false;
                    all.Checked = ParentChecked;
                    all.Id = data.ParentCategory.Id;
                    AppDelegate.SubCategories.Categories.Insert(0, all);
                    TableView.ReloadData();
                    TableView.Hidden = false;
                    spinner.StopAnimating();
                });
            };
            request.Send (string.Format(RequestConfig.SubCategories, CategoryId), "GET");

            this.TableView.Source = new PreferencesSubControllerSource ();
            this.TableView.AllowsMultipleSelection = true;
        }
        public override void ViewWillAppear(bool animated)
        {
            this.DateToday.Text = DateTime.Now.ToLongDateString();

            this.SportImageToday.Image = UIImage.FromFile ("./Assets/football-icon.png");
            this.SwitchTo.Frame = new RectangleF(0, 44, 640, 504);
            this.SwitchTo.ContentSize=new SizeF (640, 504);
            this.SwitchTo.ScrollEnabled = false;

            var request = new RestRequest ();
            request.RequestFinished += (object sender, RequestEndedArgs e) => {
                InvokeOnMainThread(delegate {
                    var data = (LiveScoreViewModel)JsonConvert.DeserializeObject(e.Result, typeof(LiveScoreViewModel));
                    this.TodayTable.Source = new TodayTableSource(data);
                    this.TodayTable.ReloadData();
                });
            };
            request.Send (string.Format (RequestConfig.LiveScore, 0, 0), "GET");

            this.TodayTable.ShowsVerticalScrollIndicator = false;
            this.TodayTable.BackgroundColor=  UIColor.FromRGB (26, 26, 26);

            this.SwitchCategory.SetBackgroundImage (UIImage.FromFile ("./Assets/dropdown.png"), UIControlState.Normal);

            request = new RestRequest ();
            request.RequestFinished += (object sender, RequestEndedArgs e) => {
                InvokeOnMainThread(delegate {
                    var data = (List<LiveScoreSportModel>)JsonConvert.DeserializeObject(e.Result, typeof(List<LiveScoreSportModel>));
                    this.Categories.Source = new SwitchCategorySource(data, TodayTable);
                    this.Categories.ReloadData();
                });
            };
            request.Send (RequestConfig.LiveScoreSports, "GET");

            if(((AppDelegate)UIApplication.SharedApplication.Delegate).IsSeven) {
                this.AutomaticallyAdjustsScrollViewInsets = false;
            }
        }
Exemplo n.º 10
0
        public static void SetUserInfo(Activity activity)
        {
            var name       = activity.FindViewById <TextView> (Resource.Id.MenuName);
            var settings   = activity.FindViewById <Button> (Resource.Id.Settings);
            var addContent = activity.FindViewById <Button> (Resource.Id.AddContent);

            if (IsLoggedIn())
            {
                var request = new RestRequest();
                request.RequestFinished += (object sender, RequestEndedArgs e) => {
                    var data = (ProfileUpdateModel)JsonConvert.DeserializeObject(e.Result, typeof(ProfileUpdateModel));
                    activity.RunOnUiThread(delegate {
                        name.Text       = data.FirstName + " " + data.LastName;
                        settings.Text   = "Logout";
                        settings.Click += (object sendr, EventArgs ev) => {
                            DeleteProfileId();
                            var intent = new Intent(activity, typeof(MainActivity));
                            intent.SetFlags(ActivityFlags.NewTask | ActivityFlags.ClearTask);
                            activity.StartActivity(intent);
                        };
                        addContent.Visibility = ViewStates.Visible;
                    });
                };
                request.Send(string.Format(RequestConfig.Profile, GetProfileId()), "GET");
            }
            else
            {
                name.Text       = "Welcome";
                settings.Text   = "Login";
                settings.Click += (object sender, EventArgs e) => {
                    var intent = new Intent(activity, typeof(MainActivity));
                    intent.SetFlags(ActivityFlags.NewTask | ActivityFlags.ClearTask);
                    activity.StartActivity(intent);
                };
                addContent.Visibility = ViewStates.Invisible;
            }
        }
Exemplo n.º 11
0
        public void OnConnected(Bundle p0)
        {
            Alert("Google", "Connected", false, (res) => {});
            var request = new RestRequest();
            var gName   = plusClient.CurrentPerson.Name;
            var gImage  = plusClient.CurrentPerson.Image;

            request.RequestFinished += (object sender, RequestEndedArgs e) => {
                RunOnUiThread(delegate {
                    Globals.DeleteProfileId();
                    var id = (string)JsonConvert.DeserializeObject(e.Result, typeof(string));
                    Globals.SaveProfileId(id);
                    StartActivity(main);
                });
            };
            request.Send(RequestConfig.Google, "POST", new GoogleClient {
                name        = plusClient.CurrentPerson.DisplayName,
                family_name = gName.FamilyName,
                given_name  = gName.GivenName,
                id          = plusClient.CurrentPerson.Id,
                picture     = gImage.Url,
                email       = plusClient.AccountName
            });
        }
        public override void RowSelected(UITableView tableView, NSIndexPath indexPath)
        {
            UIStoryboard board = UIStoryboard.FromName ("MainStoryboard", null);
            PicturesCollectionController gallery = (PicturesCollectionController)board.InstantiateViewController ("picturesCollectionController");

            var request = new RestRequest ();
            request.RequestFinished += (object sender, RequestEndedArgs e) => {
                InvokeOnMainThread(delegate {
                    var data = (GalleryArticleModel)JsonConvert.DeserializeObject(e.Result, typeof(GalleryArticleModel));
                    gallery.Items = data;
                    gallery.Title = data.CategoryName;
                    gallery.Spinner.StopAnimating ();
                    gallery.CollectionView.ReloadData();
                });
            };
            request.Send (string.Format (RequestConfig.PicturesArticle, items [indexPath.Row].Id), "GET");

            ((MainTabController)UIApplication.SharedApplication.Delegate.Window.RootViewController).
                Pictures.InternalTopNavigation.PushViewController (gallery,true);
        }
Exemplo n.º 13
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            SetContentView(Resource.Layout.Gallery);
            Console.WriteLine("GalleryActivity");

            this.id = Intent.GetStringExtra("MyModel") ?? "Data not available";

            this.pictures = Intent.GetIntExtra("MyPicturesCount", 0);
            TextView headline = FindViewById <TextView> (Resource.Id.GalleryHeading);

            this.heading  = Intent.GetStringExtra("MyHeading") ?? "Data not available";
            headline.Text = heading;

            TextView photoIndex = FindViewById <TextView> (Resource.Id.NumberOfPictures);

            photoIndex.Text = string.Format("{0}", pictures);

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

            title.Text = Intent.GetStringExtra("MyCategory") ?? "Data not available";

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

            logo.Visibility = ViewStates.Invisible;

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

            menu.Visibility = ViewStates.Invisible;

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

            back.Click += delegate {
                var parent = (PictureGroupActivity)Parent;
                parent.OnBackPressed();
            };
            // Create your application here
            this.gridview = FindViewById <GridView> (Resource.Id.GalleryGridview);

            List <string> pictureModel = new List <string> ();

            //-------------------------------------------------------------------------------------------------------------
            var request = new RestRequest();

            request.RequestFinished += (object sender, RequestEndedArgs e) => {
                var data = (GalleryArticleModel)JsonConvert.DeserializeObject(e.Result, typeof(GalleryArticleModel));
                model        = data;
                pictureModel = model.Images;
                // invoke it on the main thread
                RunOnUiThread(delegate {
                    gridview.Adapter = new GalleryAdapter(this, model);
                });
            };
            request.Send(string.Format(RequestConfig.PicturesArticle, this.id), "GET");
            //-------------------------------------------------------------------------------------------------------------



            gridview.ItemClick += (s, arg) => {
                gridview.GetChildAt(arg.Position).FindViewById <ImageView>(Resource.Id.Frame).Visibility = ViewStates.Visible;
                Console.WriteLine("Item at {0} position is clicked!", arg.Position);
                var picture = new Intent(this, typeof(PictureActivity));
                picture.PutExtra("PicturesCount", this.pictures);
                picture.PutExtra("PicturePosition", arg.Position);
                picture.PutStringArrayListExtra("Model", pictureModel);


                StartActivity(picture);
            };
        }
Exemplo n.º 14
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            SetContentView(Resource.Layout.AccountSettings);
            Console.WriteLine("AccountSettingsActivity");

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

            logo.Visibility = ViewStates.Invisible;

            ImageView menu = FindViewById <ImageView> (Resource.Id.ActionBarMenu);
            //menu.Visibility = ViewStates.Invisible;

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

            title.Text = "Account Settings";

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

            back.Visibility = ViewStates.Invisible;

            Button editProfile = FindViewById <Button> (Resource.Id.EditProfileButton);

            editProfile.Click += delegate {
                var edit = new Intent(this, typeof(EditProfileActivity));
                StartActivity(edit);
            };

            Button changePass = FindViewById <Button> (Resource.Id.ChangePasswordButton);

            changePass.Click += delegate {
                var pass = new Intent(this, typeof(ChangePasswordActivity));
                StartActivity(pass);
            };

            Button notifications = FindViewById <Button> (Resource.Id.NotificationsButton);

            notifications.Click += delegate {
                var notification = new Intent(this, typeof(NotificationsActivity));
                StartActivity(notification);
            };

            Button remove = FindViewById <Button> (Resource.Id.RemoveAccountButton);

            remove.Click += delegate {
                var removeAcc = new Intent(this, typeof(RemoveAccountActivity));
                StartActivity(removeAcc);
            };

            Button aboutApp = FindViewById <Button> (Resource.Id.AboutAppButton);

            aboutApp.Click += delegate {
                var about = new Intent(this, typeof(AboutThisAppActivity));
                StartActivity(about);
            };

            Button signOut = FindViewById <Button> (Resource.Id.SignOutButton);

            signOut.Click += delegate {
                var sdCardPath = Android.OS.Environment.ExternalStorageDirectory.Path;
                var filePath   = System.IO.Path.Combine(sdCardPath, "ExampleFile.txt");
                if (System.IO.File.Exists(filePath))
                {
                    System.IO.File.Delete(filePath);
                }
                StartActivity(typeof(MainActivity));
            };

            Button settings = FindViewById <Button> (Resource.Id.Settings);

            settings.Click += delegate {
                _slideLeftBtn.PerformClick();
            };

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

            //----------------------------------------------------------------------------------------------
            var request = new RestRequest();

            request.RequestFinished += (object sender, RequestEndedArgs e) => {
                var data = (CategoryModel)JsonConvert.DeserializeObject(e.Result, typeof(CategoryModel));
                model = data;
                // invoke it on the main thread
                RunOnUiThread(delegate {
                    menuList.Adapter = new MainMenuListAdapter(this, model.Categories);
                });
            };
            request.Send(string.Format(RequestConfig.News(), 0, 0), "GET");
            //----------------------------------------------------------------------------------------------


            _context = ApplicationContext;



            //menuList = FindViewById<ListView> (Resource.Id.MenuMenu);
            //menuList.Adapter = new MainMenuListAdapter (this, sports,checkedPosition);

            TextView menuName = FindViewById <TextView> (Resource.Id.MenuName);

            menuName.Text = string.Format("{0} {1}", Globals.firstName, Globals.lastName);

            menuList.ItemClick += (s, arg) => {
                var main = new Intent(this, typeof(MainTabActivity));
                StartActivity(main);
            };

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

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

            TextView firstName = FindViewById <TextView> (Resource.Id.FirstName);

            firstName.Text = Globals.firstName;
            TextView lastName = FindViewById <TextView> (Resource.Id.LastName);

            lastName.Text = Globals.lastName;
            TextView email = FindViewById <TextView> (Resource.Id.Email);

            email.Text = Globals.email;

            DefineGui();
        }
Exemplo n.º 15
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad ();

            //AppDelegate appDelegate = (AppDelegate)UIApplication.SharedApplication.Delegate;
            //UIStoryboard board = UIStoryboard.FromName ("MainStoryboard", null);

            if (AppDelegate.IsLoggedIn ()) {
                this.Login.Hidden = true;
                this.SignUp.Hidden = true;

                var request = new RestRequest ();
                request.RequestFinished += (object sender, RequestEndedArgs e) => {
                    var data = (ProfileUpdateModel)JsonConvert.DeserializeObject(e.Result, typeof(ProfileUpdateModel));
                    InvokeOnMainThread(delegate {
                        this.Name.SetTitle(data.FirstName + " " + data.LastName, UIControlState.Normal);
                        this.Settings.SetTitle("Logout", UIControlState.Normal);
                        if(!string.IsNullOrEmpty(data.PictureUrl)) {
                            AppDelegate.MakeImageFromURL(this.Image, data.PictureUrl);
                        }
                    });
                };
                request.Send (string.Format (RequestConfig.Profile, AppDelegate.GetProfileId()), "GET");
            }
            else {
                this.Name.Hidden = true;
                this.Settings.Hidden = true;
            }

            this.Login.TouchUpInside += (object sender, EventArgs e) => {
                UINavigationController welcomeNav = new UINavigationController ();
                welcomeNav.NavigationBar.SetBackgroundImage (UIImage.FromFile ("./Assets/navbar.png"),
                                                             MonoTouch.UIKit.UIBarMetrics.Default);
                UIStoryboard board = UIStoryboard.FromName ("MainStoryboard", null);
                WelcomeController welcome = (WelcomeController)board.InstantiateViewController ("welcomecontroller");
                UINavigationBar.Appearance.SetTitleTextAttributes
                    (new UITextAttributes { TextColor = UIColor.FromRGB(102, 102, 102) });

                welcomeNav.PushViewController (welcome, false);

                UIApplication.SharedApplication.KeyWindow.RootViewController = welcomeNav;
            };

            this.SignUp.TouchUpInside += (object sender, EventArgs e) => {
                //AccountSettingsController accSettings = (AccountSettingsController)board.InstantiateViewController ("accountSettingsController");
                //this.NavigationController.PushViewController(accSettings, true);

                UINavigationController welcomeNav = new UINavigationController ();
                welcomeNav.NavigationBar.SetBackgroundImage (UIImage.FromFile ("./Assets/navbar.png"),
                                                             MonoTouch.UIKit.UIBarMetrics.Default);
                UIStoryboard board = UIStoryboard.FromName ("MainStoryboard", null);
                WelcomeController welcome = (WelcomeController)board.InstantiateViewController ("welcomecontroller");
                UINavigationBar.Appearance.SetTitleTextAttributes
                    (new UITextAttributes { TextColor = UIColor.FromRGB(102, 102, 102) });

                welcomeNav.PushViewController (welcome, false);

                UIApplication.SharedApplication.KeyWindow.RootViewController = welcomeNav;
            };

            this.Settings.TouchUpInside += (object sender, EventArgs e) => {
                AppDelegate.DeleteProfileId();

                UINavigationController welcomeNav = new UINavigationController ();
                welcomeNav.NavigationBar.SetBackgroundImage (UIImage.FromFile ("./Assets/navbar.png"),
                                                             MonoTouch.UIKit.UIBarMetrics.Default);
                UIStoryboard board = UIStoryboard.FromName ("MainStoryboard", null);
                WelcomeController welcome = (WelcomeController)board.InstantiateViewController ("welcomecontroller");
                UINavigationBar.Appearance.SetTitleTextAttributes
                    (new UITextAttributes { TextColor = UIColor.FromRGB(102, 102, 102) });

                welcomeNav.PushViewController (welcome, false);

                UIApplication.SharedApplication.KeyWindow.RootViewController = welcomeNav;
            };

            this.AddContent.TouchUpInside += (object sender, EventArgs e) => {
                UINavigationController prefsNav = new UINavigationController ();
                prefsNav.NavigationBar.SetBackgroundImage (UIImage.FromFile ("./Assets/navbar.png"),
                                                             MonoTouch.UIKit.UIBarMetrics.Default);
                UIStoryboard board = UIStoryboard.FromName ("MainStoryboard", null);
                var prefs = (PreferencesController)board.InstantiateViewController ("preferencescontroller");
                UINavigationBar.Appearance.SetTitleTextAttributes
                    (new UITextAttributes { TextColor = UIColor.FromRGB(102, 102, 102) });

                prefs.Title = "Welcome";
                prefsNav.PushViewController (prefs, false);
                UIApplication.SharedApplication.Delegate.Window.RootViewController = prefsNav;
            };
        }
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            SetContentView(Resource.Layout.CustomizingSelectionCategory);
            Console.WriteLine("CustomizingSelectionCategoryActivity");

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

            //string name = Intent.GetStringExtra ("MyName") ?? "Data not available";
            title.Text = string.Format("{0}", Intent.GetStringExtra("SportName") ?? "Data not available");
            string id = string.Format("{0}", Intent.GetStringExtra("SportId") ?? "Data not available");

            isAllFromSportChecked = Intent.GetBooleanExtra("IsSportChecked", false);
            Button back = FindViewById <Button> (Resource.Id.ActionBarBack);

            back.Click += delegate {
                Finish();
            };

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

            menu.Visibility = ViewStates.Invisible;

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

            logo.Visibility = ViewStates.Invisible;

            listView = FindViewById <ListView>(Resource.Id.CustomizingCategory);
            //listView.Adapter = new CustomizingSelectionCategoryAdapter(this, category);
            var request = new RestRequest();

            request.RequestFinished += (object sender, RequestEndedArgs e) => {
                var data = (AddContentModel)JsonConvert.DeserializeObject(e.Result, typeof(AddContentModel));
                RunOnUiThread(delegate {
                    this.model = data.Categories;
                    this.model.Insert(0, new AddContentItem {
                        Name = string.Format("All from {0}", title.Text), HasChildren = false, Checked = this.isAllFromSportChecked, Id = data.ParentCategory.Id
                    });
                    listView.Adapter = new CustomizingSelectionCategoryAdapter(this, data.Categories, false);
                });
            };
            request.Send(string.Format(RequestConfig.SubCategories, id), "GET");

            var category = new Intent(this, typeof(CustomizingSelectionCategoryActivity));

            listView.ItemClick += (sender, e) => {
                IParcelable state = listView.OnSaveInstanceState();
                if (e.Position != 0)
                {
                    if (((CustomizingSelectionCategoryAdapter)this.listView.Adapter).Model[e.Position].HasChildren)
                    {
                        category.PutExtra("SportName", ((CustomizingSelectionCategoryAdapter)this.listView.Adapter).Model[e.Position].Name);
                        category.PutExtra("SportId", ((CustomizingSelectionCategoryAdapter)this.listView.Adapter).Model[e.Position].Id.ToString());
                        StartActivity(category);
                    }
                    else
                    {
                        saveChange(e.Position, state);
                    }
                }
                else
                {
                    saveChange(e.Position, state);
                }
            };
        }
Exemplo n.º 17
0
        private void getData()
        {
            var request = new RestRequest ();
            request.RequestFinished += (object sender, RequestEndedArgs e) => {
                InvokeOnMainThread(delegate {
                    var data = (CategoryModel)JsonConvert.DeserializeObject(e.Result, typeof(CategoryModel));
                    var menuController = (MenuController)((MainTabController)UIApplication.SharedApplication.Delegate.Window.RootViewController).News.MenuViewLeft;

                    var featured = (List<NewsModelItem>)data.News;
                    featured = featured.Where(c => !string.IsNullOrEmpty(c.Img)).Take(4).ToList();

                    TableView.Source = new HomeControllerSource(featured, data.Categories);
                    menuController.TableView.Source = new MenuControllerSource(data.Categories, "news");
                    menuController.TableView.ReloadData();
                    TableView.ReloadData();
                    spinner.StopAnimating();
                });
            };
            request.Send (string.Format(RequestConfig.News(), 0, 0), "GET");
        }
Exemplo n.º 18
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad ();

            var request = new RestRequest ();
            request.RequestFinished += (object sender, RequestEndedArgs e) => {
                var data = (AddContentModel)JsonConvert.DeserializeObject(e.Result, typeof(AddContentModel));
                InvokeOnMainThread(delegate {
                    AppDelegate.MainCategories = data;
                    CollectionView.ReloadData();
                    spinner.StopAnimating();
                });
            };
            request.Send (string.Format (RequestConfig.MainCategories, AppDelegate.GetProfileId ()), "GET");
        }
Exemplo n.º 19
0
        private void getData()
        {
            // load the articles and the menu from the server on a background thread
            var request = new RestRequest ();
            request.RequestFinished += (object sender, RequestEndedArgs e) => {
                InvokeOnMainThread(delegate {
                    var data = (CategoryVideoModel)JsonConvert.DeserializeObject(e.Result, typeof(CategoryVideoModel));
                    var menuController = (MenuController)((MainTabController)UIApplication.SharedApplication.Delegate.Window.RootViewController).Video.MenuViewLeft;

                    // add 'all sports' item to the categories list
                    if(data.Parent.Link == 0) {
                        data.Categories.Insert(0, new CategoriesMenuModelItem { Name = "All Sports", Link = 0 });
                    }
                    else {
                        data.Categories.Insert(0, new CategoriesMenuModelItem { Name = "Back" , Link = data.Parent.Link });
                    }

                    TableView.Source = new VideoControllerSource(data.News, data.CategoryId);
                    menuController.TableView.Source = new MenuControllerSource(data.Categories, "video");
                    menuController.TableView.ReloadData();
                    TableView.ReloadData();
                    spinner.StopAnimating();
                });
            };
            request.Send (string.Format(RequestConfig.Videos, 0, 0), "GET");
        }
Exemplo n.º 20
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();
        }
        public override void RowSelected(UITableView tableView, NSIndexPath indexPath)
        {
            var cell = tableView.CellAt (indexPath);

            if (indexPath.Row != 0) {
                if (AppDelegate.SubCategories.Categories [indexPath.Row].HasChildren) {
                    UIStoryboard board = UIStoryboard.FromName ("MainStoryboard", null);
                    var prefs = (PreferencesSubController)board.InstantiateViewController ("preferencessub");
                    prefs.CategoryId = AppDelegate.SubCategories.Categories [indexPath.Row].Id;
                    prefs.ParentChecked = AppDelegate.SubCategories.Categories [indexPath.Row].Checked;
                    prefs.Title = AppDelegate.SubCategories.Categories [indexPath.Row].Name;
                    ((UINavigationController)UIApplication.SharedApplication.KeyWindow.RootViewController).PushViewController (prefs, true);
                }
                else {
                    AppDelegate.SubCategories.Categories [indexPath.Row].Checked = !AppDelegate.SubCategories.Categories [indexPath.Row].Checked;
                    setCell (cell, indexPath);
                    var request = new RestRequest ();
                    request.RequestFailed += (object sender, EventArgs e) => {
                        AppDelegate.SubCategories.Categories [indexPath.Row].Checked = !AppDelegate.SubCategories.Categories [indexPath.Row].Checked;
                        setCell (cell, indexPath);
                    };
                    request.Send (RequestConfig.AddContent, "POST", AppDelegate.SubCategories.Categories [indexPath.Row]);
                }
            }
            else {
                AddContentItem model = AppDelegate.MainCategories.Categories.Find (i => i.Id == AppDelegate.SubCategories.ParentCategory.Id);
                if (model == null) {
                    var request2 = new RestRequest ();
                    request2.RequestFinished += (object sender, RequestEndedArgs e) => {
                        InvokeOnMainThread(delegate() {
                            var data = (AddContentModel)JsonConvert.DeserializeObject(e.Result, typeof(AddContentModel));
                            model = data.Categories.Find(i => i.Id == AppDelegate.SubCategories.ParentCategory.Id);
                            model.Checked = !model.Checked;
                            AppDelegate.SubCategories.Categories [0].Checked = !AppDelegate.SubCategories.Categories [0].Checked;
                            setCell (cell, indexPath);

                            var request = new RestRequest ();
                            request.RequestFailed += (object snder, EventArgs ev) => {
                                InvokeOnMainThread(delegate() {
                                    model.Checked = !model.Checked;
                                    AppDelegate.SubCategories.Categories [0].Checked = !AppDelegate.SubCategories.Categories [0].Checked;
                                    setCell (cell, indexPath);
                                });
                            };
                            request.Send (RequestConfig.AddContent, "POST", model);
                        });
                    };
                    request2.Send (string.Format (RequestConfig.SubCategories, AppDelegate.SubCategories.ParentCategory.fkParent), "GET");
                }
                else {
                    model.Checked = !model.Checked;
                    AppDelegate.SubCategories.Categories [0].Checked = !AppDelegate.SubCategories.Categories [0].Checked;
                    setCell (cell, indexPath);
                    var request = new RestRequest ();
                    request.RequestFailed += (object snder, EventArgs ev) => {
                        InvokeOnMainThread(delegate() {
                            model.Checked = !model.Checked;
                            AppDelegate.SubCategories.Categories [0].Checked = !AppDelegate.SubCategories.Categories [0].Checked;
                            setCell (cell, indexPath);
                        });
                    };
                    request.Send (RequestConfig.AddContent, "POST", model);
                }
            }
        }
Exemplo n.º 22
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            SetContentView(Resource.Layout.CustomizingSelction);
            Console.WriteLine("CustomizingSelectionActivity");

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

            //string name = Intent.GetStringExtra ("MyName") ?? "Data not available";
            title.Text = string.Format("Welcome, {0} {1}", Globals.firstName, Globals.lastName);

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

            back.Visibility = ViewStates.Invisible;

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

            menu.Visibility = ViewStates.Invisible;

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

            logo.Visibility = ViewStates.Invisible;

            this.index2 = index;
            var category = new Intent(this, typeof(CustomizingSelectionCategoryActivity));

            this.gridview = FindViewById <GridView> (Resource.Id.gridview);

            var request = new RestRequest();

            request.RequestFinished += (object sender, RequestEndedArgs e) => {
                var data = (AddContentModel)JsonConvert.DeserializeObject(e.Result, typeof(AddContentModel));
                RunOnUiThread(delegate {
                    this.gridview.Adapter = new SelectionAdapter(this, data);
                });
            };
            request.Send(string.Format(RequestConfig.MainCategories, Globals.GetProfileId()), "GET");


            gridview.ItemClick += (s, arg) => {
                /*int pos = arg.Position;
                 * Console.WriteLine ("{0}", pos);
                 * if(this.selected[pos]==0){		//	Not Selected
                 *
                 *      this.selected[pos]=1;
                 *      category.PutExtra ("MyData", sports[pos]);
                 *      StartActivity(category);
                 *
                 * } else	{						// Selected
                 *
                 *      this.selected[pos]=0;
                 *      this.index = gridview.FirstVisiblePosition;
                 *      this.gridview.Adapter = new SelectionAdapter (this,thums,selected, sports);
                 *      this.gridview.SetSelection (index);
                 * }*/
                category.PutExtra("SportName", ((SelectionAdapter)this.gridview.Adapter).Model.Categories[arg.Position].Name);
                category.PutExtra("SportId", ((SelectionAdapter)this.gridview.Adapter).Model.Categories[arg.Position].Id.ToString());
                category.PutExtra("IsSportChecked", ((SelectionAdapter)this.gridview.Adapter).Model.Categories[arg.Position].Checked);

                //((SelectionAdapter)this.gridview.Adapter).Model.Categories[arg.Position].Checked=!((SelectionAdapter)this.gridview.Adapter).Model.Categories[arg.Position].Checked;

                StartActivity(category);
            };
            Button startReading = FindViewById <Button> (Resource.Id.StartReading);

            startReading.Click += delegate {
                var main = new Intent(this, typeof(MainTabActivity));
                StartActivity(main);
            };
        }
Exemplo n.º 23
0
        private void changePicturesCategory(NSIndexPath indexPath)
        {
            var controller = (SlideoutNavigationController)((MainTabController)UIApplication.SharedApplication.Delegate.Window.RootViewController).Pictures;
            var pictures = (PicturesController)controller.TopView;
            var request = new RestRequest ();
            ((PicturesController)controller.TopView).Spinner.StartAnimating ();
            //controller.Hide ();

            request.RequestFinished += (object sender, RequestEndedArgs e) => {
                InvokeOnMainThread(delegate {
                    var data = (CategoryPicturesModel)JsonConvert.DeserializeObject(e.Result, typeof(CategoryPicturesModel));
                    var menuController = (MenuController)((MainTabController)UIApplication.SharedApplication.Delegate.Window.RootViewController).Pictures.MenuViewLeft;

                    // add 'all sports' item to the categories list
                    if(data.Parent.Link == 0) {
                        data.Categories.Insert(0, new CategoriesMenuModelItem { Name = "All Sports", Link = 0 });
                    }
                    else {
                        data.Categories.Insert(0, new CategoriesMenuModelItem { Name = "Back" , Link = data.Parent.Link });
                    }

                    pictures.TableView.Source = new PicturesControllerSource(data.News, data.CategoryId);
                    menuController.TableView.Source = new MenuControllerSource(data.Categories, "pictures");
                    menuController.TableView.ReloadData();
                    pictures.TableView.ReloadData();
                    pictures.Spinner.StopAnimating();
                });
            };
            request.Send (string.Format(RequestConfig.Pictures, categories[indexPath.Row].Link, 0), "GET");
        }
Exemplo n.º 24
0
        private void changeVideoCategory(NSIndexPath indexPath)
        {
            var controller = (SlideoutNavigationController)((MainTabController)UIApplication.SharedApplication.Delegate.Window.RootViewController).Video;
            var video = (VideoController)controller.TopView;
            var request = new RestRequest ();
            ((VideoController)controller.TopView).Spinner.StartAnimating ();
            //controller.Hide ();

            request.RequestFinished += (object sender, RequestEndedArgs e) => {
                InvokeOnMainThread(delegate {
                    var data = (CategoryVideoModel)JsonConvert.DeserializeObject(e.Result, typeof(CategoryVideoModel));
                    var menuController = (MenuController)((MainTabController)UIApplication.SharedApplication.Delegate.Window.RootViewController).Video.MenuViewLeft;

                    // add 'all sports' item to the categories list
                    if(data.CategoryId == 0) {
                        data.Categories.Insert(0, new CategoriesMenuModelItem { Name = "All Sports", Link = 0 });
                    }
                    else {
                        data.Categories.Insert(0, new CategoriesMenuModelItem { Name = "Back" , Link = data.Parent.Link });
                    }

                    video.TableView.Source = new VideoControllerSource(data.News, data.CategoryId);
                    menuController.TableView.Source = new MenuControllerSource(data.Categories, "video");
                    menuController.TableView.ReloadData();
                    video.TableView.ReloadData();
                    try {
                        video.TableView.ScrollToRow(NSIndexPath.FromRowSection(0, 0), UITableViewScrollPosition.Top, false);
                    }
                    catch(Exception) {}
                    video.Spinner.StopAnimating();
                });
            };
            request.Send(string.Format(RequestConfig.Videos, categories[indexPath.Row].Link, 0), "GET");
        }
Exemplo n.º 25
0
        public override void ViewWillAppear(bool animated)
        {
            this.Email.Background = UIImage.FromFile ("./Assets/input.png");
            this.Password.Background = UIImage.FromFile ("./Assets/input.png");
            this.Login.SetBackgroundImage (UIImage.FromFile ("./Assets/buttonlong.png"), UIControlState.Normal);

            this.Email.LeftView = new UIView (new RectangleF (0, 0, 5, 30));
            this.Email.LeftViewMode = UITextFieldViewMode.Always;
            this.Password.LeftView = new UIView (new RectangleF (0, 0, 5, 30));
            this.Password.LeftViewMode = UITextFieldViewMode.Always;

            var button = new UIBarButtonItem ("Back", UIBarButtonItemStyle.Plain, null);
            var custom = new UIButton (new RectangleF (0, 0, 26, 15));
            custom.SetBackgroundImage(UIImage.FromFile("./Assets/back.png"), UIControlState.Normal);
            custom.TouchUpInside += (sender, e) => NavigationController.PopViewControllerAnimated (true);
            button.CustomView = custom;

            this.NavigationItem.LeftBarButtonItem = button;
            this.NavigationController.SetNavigationBarHidden (false, false);

            // FACEBOOK LOGIN
            fbLogin = new FBLoginView (AppDelegate.Permissions);
            FacebookView.AddSubview (fbLogin);
            fbLogin.SizeToFit ();

            fbLogin.FetchedUserInfo += (object sender, FBLoginViewUserInfoEventArgs e) => {
                if (FBSession.ActiveSession.IsOpen) {
                    var model = new FacebookProfile { Id = long.Parse (e.User.Id), Name = e.User.Name,
                        first_name = e.User.FirstName, last_name = e.User.LastName,
                        Birthday = e.User.Birthday, Email = e.User.ObjectForKey ("email").ToString (), UserName = e.User.Username
                    };
                    var request = new RestRequest ();
                    request.RequestFinished += (object sendr, RequestEndedArgs ev) => {
                        var jsonId = (int)JsonConvert.DeserializeObject (ev.Result, typeof(int));
                        InvokeOnMainThread (delegate {
                            AppDelegate.SaveProfileId(jsonId);
                            var tabbar = new MainTabController();
                            UIApplication.SharedApplication.Delegate.Window.RootViewController = tabbar;
                        });
                    };
                    request.Send (RequestConfig.Facebook, "POST", model);
                }
            };

            fbLogin.ShowingLoggedOutUser += (object sender, EventArgs e) => {
                Console.WriteLine(e.ToString());
            };
            fbLogin.ShowingLoggedInUser += (object sender, EventArgs e) => {
                Console.WriteLine("Logged in.");
            };

            // GOOGLE LOGIN
            var signIn = SignIn.SharedInstance;
            signIn.ClientId = AppDelegate.GoogleClientId;
            signIn.Scopes = new [] { PlusConstants.AuthScopePlusLogin, PlusConstants.AuthScopePlusMe,
                                    "https://www.googleapis.com/auth/userinfo.profile",
                                    "https://www.googleapis.com/auth/userinfo.email" };
            signIn.ShouldFetchGoogleUserEmail = true;
            signIn.ShouldFetchGoogleUserId = true;

            signIn.Finished += (object sender, SignInDelegateFinishedEventArgs e) => {
                if(e.Error != null) {
                    InvokeOnMainThread(delegate {
                        new UIAlertView("Error.", "Could not sign in.", null, "Ok", null).Show();
                    });
                }
                else {
                    var request = new RestRequest();
                    request.RequestFinished += (object sendr, RequestEndedArgs ev) => {
                        var data = (GoogleClient)JsonConvert.DeserializeObject(ev.Result, typeof(GoogleClient));
                        var request2 = new RestRequest();
                        request2.RequestFinished += (object sndr, RequestEndedArgs evnt) => {
                            var jsonId = (int)JsonConvert.DeserializeObject (evnt.Result, typeof(int));
                            InvokeOnMainThread (delegate {
                                AppDelegate.SaveProfileId(jsonId);
                                var tabbar = new MainTabController();
                                UIApplication.SharedApplication.Delegate.Window.RootViewController = tabbar;
                            });
                        };
                        request2.Send(RequestConfig.Google, "POST", data);
                    };
                    request.Send(String.Format(RequestConfig.GoogleFetch, Uri.EscapeDataString(signIn.Authentication.AccessToken)), "GET");
                }
            };

            var signInButton = new SignInButton ();
            GoogleView.AddSubview (signInButton);
            signInButton.Frame = new RectangleF (0, 0, GoogleView.Frame.Size.Width - 8, GoogleView.Frame.Size.Height);
            signInButton.SizeToFit ();
        }
Exemplo n.º 26
0
        protected override void OnActivityResult(int requestCode, Result resultCode, Intent data)
        {
            base.OnActivityResult(requestCode, resultCode, data);

            // google
            if (requestCode == 9000)
            {
                if (resultCode == Result.Ok)
                {
                    plusClient.Connect();
                }
                return;
            }

            // facebook
            switch (resultCode)
            {
            case Result.Ok:
                accessToken = data.GetStringExtra("AccessToken");
                string userId = data.GetStringExtra("UserId");
                string error  = data.GetStringExtra("Exception");

                fb = new FacebookClient(accessToken);
                fb.GetTaskAsync("me").ContinueWith(t => {
                    if (!t.IsFaulted)
                    {
                        var result  = (IDictionary <string, object>)t.Result;
                        var request = new RestRequest();

                        RunOnUiThread(delegate {
                            request.RequestFinished += (object sender, RequestEndedArgs e) => {
                                RunOnUiThread(delegate {
                                    Globals.DeleteProfileId();
                                    var id = (string)JsonConvert.DeserializeObject(e.Result, typeof(string));
                                    Globals.SaveProfileId(id);
                                    StartActivity(main);
                                });
                            };
                            request.Send(RequestConfig.Facebook, "POST", new FacebookProfile {
                                Id         = long.Parse(result["id"].ToString()),
                                Name       = (string)result["name"],
                                first_name = (string)result["first_name"],
                                last_name  = (string)result["last_name"],
                                Birthday   = (string)result["birthday"],
                                Email      = (string)result["email"],
                                UserName   = (string)result["username"]
                            });
                        });
                    }
                    else
                    {
                        Alert("Failed to log in", "Reason: " + error, false, (res) => {});
                    }
                });

                /*
                 * var request = new RestRequest ();
                 * request.RequestFinished += (object sender, RequestEndedArgs e) => {
                 *      Globals.DeleteProfileId();
                 *      RunOnUiThread(delegate {
                 *              var id = (string)JsonConvert.DeserializeObject(e.Result, typeof(string));
                 *              Globals.SaveProfileId(id);
                 *              StartActivity (main);
                 *      });
                 * };
                 * request.Send(RequestConfig.Facebook*/

                break;

            case Result.Canceled:
                Alert("Failed to log in.", "User Cancelled", false, (res) => {});
                break;

            default:
                Alert("Something went wrong, please try again in a few minutes.", "Oops!", false, (res) => {});
                break;
            }
            ;
        }
Exemplo n.º 27
0
        public override void Scrolled(UIScrollView scrollView)
        {
            if (loading) {
                return;
            }

            PointF offset = scrollView.ContentOffset;
            RectangleF bounds = scrollView.Bounds;
            SizeF size = scrollView.ContentSize;
            UIEdgeInsets inset = scrollView.ContentInset;

            float y = offset.Y + bounds.Size.Height - inset.Bottom;
            float h = size.Height;

            if(y > h - 50) {
                var request = new RestRequest ();

                request.RequestFinished += (object sender, RequestEndedArgs e) => {
                    InvokeOnMainThread(delegate {
                        var data = (List<NewsModelItem>)JsonConvert.DeserializeObject(e.Result, typeof(List<NewsModelItem>));
                        items.AddRange(new List<NewsModelItem>(data));
                        loading = false;
                        var tabController = (MainTabController)UIApplication.SharedApplication.Delegate.Window.RootViewController;
                        ((NewsController)tabController.News.TopView).TableView.ReloadData();
                        NextPage++;
                    });
                };
                request.Send (string.Format(RequestConfig.NewsPaged, CurrentCategory, NextPage), "GET");
                loading = true;
            }
        }
Exemplo n.º 28
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            SetContentView(Resource.Layout.Login);
            Console.WriteLine("LoginActivity");

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

            logo.Visibility = ViewStates.Invisible;

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

            menu.Visibility = ViewStates.Invisible;

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

            title.Text = "Login";

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

            back.Click += delegate {
                Finish();
            };

            EditText email    = FindViewById <EditText> (Resource.Id.Email);
            EditText password = FindViewById <EditText> (Resource.Id.Password);

            email.TextChanged    += (object sender, Android.Text.TextChangedEventArgs e) => {
            };
            password.TextChanged += (object sender, Android.Text.TextChangedEventArgs e) => {
            };

            ImageButton facebook = FindViewById <ImageButton> (Resource.Id.loginViaFacebook);

            facebook.Click += delegate {
                var webAuth = new Intent(this, typeof(FBWebViewAuthActivity));
                webAuth.PutExtra("AppId", AppId);
                webAuth.PutExtra("ExtendedPermissions", ExtendedPermissions);
                StartActivityForResult(webAuth, 0);
            };

            ImageButton googlePlus = FindViewById <ImageButton> (Resource.Id.loginViaGoogle);

            plusClient = new PlusClient.Builder(this, this, this).Build();
            plusClient.RegisterConnectionCallbacks(this);
            plusClient.IsConnectionFailedListenerRegistered(this);

            googlePlus.Click += (object sender, EventArgs e) => {
                if (plusClient.IsConnected || plusClient.IsConnecting)
                {
                    return;
                }

                if (connectionResult == null)
                {
                    plusClient.Connect();
                }
                else
                {
                    resolveGoogleLogin(connectionResult);
                }
            };

            main = new Intent(this, typeof(MainTabActivity));
            Button login = FindViewById <Button> (Resource.Id.loginButton);

            login.Click += delegate {
                Globals.DeleteProfileId();
                var request = new RestRequest();
                request.RequestFinished += (object sender, RequestEndedArgs e) => {
                    RunOnUiThread(delegate {
                        var id = (string)JsonConvert.DeserializeObject(e.Result, typeof(string));
                        Globals.SaveProfileId(id);
                        StartActivity(main);
                    });
                };
                request.Send(RequestConfig.Login, "POST", new LoginModel {
                    Email = email.Text.Trim(), Password = password.Text.Trim(), RememberMe = true
                });
            };

            Button forgotPass         = FindViewById <Button> (Resource.Id.forgotPassButton);
            var    forgotPassActivity = new Intent(this, typeof(ForgotPassActivity));

            forgotPass.Click += delegate {
                StartActivity(forgotPassActivity);
            };
        }
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            SetContentView(Resource.Layout.TodayLiveScore);
            Console.WriteLine("TodayLiveScoreActivity");

            this.root = true;

            var heading = FindViewById <TextView>(Resource.Id.Heading);

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

            title.Text = "Livescore";

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

            logo.Visibility = ViewStates.Invisible;

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

            menu.Visibility = ViewStates.Invisible;

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

            back.Visibility = ViewStates.Invisible;

            listView = FindViewById <ListView>(Resource.Id.ListLiveScoreToday);            // get reference to the ListView in the layout
            menuList = FindViewById <ListView> (Resource.Id.MenuList);

            //-------------------------------------------------------------------------------------------------------------------------
            var request = new RestRequest();

            request.RequestFinished += (object sender, RequestEndedArgs e) => {
                var data = (LiveScoreViewModel)JsonConvert.DeserializeObject(e.Result, typeof(LiveScoreViewModel));
                model = data;
                // invoke it on the main thread
                RunOnUiThread(delegate {
                    listView.Adapter = new TodayLiveScoreAdapter(this, model);
                });
            };
            request.Send(string.Format(RequestConfig.LiveScore, currentSport, currentCategory), "GET");
            //-------------------------------------------------------------------------------------------------------------------------*/
            request = new RestRequest();
            request.RequestFinished += (object sender, RequestEndedArgs e) => {
                var data = (List <LiveScoreSportModel>)JsonConvert.DeserializeObject(e.Result, typeof(List <LiveScoreSportModel>));
                sportModels = data;
                // invoke it on the main thread
                RunOnUiThread(delegate {
                    //checkedPosition = new int[sportModel];
                    menuList.Adapter = new MenuListAdapter(this, sportModels, root);
                });
            };
            request.Send(string.Format(RequestConfig.LiveScoreSports), "GET");
            //-------------------------------------------------------------------------------------------------------------------------*/

            menuList.Visibility = ViewStates.Invisible;

            ImageView showPopMenu   = FindViewById <ImageView> (Resource.Id.dropDownContainer);
            bool      isMenuVisible = false;

            showPopMenu.Click += (s, arg) => {
                if (!isMenuVisible)
                {
                    menuList.Visibility = ViewStates.Visible;
                    isMenuVisible       = true;
                }
                else
                {
                    menuList.Visibility = ViewStates.Invisible;
                    isMenuVisible       = false;
                }
            };

            listView.ItemClick += (s, arg) => {
                if (isMenuVisible)
                {
                    menuList.Visibility = ViewStates.Invisible;
                    isMenuVisible       = false;
                }
            };

            RelativeLayout listviewContainer = FindViewById <RelativeLayout> (Resource.Id.ListViewContainer);

            listviewContainer.Clickable = true;
            listviewContainer.Click    += (object sender, EventArgs e) => {
                if (isMenuVisible)
                {
                    menuList.Visibility = ViewStates.Invisible;
                    isMenuVisible       = false;
                }
            };

            RelativeLayout sportContainer = FindViewById <RelativeLayout> (Resource.Id.SportContainer);

            sportContainer.Click += (object sender, EventArgs e) => {
                if (isMenuVisible)
                {
                    menuList.Visibility = ViewStates.Invisible;
                    isMenuVisible       = false;
                }
            };

            menuList.ItemClick += (s, arg) => {                         //	Root is TRUE by default
                if (arg.Position == 0 && !root)                         // When BACK cell is pressed
                //-------------------------------------------------------------------------------------------------------------------------
                {
                    Console.WriteLine("Back");

                    request = new RestRequest();
                    request.RequestFinished += (object sender, RequestEndedArgs e) => {
                        var data = (List <LiveScoreSportModel>)JsonConvert.DeserializeObject(e.Result, typeof(List <LiveScoreSportModel>));
                        sportModels = data;
                        // invoke it on the main thread
                        RunOnUiThread(delegate {
                            //checkedPosition = new int[sportModel];
                            menuList.Adapter = new MenuListAdapter(this, sportModels, true);
                            root             = true;
                        });
                    };
                    request.Send(string.Format(RequestConfig.LiveScoreSports), "GET");
                    //-------------------------------------------------------------------------------------------------------------------------
                    var request2 = new RestRequest();
                    request2.RequestFinished += (object sender, RequestEndedArgs e) => {
                        RunOnUiThread(delegate {
                            var data         = (LiveScoreViewModel)JsonConvert.DeserializeObject(e.Result, typeof(LiveScoreViewModel));
                            listView.Adapter = new TodayLiveScoreAdapter(this, data);
                        });
                    };
                    request2.Send(string.Format(RequestConfig.LiveScore, 0, 0), "GET");
                    heading.Text = "All Sports";

                    //-------------------------------------------------------------------------------------------------------------------------
                }
                else                                                                                                                                                                    // When other cell is pressed

                {
                    var request2 = new RestRequest();

                    if (root)
                    {
                        Console.WriteLine();
                        Console.WriteLine("{0} position in ROOT", arg.Position);
                        Console.WriteLine();                                                                                                                                            // When the other cell is in the root
                        request.RequestFinished += (object sender, RequestEndedArgs e) => {
                            RunOnUiThread(delegate {
                                var data = (List <LiveScoreCategoryModel>)JsonConvert.DeserializeObject(e.Result, typeof(List <LiveScoreCategoryModel>));
                                data.Insert(0, new LiveScoreCategoryModel {
                                    Name = "Back"
                                });

                                menuList.Adapter = new MenuListAdapter(this, data, false);
                                root             = false;
                            });
                        };
                        request.Send(string.Format(RequestConfig.LiveScoreCategories, sportModels[arg.Position].Id), "GET");

                        request2.RequestFinished += (object sender, RequestEndedArgs e) => {
                            RunOnUiThread(delegate {
                                var data = (LiveScoreViewModel)JsonConvert.DeserializeObject(e.Result, typeof(LiveScoreViewModel));
                                //	this.target.Source = new TodayTableSource(data);
                                //this.target.ReloadData();
                                currentSport     = data.CurrentSport.Id;
                                listView.Adapter = new TodayLiveScoreAdapter(this, data);
                            });
                        };
                        request2.Send(string.Format(RequestConfig.LiveScore, sportModels[arg.Position].Id, 0), "GET");
                        heading.Text = sportModels[arg.Position].Name;
                    }
                    else
                    {
                        Console.WriteLine();
                        Console.WriteLine("{0} NOT in ROOT", arg.Position);
                        Console.WriteLine();
                        currentCategory           = arg.Position;                                                                                                                                               // When the other cell is not in the root
                        request2.RequestFinished += (object sender, RequestEndedArgs e) => {
                            RunOnUiThread(delegate {
                                var data = (LiveScoreViewModel)JsonConvert.DeserializeObject(e.Result, typeof(LiveScoreViewModel));
                                //	this.target.Source = new TodayTableSource(data);
                                //this.target.ReloadData();
                                listView.Adapter  = new TodayLiveScoreAdapter(this, data);
                                IParcelable state = menuList.OnSaveInstanceState();
                                menuList.Adapter  = new MenuListAdapter(this, ((MenuListAdapter)menuList.Adapter).Categories, false, arg.Position);
                                menuList.OnRestoreInstanceState(state);
                            });
                        };

                        request2.Send(string.Format(RequestConfig.LiveScore, currentSport, ((MenuListAdapter)menuList.Adapter).IdAt(arg.Position)), "GET");
                    }
                }



                /*
                 * currentSport = arg.Position;
                 * menuList.Adapter = new MenuListAdapter (this, sportModels,currentSport);
                 * Console.WriteLine("{0}",currentSport);
                 * menuList.Visibility= ViewStates.Invisible;
                 *
                 */
            };
        }
Exemplo n.º 30
0
        private void changeNewsCategory(NSIndexPath indexPath)
        {
            var controller = (SlideoutNavigationController)((MainTabController)UIApplication.SharedApplication.Delegate.Window.RootViewController).News;
            var news = (NewsController)controller.TopView;
            var request = new RestRequest ();
            ((NewsController)controller.TopView).Spinner.StartAnimating ();
            //controller.Hide ();

            request.RequestFinished += (object sender, RequestEndedArgs e) => {
                InvokeOnMainThread(delegate {
                    var data = (CategoryModel)JsonConvert.DeserializeObject(e.Result, typeof(CategoryModel));
                    var menuController = (MenuController)((MainTabController)UIApplication.SharedApplication.Delegate.Window.RootViewController).News.MenuViewLeft;

                    // slice the news list into featured and normal articles
                    var featured = (List<NewsModelItem>)data.News;
                    featured = featured.Where(c => !string.IsNullOrEmpty(c.Img)).Take(4).ToList();
                    foreach(var i in featured) {
                        data.News.Remove(i);
                    }

                    // add 'all sports' item to the categories list
                    if(data.CategoryId == 0) {
                        data.Categories.Insert(0, new CategoriesMenuModelItem { Name = "All Sports", Link = 0 });
                    }
                    else {
                        data.Categories.Insert(0, new CategoriesMenuModelItem { Name = "Back" , Link = data.Parent.Link });
                    }

                    news.TableView.Source = new NewsControllerSource(data.News, featured, data.CategoryId);
                    menuController.TableView.Source = new MenuControllerSource(data.Categories, "news");
                    menuController.TableView.ReloadData();
                    news.TableView.ReloadData();
                    try {
                        news.TableView.ScrollToRow(NSIndexPath.FromRowSection(0, 0), UITableViewScrollPosition.Top, false);
                    }
                    catch (Exception) {}
                    news.Spinner.StopAnimating();
                });
            };
            request.Send(string.Format(RequestConfig.News(), categories[indexPath.Row].Link, 0), "GET");
        }
Exemplo n.º 31
0
        private void getData()
        {
            // load the articles and the menu from the server on a background thread
            var request = new RestRequest ();
            request.RequestFinished += (object sender, RequestEndedArgs e) => {
                InvokeOnMainThread(delegate {
                    var data = (CategoryModel)JsonConvert.DeserializeObject(e.Result, typeof(CategoryModel));
                    var menuController = (MenuController)((MainTabController)UIApplication.SharedApplication.Delegate.Window.RootViewController).News.MenuViewLeft;

                    // slice the news list into featured and normal articles
                    var featured = (List<NewsModelItem>)data.News;
                    featured = featured.Where(c => !string.IsNullOrEmpty(c.Img)).Take(4).ToList();
                    foreach(var i in featured) {
                        data.News.Remove(i);
                    }

                    // add 'all sports' item to the categories list
                    if(data.Parent.Link == 0) {
                        data.Categories.Insert(0, new CategoriesMenuModelItem { Name = "All Sports", Link = 0 });
                    }
                    else {
                        data.Categories.Insert(0, new CategoriesMenuModelItem { Name = "Back" , Link = data.Parent.Link });
                    }

                    TableView.Source = new NewsControllerSource(data.News, featured, data.CategoryId);
                    menuController.TableView.Source = new MenuControllerSource(data.Categories, "news");
                    menuController.TableView.ReloadData();
                    TableView.ReloadData();
                    spinner.StopAnimating();
                });
            };
            if (Category.HasValue) {
                request.Send (string.Format(RequestConfig.News(), Category, 0), "GET");
            }
            else {
                request.Send (string.Format(RequestConfig.News(), 0, 0), "GET");
            }
        }
Exemplo n.º 32
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            SetContentView(Resource.Layout.SignUp);
            Console.WriteLine("SignUpActivity");

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

            logo.Visibility = ViewStates.Invisible;

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

            menu.Visibility = ViewStates.Invisible;

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

            title.Text = "Sign Up";

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

            back.Click += delegate {
                Finish();
            };
            // Create your application here

            Button      createAcc  = FindViewById <Button> (Resource.Id.createAccButton);
            Button      choseImage = FindViewById <Button> (Resource.Id.Chose);
            ImageButton facebook   = FindViewById <ImageButton> (Resource.Id.signUpViaFacebook);
            ImageButton twitter    = FindViewById <ImageButton> (Resource.Id.signUpViaTwitter);
            ImageButton googlePlus = FindViewById <ImageButton> (Resource.Id.signUpViaGoogle);
            EditText    firstName  = FindViewById <EditText> (Resource.Id.FirstName);
            EditText    lastName   = FindViewById <EditText> (Resource.Id.LastName);
            EditText    email      = FindViewById <EditText> (Resource.Id.Email);
            EditText    password   = FindViewById <EditText> (Resource.Id.Password);
            var         customize  = new Intent(this, typeof(CustomizingSelectionActivity));

            // Create your application here

            choseImage.Click += delegate {
                var imageIntent = new Intent();
                imageIntent.SetType("image/*");
                imageIntent.SetAction(Intent.ActionGetContent);
                StartActivityForResult(
                    Intent.CreateChooser(imageIntent, "Select photo"), 0);
            };


            /*firstName.KeyPress += (object sender, View.KeyEventArgs e) => {
             *      e.Handled = false;
             *      if (e.Event.Action == KeyEventActions.Down && e.KeyCode == Keycode.Enter) {
             *              Globals.firstName = firstName.Text;
             *
             *              var inputManager = GetSystemService(InputMethodService) as InputMethodManager;
             *              inputManager.HideSoftInputFromWindow(firstName.WindowToken, 0);
             *      }
             * };
             *
             * lastName.KeyPress += (object sender, View.KeyEventArgs e) => {
             *      e.Handled = false;
             *      if (e.Event.Action == KeyEventActions.Down && e.KeyCode == Keycode.Enter) {
             *              Globals.lastName = lastName.Text;
             *
             *              var inputManager = GetSystemService(InputMethodService) as InputMethodManager;
             *              inputManager.HideSoftInputFromWindow(firstName.WindowToken, 0);
             *      }
             * };
             *
             * email.KeyPress += (object sender, View.KeyEventArgs e) => {
             *      e.Handled = false;
             *      if (e.Event.Action == KeyEventActions.Down && e.KeyCode == Keycode.Enter) {
             *              Globals.email = email.Text;
             *              var inputManager = GetSystemService(InputMethodService) as InputMethodManager;
             *              inputManager.HideSoftInputFromWindow(email.WindowToken, 0);
             *      }
             * };
             *
             * password.KeyPress += (object sender, View.KeyEventArgs e) => {
             *      e.Handled = false;
             *      if (e.Event.Action == KeyEventActions.Down && e.KeyCode == Keycode.Enter) {
             *
             *              var inputManager = GetSystemService(InputMethodService) as InputMethodManager;
             *              inputManager.HideSoftInputFromWindow(password.WindowToken, 0);
             *      }
             * };*/
            firstName.TextChanged += (object sender, Android.Text.TextChangedEventArgs e) => {
            };
            lastName.TextChanged  += (object sender, Android.Text.TextChangedEventArgs e) => {
            };
            email.TextChanged     += (object sender, Android.Text.TextChangedEventArgs e) => {
            };
            password.TextChanged  += (object sender, Android.Text.TextChangedEventArgs e) => {
            };

            this.fName = Globals.firstName;
            this.lName = Globals.lastName;


            createAcc.Click += delegate {
                var model = new RegisterModel {
                    Email = email.Text, FirstName = firstName.Text, LastName = lastName.Text, Password = password.Text.Trim()
                };
                var request = new RestRequest();
                request.RequestFinished += (object sender, RequestEndedArgs e) => {
                    var id = (string)JsonConvert.DeserializeObject(e.Result, typeof(string));
                    Globals.SaveProfileId(id);
                    StartActivity(customize);
                };
                request.Send(RequestConfig.Register, "POST", model);
            };

            facebook.Click += delegate {
                Console.WriteLine("Just clicked signup via Facebook");
            };

            twitter.Click += delegate {
                Console.WriteLine("Just clicked signup via Twitter");
            };

            googlePlus.Click += delegate {
                Console.WriteLine("Just clicked login via Google Plus");
            };
        }