コード例 #1
0
ファイル: MainTabBarActivity.cs プロジェクト: medvedy/toggl
        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);
        }
コード例 #2
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);
        }
コード例 #3
0
        private void ResetController (ReportsFragment.Controller inst)
        {
            // Remove from parent
            var parent = inst.View.Parent as ViewGroup;
            if (parent != null) {
                parent.RemoveView (inst.View);
            }

            // Reset data
            inst.Data = null;
            inst.SnapPosition = 0;
        }
コード例 #4
0
 private void ShowSyncError (object sender, ReportsFragment.LoadReadyEventArgs args)
 {
     if (LoadReady != null) {
         LoadReady (this, args);
     }
 }
コード例 #5
0
 private void OnLoadReady (object sender, ReportsFragment.LoadReadyEventArgs e)
 {
     ShowSyncError (e.IsError);
 }