Ejemplo n.º 1
0
        public static bool switchByIdFromList(int id, Android.App.Activity activity)
        {
            switch (id)
            {
            case 2:
                activity.StartActivity((typeof(PlaylistsActivity)));
                return(true);

            case 3:
                activity.StartActivity((typeof(ArtistsActivity)));
                return(true);

            case 4:
                activity.StartActivity((typeof(GenresPageActivity)));
                return(true);

            case 6:
                activity.StartActivity(typeof(AccountActivity));
                return(true);

            case 7:
                activity.StartActivity(typeof(PasswordChangeActivity));
                return(true);

            case 8:
                switchSavedUser(null);
                activity.StartActivity(typeof(LoginActivity));
                activity.Finish();
                return(true);

            default:
                return(false);
            }
        }
		/**
	     * Show End User License Agreement.
	     *
	     * @param accepted True IFF user has accepted license already, which means it can be dismissed.
	     *                 If the user hasn't accepted, then the EULA must be accepted or the program
	     *                 exits.
	     * @param activity Activity started from.
	     */
		public static void ShowEula(bool accepted, Activity activity)
		{
			AlertDialog.Builder eula = new AlertDialog.Builder(activity)
				.SetTitle(Resource.String.eula_title)
				.SetIcon(Android.Resource.Drawable.IcDialogInfo)
				.SetMessage(Resource.String.eula_text)
				.SetCancelable(accepted);
			
			if (accepted) 
			{
				eula.SetPositiveButton(Android.Resource.String.Ok, (object dialog, DialogClickEventArgs which) => {
					(dialog as IDialogInterface).Dismiss();	
				});
			} else {
				eula.SetPositiveButton(Resource.String.accept,(object dialog, DialogClickEventArgs which) => {
					SetAcceptedEula(activity);
					(dialog as IDialogInterface).Dismiss();
				})
				.SetNegativeButton(Resource.String.decline, (object dialog, DialogClickEventArgs which) => { 
					(dialog as IDialogInterface).Cancel();
					activity.Finish();
				});
			}
			eula.Show();
		}
Ejemplo n.º 3
0
 /// <summary>
 /// 摧毁本库的 AcpActivity
 /// </summary>
 private void OnDestroy()
 {
     if (mActivity != null)
     {
         mActivity.Finish();
         mActivity = null;
     }
     mCallback = null;
 }
Ejemplo n.º 4
0
        public DetailActivityViewModel(Activity context, AppContext app)
        {
            this.EditTarget = app.Detail
                .ObserveProperty(x => x.EditTarget)
                .Select(x => new PersonViewModel(x))
                .ToReactiveProperty();

            this.SaveCommand = new ReactiveCommand();
            this.SaveCommand.Subscribe(_ =>
                {
                    app.Detail.Update();
                    context.Finish();
                });
        }
		public static bool CheckPlayServices (Activity context)
		{
			int result = GooglePlayServicesUtil.IsGooglePlayServicesAvailable (context);

			if (result != ConnectionResult.Success) 
			{
				if (GooglePlayServicesUtil.IsUserRecoverableError (result)) 
				{
					GooglePlayServicesUtil.GetErrorDialog (result, context, PLAY_SERVICE_RESOLUTION_REQ).Show ();
				} 
				else 
				{
					Log.Debug ("GetMapAsync", "Google Play Services is not supported on this device");
					context.Finish ();
				}
				return false;
			}
			return true;//we're good 
		}
Ejemplo n.º 6
0
 public static void FinishAndForward(Activity activity, Intent i)
 {
     i.SetFlags(ActivityFlags.ForwardResult);
     activity.StartActivity(i);
     activity.Finish();
 }
