Exemplo n.º 1
0
            override public void OnCancel(IDialogInterface dialog)
            {
                base.OnCancel(dialog);
                FragmentActivity activity = GetActivity();

                if (activity == null)
                {
                    return;
                }

                Fragment fragment = activity.GetSupportFragmentManager().FindFragmentByTag(TAG_PLUS_CLIENT);

                if (fragment is PlusClientFragment)
                {
                    ((PlusClientFragment)fragment).onDialogCanceled(GetTag());
                }
            }
Exemplo n.º 2
0
        // Attach a PlusClient managing fragment to you activity.
        public static PlusClientFragment GetPlusClientFragment(
            FragmentActivity activity, String[] visibleActivities)
        {
            if (!(activity is OnSignedInListener))
            {
                throw new ArgumentException(
                          "The activity must implement OnSignedInListener to receive callbacks.");
            }

            // Check if the fragment is already attached.
            FragmentManager fragmentManager = activity.GetSupportFragmentManager();
            Fragment        fragment        = fragmentManager.FindFragmentByTag(TAG_PLUS_CLIENT);

            if (fragment is PlusClientFragment)
            {
                // The fragment is attached.  If it has the right visible activities, return it.
                if (Arrays.Equals(visibleActivities,
                                  fragment.GetArguments().GetStringArray(ARG_VISIBLE_ACTIVITIES)))
                {
                    return((PlusClientFragment)fragment);
                }
            }

            FragmentTransaction fragmentTransaction = fragmentManager.BeginTransaction();

            // If a fragment was already attached, remove it to clean up.
            if (fragment != null)
            {
                fragmentTransaction.Remove(fragment);
            }

            // Create a new fragment and attach it to the fragment manager.
            Bundle arguments = new Bundle();

            arguments.PutStringArray(ARG_VISIBLE_ACTIVITIES, visibleActivities);
            PlusClientFragment signInFragment = new PlusClientFragment();

            signInFragment.SetArguments(arguments);
            fragmentTransaction.Add(signInFragment, TAG_PLUS_CLIENT);
            fragmentTransaction.Commit();
            return(signInFragment);
        }
Exemplo n.º 3
0
 public TabsAdapter(FragmentActivity activity, TabHost tabHost, ViewPager pager) : base(activity.GetSupportFragmentManager())
 {
     mContext = activity;
     mTabHost = tabHost;
     mViewPager = pager;
     mTabHost.SetOnTabChangedListener(this);
     mViewPager.SetAdapter(this);
     mViewPager.SetOnPageChangeListener(this);
 }
Exemplo n.º 4
0
 public TabsAdapter(FragmentActivity activity, TabHost tabHost, ViewPager pager) : base(activity.GetSupportFragmentManager())
 {
     mContext   = activity;
     mTabHost   = tabHost;
     mViewPager = pager;
     mTabHost.SetOnTabChangedListener(this);
     mViewPager.SetAdapter(this);
     mViewPager.SetOnPageChangeListener(this);
 }
      // Attach a PlusClient managing fragment to you activity.
      public static PlusClientFragment GetPlusClientFragment(
              FragmentActivity activity, String[] visibleActivities)
      {
         if (!(activity is OnSignedInListener))
         {
            throw new ArgumentException(
                    "The activity must implement OnSignedInListener to receive callbacks.");
         }

         // Check if the fragment is already attached.
         FragmentManager fragmentManager = activity.GetSupportFragmentManager();
         Fragment fragment = fragmentManager.FindFragmentByTag(TAG_PLUS_CLIENT);
         if (fragment is PlusClientFragment)
         {
            // The fragment is attached.  If it has the right visible activities, return it.
            if (Arrays.Equals(visibleActivities,
                    fragment.GetArguments().GetStringArray(ARG_VISIBLE_ACTIVITIES)))
            {
               return (PlusClientFragment)fragment;
            }
         }

         FragmentTransaction fragmentTransaction = fragmentManager.BeginTransaction();
         // If a fragment was already attached, remove it to clean up.
         if (fragment != null)
         {
            fragmentTransaction.Remove(fragment);
         }

         // Create a new fragment and attach it to the fragment manager.
         Bundle arguments = new Bundle();
         arguments.PutStringArray(ARG_VISIBLE_ACTIVITIES, visibleActivities);
         PlusClientFragment signInFragment = new PlusClientFragment();
         signInFragment.SetArguments(arguments);
         fragmentTransaction.Add(signInFragment, TAG_PLUS_CLIENT);
         fragmentTransaction.Commit();
         return signInFragment;
      }