Ejemplo n.º 1
0
 public override void OnComplete(String response, Object state)
 {
     // callback should be run in the original thread,
     // not the background thread
     parent.mHandler.Post(delegate {
         SessionEvents.OnLogoutFinish();
     });
 }
Ejemplo n.º 2
0
 public void OnClick(View arg0)
 {
     if (parent.mFb.IsSessionValid)
     {
         SessionEvents.OnLogoutBegin();
         AsyncFacebookRunner asyncRunner = new AsyncFacebookRunner(parent.mFb);
         asyncRunner.Logout(parent.Context, new LogoutRequestListener(parent));
     }
     else
     {
         parent.mFb.Authorize(parent.mActivity, parent.mPermissions,
                              new LoginDialogListener());
     }
 }
Ejemplo n.º 3
0
        public void Init(Activity activity, Facebook fb, String[] permissions)
        {
            mActivity    = activity;
            mFb          = fb;
            mPermissions = permissions;
            mHandler     = new Handler();

            SetBackgroundColor(Color.Transparent);
            SetAdjustViewBounds(true);
            SetImageResource(fb.IsSessionValid ?
                             Resource.Drawable.logout_button :
                             Resource.Drawable.login_button);
            DrawableStateChanged();

            SessionEvents.AddAuthListener(mSessionListener);
            SessionEvents.AddLogoutListener(mSessionListener);
            SetOnClickListener(new ButtonOnClickListener(this));
        }
Ejemplo n.º 4
0
        /** Called when the activity is first created. */
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            if (APP_ID == null)
            {
                Util.ShowAlert(this, "Warning", "Facebook Applicaton ID must be " +
                               "specified before running this example: see Example.java");
            }

            SetContentView(Resource.Layout.main);
            mLoginButton   = (LoginButton)FindViewById(Resource.Id.login);
            mText          = (TextView)FindViewById(Resource.Id.txt);
            mRequestButton = (Button)FindViewById(Resource.Id.requestButton);
            mPostButton    = (Button)FindViewById(Resource.Id.postButton);
            mDeleteButton  = (Button)FindViewById(Resource.Id.deletePostButton);
            mUploadButton  = (Button)FindViewById(Resource.Id.uploadButton);

            mFacebook    = new Facebook(APP_ID);
            mAsyncRunner = new AsyncFacebookRunner(mFacebook);

            SessionStore.Restore(mFacebook, this);
            SessionEvents.AddAuthListener(new SampleAuthListener(this));
            SessionEvents.AddLogoutListener(new SampleLogoutListener(this));
            mLoginButton.Init(this, mFacebook);

            mRequestButton.Click += delegate {
                mAsyncRunner.Request("me", new SampleRequestListener(this));
            };
            mRequestButton.Visibility = mFacebook.IsSessionValid ?
                                        ViewStates.Visible :
                                        ViewStates.Invisible;

            mUploadButton.Click += async delegate {
                Bundle parameters = new Bundle();
                parameters.PutString("method", "photos.upload");

                URL uploadFileUrl = null;
                try {
                    uploadFileUrl = new URL(
                        "http://www.facebook.com/images/devsite/iphone_connect_btn.jpg");
                } catch (MalformedURLException e) {
                    e.PrintStackTrace();
                }
                try {
                    HttpURLConnection conn = (HttpURLConnection)uploadFileUrl.OpenConnection();
                    conn.DoInput = true;
                    await conn.ConnectAsync();

                    int length = conn.ContentLength;

                    byte[] imgData = new byte[length];
                    var    ins     = conn.InputStream;
                    await ins.ReadAsync(imgData, 0, imgData.Length);

                    parameters.PutByteArray("picture", imgData);
                } catch (IOException e) {
                    e.PrintStackTrace();
                }

                mAsyncRunner.Request(null, parameters, "POST",
                                     new SampleUploadListener(this), null);
            };
            mUploadButton.Visibility = mFacebook.IsSessionValid ?
                                       ViewStates.Visible :
                                       ViewStates.Invisible;

            mPostButton.Click += delegate {
                mFacebook.Dialog(this, "feed",
                                 new SampleDialogListener(this));
            };
            mPostButton.Visibility = mFacebook.IsSessionValid ?
                                     ViewStates.Visible :
                                     ViewStates.Invisible;
        }
Ejemplo n.º 5
0
 public void OnCancel()
 {
     SessionEvents.OnLoginError("Action Canceled");
 }
Ejemplo n.º 6
0
 public void OnError(DialogError error)
 {
     SessionEvents.OnLoginError(error.Message);
 }
Ejemplo n.º 7
0
 public void OnFacebookError(FacebookError error)
 {
     SessionEvents.OnLoginError(error.Message);
 }
Ejemplo n.º 8
0
 public void OnComplete(Bundle values)
 {
     SessionEvents.OnLoginSuccess();
 }