private async void PopulateListView() { progressBar.Visibility = ViewStates.Visible; var firebase = new FirebaseClient(FirebaseURL); string fileName_pastQs = "pastqs_" + myAttributes.attribute1; var pastQs = await firebase.Child("pastqs").Child(fileName_pastQs).OnceAsync <PastQ>(); List <int> studentIds = new List <int>(); List <string> studentNames = new List <string>(); List <string> studentRatings = new List <string>(); foreach (var pastq in pastQs) { studentIds.Add(Convert.ToInt32(pastq.Object.studentid)); studentNames.Add(pastq.Object.name); studentRatings.Add(pastq.Object.rating); } PastQueuesListViewAdapter adapter = new PastQueuesListViewAdapter(mContainer.Context, studentIds, "PastQs", studentNames, studentRatings); lv_pastqs.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(); } } }