コード例 #1
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.list_moments_activity);

            var options = new PlusClass.PlusOptions.Builder()
                          .AddActivityTypes(MomentUtil.ACTIONS).Build();

            mGoogleApiClient = new GoogleApiClientBuilder(this)
                               .AddConnectionCallbacks(this)
                               .AddOnConnectionFailedListener(this)
                               .AddApi(PlusClass.API, options)
                               .AddScope(PlusClass.ScopePlusLogin)
                               .Build();

            mListItems                 = new List <IMoment>();
            mMomentListAdapter         = new MomentListAdapter(this, Android.Resource.Layout.SimpleListItem1, mListItems);
            mMomentListView            = FindViewById <ListView> (Resource.Id.moment_list);
            mMomentListView.ItemClick += (sender, e) => {
                var moment = mMomentListAdapter.GetItem(e.Position);
                if (moment != null)
                {
                    if (mGoogleApiClient.IsConnected)
                    {
                        PlusClass.MomentsApi.Remove(mGoogleApiClient, moment.Id);
                        Toast.MakeText(this, GetString(Resource.String.plus_remove_moment_status),
                                       ToastLength.Short).Show();
                    }
                    else
                    {
                        Toast.MakeText(this, GetString(Resource.String.greeting_status_sign_in_required),
                                       ToastLength.Short).Show();
                    }
                }
            };

            mResolvingError = savedInstanceState != null &&
                              savedInstanceState.GetBoolean(STATE_RESOLVING_ERROR, false);

            int available = GooglePlayServicesUtil.IsGooglePlayServicesAvailable(this);

            if (available != CommonStatusCodes.Success)
            {
                ShowDialog(DIALOG_GET_GOOGLE_PLAY_SERVICES);
            }

            if (Build.VERSION.SdkInt >= BuildVersionCodes.Honeycomb)
            {
                this.ActionBar.SetDisplayHomeAsUpEnabled(true);
            }
        }
コード例 #2
0
        override protected void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(R.Layout.list_moments_activity);

            mPendingDeletion   = new ArrayList <IMoment>();
            mListItems         = new ArrayList <IMoment>();
            mMomentListAdapter = new MomentListAdapter(this, Android.R.Layout.Simple_list_item_1,
                                                       mListItems);
            mMomentListView = (ListView)FindViewById(R.Id.moment_list);
            mMomentListView.SetAdapter(mMomentListAdapter);
            mMomentListView.SetOnItemClickListener(this);
            mPlusClientFragment = PlusClientFragment.GetPlusClientFragment(this,
                                                                           MomentUtil.VISIBLE_ACTIVITIES);
        }