Example #1
0
 /// <summary>
 /// Çàêðûòü êëàâèàòóðó
 /// </summary>
 /// <param name="activity"></param>
 /// <param name="view"></param>
 public static void HideKeyboard(MvxActivity activity, View view)
 {
     if (activity != null && view != null)
     {
         var inputMethodManager = (InputMethodManager)activity.GetSystemService(Context.InputMethodService);
         inputMethodManager.HideSoftInputFromWindow(view.WindowToken, 0);
     }
 }
Example #2
0
        public static TFragment FindFragmentByTag <TFragment>(this MvxActivity activity, string tag)
            where TFragment : Fragment
        {
            var fragment = activity.FragmentManager.FindFragmentByTag(tag);

            if (fragment == null)
            {
                MvxLog.Instance.Warn("Failed to find fragment tag {0} in {1}", tag, activity.GetType().Name);
                return(default(TFragment));
            }

            return(SafeCast <TFragment>(fragment));
        }
Example #3
0
        public static TFragment FindFragmentById <TFragment>(this MvxActivity activity, int resourceId)
            where TFragment : Fragment
        {
            var fragment = activity.FragmentManager.FindFragmentById(resourceId);

            if (fragment == null)
            {
                MvxLog.Instance.Warn("Failed to find fragment id {0} in {1}", resourceId, activity.GetType().Name);
                return(default(TFragment));
            }

            return(SafeCast <TFragment>(fragment));
        }
Example #4
0
        public static TFragment FindFragmentByTag <TFragment>(this MvxActivity activity, string tag)
            where TFragment : Fragment
        {
            var fragment = activity.SupportFragmentManager.FindFragmentByTag(tag);

            if (fragment == null)
            {
                MvxLogHost.Default?.Log(LogLevel.Warning,
                                        "Failed to find fragment tag {tag} in {activityTypeName}", tag, activity.GetType().Name);
                return(default(TFragment));
            }

            return(SafeCast <TFragment>(fragment));
        }
Example #5
0
        public static TFragment FindFragmentById <TFragment>(this MvxActivity activity, int resourceId)
            where TFragment : Fragment
        {
            var fragment = activity.SupportFragmentManager.FindFragmentById(resourceId);

            if (fragment == null)
            {
                MvxLogHost.Default?.Log(LogLevel.Warning,
                                        "Failed to find fragment id {resourceId} in {activityTypeName}", resourceId, activity.GetType().Name);
                return(default(TFragment));
            }

            return(SafeCast <TFragment>(fragment));
        }
Example #6
0
 public void Include(MvxActivity act)
 {
     act.Title = act.Title + "";
 }
Example #7
0
        public void OnClick(View v)
        {
            // get activity
            MvxActivity      Activity = GetActivity(v);
            OriginalModeView view     = (OriginalModeView)Activity;

            // get model
            Core.ViewModels.MainViewModel Model = (Core.ViewModels.MainViewModel)view.ViewModel;

            // get current name textview
            TextView tv_currentName = Activity.FindViewById <TextView>(Resource.Id.textView_currentName);

            if (tv_currentName.Text.Equals(Profile.FullName))
            {
                MainView.CorrectGuesses++;
                TextView tv = Activity.FindViewById <TextView>(Resource.Id.tv_correct);
                tv.Text = "Correct: " + MainView.CorrectGuesses;
                tv.RefreshDrawableState();

                view.CurrentProfiles    = Model.PickProfiles(view.Profiles, view.CurrentProfiles.Count);
                view.CurrentProfileName = view.CurrentProfiles[new Random().Next(0, view.CurrentProfiles.Count - 1)].FullName;

                // update listview with profile items
                // get listview
                ListView lv = Activity.FindViewById <ListView>(Resource.Id.listView_Pictures);

                // get current name textview
                lv.Adapter          = new Core.Adapters.NameGameAdapter(view, view.CurrentProfiles);
                tv_currentName.Text = view.CurrentProfileName;
                tv_currentName.RefreshDrawableState();
            }
            else
            {
                MainView.IncorrectGuesses++;
                TextView tv = Activity.FindViewById <TextView>(Resource.Id.tv_incorrect);
                tv.Text = "Incorrect: " + MainView.IncorrectGuesses;
                tv.RefreshDrawableState();

                if (MainView.IncorrectGuesses >= 3)
                {
                    tv_currentName.Text = "Oh no, you're out of guesses!";
                    tv_currentName.RefreshDrawableState();

                    // get listview
                    ListView lv = Activity.FindViewById <ListView>(Resource.Id.listView_Pictures);
                    lv.Visibility = ViewStates.Gone;
                    lv.RefreshDrawableState();

                    // create back button
                    LinearLayout lo   = Activity.FindViewById <LinearLayout>(Resource.Id.llayout_images);
                    Button       back = lo.FindViewById <Button>(Resource.Id.btn_back);
                    back.Click += delegate
                    {
                        // open starting screen
                        view.StartActivityForResult(new Intent(back.Context, typeof(MainView)), 0);
                        view.Finish();
                    };
                    back.Visibility = ViewStates.Visible;
                    back.RefreshDrawableState();

                    return;
                }

                ImageView iv = (ImageView)v;
                iv.SetColorFilter(Android.Graphics.Color.DarkGray, Android.Graphics.PorterDuff.Mode.Multiply);
                iv.RefreshDrawableState();
                iv.SetOnClickListener(null);
            }
        }