Exemplo n.º 1
0
        private void MenuItemClicked(int menuId)
        {
            Android.Support.V4.App.Fragment fragment = null;
            switch (menuId)
            {
            case Resource.Id.nav_home:
                fragment = CalendarFragment.NewInstance();
                break;

            case Resource.Id.nav_SaftyMonitoring:
            {
                fragment = SafetyMonitoringFragment.NewInstance();
            }
            break;

            case Resource.Id.nav_visits:
            {
                var intent = new Intent(this, typeof(MyShiftActivity));

                StartActivity(intent);
                Finish();
                return;
            }
            }
            if (fragment != null)
            {
                SupportFragmentManager.BeginTransaction()
                .Replace(Droid.Resource.Id.content_frame, fragment)
                .Commit();
            }
        }
Exemplo n.º 2
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            SetTheme(Resource.Style.MyTheme);

            base.OnCreate(savedInstanceState);

            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Main);

            //Toolbar takes on default actionbar characteristics
            var toolbar = FindViewById <SupportToolbar>(Resource.Id.toolbar);

            SetSupportActionBar(toolbar);

            //left menu
            drawerLayout = FindViewById <DrawerLayout>(Resource.Id.drawer_layout);
            drawerToggle = new ActionBarDrawerToggle(this, drawerLayout, toolbar, Resource.String.openDrawer, Resource.String.closeDrawer);
            drawerLayout.AddDrawerListener(drawerToggle);
            drawerToggle.SyncState();
            navigationView = FindViewById <NavigationView>(Resource.Id.nav_view);
            navigationView.SetNavigationItemSelectedListener(this);

            //fragments
            addReminderFragment      = new AddReminderFragment();
            reminderListFragment     = new ListRemindersFragment();
            historyListFragment      = new ListHistoryFragment();
            calendarFragment         = new CalendarFragment();
            addMeasurementFragment   = new AddMeasurementFragment();
            measurementsListFragment = new ListMeasurementsFragment();

            var trans = FragmentManager.BeginTransaction();

            //check if notification opened the app
            string notification = Intent.GetStringExtra("notification");

            if (notification == "measurement")
            {
                Bundle bundle = new Bundle();
                bundle.PutInt("id", Intent.GetIntExtra("id", 0));
                bundle.PutInt("type", Intent.GetIntExtra("type", 0));
                addMeasurementFragment.Arguments = bundle;
                ReplaceFragment(addMeasurementFragment);
            }
            else if (notification == "visit" || notification == "medicine")
            {
                EventFromNotificationFragment eventFragment = new EventFromNotificationFragment();
                Bundle bundle = new Bundle();
                bundle.PutInt("id", Intent.GetIntExtra("id", 0));
                eventFragment.Arguments = bundle;
                ReplaceFragment(eventFragment);
            }
            else
            {
                trans.Add(Resource.Id.fragmentContainer, reminderListFragment);
                trans.Commit();
            }
        }
Exemplo n.º 3
0
        public override Android.Support.V4.App.Fragment GetItem(int position)
        {
            switch (position)
            {
            case 0: return(CalendarFragment.NewInstance());

            case 1: return(SafetyMonitoringFragment.NewInstance());
            }
            return(null);
        }
        // Replace the contents of a view (invoked by the layout manager)
        public override void OnBindViewHolder(RecyclerView.ViewHolder viewHolder, int position)
        {
            CalendarFragment calendar = new CalendarFragment();

            var holder = viewHolder as WorkoutDatabaseAdapterViewHolder;

            if (Items[position].Date == CalendarFragment.selectedDay)
            {
                holder.workoutText.Text = Items[position].Workouts;
                holder.repText.Text     = Items[position].Rep;
            }
            else
            {
                holder.workoutLayout.LayoutParameters.Height = 0;
            }
        }
