Exemplo n.º 1
0
 public MyOnMapReadyCallback(TrapNotificationFragment fragment)
 {
     TrapNotificationFragment = fragment;
 }
Exemplo n.º 2
0
        public void OnSectionAttached(int number, bool update = false)
        {
            try
            {
                if (armFragment != null)
                {
                    ((PlantFragment)armFragment).StopMonitoring();

                    armFragment = null;
                }

                currentFragmentPosition = number;

                actualFragment = new Fragment();

                if (showNotification)
                {
                    showNotification = false;

                    var notificationFragment = new TrapNotificationFragment();

                    notificationFragment.pointsEarned   = Convert.ToInt32(Intent.Extras.GetString("points"));
                    notificationFragment.trapNameKey    = Intent.Extras.GetString("trap");
                    notificationFragment.latitude       = float.Parse(Intent.Extras.GetString("lat").Replace(",", "."));
                    notificationFragment.longitude      = float.Parse(Intent.Extras.GetString("lng").Replace(",", "."));
                    notificationFragment.date           = DateUtils.StringToDate(Intent.Extras.GetString("date"));
                    notificationFragment.date           = notificationFragment.date.ToLocalTime();
                    notificationFragment.otherUserName  = Intent.Extras.GetString("userName");
                    notificationFragment.otherUserImage = Intent.Extras.GetString("img");

                    var isOwner = Intent.Extras.GetString("owner");

                    notificationFragment.isOwner = !string.IsNullOrEmpty(isOwner);

                    actualFragment = notificationFragment;
                }
                else if (number == HOME_MENU_INDEX)
                {
                    if (homeFragment == null)
                    {
                        homeFragment = new HomeFragment();
                    }
                    else if (homeFragment != null && update)
                    {
                        ((HomeFragment)homeFragment).RequestProfile(true);
                    }

                    actualFragment = homeFragment;
                }
                else if (number == PLANT_MENU_INDEX)
                {
                    if (AppStatus.UserLogged.ContainsTraps())
                    {
                        actualFragment = new PlantFragment();
                        armFragment    = actualFragment;
                    }
                    else
                    {
                        actualFragment = new ShopFragment();
                    }
                }
                else if (number == BUY_MENU_INDEX)
                {
                    actualFragment = new ShopFragment();
                }
                else if (number == ARMED_TRAPS)
                {
                    actualFragment = new ArmedTrapsFragment();
                }
                else
                {
                    actualFragment = null;
                }

                if (actualFragment != null)
                {
                    if (!IsFinishing)
                    {
                        FragmentManager.BeginTransaction().Replace(MyTrap.Droid.Resource.Id.container, actualFragment).Commit();
                    }
                }
            }
            catch (Exception exception)
            {
                InsightsUtils.LogException(exception);
            }
        }