Ejemplo n.º 7
0
        internal void LaunchApp(Activity ctx, ParseUser withUser, Action uiCallback)
        {
            // Fetch the person corresponding to the user
            Task.Factory.StartNew (() => {
                var query = new ParseQuery ("Person");
                query.SetCachePolicy (ParseQuery.CachePolicy.CacheElseNetwork);
                query.WhereEqualTo ("parseUser", withUser);
                query.Include ("parseUser");
                ParseObject self = null;
                try {
                    self = query.First;
                } catch (ParseException ex) {
                    // We may have a stall result from a previous registration
                    if (query.HasCachedResult) {
                        query.ClearCachedResult ();
                        try {
                            self = query.First;
                        } catch {
                            Android.Util.Log.Error ("Landing", "Error when trying to retrieve user 2. Normal if empty. {0}", ex.ToString ());
                        }
                    }
                    Android.Util.Log.Error ("Landing", "Error when trying to retrieve user. Normal if empty. {0}", ex.ToString ());
                }
                // First time ever, fill the info
                if (self == null) {
                    TabPerson person = null;
                    // Check if our TabPerson wasn't created indirectly by another user
                    query = new ParseQuery ("Person");
                    query.WhereEqualTo ("emails", TabPerson.MD5Hash (withUser.Email));
                    try {
                        person = TabPerson.FromParse (query.First);
                        person.AssociatedUser = withUser;
                    } catch {
                        // We use the main address email we got by parseUser
                        // and we will fill the rest lazily later from profile
                        // idem for the display name
                        person = new TabPerson {
                            AssociatedUser = withUser,
                            Emails = new string[] { withUser.Email }
                        };
                    }
                    return person;
                } else {
                    TabPerson.CurrentPerson = TabPerson.FromParse (self);
                    return null;
                }
            }).ContinueWith (t => {
                ctx.RunOnUiThread (() => {
                    // If the user was created, we setup a CursorLoader to query the information we need
                    if (t.Result != null) {
                        var person = t.Result;
                        person.DisplayName = profile.DisplayName;
                        person.Emails = profile.Emails.Union (person.Emails);
                        person.ToParse ().SaveEventually ();
                        TabPerson.CurrentPerson = person;
                    }

                    if (uiCallback != null)
                        uiCallback ();
                    ctx.Finish ();
                    ctx.StartActivity (typeof (MainActivity));
                });
            });
        }
 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;
     }
 }
        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;
            }
        }
Ejemplo n.º 10
0
		//closeActivity is for finish() activity
		public static void dialogErrorInternet(Activity context,int errorType,int close){

			context.RunOnUiThread (() => {
				string errorMsg = "";
				if(errorType == errorInternet){
					errorMsg = "Ralat. Sila semak sambungan internet anda.";
				}else if(errorType == errorServer){
					errorMsg = "Ralat. Server Pi1M dalam proses penyelenggaraan .";
				}

				Android.App.AlertDialog alertDialog;
				Android.App.AlertDialog.Builder alertDialogBuilder = new Android.App.AlertDialog.Builder (context);

				alertDialogBuilder
					.SetTitle ("Masalah")
					.SetMessage (string.Format (errorMsg))
					.SetCancelable (false)
					.SetPositiveButton ("OK", delegate {
						if(close==closeActivity){
							context.Finish ();
						}
					});
				alertDialog = alertDialogBuilder.Create ();
				alertDialog.Show ();
			});
		}
