Inheritance: Cirrious.MvvmCross.Droid.FullFragging.Fragments.MvxFragment
示例#1
0
        public static HomeView NewInstance()
        {
            var frag = new HomeView {
                Arguments = new Bundle()
            };

            return(frag);
        }
示例#2
0
		public static HomeView NewInstance()
		{
			var frag = new HomeView { Arguments = new Bundle() };
			return frag;
		}
示例#3
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);


            // Create your application here
            SetContentView(Resource.Layout.RootView);

            if (Settings.USE_RECENT_POSTS)
            {
                CreateViewFor(RecentPostsView.NewInstance(), RootViewModel.Home, Resource.Id.content_frame);
            }
            else
            {
                CreateViewFor(HomeView.NewInstance(), RootViewModel.Home, Resource.Id.content_frame);
            }

            SetBehindContentView(Resource.Layout.menu_frame);

            SlidingMenu.ShadowWidthRes    = Resource.Dimension.shadow_width;
            SlidingMenu.BehindOffsetRes   = Resource.Dimension.slidingmenu_offset;
            SlidingMenu.ShadowDrawableRes = Resource.Drawable.shadow;
            SlidingMenu.FadeDegree        = 0.25f;
            SlidingMenu.TouchModeAbove    = TouchMode.Fullscreen;          //TouchMode.Margin;

            CreateViewFor(MenuView.NewInstance(), RootViewModel.Menu, Resource.Id.menu_frame);

            if (RootViewModel.Home is RecentPostsViewModel)
            {
                ((RecentPostsViewModel)RootViewModel.Home).MenuButtonSelected += (sender, e) => Toggle();
            }
            else
            {
                ((HomeViewModel)RootViewModel.Home).MenuButtonSelected += (sender, e) => Toggle();                //top left menu button
            }

            RootViewModel.Menu.SignoutSelected += (sender, e) => {
                //do something
                Finish();
            };            //close activity
            RootViewModel.Menu.MenuSelected += (sender, e) => {
                Toggle();
                if (Settings.USE_RECENT_POSTS)
                {
                    MenuEventArgs me = (MenuEventArgs)e;
                    if (me.Object is CategoryOptionItem)
                    {
                        ((RecentPostsViewModel)RootViewModel.Home).ClearData();

                        CategoryOptionItem cat = (CategoryOptionItem)me.Object;
                        ((RecentPostsViewModel)RootViewModel.Home).Init(cat.Id, cat.Title);
                        ((RecentPostsViewModel)RootViewModel.Home).RefreshData();
                        ((RecentPostsViewModel)RootViewModel.Home).Title = cat.Title;
                    }
                }
            };

            RootViewModel.Home.ErrorHandler += (sender, e) => {
                ErrorEventArgs ee         = (ErrorEventArgs)e;
                var            dispatcher = Mvx.Resolve <IMvxMainThreadDispatcher> ();
                dispatcher.RequestMainThreadAction(() => {
                    AlertDialog.Builder builder = new AlertDialog.Builder(this);
                    builder.SetTitle(ee.Title);
                    builder.SetMessage(ee.Message);
                    builder.SetNegativeButton(ee.CloseTitle, (EventHandler <DialogClickEventArgs>)null);
                    builder.Show();
                });
            };

            this.StartCalled += (sender, e) => {
                if (FromLogin)
                {
                    FromLogin = false;
                    this.OverridePendingTransition(Resource.Animation.slide_right, Resource.Animation.slide_left);
                }
                else
                {
                    this.OverridePendingTransition(Resource.Animation.slide_left_right, Resource.Animation.slide_right_right);
                }

                CatalogNewsView.FromHome = true;

                if (mLastTime == -1 || SystemClock.CurrentThreadTimeMillis() - mLastTime > Settings.HOME_REFRESH_TIME)
                {
                    System.Diagnostics.Debug.WriteLine("Refresh Home Page");
                    mLastTime = SystemClock.CurrentThreadTimeMillis();
                    RootViewModel.RefreshData();
                }
            };

            CatalogNewsView.FromHome = true;
        }