protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); Xamarin.Essentials.Platform.Init(this, savedInstanceState); SetContentView(Resource.Layout.activity_main); newTaskFragment = new NewTaskFragment(this); historyFragment = new HistoryFragment(this); donationFragment = new DonationFragment(); preferenceFragment = new PreferenceFragment(this); toolbar = FindViewById <Android.Support.V7.Widget.Toolbar>(Resource.Id.mainToolBar); SetSupportActionBar(toolbar); navigation = FindViewById <Google.Android.Material.BottomNavigation.BottomNavigationView>(Resource.Id.navigation); navigation.SetOnNavigationItemSelectedListener(this); ChangeFragment(newTaskFragment); MobileAds.Initialize(this); if (!ExtractRAdManager.UserHasDonated(this)) { interstitialAd = ExtractRAdManager.LoadAdInBackground(this); } if (AppCompatDelegate.DefaultNightMode == AppCompatDelegate.ModeNightYes) { navigation.ItemIconTintList = Android.Content.Res.ColorStateList.ValueOf(Android.Graphics.Color.GhostWhite); navigation.ItemTextColor = Android.Content.Res.ColorStateList.ValueOf(Android.Graphics.Color.GhostWhite); } else if (AppCompatDelegate.DefaultNightMode == AppCompatDelegate.ModeNightNo) { string accentColorString = "#" + GetColor(Resource.Color.colorAccent).ToString("X"); Android.Graphics.Color accentColor = Android.Graphics.Color.ParseColor(accentColorString); navigation.ItemIconTintList = Android.Content.Res.ColorStateList.ValueOf(accentColor); navigation.ItemTextColor = Android.Content.Res.ColorStateList.ValueOf(accentColor); } }
/// <summary> /// Sets the child fragment for when each navigation item is selected /// </summary> private void SetFrameFragment(int index) { assignment = assignmentViewModel.SelectedAssignment; //var transaction = FragmentManager.BeginTransaction (); var screen = Constants.Navigation [index]; switch (screen) { case "Summary": { var fragment = new SummaryFragment(); fragment.Assignment = assignment; // transaction.SetTransition (FragmentTransit.FragmentOpen); // transaction.Replace (Resource.Id.contentFrame, fragment); // transaction.Commit (); items.Visibility = addItems.Visibility = ViewStates.Invisible; addExpense.Visibility = addLabor.Visibility = ViewStates.Gone; } break; case "Map": { var fragment = new MapFragment(); // transaction.SetTransition (FragmentTransit.FragmentOpen); // transaction.Replace (Resource.Id.contentFrame, fragment); // transaction.Commit (); items.Visibility = addItems.Visibility = ViewStates.Invisible; addExpense.Visibility = addLabor.Visibility = ViewStates.Gone; } break; case "Items": { var fragment = new ItemFragment(); fragment.Assignment = assignment; itemViewModel.LoadAssignmentItemsAsync(assignment).ContinueWith(_ => { RunOnUiThread(() => { fragment.AssignmentItems = itemViewModel.AssignmentItems; // transaction.SetTransition (FragmentTransit.FragmentOpen); // transaction.Replace (Resource.Id.contentFrame, fragment); // transaction.Commit (); items.Visibility = addItems.Visibility = ViewStates.Visible; addExpense.Visibility = addLabor.Visibility = ViewStates.Gone; items.Text = string.Format("({0}) Items", assignment.TotalItems.ToString()); }); }); } break; case "Labor Hours": { var fragment = new LaborHourFragment(); laborViewModel.LoadLaborHoursAsync(assignment).ContinueWith(_ => { RunOnUiThread(() => { fragment.LaborHours = laborViewModel.LaborHours; fragment.Assignment = assignment; // transaction.SetTransition (FragmentTransit.FragmentOpen); // transaction.Replace (Resource.Id.contentFrame, fragment); // transaction.Commit (); addLabor.Visibility = items.Visibility = ViewStates.Visible; addExpense.Visibility = addItems.Visibility = ViewStates.Gone; items.Text = string.Format("{0} hrs", assignment.TotalHours.TotalHours.ToString("0.0")); }); }); } break; case "Confirmations": { var fragment = new ConfirmationFragment(); photoViewModel.LoadPhotosAsync(assignment).ContinueWith(_ => { RunOnUiThread(() => { fragment.Photos = photoViewModel.Photos; fragment.Assignment = assignment; // transaction.SetTransition (FragmentTransit.FragmentOpen); // transaction.Replace (Resource.Id.contentFrame, fragment); // transaction.Commit (); addLabor.Visibility = items.Visibility = ViewStates.Invisible; addExpense.Visibility = addItems.Visibility = ViewStates.Gone; }); }); } break; case "Expenses": { var fragment = new ExpenseFragment(); expenseViewModel.LoadExpensesAsync(assignment).ContinueWith(_ => { RunOnUiThread(() => { fragment.Expenses = expenseViewModel.Expenses; fragment.Assignment = assignment; // transaction.SetTransition (FragmentTransit.FragmentOpen); // transaction.Replace (Resource.Id.contentFrame, fragment); // transaction.Commit (); addLabor.Visibility = addItems.Visibility = ViewStates.Gone; items.Visibility = addExpense.Visibility = ViewStates.Visible; items.Text = assignment.TotalExpenses.ToString("$0.00"); }); }); } break; case "Documents": { var fragment = new DocumentFragment(); documentViewModel.LoadDocumentsAsync().ContinueWith(_ => { RunOnUiThread(() => { fragment.Documents = documentViewModel.Documents; // transaction.SetTransition (FragmentTransit.FragmentOpen); // transaction.Replace (Resource.Id.contentFrame, fragment); // transaction.Commit (); items.Visibility = addItems.Visibility = ViewStates.Invisible; addExpense.Visibility = addLabor.Visibility = ViewStates.Gone; }); }); } break; case "History": { var fragment = new HistoryFragment(); historyViewModel.LoadHistoryAsync(assignment).ContinueWith(_ => { RunOnUiThread(() => { fragment.History = historyViewModel.History; fragment.Assignment = assignment; // transaction.SetTransition (FragmentTransit.FragmentOpen); // transaction.Replace (Resource.Id.contentFrame, fragment); // transaction.Commit (); items.Visibility = addItems.Visibility = ViewStates.Invisible; addExpense.Visibility = addLabor.Visibility = ViewStates.Gone; }); }); } break; default: break; } }
protected override async void OnCreate(Bundle bundle) { base.OnCreate(bundle); // TODO: Remove on prod? Or put in Application class? AndroidEnvironment.UnhandledExceptionRaiser += (sender, e) => { Console.WriteLine(e.Exception.Message); Console.WriteLine(e.Exception.StackTrace); }; SetContentView(Resource.Layout.Main); var toolbar = FindViewById <Android.Support.V7.Widget.Toolbar>(Resource.Id.MainToolbar); var drawerLayout = FindViewById <Android.Support.V4.Widget.DrawerLayout>(Resource.Id.MainDrawerLayout); SetSupportActionBar(toolbar); SupportActionBar.Title = "Quick Check In"; SupportActionBar.SetDisplayShowHomeEnabled(true); SupportActionBar.SetDisplayHomeAsUpEnabled(true); drawerToggle = new ActionBarDrawerToggle(this, drawerLayout, Resource.String.OpenDrawer, Resource.String.CloseDrawer); drawerToggle.DrawerIndicatorEnabled = true; drawerLayout.AddDrawerListener(drawerToggle); drawerToggle.SyncState(); var drawerListView = FindViewById <ListView>(Resource.Id.DrawerListView); string[] items = { "On Deck", "Trending", "Lists", "History" }; drawerListView.Adapter = new ArrayAdapter <String>(this, Android.Resource.Layout.SimpleListItem1, items); drawerListView.ItemClick += (sender, e) => { Android.Support.V4.App.Fragment fragment = null; // TODO: Improve, don't rely on indices switch (e.Position) { case 0: // On Deck fragment = new OnDeckFragment(); break; case 1: // Trending // TODO: Add TrendingFragment break; case 2: // Lists fragment = new ListOverviewFragment(); break; case 3: // History fragment = new HistoryFragment(); break; } if (fragment != null) { var drawerTransaction = SupportFragmentManager.BeginTransaction(); drawerTransaction.Replace(Resource.Id.MainFrameLayout, fragment); drawerTransaction.AddToBackStack(null); // Name? drawerTransaction.Commit(); drawerLayout.CloseDrawer(FindViewById <LinearLayout>(Resource.Id.DrawerChildLayout)); // Parameter richtig? } }; client = TraktApiHelper.Client; if (!client.Authorization.IsValid || (client.Authorization.IsValid && client.Authorization.IsExpired)) { if (client.Authorization.IsRefreshPossible) { var traktAuthorization = await client.OAuth.RefreshAuthorizationAsync(); TraktApiHelper.SaveAuthorization(traktAuthorization); } else { Intent authorizationIntent = new Intent(this, typeof(AuthorizationActivity)); StartActivity(authorizationIntent); } } var logoutTextView = FindViewById <TextView>(Resource.Id.LogoutTextView); logoutTextView.Click += (sender, e) => { if (client.Authorization == null || !client.Authorization.IsValid) { Intent authorizationIntent = new Intent(this, typeof(AuthorizationActivity)); StartActivity(authorizationIntent); } else { client.Authorization = null; TraktApiHelper.DeleteAuthorization(); logoutTextView.Text = "Login"; var usernameTextView = FindViewById <TextView>(Resource.Id.UsernameTextView); usernameTextView.Visibility = ViewStates.Gone; var currentlyWatchingLayout = FindViewById <LinearLayout>(Resource.Id.CurrentlyWatchingLayout); currentlyWatchingLayout.Visibility = ViewStates.Gone; } }; var transaction = SupportFragmentManager.BeginTransaction(); transaction.Add(Resource.Id.MainFrameLayout, new OnDeckFragment()); transaction.SetTransition((int)FragmentTransit.FragmentOpen); // Do not add this transaction to the back stack because then the app would be empty when the user presses back transaction.Commit(); }
public FileDeletionCallback(string filePath, HistoryFragment historyFragment, List <HistoryViewModel> historyViewModels) { this.filePath = filePath; this.historyFragment = historyFragment; this.historyViewModels = historyViewModels; }