Ejemplo n.º 11
0
		public static void onSignOutRequest(Activity _activity){
			new System.Threading.Thread(new System.Threading.ThreadStart(() => {
				//TCSignalRClient.getInstance().stop();
				if(MApplication.getInstance().tcSignalR != null){
					MApplication.getInstance().tcSignalR.stop();
				}
			})).Start();

			if (constants.isSignInFromSplashScreen) {
				constants.isSignInFromSplashScreen = false;
				Intent intent = new Intent (_activity, typeof(HomeActivity));
				_activity.StartActivity (intent);
			} else {
				_activity.SetResult (Result.Ok);
			}

			// Clear observer
			if (HomeDashBoard.homeDashBoardActivity != null) {
				TCNotificationCenter.defaultCenter.removeObserver (HomeDashBoard.homeDashBoardActivity, Constants.kPostNotifyAlertChange);
				try{
					HomeDashBoard.homeDashBoardActivity.Finish ();
				} catch(Exception ex){
					#if DEBUG
					Console.Write(ex.Message);
					#endif
				}
			}

			if(SearchResultActivity.searchActivity != null){
				TCNotificationCenter.defaultCenter.removeObserver (SearchResultActivity.searchActivity, constants.kAddFavoriteSuccess);
				TCNotificationCenter.defaultCenter.removeObserver (SearchResultActivity.searchActivity, constants.kRemoveFavoriteSuccess);
				try {
					SearchResultActivity.searchActivity.Finish();
				} catch(Exception ex){
					#if DEBUG
					Console.Write(ex.Message);
					#endif
				}
			}

			if (SpecialistDetailActivity.specDetailActivity != null) {
				TCNotificationCenter.defaultCenter.removeObserver (SpecialistDetailActivity.specDetailActivity, Constants.kUpdateTalkNowStep);
				TCNotificationCenter.defaultCenter.removeObserver (SpecialistDetailActivity.specDetailActivity, constants.kDeferSuccess);
				try{
					SpecialistDetailActivity.specDetailActivity.Finish();
				} catch(Exception e){
					#if DEBUG
					Console.Write(e.Message);
					#endif
				}
				//SpecialistDetailActivity.specDetailActivity = null;
			}

			if (ListFavoriteActivity.listFavoriteActivity != null) {
				TCNotificationCenter.defaultCenter.removeObserver (ListFavoriteActivity.listFavoriteActivity, constants.kRemoveFavoriteSuccess);
				TCNotificationCenter.defaultCenter.removeObserver (ListFavoriteActivity.listFavoriteActivity, constants.kAddFavoriteSuccess);
				try {
					ListFavoriteActivity.listFavoriteActivity.Finish ();
				} catch(Exception ex){
					#if DEBUG
					Console.Write(ex.Message);
					#endif
				}
			}

			if (AlertActivity.eventActivity != null) {
				try {
					TCNotificationCenter.defaultCenter.removeObserver (AlertActivity.eventActivity, Constants.kPostDeleteFileSuccess);
					TCNotificationCenter.defaultCenter.removeObserver (AlertActivity.eventActivity, constants.kUpdateAlertWhenDeleteFileLocal);
					AlertActivity.eventActivity.Finish ();
				} catch(Exception ex){
					#if DEBUG
					Console.Write(ex.Message);
					#endif
				}
			}

			if (ConfirmedRequestsActivity.confirmedActivity != null) {
				TCNotificationCenter.defaultCenter.removeObserver (ConfirmedRequestsActivity.confirmedActivity, constants.kDeleteFileConfirmed);
				TCNotificationCenter.defaultCenter.removeObserver (ConfirmedRequestsActivity.confirmedActivity, Constants.kPostDeleteFileSuccess);
				try {
					ConfirmedRequestsActivity.confirmedActivity.Finish ();
				} catch(Exception ex){
					#if DEBUG
					Console.Write(ex.Message);
					#endif
				}
			}

			if(PastBookingActivity.pastBookingActivity != null){
				TCNotificationCenter.defaultCenter.removeObserver (PastBookingActivity.pastBookingActivity, constants.kDeleteFilePast);
				TCNotificationCenter.defaultCenter.removeObserver (PastBookingActivity.pastBookingActivity, constants.kNotifyUpdateBookingInfo);
				TCNotificationCenter.defaultCenter.removeObserver (PastBookingActivity.pastBookingActivity, Constants.kPostDeleteFileSuccess);
				try {
					PastBookingActivity.pastBookingActivity.Finish ();
				} catch(Exception ex){
					#if DEBUG
					Console.Write(ex.Message);
					#endif
				}
			}

			if (PastHistoryDetail.pastDetailActivity != null) {
				TCNotificationCenter.defaultCenter.removeObserver (PastHistoryDetail.pastDetailActivity, Constants.kUpdateTalkNowStep);
				TCNotificationCenter.defaultCenter.removeObserver (PastHistoryDetail.pastDetailActivity, constants.kDeferSuccess);
				try {
					PastHistoryDetail.pastDetailActivity.Finish ();
				} catch(Exception ex){
					#if DEBUG
					Console.Write(ex.Message);
					#endif
				}
			}

			if (MyProfileActivity.myProfileActivity != null) {
				try {
					TCNotificationCenter.defaultCenter.removeObserver(MyProfileActivity.myProfileActivity, constants.kGetStatusCurrentUser);
					MyProfileActivity.myProfileActivity.Finish ();
				} catch(Exception ex){
					#if DEBUG
					Console.Write(ex.Message);
					#endif
				}
			}

			if (CallingDurationActivity.callingActivity != null) {
				TCNotificationCenter.defaultCenter.removeObserver (CallingDurationActivity.callingActivity, Constants.kPostStopCall);
				TCNotificationCenter.defaultCenter.removeObserver (CallingDurationActivity.callingActivity, Constants.kPostFolloUp);
				TCNotificationCenter.defaultCenter.removeObserver (CallingDurationActivity.callingActivity, Constants.kPostUploadFileSuccess);
				try {
					CallingDurationActivity.callingActivity.Finish ();
				} catch(Exception ex){
					#if DEBUG
					Console.Write(ex.Message);
					#endif
				}
			}

			if (BookingRequestsActivity.bookingActivity != null) {
				try {
					BookingRequestsActivity.bookingActivity.Finish ();
				} catch(Exception ex){
					#if DEBUG
					Console.Write(ex.Message);
					#endif
				}
			}

			if (ChangePasswordActivity.changePassActivity != null) {
				try {
					ChangePasswordActivity.changePassActivity.Finish ();
				} catch(Exception ex){
					#if DEBUG
					Console.Write(ex.Message);
					#endif
				}
			}

			try {
				_activity.Finish();
			} catch(Exception ex){
				#if DEBUG
				Console.Write(ex.Message);
				#endif
			}
		}