private async void NextWeekBtn_Click(object sender, EventArgs e) { GetWeekDates getWeekDates = new GetWeekDates(); GetTimetable getTimeTable = new GetTimetable(); ChosenMonday = getWeekDates.GetNextWeek(ChosenMonday); ChosenSunday = getWeekDates.GetSunday(ChosenMonday); list.Visibility = ViewStates.Invisible; loader.Visibility = ViewStates.Visible; var timeTable = await getTimeTable.Pull(string.Format("https://tpt.siseveeb.ee/veebivormid/tunniplaan/tunniplaan?oppegrupp={0}&nadal={1}", ClassNum, ChosenMonday.ToString("dd.MM.yyyy"))); if (timeTable != null) { FullTimeTable = getTimeTable.SortByDay(timeTable); list.Visibility = ViewStates.Visible; loader.Visibility = ViewStates.Invisible; } ClickCurrentDay(crntSelection); week.Text = ChosenMonday.ToString("dd/MM") + " - " + ChosenSunday.ToString("dd/MM"); }
protected override async void OnCreate(Bundle savedInstanceState) { AppCenter.Start("d256fb85-c190-4b81-a6cf-05ac0738a42e", typeof(Analytics), typeof(Crashes), typeof(Distribute)); ClassNum = Preferences.Get("class_num", "226"); base.OnCreate(savedInstanceState); // Set our view from the "main" layout resource SetContentView(Resource.Layout.side_panel); loader = FindViewById <ProgressBar>(Resource.Id.progressBar1); loader.Visibility = Android.Views.ViewStates.Visible; list = FindViewById <ListView>(Resource.Id.listView1); week = FindViewById <TextView>(Resource.Id.textViewWeek); try { GetTimetable getTimeTable = new GetTimetable(); var timeTable = await getTimeTable.Pull("https://tpt.siseveeb.ee/veebivormid/tunniplaan/tunniplaan?oppegrupp=" + ClassNum); FullTimeTable = getTimeTable.SortByDay(timeTable); ClickCurrentDay(); loader.Visibility = Android.Views.ViewStates.Invisible; } catch (System.Net.WebException) { Android.App.AlertDialog.Builder dialog = new Android.App.AlertDialog.Builder(this); Android.App.AlertDialog alert = dialog.Create(); alert.SetTitle("Error"); alert.SetMessage("You have no connection to the internet"); alert.SetButton("Ok", (c, ev) => { this.FinishAffinity(); }); alert.Show(); } GetWeekDates getWeekDates = new GetWeekDates(); ChosenMonday = getWeekDates.GetMonday(DateTime.Now); ChosenSunday = getWeekDates.GetSunday(ChosenMonday); week.Text = ChosenMonday.ToString("dd/MM") + " - " + ChosenSunday.ToString("dd/MM"); var nextWeekBtn = FindViewById <ImageButton>(Resource.Id.nextWeekBtn); var prevWeekBtn = FindViewById <ImageButton>(Resource.Id.prevWeekBtn); var drawer = FindViewById <NavigationView>(Resource.Id.nav_view); var menuButton = FindViewById <ImageButton>(Resource.Id.menuButton); var lang = Resources.Configuration.Locale; menuButton.Click += MenuButton_Click; drawer.NavigationItemSelected += Drawer_NavigationItemSelected; nextWeekBtn.Click += NextWeekBtn_Click; prevWeekBtn.Click += PrevWeekBtn_Click; _gestureListener = new GestureListener(); _gestureListener.LeftEvent += GestureLeft; _gestureListener.RightEvent += GestureRight; _gestureDetector = new GestureDetector(this, _gestureListener); }
private async void Drawer_NavigationItemSelected(object sender, NavigationView.NavigationItemSelectedEventArgs e) { Analytics.TrackEvent(e.MenuItem.TitleFormatted.ToString()); var drawerlayout = FindViewById <DrawerLayout>(Resource.Id.drawer_layout); e.MenuItem.SetChecked(true); switch (e.MenuItem.ItemId) { case Resource.Id.open_github: var uri = Android.Net.Uri.Parse("https://github.com/truberton/UltraAwesomeTPTTimeTable"); var intent = new Intent(Intent.ActionView, uri); StartActivity(intent); return; case Resource.Id.AA17: ClassNum = Resources.GetString(Resource.String.AA17); break; case Resource.Id.AA18: ClassNum = Resources.GetString(Resource.String.AA18); break; case Resource.Id.AV17: ClassNum = Resources.GetString(Resource.String.AV17); break; case Resource.Id.AV18: ClassNum = Resources.GetString(Resource.String.AV18); break; case Resource.Id.EA17: ClassNum = Resources.GetString(Resource.String.EA17); break; case Resource.Id.EA18: ClassNum = Resources.GetString(Resource.String.EA18); break; case Resource.Id.EV17: ClassNum = Resources.GetString(Resource.String.EV17); break; case Resource.Id.EV18: ClassNum = Resources.GetString(Resource.String.EV18); break; case Resource.Id.FS18: ClassNum = Resources.GetString(Resource.String.FS18); break; case Resource.Id.IT16E: ClassNum = Resources.GetString(Resource.String.IT16E); break; case Resource.Id.IT16V: ClassNum = Resources.GetString(Resource.String.IT16V); break; case Resource.Id.IT17E: ClassNum = Resources.GetString(Resource.String.IT17E); break; case Resource.Id.IT17V: ClassNum = Resources.GetString(Resource.String.IT17V); break; case Resource.Id.IT18E: ClassNum = Resources.GetString(Resource.String.IT18E); break; case Resource.Id.IT18V: ClassNum = Resources.GetString(Resource.String.IT18V); break; case Resource.Id.KEV17: ClassNum = Resources.GetString(Resource.String.KEV17); break; case Resource.Id.KIT17V: ClassNum = Resources.GetString(Resource.String.KIT17V); break; case Resource.Id.KIT18E: ClassNum = Resources.GetString(Resource.String.KIT18E); break; case Resource.Id.KK218V: ClassNum = Resources.GetString(Resource.String.KK218V); break; case Resource.Id.KTA17E: ClassNum = Resources.GetString(Resource.String.KTA17E); break; case Resource.Id.MM17: ClassNum = Resources.GetString(Resource.String.MM17); break; case Resource.Id.MM18: ClassNum = Resources.GetString(Resource.String.MM18); break; case Resource.Id.MS18: ClassNum = Resources.GetString(Resource.String.MS18); break; case Resource.Id.SA17: ClassNum = Resources.GetString(Resource.String.SA17); break; case Resource.Id.SA18: ClassNum = Resources.GetString(Resource.String.SA18); break; case Resource.Id.TA16E: ClassNum = Resources.GetString(Resource.String.TA16E); break; case Resource.Id.TA16V: ClassNum = Resources.GetString(Resource.String.TA16V); break; case Resource.Id.TA17E: ClassNum = Resources.GetString(Resource.String.TA17E); break; case Resource.Id.TA17V: ClassNum = Resources.GetString(Resource.String.TA17V); break; case Resource.Id.TA18E: ClassNum = Resources.GetString(Resource.String.TA18E); break; case Resource.Id.TA18V: ClassNum = Resources.GetString(Resource.String.TA18V); break; case Resource.Id.TJ18A: ClassNum = Resources.GetString(Resource.String.TJ18A); break; case Resource.Id.TS18E: ClassNum = Resources.GetString(Resource.String.TS18E); break; case Resource.Id.TS18T: ClassNum = Resources.GetString(Resource.String.TS18T); break; case Resource.Id.TT17E: ClassNum = Resources.GetString(Resource.String.TT17E); break; case Resource.Id.TT17T: ClassNum = Resources.GetString(Resource.String.TT17T); break; case Resource.Id.TT18E: ClassNum = Resources.GetString(Resource.String.TT18E); break; case Resource.Id.TT18T: ClassNum = Resources.GetString(Resource.String.TT18T); break; default: ClassNum = "226"; break; } Preferences.Set("class_num", ClassNum); GetTimetable getTimeTable = new GetTimetable(); list.Visibility = ViewStates.Invisible; loader.Visibility = ViewStates.Visible; var timeTable = await getTimeTable.Pull("https://tpt.siseveeb.ee/veebivormid/tunniplaan/tunniplaan?oppegrupp=" + ClassNum); FullTimeTable = getTimeTable.SortByDay(timeTable); list.Visibility = ViewStates.Visible; loader.Visibility = ViewStates.Invisible; Preferences.Set("class_num", ClassNum); ClickCurrentDay(); drawerlayout.CloseDrawers(); }