예제 #1
0
        private async Task LoadCF(bool onStart)
        {
            if (onStart == true)
            {
                progressBar.Visibility = ViewStates.Visible;
            }
            var firebase = new FirebaseClient(FirebaseURL);

            var cfItems = await firebase.Child("cfids").OnceAsync <Cfid>();

            foreach (var item in cfItems)
            {
                if (item.Object.cfid == myAttributes.cfid.ToString())
                {
                    myCFName = item.Object.name;
                    break;
                }
            }

            var myCFcompanies = await firebase.Child("careerfairs").Child(myAttributes.cfid.ToString()).OnceAsync <Company>();

            mItems       = new List <string>();
            mFavList     = new List <bool>();
            mWaitTimes   = new List <string>();
            mNumStudents = new List <string>();
            mCompanyIds  = new List <string>();

            foreach (var company in myCFcompanies)
            {
                mCompanyIds.Add(company.Object.companyid);
                mItems.Add(company.Object.name);
                long     totalNumStudents = Convert.ToInt32(company.Object.numstudents);
                long     partialWaitTime  = Convert.ToInt64(company.Object.waittime);
                long     totalWaitTime    = partialWaitTime * totalNumStudents;
                TimeSpan ts       = TimeSpan.FromTicks(totalWaitTime);
                string   waittime = String.Format("{0:00}:{1:00}:{2:00}", ts.Hours, ts.Minutes, ts.Seconds);
                mWaitTimes.Add(waittime);
                mNumStudents.Add(totalNumStudents.ToString());
            }

            string favoritesFileName = "fav_" + myAttributes.cfid.ToString() + "_" + myAttributes.typeid.ToString();
            var    myFavorites       = await firebase.Child("favorites").Child(favoritesFileName).OnceAsync <Favorite>();

            mFavList = new List <bool>();

            foreach (var favorite in myFavorites)
            {
                mFavList.Add(favorite.Object.isFavorite);
            }

            cfName.Text       = myCFName;
            mAdapter          = new CompaniesListViewAdapter(mContainer.Context, mItems, mFavList, mWaitTimes, mNumStudents, mCompanyIds);
            mListView.Adapter = mAdapter;
            if (onStart == true)
            {
                progressBar.Visibility = ViewStates.Invisible;
            }
            magGlass.Enabled    = true;
            magGlass.Visibility = ViewStates.Visible;
        }
예제 #2
0
        private void MSearchField_TextChanged(object sender, Android.Text.TextChangedEventArgs e)
        {
            List <string> searchedCompanies = (from company in mItems
                                               where company.Contains(mSearchField.Text)
                                               select company).ToList <string>();

            int           position            = -1;
            List <string> searchedWaitTimes   = new List <string>();
            List <bool>   searchedFavList     = new List <bool>();
            List <string> searchedNumStudents = new List <string>();
            List <string> searchedCompanyIds  = new List <string>();

            foreach (var item in mItems)
            {
                position = position + 1;
                foreach (var searcheditem in searchedCompanies)
                {
                    if (searcheditem == item)
                    {
                        searchedWaitTimes.Add(mWaitTimes[position]);
                        searchedFavList.Add(mFavList[position]);
                        searchedNumStudents.Add(mNumStudents[position]);
                        searchedCompanyIds.Add(mCompanyIds[position]);
                    }
                }
            }

            mAdapter          = new CompaniesListViewAdapter(mContainer.Context, searchedCompanies, searchedFavList, searchedWaitTimes, searchedNumStudents, searchedCompanyIds);
            mListView.Adapter = mAdapter;
        }
예제 #3
0
        private async void LoadCF()
        {
            progressBar.Visibility = ViewStates.Visible;
            var firebase = new FirebaseClient(FirebaseURL);

            var cfItems = await firebase.Child("cfids").OnceAsync <Cfid>();

            foreach (var item in cfItems)
            {
                if (item.Object.cfid == myAttributes.cfid.ToString())
                {
                    myCFName = item.Object.name;
                    break;
                }
            }

            var myCFcompanies = await firebase.Child(myAttributes.cfid.ToString()).OnceAsync <Company>();

            foreach (var company in myCFcompanies)
            {
                mItems.Add(company.Object.name);
            }

            string favoritesFileName = "fav_" + myAttributes.cfid.ToString() + "_" + myAttributes.loginid.ToString();
            var    myFavorites       = await firebase.Child(favoritesFileName).OnceAsync <Favorite>();

            List <bool> favList = new List <bool>();

            foreach (var favorite in myFavorites)
            {
                favList.Add(favorite.Object.isFavorite);
            }

            cfName.Text = myCFName;
            CompaniesListViewAdapter adapter = new CompaniesListViewAdapter(mContainer.Context, mItems, favList);

            mListView.Adapter      = adapter;
            progressBar.Visibility = ViewStates.Invisible;
        }