Exemplo n.º 5
0
        private Fragment getCachedFragment(int itemId)
        {
            if (fragments.TryGetValue(itemId, out var fragment))
            {
                return(fragment);
            }

            switch (itemId)
            {
            case Resource.Id.MainTabTimerItem:
                fragment = new MainFragment {
                    ViewModel = getTabViewModel <MainViewModel>()
                };
                break;

            case Resource.Id.MainTabReportsItem:
                fragment = new ReportsFragment {
                    ViewModel = getTabViewModel <ReportsViewModel>()
                };
                break;

            case Resource.Id.MainTabCalendarItem:
                fragment = new CalendarFragment {
                    ViewModel = getTabViewModel <CalendarViewModel>()
                };
                break;

            case Resource.Id.MainTabSettinsItem:
                fragment = new SettingsFragment {
                    ViewModel = getTabViewModel <SettingsViewModel>()
                };
                break;

            default:
                throw new ArgumentException($"Unexpected item id {itemId}");
            }
            fragments[itemId] = fragment;
            return(fragment);
        }
Exemplo n.º 6
0
        private Fragment getCachedFragment(int itemId)
        {
            if (fragments.TryGetValue(itemId, out var fragment))
            {
                return(fragment);
            }

            switch (itemId)
            {
            case Resource.Id.MainTabTimerItem:
                var mainFragment = new MainFragment();
                mainFragment.ViewModel = ViewModel.Tabs[0] as MainViewModel;
                fragment = mainFragment;
                break;

            case Resource.Id.MainTabReportsItem:
                var reportsFragment = new ReportsFragment();
                reportsFragment.ViewModel = ViewModel.Tabs[1] as ReportsViewModel;
                fragment = reportsFragment;
                break;

            case Resource.Id.MainTabCalendarItem:
                var calendarFragment = new CalendarFragment();
                calendarFragment.ViewModel = ViewModel.Tabs[2] as CalendarViewModel;
                fragment = calendarFragment;
                break;

            case Resource.Id.MainTabSettinsItem:
                var settingsFragment = new SettingsFragment();
                settingsFragment.ViewModel = ViewModel.Tabs[3] as SettingsViewModel;
                fragment = settingsFragment;
                break;

            default:
                throw new ArgumentException($"Unexpected item id {itemId}");
            }
            fragments[itemId] = fragment;
            return(fragment);
        }
Exemplo n.º 7
0
        private void ListItemClicked(int position)
        {
            //this way we don't load twice, but you might want to modify this a bit.
            if (position == _oldPosition)
            {
                return;
            }

            _oldPosition = position;

            Android.Support.V4.App.Fragment fragment = null;
            switch (position)
            {
            case 0:
                fragment = CalendarFragment.NewInstance();
                fragment.OnAttach(ApplicationContext);
                break;

            case 1:
                fragment = new NewsListFragment();
                fragment.OnAttach(ApplicationContext);
                break;

            case 2:
                fragment = new MemberListFragment();
                fragment.OnAttach(ApplicationContext);
                break;
            }

            if (fragment != null)
            {
                var layout = FindViewById <RelativeLayout>(Resource.Id.content_frame_wrapper);
                layout.SetPadding(_currentPadding[0], _currentPadding[1], _currentPadding[2], _currentPadding[3]);

                SupportFragmentManager.BeginTransaction()
                .Replace(Resource.Id.content_frame, fragment).AddToBackStack("tag")
                .Commit();
            }
        }
