protected override void OnActivityResult(int requestCode, Result resultCode, Intent data)
        {
            base.OnActivityResult (requestCode, resultCode, data);
            switch (requestCode) {
            case FACEBOOK_BACK:

                if (resultCode == Result.Ok) {
                    this.Provider = new LFacebookManager (LOLConstants.FacebookAPIKey,
                                                         LOLConstants.FacebookAppSecret,
                                                         AndroidData.FacebookAccessToken,
                                                         AndroidData.FacebookAccessTokenExpiration);
                    this.GetFacebookAlbums ();
                }//end if
                break;

            case GOOGLE_BACK:
                if (resultCode == Result.Ok) {
                    this.Provider = new LGooglePlusManager (LOLConstants.GooglePlusConsumerKey,
                                                           LOLConstants.GooglePlusConsumerSecret,
                                                           AndroidData.GooglePlusAccessToken,
                                                           AndroidData.GooglePlusRefreshToken,
                                                           AndroidData.GoogleAccessTokenExpiration, new HttpHelper ());
                    this.GetGooglePlusAlbums ();
                }//end if
                break;

            case LINKEDIN_BACK:
                if (resultCode == Result.Ok) {
                    this.Provider = new LLinkedInManager (LOLConstants.LinkedInConsumerKey,
                                                         LOLConstants.LinkedInConsumerSecret,
                                                         AndroidData.LinkedInAccessToken,
                                                         AndroidData.LinkedInAccessTokenSecret);
                    this.GetLinkedInAlbums ();
                }//end if
                break;
            case PHOTO_PICK:
                if (resultCode == Result.Ok) {
                    Intent resultData = new Intent ();
                    resultData.PutExtra ("filename", PhotoPickerUtil.imageFilename);
                    SetResult (Result.Ok, resultData);
                    Finish ();
                } else
                    Finish ();
                break;
            }
        }
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate (bundle);
            SetContentView (Resource.Layout.PhotoAlbumNames);
            ImageView btns = FindViewById<ImageView> (Resource.Id.imgNewUserHeader);
            TextView header = FindViewById<TextView> (Resource.Id.txtFirstScreenHeader);
            RelativeLayout relLayout = FindViewById<RelativeLayout> (Resource.Id.relativeLayout1);
            ImageHelper.setupTopPanel (btns, header, relLayout, header.Context);
            Header.headertext = Application.Context.Resources.GetString (Resource.String.photoalbumAlbumsTitle);
            Header.fontsize = 36f;
            ImageHelper.fontSizeInfo (header.Context);
            header.SetTextSize (Android.Util.ComplexUnitType.Dip, Header.fontsize);
            header.Text = Header.headertext;

            listWrapper = FindViewById<LinearLayout> (Resource.Id.linearListWrapper);
            context = listWrapper.Context;

            bool media = base.Intent.GetBooleanExtra ("media", false);
            mediaType = media == true ? MediaPickType.Video : MediaPickType.StillImage;

            int socialNetwork = base.Intent.GetIntExtra ("network", -1);
            // socialnetworks - same as in get contacts....

            switch (socialNetwork) {
            case 1:
                providerType = AccountOAuth.OAuthTypes.Google;
                if (string.IsNullOrEmpty (AndroidData.GooglePlusAccessToken)) {
                    this.Provider = new LGooglePlusManager (LOLConstants.GooglePlusConsumerKey, LOLConstants.GooglePlusConsumerSecret, new HttpHelper ());
                    gg = false;
                } else {
                    this.Provider = new LGooglePlusManager (LOLConstants.GooglePlusConsumerKey, LOLConstants.GooglePlusConsumerSecret, AndroidData.GooglePlusAccessToken, AndroidData.GooglePlusRefreshToken,
                                                           AndroidData.GoogleAccessTokenExpiration, new HttpHelper ());
                    gg = true;
                }
                break;

            case 2:
                providerType = AccountOAuth.OAuthTypes.LinkedIn;
                if (string.IsNullOrEmpty (AndroidData.LinkedInAccessToken)) {
                    this.Provider = new LLinkedInManager (LOLConstants.LinkedInConsumerKey, LOLConstants.LinkedInConsumerSecret, string.Empty, string.Empty);
                    gl = false;
                } else {
                    this.Provider = new LLinkedInManager (LOLConstants.LinkedInConsumerKey, LOLConstants.LinkedInConsumerSecret, AndroidData.LinkedInAccessToken, AndroidData.LinkedInAccessTokenSecret);
                    gl = true;
                }
                break;

            case 3:
                providerType = AccountOAuth.OAuthTypes.FaceBook;
                if (string.IsNullOrEmpty (AndroidData.FacebookAccessToken)) {
                    gf = false;
                    this.Provider = new LFacebookManager (LOLConstants.FacebookAPIKey, LOLConstants.FacebookAppSecret);
                } else {
                    this.Provider = new LFacebookManager (LOLConstants.FacebookAPIKey, LOLConstants.FacebookAppSecret, AndroidData.FacebookAccessToken, AndroidData.FacebookAccessTokenExpiration);
                    gf = true;
                }
                break;
            }

            ImageButton btnHome = FindViewById<ImageButton> (Resource.Id.btnHome);
            ImageButton btnBack = FindViewById<ImageButton> (Resource.Id.btnBack);

            btnBack.Click += delegate {
                Finish ();
            };
            btnHome.Click += delegate {
                Intent i = new Intent (this, typeof(Main.HomeActivity));
                i.SetFlags (ActivityFlags.ClearTop);
                StartActivity (i);
            };

            btnBack.Tag = 0;
            btnHome.Tag = 1;
            LinearLayout bottom = FindViewById<LinearLayout> (Resource.Id.bottomHolder);
            ImageButton[] buttons = new ImageButton[2];
            buttons [0] = btnBack;
            buttons [1] = btnHome;
            ImageHelper.setupButtonsPosition (buttons, bottom, context);

            System.Threading.Tasks.Task.Factory.StartNew (() => SetDataSources ());
        }
        protected override void OnActivityResult(int requestCode, Result resultCode, Intent data)
        {
            base.OnActivityResult(requestCode, resultCode, data);

            switch (requestCode)
            {

                case FACEBOOK_BACK:

                    if (resultCode == Result.Ok)
                    {
                        this.Provider = new LFacebookManager(LOLConstants.FacebookAPIKey,
                                                         LOLConstants.FacebookAppSecret,
                                                         AndroidData.FacebookAccessToken,
                                                         AndroidData.FacebookAccessTokenExpiration);

                        this.GetFacebookFriends();
                    }//end if
                    break;

                case GOOGLE_BACK:

                    if (resultCode == Result.Ok)
                    {
                        this.Provider = new LGooglePlusManager(LOLConstants.GooglePlusConsumerKey,
                                                           LOLConstants.GooglePlusConsumerSecret,
                                                           AndroidData.GooglePlusAccessToken,
                                                           AndroidData.GooglePlusRefreshToken,
                                                           AndroidData.GoogleAccessTokenExpiration, new HttpHelper());

                        this.GetGooglePlusFriends();
                    }//end if

                    break;

                case LINKEDIN_BACK:

                    if (resultCode == Result.Ok)
                    {
                        this.Provider = new LLinkedInManager(LOLConstants.LinkedInConsumerKey,
                                                         LOLConstants.LinkedInConsumerSecret,
                                                         AndroidData.LinkedInAccessToken,
                                                         AndroidData.LinkedInAccessTokenSecret);
                        this.GetLinkedInFriends();

                    }//end if

                    break;

            }//end switch
        }
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            SetContentView(Resource.Layout.GetConnectedContacts);

            db = wowZapp.LaffOutOut.Singleton.dbm;

            isFind = base.Intent.GetBooleanExtra("isfind", true);
            selectedContacts = new List<Contact>();
            searchResults = new List<Contact>();
            contacts = new List<Contact>();

            if (ContactsUtil.contacts == null)
                ContactsUtil.contacts = new List<ContactDB>();

            search = FindViewById<EditText>(Resource.Id.editSearch);
            Button cont = FindViewById<Button>(Resource.Id.btnGetConnectedContinue);
            scroller = FindViewById<ScrollView>(Resource.Id.scrollViewContainer);
            listContainer = FindViewById<LinearLayout>(Resource.Id.linearListContainer);

            context = scroller.Context;

            TextView header = FindViewById<TextView>(Resource.Id.txtFirstScreenHeader);
            ImageView btns = FindViewById<ImageView>(Resource.Id.imgNewUserHeader);
            RelativeLayout relLayout = FindViewById<RelativeLayout>(Resource.Id.relativeLayout1);
            ImageHelper.setupTopPanel(btns, header, relLayout, header.Context);

            Header.headertext = Application.Context.Resources.GetString(Resource.String.getconnectedTitle);
            Header.fontsize = 36f;
            ImageHelper.fontSizeInfo(header.Context);
            header.SetTextSize(Android.Util.ComplexUnitType.Dip, Header.fontsize);
            header.Text = Header.headertext;

            int netType = base.Intent.GetIntExtra("type", 0);
            switch (netType)
            {
                case 1:
                    this.networkType = AccountOAuth.OAuthTypes.Google;
                    if (string.IsNullOrEmpty(AndroidData.GooglePlusAccessToken))
                    {
                        this.Provider = new LGooglePlusManager(LOLConstants.GooglePlusConsumerKey, LOLConstants.GooglePlusConsumerSecret, new HttpHelper());
                        gg = false;
                    } else
                    {
                        this.Provider = new LGooglePlusManager(LOLConstants.GooglePlusConsumerKey, LOLConstants.GooglePlusConsumerSecret, AndroidData.GooglePlusAccessToken, AndroidData.GooglePlusRefreshToken,
                            AndroidData.GoogleAccessTokenExpiration, new HttpHelper());
                        gg = true;
                    }
                    break;

                case 2:
                    this.networkType = AccountOAuth.OAuthTypes.LinkedIn;
                    if (string.IsNullOrEmpty(AndroidData.LinkedInAccessToken))
                    {
                        this.Provider = new LLinkedInManager(LOLConstants.LinkedInConsumerKey, LOLConstants.LinkedInConsumerSecret, string.Empty, string.Empty);
                        gl = false;
                    } else
                    {
                        this.Provider = new LLinkedInManager(LOLConstants.LinkedInConsumerKey, LOLConstants.LinkedInConsumerSecret, AndroidData.LinkedInAccessToken, AndroidData.LinkedInAccessTokenSecret);
                        gl = true;
                    }
                    break;

                case 3:
                    this.networkType = AccountOAuth.OAuthTypes.FaceBook;
                    if (string.IsNullOrEmpty(AndroidData.FacebookAccessToken))
                    {
                        gf = false;
                        this.Provider = new LFacebookManager(LOLConstants.FacebookAPIKey, LOLConstants.FacebookAppSecret);
                    } else
                    {
                        this.Provider = new LFacebookManager(LOLConstants.FacebookAPIKey, LOLConstants.FacebookAppSecret, AndroidData.FacebookAccessToken, AndroidData.FacebookAccessTokenExpiration);
                        gf = true;
                    }
                    break;
            }

            System.Threading.Tasks.Task.Factory.StartNew(() => SetDataSources());

            cont.Click += (object s, EventArgs e) => {
                cont_Click(); };
            search.Clickable = true;
            search.TextChanged += delegate
            {
                #if DEBUG
                System.Diagnostics.Debug.WriteLine("Text changed - now is {0}", search.Text);
                #endif
                FilterContacts();
            };
        }
 public dealWithSACWebView(Activity f, AccountOAuth.OAuthTypes ProviderType, ISocialProviderManager Provider, ImageButton btnBack)
 {
     this.parent = f;
     this.Provider = Provider;
     this.ProviderType = ProviderType;
     string authUrl = this.Provider.BrowserAuthUrl;
     btnBack.Click += delegate
     {
         parent.Finish();
     };
     switch (ProviderType)
     {
         case AccountOAuth.OAuthTypes.Google:
             AccessTokenReceived += (occurred, expires, accessToken, accessTokenSecret, refreshToken) =>
             {
                 AndroidData.GooglePlusAccessToken = accessToken;
                 AndroidData.GooglePlusRefreshToken = refreshToken;
                 AndroidData.GoogleAccessTokenExpiration = expires;
                 ShowAfterLoginScreen();
             };
             break;
         case AccountOAuth.OAuthTypes.FaceBook:
             LFacebookManager lFace = new LFacebookManager(LOLConstants.FacebookAPIKey, LOLConstants.FacebookAppSecret);
             AccessTokenReceived += (occurred, expires, accessToken, accessTokenSecret, refreshToken) =>
             {
                 try
                 {
                     if (lFace.RefreshAccessToken())
                     {
                         AndroidData.FacebookAccessToken = lFace.AccessToken;
                         AndroidData.FacebookAccessTokenExpiration =
                             lFace.AccessTokenExpirationTime ?? DateTime.Now;
                     }//end if
                 } catch
                 {
                     AndroidData.FacebookAccessToken = accessToken;
                     AndroidData.FacebookAccessTokenExpiration = expires;
                 }
                 ShowAfterLoginScreen();
             };
             break;
         case AccountOAuth.OAuthTypes.LinkedIn:
             AccessTokenReceived += (occurred, expires, accessToken, accessTokenSecret, refreshToken) =>
             {
                 AndroidData.LinkedInAccessToken = accessToken;
                 AndroidData.LinkedInAccessTokenSecret = accessTokenSecret;
                 ShowAfterLoginScreen();
             };
             break;
     }
 }
 private void startUserLogin(ISocialProviderManager provider)
 {
     parent.RunOnUiThread(() => Toast.MakeText(c, Resource.String.commonLoggingIn, ToastLength.Short).Show());
     LOLConnectClient service = new LOLConnectClient(LOLConstants.DefaultHttpBinding,
         LOLConstants.LOLConnectEndpoint);
     service.AuthenticationTokenGetCompleted += Service_AuthenticationTokenGetCompleted;
     service.AuthenticationTokenGetAsync(AndroidData.NewDeviceID, provider);
 }
        public dealWithWebView(Activity f, AccountOAuth.OAuthTypes ProviderType, ISocialProviderManager Provider, ImageButton btnBack)
        {
            this.parent = f;
            this.Provider = Provider;
            this.ProviderType = ProviderType;
            string authUrl = this.Provider.BrowserAuthUrl;
            user = AndroidData.user;
            btnBack.Click += delegate
            {
                parent.Finish();
            };
            switch (ProviderType)
            {
                case AccountOAuth.OAuthTypes.Google:
                    AccessTokenReceived += (occurred, expires, accessToken, accessTokenSecret, refreshToken) =>
                    {
                        AndroidData.GooglePlusAccessToken = accessToken;
                        AndroidData.GooglePlusRefreshToken = refreshToken;
                        AndroidData.GoogleAccessTokenExpiration = expires;
                        startUserLogin(Provider);
                    };
                    break;

                case AccountOAuth.OAuthTypes.FaceBook:
                    LFacebookManager lFace = new LFacebookManager(LOLConstants.FacebookAPIKey, LOLConstants.FacebookAppSecret);
                    AccessTokenReceived += (occurred, expires, accessToken, accessTokenSecret, refreshToken) =>
                    {
                        try
                        {
                            if (lFace.RefreshAccessToken())
                            {
                                AndroidData.FacebookAccessToken = lFace.AccessToken;
                                AndroidData.FacebookAccessTokenExpiration = lFace.AccessTokenExpirationTime ?? DateTime.Now;
                            }
                        } catch
                        {
                            AndroidData.FacebookAccessToken = accessToken;
                            AndroidData.FacebookAccessTokenExpiration = expires;
                        }
                        startUserLogin(Provider);
                    };
                    break;

                case AccountOAuth.OAuthTypes.LinkedIn:
                    AccessTokenReceived += (occurred, expires, accessToken, accessTokenSecret, refreshToken) =>
                    {
                        AndroidData.LinkedInAccessToken = accessToken;
                        AndroidData.LinkedInAccessTokenSecret = accessTokenSecret;
                        startUserLogin(Provider);
                    };
                    break;

                case AccountOAuth.OAuthTypes.Twitter:
                    LTwitterManager lTwit = new LTwitterManager(LOLConstants.TwitterConsumerKey, LOLConstants.TwitterConsumerSecret, AndroidData.TwitterAccessToken, AndroidData.TwitterAccessTokenSecret,
                        AndroidData.TwitterScreenName, AndroidData.TwitterUserId);
                    AccessTokenReceived += (occurred, expires, accessToken, accessTokenSecret, refreshToken) =>
                    {
                        AndroidData.TwitterAccessToken = accessToken;
                        AndroidData.TwitterAccessTokenSecret = accessTokenSecret;
                        AndroidData.TwitterScreenName = lTwit.ScreenName;
                        AndroidData.TwitterUserId = lTwit.UserId;
                        startUserLogin(Provider);
                    };
                    break;

                case AccountOAuth.OAuthTypes.YouTube:
                    AccessTokenReceived += (occurred, expires, accessToken, accessTokenSecret, refreshToken) =>
                    {
                        AndroidData.YouTubeAccessToken = accessToken;
                        AndroidData.YouTubeRefreshToken = refreshToken;
                        AndroidData.YouTubeAccessTokenExpiration = expires;
                        startUserLogin(Provider);
                    };
                    break;
            }
        }