예제 #4
0
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            mContainer = container;
            string dbPath_attributes = System.IO.Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal), "attributes.db3");
            var    db_attributes     = new SQLiteConnection(dbPath_attributes);

            myAttributes = db_attributes.Get <MyAttributes>(1);
            int myCFID = myAttributes.cfid;

            if (myCFID == 0) // If not registered for a career fair
            {
                View view = inflater.Inflate(Resource.Layout.GoToRegister, container, false);
                return(view);
            }

            else
            {
                if (myAttributes.type == "Student")
                {
                    // Inflate View
                    View view = inflater.Inflate(Resource.Layout.HomeTab, container, false);

                    // Call UI Elements
                    mListView      = view.FindViewById <ListView>(Resource.Id.listView1);
                    cfName         = view.FindViewById <TextView>(Resource.Id.cfName);
                    progressBar    = view.FindViewById <ProgressBar>(Resource.Id.circularProgress);
                    magGlass       = view.FindViewById <ImageView>(Resource.Id.magGlass);
                    mSearchField   = view.FindViewById <EditText>(Resource.Id.searchCompanies);
                    rootLayout     = view.FindViewById <LinearLayout>(Resource.Id.rootLayout);
                    swipeContainer = view.FindViewById <SwipeRefreshLayout>(Resource.Id.swipeLayout);

                    magGlass.Enabled = false;

                    mItems = new List <string>();

#pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
                    LoadCF(true);
#pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed

                    bool searchFieldVisible = false;
                    magGlass.Click += (sender, e) =>
                    {
                        if (searchFieldVisible == false)
                        {
                            mSearchField.Visibility = ViewStates.Visible;
                            cfName.Visibility       = ViewStates.Invisible;
                            searchFieldVisible      = true;
                            rootLayout.ClearFocus();
                            mSearchField.RequestFocus();
                            InputMethodManager imm = (InputMethodManager)this.Activity.GetSystemService(Context.InputMethodService);
                            imm.ShowSoftInput(mSearchField, 0);
                        }
                        else if (searchFieldVisible == true)
                        {
                            InputMethodManager imm = (InputMethodManager)this.Activity.GetSystemService(Context.InputMethodService);
                            imm.HideSoftInputFromWindow(mSearchField.WindowToken, 0);
                            rootLayout.RequestFocus();
                            mSearchField.Visibility = ViewStates.Invisible;
                            mSearchField.RequestFocus();
                            cfName.Visibility  = ViewStates.Visible;
                            searchFieldVisible = false;
                            mAdapter           = new CompaniesListViewAdapter(mContainer.Context, mItems, mFavList, mWaitTimes, mNumStudents, mCompanyIds);
                            mListView.Adapter  = mAdapter;
                        }
                    };

                    mSearchField.TextChanged += MSearchField_TextChanged;
                    swipeContainer.SetColorSchemeResources(Android.Resource.Color.HoloBlueLight, Android.Resource.Color.HoloGreenLight,
                                                           Android.Resource.Color.HoloOrangeLight, Android.Resource.Color.HoloRedLight);
                    swipeContainer.Refresh += RefreshOnSwipe;

                    return(view);
                }
                else if (myAttributes.type == "Recruiter")
                {
                    View view = inflater.Inflate(Resource.Layout.RecruiterHomeTab, container, false);

                    progressBar = view.FindViewById <ProgressBar>(Resource.Id.circularProgress);

                    HMAllRadio    = view.FindViewById <Button>(Resource.Id.HMAllRadio);
                    HGTAllRadio   = view.FindViewById <Button>(Resource.Id.HGTAllRadio);
                    HGPANoneRadio = view.FindViewById <Button>(Resource.Id.HGPANoneRadio);
                    plus_major    = view.FindViewById <Button>(Resource.Id.plus_majors);
                    hmspinner1    = view.FindViewById <Spinner>(Resource.Id.hmspinner1);
                    hmspinner2    = view.FindViewById <Spinner>(Resource.Id.hmspinner2);
                    hmspinner3    = view.FindViewById <Spinner>(Resource.Id.hmspinner3);
                    hmspinner4    = view.FindViewById <Spinner>(Resource.Id.hmspinner4);
                    hmspinner5    = view.FindViewById <Spinner>(Resource.Id.hmspinner5);
                    minus_major   = view.FindViewById <Button>(Resource.Id.minus_majors);

                    hgtspinner1 = view.FindViewById <Spinner>(Resource.Id.hgtspinner1);
                    hgtspinner2 = view.FindViewById <Spinner>(Resource.Id.hgtspinner2);
                    hgtspinner3 = view.FindViewById <Spinner>(Resource.Id.hgtspinner3);
                    plus_gt     = view.FindViewById <Button>(Resource.Id.plus_gt);
                    minus_gt    = view.FindViewById <Button>(Resource.Id.minus_gradterms);

                    minGPAspinner = view.FindViewById <Spinner>(Resource.Id.minGPAspinner);

                    Button saveChanges = view.FindViewById <Button>(Resource.Id.saveChangesButton);
                    cfName = view.FindViewById <TextView>(Resource.Id.cfName);
                    TextView             HMAllText      = view.FindViewById <TextView>(Resource.Id.HMAllText);
                    TextView             HGTAllText     = view.FindViewById <TextView>(Resource.Id.HGTAllText);
                    TextView             MinGPANoneText = view.FindViewById <TextView>(Resource.Id.MinGPANoneText);
                    Android.Widget.Space plus1extender  = view.FindViewById <Android.Widget.Space>(Resource.Id.plusspace1);
                    Android.Widget.Space plus2extender  = view.FindViewById <Android.Widget.Space>(Resource.Id.plusspace2);

                    // Change name to my CF name
                    PopulateName();

                    // Click methods
                    HMAllRadio.Click     += HMAllRadio_Click;
                    HMAllText.Click      += HMAllRadio_Click;
                    HGTAllRadio.Click    += HGTAllRadio_Click;
                    HGTAllText.Click     += HGTAllRadio_Click;
                    HGPANoneRadio.Click  += HGPANoneRadio_Click;
                    MinGPANoneText.Click += HGPANoneRadio_Click;
                    saveChanges.Click    += SaveChanges_Click;

                    // connect to firebase preferences database
                    PopulatePreferences();

                    // On plus major click
                    plus_major.Click    += Plus_major_Click;
                    plus1extender.Click += Plus_major_Click;

                    // On plus gt click
                    plus_gt.Click       += Plus_gt_Click;
                    plus2extender.Click += Plus_gt_Click;

                    // on minus major click
                    minus_major.Click += (sender, e) =>
                    {
                        numMPs = numMPs - 1;
                        if (numMPs == 1)
                        {
                            hmspinner2.Visibility  = ViewStates.Gone;
                            minus_major.Visibility = ViewStates.Gone;
                        }
                        else if (numMPs == 2)
                        {
                            hmspinner3.Visibility = ViewStates.Gone;
                        }
                        else if (numMPs == 3)
                        {
                            hmspinner4.Visibility = ViewStates.Gone;
                        }
                        else if (numMPs == 4)
                        {
                            hmspinner5.Visibility = ViewStates.Gone;
                        }
                    };
                    // on minus grad term click
                    minus_gt.Click += (sender, e) =>
                    {
                        numGTPs = numGTPs - 1;
                        if (numGTPs == 1)
                        {
                            hgtspinner2.Visibility = ViewStates.Gone;
                            minus_gt.Visibility    = ViewStates.Gone;
                        }
                        else if (numGTPs == 2)
                        {
                            hgtspinner3.Visibility = ViewStates.Gone;
                        }
                    };

                    return(view);
                }
                else
                {
                    throw new NotImplementedException();
                }
            }
        }