Exemplo n.º 8
0
        void setupDrawerContent(NavigationView navigationView)
        {
            navigationView.NavigationItemSelected += (sender, e) =>
            {
                e.MenuItem.SetChecked(true);
                Android.App.FragmentTransaction transaction1 = this.FragmentManager.BeginTransaction();
                switch (e.MenuItem.ItemId)
                {
                case Resource.Id.navmain:
                    HomeFragment home = new HomeFragment();
                    transaction1.Replace(Resource.Id.framelayout, home).AddToBackStack(null).Commit();
                    break;

                case Resource.Id.navlist:
                    ProductFragment products = new ProductFragment();
                    transaction1.Replace(Resource.Id.framelayout, products).AddToBackStack(null).Commit();
                    break;

                case Resource.Id.navmap:
                    MapsFragment maps = new MapsFragment();
                    transaction1.Replace(Resource.Id.framelayout, maps).AddToBackStack(null).Commit();
                    break;

                case Resource.Id.navprice:
                    ExchangeRateFragment exchange = new ExchangeRateFragment();
                    transaction1.Replace(Resource.Id.framelayout, exchange).AddToBackStack(null).Commit();
                    break;

                case Resource.Id.navcalendar:
                    CalendarFragment calendar = new CalendarFragment();
                    transaction1.Replace(Resource.Id.framelayout, calendar).AddToBackStack(null).Commit();
                    break;
                }
                drawerLayout.CloseDrawers();
            };
        }
Exemplo n.º 9
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.main);

            RequestedOrientation = ScreenOrientation.Portrait;

            UserDialogs.Init(this);

            _application = ApplicationContext as MyApplication;

            var toolbar = FindViewById <Android.Support.V7.Widget.Toolbar>(Resource.Id.toolbar);

            if (toolbar != null)
            {
                SetSupportActionBar(toolbar);
                SupportActionBar.SetDisplayHomeAsUpEnabled(true);
                SupportActionBar.SetHomeButtonEnabled(true);
            }

            _drawerLayout = FindViewById <DrawerLayout>(Resource.Id.drawer_layout);

            //Set hamburger items menu
            SupportActionBar.SetHomeAsUpIndicator(Resource.Drawable.ic_menu);

            //setup navigation view
            _navigationView = FindViewById <NavigationView>(Resource.Id.nav_view);
            var view = _navigationView.GetHeaderView(0);

            var usernameTextView = view.FindViewById <TextView>(Resource.Id.nav_header_username);

            usernameTextView.Text = _application.CurrentUser.Username;

            var nameTextView = view.FindViewById <TextView>(Resource.Id.nav_header_name);

            nameTextView.Text = _application.CurrentUser.Firstname + " " + _application.CurrentUser.Lastname;

            var emailTextView = view.FindViewById <TextView>(Resource.Id.nav_header_email);

            emailTextView.Text = _application.CurrentUser.Email;

            var changeTeamTextView = _navigationView.FindViewById <TextView>(Resource.Id.nav_footer_item_change_team);

            changeTeamTextView.Click += ChangeTeam;

            var logoutTextView = _navigationView.FindViewById <TextView>(Resource.Id.nav_footer_item_logout);

            logoutTextView.Click += Logout;

            var layout = FindViewById <RelativeLayout>(Resource.Id.content_frame_wrapper);

            _currentPadding[0] = layout.PaddingLeft;
            _currentPadding[1] = layout.PaddingTop;
            _currentPadding[2] = layout.PaddingRight;
            _currentPadding[3] = layout.PaddingBottom;

            //handle navigation
            _navigationView.NavigationItemSelected += (sender, e) =>
            {
                _previousItem?.SetChecked(false);

                _navigationView.SetCheckedItem(e.MenuItem.ItemId);

                _previousItem = e.MenuItem;

                switch (e.MenuItem.ItemId)
                {
                case Resource.Id.nav_calendar:
                    ListItemClicked(0);
                    break;

                case Resource.Id.nav_news:
                    ListItemClicked(1);
                    break;

                case Resource.Id.nav_member_list:
                    ListItemClicked(2);
                    break;
                }

                _drawerLayout.CloseDrawers();
            };


            //if first time you will want to go ahead and click first item.
            if (savedInstanceState == null)
            {
                _navigationView.SetCheckedItem(Resource.Id.nav_calendar);
                var fragment = CalendarFragment.NewInstance();
                fragment.OnAttach(ApplicationContext);

                SupportFragmentManager.BeginTransaction()
                .Replace(Resource.Id.content_frame, fragment)
                .Commit();
            }
        }
