Ejemplo n.º 1
0
        protected override Java.Lang.Object DoInBackground(params Java.Lang.Object[] @params)
        {
            var auth = new KiwiLoginService ();
            var loggingOut = auth.Logout(authtoken);
            try{
                Task.WaitAll(loggingOut);
                //TODO: invalidate authtoken in account manager.
            } catch (Exception e) {
                Toast.MakeText(Application.Context, "Error logging out.", ToastLength.Long).Show();
            }

            Intent intent = new Intent (activity, typeof(LoginActivity));

            return intent;
        }
Ejemplo n.º 2
0
        public override Bundle GetAuthToken(AccountAuthenticatorResponse response, Account account, String authTokenType, Bundle options)
        {
            // Extract the username and password from the Account Manager, and ask
            // the server for an appropriate AuthToken.
            AccountManager am = AccountManager.Get(mContext);

            String authToken = am.PeekAuthToken(account, authTokenType);

            // Lets give another try to authenticate the user
            if (TextUtils.IsEmpty(authToken)) {
                String password = am.GetPassword(account);
                if (password != null) {
                    //var auth = new KiwiServerAuthenticate ();
                    var auth = new KiwiLoginService ();
                    var authTokenResult = auth.Login(account.Name, password);
                    Task.WaitAll(authTokenResult);
                    authToken = authTokenResult.Result.AuthToken;
                }
            }

            // If we get an authToken - we return it
            if (!TextUtils.IsEmpty(authToken)) {
                Bundle result = new Bundle();
                result.PutString(AccountManager.KeyAccountName, account.Name);
                result.PutString(AccountManager.KeyAccountType, account.Type);
                result.PutString(AccountManager.KeyAuthtoken, authToken);
                return result;
            }

            // If we get here, then we couldn't access the user's password - so we
            // need to re-prompt them for their credentials. We do that by creating
            // an intent to display our AuthenticatorActivity.
            Intent intent = new Intent(mContext, typeof(LoginActivity));
            intent.PutExtra(AccountManager.KeyAccountAuthenticatorResponse, response);
            intent.PutExtra("accountType", account.Type);
            intent.PutExtra("authTokenType", authTokenType);
            intent.PutExtra ("accountName", account.Name);
            Bundle bundle = new Bundle();
            bundle.PutParcelable(AccountManager.KeyIntent, intent);
            return bundle;
        }
Ejemplo n.º 3
0
        protected override Java.Lang.Object DoInBackground(params Java.Lang.Object[] @params)
        {
            var auth = new KiwiLoginService ();
            var eventsTask = auth.GetEvents(authtoken);
            try{

                Task.WaitAll(eventsTask);
                var events = eventsTask.Result;

                foreach (var e in events)
                {
                    eventList.Add (e);
                }

            } catch (Exception e) {
                Toast.MakeText(Application.Context, "Error fetching events.", ToastLength.Long).Show();
            }

            Intent intent = new Intent (activity, typeof(EventsExplorerActivity));

            return intent;
        }
Ejemplo n.º 4
0
        protected override Java.Lang.Object DoInBackground(params Java.Lang.Object[] @params)
        {
            System.Console.WriteLine ("PostTask DoInBackground");
            //BACKGROUND SERVICE
            var auth = new KiwiLoginService ();
            var postComment = auth.PostComment (eventID, comment, authtoken);

            try{
                Task.WaitAll(postComment);
            } catch (Exception e) {
                Toast.MakeText(Application.Context, "ERROR", ToastLength.Long).Show();
            }

            Intent intent = new Intent (activity, typeof(EventPageActivity));

            return intent;
        }
Ejemplo n.º 5
0
        protected override Java.Lang.Object DoInBackground(params Java.Lang.Object[] @params)
        {
            //BACKGROUND SERVICE
            var auth = new KiwiLoginService ();
            var fetchEvent = auth.GetEvent(authtoken, eventID);
            try{

                Task.WaitAll(fetchEvent);
                var singleEvent = fetchEvent.Result;

                activity.thisEvent = singleEvent;

                try {

                    URL url = new URL(singleEvent.PictureUrl);
                    HttpURLConnection conn = (HttpURLConnection) url.OpenConnection();
                    conn.DoInput = true;
                    conn.Connect();
                    Stream stream = conn.InputStream;
                    Bitmap bmImg = BitmapFactory.DecodeStream(stream);

                    ImageView eventpic = (ImageView)activity.FindViewById(Resource.Id.eventPageEventImage);
                    eventpic.SetImageBitmap(bmImg);

                }
                catch (System.IO.IOException e)
                {
                    return null;
                }

            } catch (Exception e) {
                System.Console.WriteLine("-----Error pulling event data-----");
            }

            Intent intent = new Intent (activity, typeof(EventPageActivity));

            return intent;
        }
Ejemplo n.º 6
0
        protected override Java.Lang.Object DoInBackground(params Java.Lang.Object[] @params)
        {
            System.Console.WriteLine ("LoginTask: DoInBackground");

            String authtoken = null;

            //var auth = new KiwiServerAuthenticate ();
            var auth = new KiwiLoginService ();
            var authTokenResult = auth.Login(username, password);
            try{
                Task.WaitAll(authTokenResult);
            } catch (Exception e) {
                Toast.MakeText(Application.Context, "There seems to be a problem with the server. Please try again later.", ToastLength.Long).Show();
            }
            if (authTokenResult.Result.Successful) {
                authtoken = authTokenResult.Result.AuthToken;
            }

            Intent res = new Intent();

            res.PutExtra(AccountManager.KeyAccountName, username);
            res.PutExtra(AccountManager.KeyAccountType, "com.SnapAndGo.auth");
            res.PutExtra(AccountManager.KeyAuthtoken, authtoken);
            res.PutExtra("password", password);

            return res;
        }
Ejemplo n.º 7
0
        protected override Java.Lang.Object DoInBackground(params Java.Lang.Object[] @params)
        {
            var auth = new KiwiLoginService ();
            var postPicture = auth.UploadImage(filepath);
            try{
                Task.WaitAll(postPicture);
            } catch (Exception e) {
                Toast.MakeText(Application.Context, "Error posting", ToastLength.Long).Show();
                System.Console.WriteLine("NULL RETURNED FROM POSTPICTURE");
            }

            Intent intent = new Intent (activity, typeof(CustomCameraActivity));

            return intent;
        }