Exemplo n.º 1
0
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            var parser        = new CompaniesParser();
            var companies     = parser.Companies;
            var layout        = inflater.Inflate(Resource.Layout.CompaniesGrid, container, false);
            var companiesGrid = layout.FindViewById <GridView> (Resource.Id.Companies);

            companiesGrid.Adapter    = new CompaniesAdapter(inflater, companies);
            companiesGrid.ItemClick += (sender, e) => {
                var comp         = companies [e.Position];
                var publications = new PublicationsFragment(false, comp.Id);
                MainActivity.DrawerToggle.DrawerIndicatorEnabled = false;
                FragmentManager.BeginTransaction().Replace(Resource.Id.content_frame, publications).AddToBackStack(null).Commit();
            };
            return(layout);
        }
Exemplo n.º 2
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            RequestWindowFeature(WindowFeatures.IndeterminateProgress);
            SetContentView(Resource.Layout.Navigation);

            if (HasPlayServices)
            {
                GCM   = GoogleCloudMessaging.GetInstance(this);
                RegID = RegistrationId;
                if (String.IsNullOrEmpty(RegID))
                {
                    RegisterInBackground();
                }
                else
                {
                    Console.WriteLine("Seems like we have a RegID");
                }
            }


            cnHelper               = ConnectivityHelper.Instance(this);
            mDrawerLayout          = FindViewById <DrawerLayout> (Resource.Id.drawer_layout);
            mDrawerList            = FindViewById <ListView> (Resource.Id.left_drawer);
            mDrawerList.Adapter    = new DrawerAdapter(this);
            mDrawerList.ItemClick += (sender, e) => {
                switch (e.Position)
                {
                case 0:
                    var publications = new PublicationsFragment(false);
                    FragmentManager.BeginTransaction().Replace(Resource.Id.content_frame, publications).Commit();
                    SetTitle(Resource.String.main_title);
                    mDrawerLayout.CloseDrawer(mDrawerList);
                    break;

                case 1:
                    var companies = new CompaniesFragment();
                    FragmentManager.BeginTransaction().Replace(Resource.Id.content_frame, companies).Commit();
                    SetTitle(Resource.String.companies);
                    mDrawerLayout.CloseDrawer(mDrawerList);
                    break;
                }
            };

            mDrawerLayout.SetDrawerShadow(Resource.Drawable.drawer_shadow, GravityCompat.Start);

            ActionBar.SetDisplayHomeAsUpEnabled(true);
            ActionBar.SetHomeButtonEnabled(true);

            DrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, Resource.Drawable.ic_navigation_drawer, Resource.String.drawer_open, Resource.String.drawer_close);
            mDrawerLayout.SetDrawerListener(DrawerToggle);

            mDrawerLayout.DrawerOpened += delegate {
                ActionBar.SetTitle(Resource.String.menu);
                //mDrawerLayout.
                InvalidateOptionsMenu();
            };
            mDrawerLayout.DrawerClosed += delegate {
                SetTitle(mTitle);
                InvalidateOptionsMenu();
            };

            pubs = new PublicationsFragment();
            FragmentManager.BeginTransaction().Replace(Resource.Id.content_frame, pubs).Commit();
            mDrawerList.SetItemChecked(0, true);
            HandleIntent(Intent);
        }