protected View CreateConceptView(Concept concept)
        {
            View view;

            var inflater = LayoutInflater.From(Activity.BaseContext);

            if (concept is InputText)
            {
                view = inflater.Inflate(Resource.Layout.InputTextConcept, null);
                if ((concept as InputText).LetterCount > 0)
                {
                    (view as EditText).SetMinEms((concept as InputText).LetterCount);
                }
                else
                {
                    (view as EditText).SetMinEms((concept as InputText).Text.Length - ((concept as InputText).Text.Length / 2));
                }

                if ((concept as InputText).Size > 0)
                {
                    (view as EditText).SetTextSize(Android.Util.ComplexUnitType.Dip, (concept as InputText).Size);
                }
            }
            else if (concept is BaseText)
            {
                var baseText = (concept as BaseText);
                if (baseText.LetterTags != null && baseText.LetterTags.Count > 0)
                {
                    view = ApplyLetterTags(inflater, baseText);
                }
                else
                {
                    view = inflater.Inflate(Resource.Layout.BaseText, null);
                    var tvText = view.FindViewById <TextView>(Resource.Id.tvText);
                    DecorateText(tvText, baseText, new Android.Graphics.Color(
                                     ContextCompat.GetColor(Activity.BaseContext, Resource.Color.neon)),
                                 TextDecorationType.Background);
                    SetTextAlign(tvText, baseText);
                    SetTextColor(tvText, baseText);
                    AdjustTextSize(tvText, baseText);
                }

                if (baseText is ISound && baseText.SoundPath != null)
                {
                    var speakerDecorator = (ViewGroup)inflater.Inflate(Resource.Layout.BaseTextSpeaker, null);
                    speakerDecorator.AddView(view);
                    view = speakerDecorator;
                }

                if (IsTextCardCallback(concept as BaseText))
                {
                    var cardView = (FrameLayout)inflater.Inflate(Resource.Layout.CardConcept, null);

                    if (baseText.Size > 0)
                    {
                        cardView.LayoutParameters = new FrameLayout.LayoutParams(
                            baseText.Size > 0 ? ToPx(baseText.Size) : ViewGroup.LayoutParams.MatchParent,
                            baseText.Size > 0 ? ToPx(baseText.Size) : ViewGroup.LayoutParams.MatchParent);
                    }

                    cardView.AddView(view);
                    view = cardView;
                }
                else
                {
                    if (!baseText.ShowAsPlainText)
                    {
                        var borderedView = (FrameLayout)inflater.Inflate(Resource.Layout.BaseTextBordered, null);
                        borderedView.AddView(view);
                        view = borderedView;
                    }
                }
            }
            else if (concept is Speaker)
            {
                view = inflater.Inflate(Resource.Layout.SpeakerConcept, null);

                if (IsSpeakerCardCallback(concept as Speaker))
                {
                    var cardView = (FrameLayout)inflater.Inflate(Resource.Layout.CardConcept, null);
                    cardView.AddView(view);
                    view = cardView;
                }
                else
                {
                    view.SetBackgroundResource(Resource.Drawable.concept_bordered);
                }
            }
            else if (concept is Picture)
            {
                var picture = concept as Picture;

                view = inflater.Inflate(Resource.Layout.PictureConcept, null);

                if (concept.ActivateOnSuccess || concept.ActivateOnMistake)
                {
                    int defaultSize = (IsSmallHeight() ? 100 : 120);
                    (view as ViewGroup).GetChildAt(0).LayoutParameters = new FrameLayout.LayoutParams(ToPx(defaultSize), ToPx(defaultSize));
                }

                if (picture.Size > 0)
                {
                    (view as ViewGroup).GetChildAt(0).LayoutParameters = new FrameLayout.LayoutParams(
                        picture.Size > 0 ? ToPx(picture.Size) : ViewGroup.LayoutParams.MatchParent,
                        picture.Size > 0 ? ToPx(picture.Size) : ViewGroup.LayoutParams.MatchParent);
                }

                if (!string.IsNullOrEmpty(picture.ImagePath))
                {
                    var bitmap = BitmapLoader.Instance.LoadBitmap(CountPictureItems(), Activity.BaseContext, picture.ImagePath);
                    if (bitmap != null)
                    {
                        var ivPicture = view.FindViewById <ImageView>(Resource.Id.ivPicture);
                        ivPicture.SetImageBitmap(bitmap);
                    }
                }

                if (IsPictureCardCallback(picture))
                {
                    var cardView = (FrameLayout)inflater.Inflate(Resource.Layout.CardConcept, null);
                    cardView.AddView(view);
                    view = cardView;
                }
            }
            else if (concept is Models.Space)
            {
                view = new Android.Widget.Space(Activity.BaseContext);
                view.LayoutParameters = new LinearLayout.LayoutParams(ToPx((concept as Models.Space).Width), ToPx((concept as Models.Space).Height));
            }
            else
            {
                view = inflater.Inflate(Resource.Layout.BaseText, null);
                var tvText = view.FindViewById <TextView>(Resource.Id.tvText);
                tvText.Text = string.Format("Concept type {0} does not exist!", concept.GetType().ToString());
            }

            // Attach concept object to view
            SetTag <Concept>(view, Resource.Id.concept_tag_key, concept);

            // Attach click handler
            view.Click += ConceptView_Click_PlaySound;

            return(view);
        }
Example #2
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();
                }
            }
        }