Exemplo n.º 10
0
        private void ShowScreen(int groupPosition, int childPosition)
        {
            Intent intent = null;

            Android.Support.V4.App.Fragment fragment = null;
            ToogleDrawer();
            switch (groupPosition)
            {
            // For Mail
            case 0:
                switch (childPosition)
                {
                case 0:
                    fragment = InboxFragment.GetInstance(
                        WebserviceConstants.INBOX_EMAIL_TYPE_ID,
                        GetString(Resource.String.inbox_title));
                    AddFrament(fragment, false);
                    break;

                case 1:
                    fragment = InboxFragment.GetInstance(
                        WebserviceConstants.DRAFT_EMAIL_TYPE_ID,
                        GetString(Resource.String.draft_title));
                    AddFrament(fragment, false);
                    break;

                case 2:
                    fragment = InboxFragment.GetInstance(
                        WebserviceConstants.SENT_EMAIL_TYPE_ID,
                        GetString(Resource.String.sent_title));
                    AddFrament(fragment, false);
                    break;

                case 3:
                    fragment = InboxFragment.GetInstance(
                        WebserviceConstants.TRASH_EMAIL_TYPE_ID,
                        GetString(Resource.String.trash_title));
                    AddFrament(fragment, false);
                    break;
                }
                break;

            // For Calendar
            case 1:
                switch (childPosition)
                {
                //For Calendar Event Detail Screen
                case 0:
                    fragment = CalendarFragment.GetInstance();
                    AddFrament(fragment, false);
                    break;

                //For Add Event Screen
                case 1:
                    intent = new Intent(mActivity, typeof(AddCalendarEventActivity));
                    intent.PutExtra("isAddEvent", true);
                    StartActivityForResult(intent, ConstantsDroid.ADD_CALENDAR_EVENT_REQUEST_CODE);
                    OverridePendingTransition(Resource.Animation.animation_enter,
                                              Resource.Animation.animation_leave);
                    break;
                }
                break;

            //For Order
            case 2:
                switch (childPosition)
                {
                //For Order list Screen
                case 0:
                    fragment = OrderListFragment.GetInstance();
                    AddFrament(fragment, false);
                    break;

                //For Order list Screen
                case 1:
                    fragment = OrderListFragment.GetInstance();
                    AddFrament(fragment, false);
                    break;

                //For Add Order Screen
                case 2:
                    intent = new Intent(mActivity, typeof(AddOrderFirstActivity));
                    StartActivityForResult(intent, ConstantsDroid.ADD_ORDER_REQUEST_CODE);
                    OverridePendingTransition(Resource.Animation.animation_enter,
                                              Resource.Animation.animation_leave);
                    break;

                //For Order list Screen
                case 3:
                    fragment = OrderListFragment.GetInstance();
                    AddFrament(fragment, false);
                    break;

                //For Order list Screen
                case 4:
                    fragment = OrderListFragment.GetInstance();
                    AddFrament(fragment, false);
                    break;
                }
                break;

            // For Notes
            case 3:
                switch (childPosition)
                {
                //For Notes list Screen
                case 0:
                    fragment = NotesListFragment.GetInstance();
                    AddFrament(fragment, false);
                    break;

                //For Notes list Screen
                case 1:
                    fragment = NotesListFragment.GetInstance();
                    AddFrament(fragment, false);

                    break;

                //For Add Notes Screen
                case 2:
                    // Show Add Notes screen
                    intent = new Intent(mActivity, typeof(AddNotesActivity));
                    intent.PutExtra("isAddNote", true);
                    StartActivityForResult(intent, ConstantsDroid.ADD_NOTES_REQUEST_CODE);
                    OverridePendingTransition(Resource.Animation.animation_enter,
                                              Resource.Animation.animation_leave);
                    break;
                    ////For Notes list Screen
                    //case 3:
                    //    fragment = NotesListFragment.GetInstance();
                    //    AddFrament(fragment, false);

                    //    break;
                }
                break;
            }


            //mAdapter.SetSelectedPosition(position);
        }
