private async void PopulateList() { progressBar.Visibility = ViewStates.Visible; var firebase = new FirebaseClient(FirebaseURL); string fileName_pastQs = "pastqs_" + myAttributes.typeid.ToString(); string fileName_favs = "fav_" + myAttributes.cfid.ToString() + "_" + myAttributes.typeid.ToString(); var pastQs = await firebase.Child("pastqs").Child(fileName_pastQs).OnceAsync <StudentQ>(); var myFavs = await firebase.Child("favorites").Child(fileName_favs).OnceAsync <Favorite>(); List <string> companies = new List <string>(); List <bool> favorites = new List <bool>(); List <int> companyIds = new List <int>(); List <string> positionBlank = new List <string>(); List <string> timeBlank = new List <string>(); foreach (var pastq in pastQs) { companies.Add(pastq.Object.company); foreach (var fav in myFavs) { if (fav.Object.name == pastq.Object.company) { favorites.Add(fav.Object.isFavorite); companyIds.Add(Convert.ToInt32(fav.Object.companyid)); } } } QsListViewAdapter adapter = new QsListViewAdapter(mContainer.Context, companies, "PastQs", favorites, companyIds, timeBlank, positionBlank); lv_pastqs.Adapter = adapter; progressBar.Visibility = ViewStates.Invisible; }
private async void PopulateList() { progressBar.Visibility = ViewStates.Visible; string fileName_myQs = "myqs_" + myAttributes.cfid.ToString() + "_" + myAttributes.typeid.ToString(); string fileName_myCareerFair = myAttributes.cfid.ToString(); var firebase = new FirebaseClient(FirebaseURL); var myQs = await firebase.Child("qs").Child(fileName_myQs).OnceAsync <StudentQ>(); var myCareerFair = await firebase.Child("careerfairs").Child(fileName_myCareerFair).OnceAsync <Company>(); if (myQs.Count == 0) { NoQsPresent fragment = new NoQsPresent(); Bundle arguments = new Bundle(); arguments.PutString("Sender", "CurrentQs"); fragment.Arguments = arguments; Android.Support.V4.App.FragmentTransaction trans = FragmentManager.BeginTransaction(); trans.Replace(Resource.Id.qs_root_frame, fragment); trans.Commit(); } List <string> mItems = new List <string>(); List <int> companyIds = new List <int>(); List <string> mPositions = new List <string>(); List <string> mWaitTimes = new List <string>(); List <bool> favs = new List <bool>(); int position = -1; foreach (var q in myQs) { position = position + 1; mItems.Add(q.Object.company); mPositions.Add(q.Object.position); foreach (var company in myCareerFair) { if (company.Object.name == mItems[position]) { long partialWaitTime = Convert.ToInt64(company.Object.waittime); long totalWaitTime = partialWaitTime * (Convert.ToInt32(mPositions[position]) - 1); // -1 because they are already in the line TimeSpan ts = TimeSpan.FromTicks(totalWaitTime); string waittime = String.Format("{0:00}:{1:00}:{2:00}", ts.Hours, ts.Minutes, ts.Seconds); mWaitTimes.Add(waittime); } } } string fileName_favorites = "fav_" + myAttributes.cfid.ToString() + "_" + myAttributes.typeid.ToString(); var myFavs = await firebase.Child("favorites").Child(fileName_favorites).OnceAsync <Favorite>(); for (int i = 0; i <= mItems.Count - 1; i++) { foreach (var fav in myFavs) { if (mItems[i] == fav.Object.name) { favs.Add(fav.Object.isFavorite); companyIds.Add(Convert.ToInt32(fav.Object.companyid)); } } } QsListViewAdapter adapter = new QsListViewAdapter(mContainer.Context, mItems, "CurrentQs", favs, companyIds, mWaitTimes, mPositions); mListView.Adapter = adapter; progressBar.Visibility = ViewStates.Invisible; }
public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { string dbPath_attributes = System.IO.Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal), "attributes.db3"); SQLiteConnection db_attributes = new SQLiteConnection(dbPath_attributes); MyAttributes myAttributes = db_attributes.Get <MyAttributes>(1); string dbPath_login = System.IO.Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal), "user.db3"); SQLiteConnection db_login = new SQLiteConnection(dbPath_login); if (myAttributes.cfid == 0) { view = inflater.Inflate(Resource.Layout.MyQsTab, container, false); ImageView backButton = view.FindViewById <ImageView>(Resource.Id.backButton); backButton.Click += (sender, e) => { Android.Support.V4.App.FragmentTransaction trans = FragmentManager.BeginTransaction(); trans.Replace(Resource.Id.qs_root_frame, new Fragments.CurrentPastQs()); trans.Commit(); }; return(view); } else { if (myAttributes.type == "Recruiter") { string myCompanyPastQsFilename = "pastqs_" + myAttributes.attribute1 + ".db3"; string dbPath_pastqs = System.IO.Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal), myCompanyPastQsFilename); var db_pastqs = new SQLiteConnection(dbPath_pastqs); List <int> studentIDs = new List <int>(); int numpastqs = db_pastqs.Table <SQLite_Tables.PastQueue>().Count(); //Toast.MakeText(this.Activity, numpastqs.ToString(), ToastLength.Short).Show(); //view = inflater.Inflate(Resource.Layout.MyQsTab, container, false); //return view; if (numpastqs == 0) { view = inflater.Inflate(Resource.Layout.MyQsTab, container, false); ImageView backButton = view.FindViewById <ImageView>(Resource.Id.backButton); backButton.Click += (sender, e) => { Android.Support.V4.App.FragmentTransaction trans = FragmentManager.BeginTransaction(); trans.Replace(Resource.Id.qs_root_frame, new Fragments.CurrentPastQs()); trans.Commit(); }; return(view); } else { view = inflater.Inflate(Resource.Layout.PastQs, container, false); ImageView backButton = view.FindViewById <ImageView>(Resource.Id.backButton); backButton.Click += (sender, e) => { Android.Support.V4.App.FragmentTransaction trans = FragmentManager.BeginTransaction(); trans.Replace(Resource.Id.qs_root_frame, new Fragments.CurrentPastQs()); trans.Commit(); }; ListView lv_pastqs = view.FindViewById <ListView>(Resource.Id.pastqslv); for (int i = 1; i <= numpastqs; i++) { int newStudentID = db_pastqs.Get <SQLite_Tables.PastQueue>(i).studentid; studentIDs.Add(newStudentID); } PastQueuesListViewAdapter adapter = new PastQueuesListViewAdapter(container.Context, studentIDs, "PastQs"); lv_pastqs.Adapter = adapter; return(view); } } else if (myAttributes.type == "Student") { string myPastQsFileName = "pastqs_" + myAttributes.loginid.ToString() + ".db3"; string dbPath_myPastQs = System.IO.Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal), myPastQsFileName); SQLiteConnection db_myPastQs = new SQLiteConnection(dbPath_myPastQs); db_myPastQs.CreateTable <SQLite_Tables.MyPastQueue>(); List <string> companies = new List <string>(); int numpastqs = db_myPastQs.Table <SQLite_Tables.MyPastQueue>().Count(); if (numpastqs == 0) { view = inflater.Inflate(Resource.Layout.MyQsTab, container, false); ImageView backButton = view.FindViewById <ImageView>(Resource.Id.backButton); backButton.Click += (sender, e) => { Android.Support.V4.App.FragmentTransaction trans = FragmentManager.BeginTransaction(); trans.Replace(Resource.Id.qs_root_frame, new Fragments.CurrentPastQs()); trans.Commit(); }; return(view); } else { view = inflater.Inflate(Resource.Layout.PastQs, container, false); ImageView backButton = view.FindViewById <ImageView>(Resource.Id.backButton); backButton.Click += (sender, e) => { Android.Support.V4.App.FragmentTransaction trans = FragmentManager.BeginTransaction(); trans.Replace(Resource.Id.qs_root_frame, new Fragments.CurrentPastQs()); trans.Commit(); }; ListView lv_pastqs = view.FindViewById <ListView>(Resource.Id.pastqslv); for (int i = 1; i <= numpastqs; i++) { string newCompany = db_myPastQs.Get <SQLite_Tables.MyPastQueue>(i).company; companies.Add(newCompany); } QsListViewAdapter adapter = new QsListViewAdapter(container.Context, companies, "PastQs"); lv_pastqs.Adapter = adapter; return(view); } } else { throw new NotImplementedException(); } } }