Exemplo n.º 11
0
        //Switch для обработки выбора пунктов Navigation Drawer
        private void SelectItem(int position)
        {
            switch (position)
            {
            //Мероприятия
            case 0:
            {
                if (fragments[position] == null)
                {
                    var fragment = new EventsListFragment();
                    fragments[position] = fragment;
                    //_lastFragment = fragment;
                    var arguments = new Bundle();
                    arguments.PutString(EventsListFragment.Account, "Emeri"); arguments.PutString(EventsListFragment.Password, "Emeri");
                    fragment.Arguments = arguments;
                    FragmentManager.BeginTransaction()
                    .Replace(Resource.Id.content_frame, fragment, "eventfragment")
                    .AddToBackStack("eventfragment")
                    .SetTransition(FragmentTransit.FragmentFade).Commit();
                }
                else if (fragments[position].IsVisible)
                {
                }
                else
                {
                    //var xyz = fragments[position].Tag;
                    var fragmentTag = Resources.GetStringArray(Resource.Array.FragmentTagMenuArray)[position];
                    ChangeFragment(fragmentTag, position);
                }

                break;
            }

            //Календарь
            case 1:
            {
                if (fragments[position] == null)
                {
                    var fragment = new CalendarFragment();
                    fragments[position] = fragment;
                    var fragmentTag = Resources.GetStringArray(Resource.Array.FragmentTagMenuArray)[position];
                    ChangeFragment(fragmentTag, position);
                }
                else if (fragments[position].IsVisible)
                {
                }
                else
                {
                    //var xyz = fragments[position].Tag;
                    var fragmentTag = Resources.GetStringArray(Resource.Array.FragmentTagMenuArray)[position];
                    ChangeFragment(fragmentTag, position);
                }

                break;
            }

            //Мои события
            case 2:
            {
                if (fragments[position] == null)
                {
                    var fragment = new MyEventsFragment();
                    fragments[position] = fragment;
                    var fragmentTag = Resources.GetStringArray(Resource.Array.FragmentTagMenuArray)[position];
                    ChangeFragment(fragmentTag, position);
                }
                else if (fragments[position].IsVisible)
                {
                }
                else
                {
                    //var xyz = fragments[position].Tag;
                    var fragmentTag = Resources.GetStringArray(Resource.Array.FragmentTagMenuArray)[position];
                    ChangeFragment(fragmentTag, position);
                }

                break;
            }

            //Фильтрация
            case 3:
            {
                if (fragments[position] == null)
                {
                    var fragment = new FiltrationFragment();
                    fragments[position] = fragment;
                    var fragmentTag = Resources.GetStringArray(Resource.Array.FragmentTagMenuArray)[position];
                    ChangeFragment(fragmentTag, position);
                }
                else if (fragments[position].IsVisible)
                {
                }
                else
                {
                    //var xyz = fragments[position].Tag;
                    var fragmentTag = Resources.GetStringArray(Resource.Array.FragmentTagMenuArray)[position];
                    ChangeFragment(fragmentTag, position);
                }

                break;
            }

            //Профиль
            case 4:
            {
                if (fragments[position] == null)
                {
                    var fragment = new ProfileFragment();
                    fragments[position] = fragment;
                    var fragmentTag = Resources.GetStringArray(Resource.Array.FragmentTagMenuArray)[position];
                    ChangeFragment(fragmentTag, position);
                }
                else if (fragments[position].IsVisible)
                {
                }
                else
                {
                    //var xyz = fragments[position].Tag;
                    var fragmentTag = Resources.GetStringArray(Resource.Array.FragmentTagMenuArray)[position];
                    ChangeFragment(fragmentTag, position);
                }

                break;
            }

            default:
                break;
            }

            _drawerList.SetItemChecked(position, true);
            //ActionBar.Title = _title = _menuTitles[position];
            _title = _menuTitles[position];
            _drawer.CloseDrawer(_drawerList);
        }