Пример #1
0
        protected override void OnRestoreInstanceState(Bundle savedInstanceState)
        {
            base.OnRestoreInstanceState(savedInstanceState);
            var n = savedInstanceState.GetLong(DTSTART_KEY);

            dtstart                     = new DateTime(n);
            distanceparcourue           = savedInstanceState.GetLong(DISTANCE_KEY);
            isRequestingLocationUpdates = savedInstanceState.GetBoolean(REQUESTING_KEY);
            var buffer = savedInstanceState.GetByteArray(TOURNEE_KEY);
            //course = new Tour(buffer);
        }
        private void UnPackBundle()
        {
            Bundle args = Arguments;

            mInitialDate = new DateTime(args.GetLong("initialDate"));
            mMinDate     = new DateTime(args.GetLong("minDate"));
            mMaxDate     = new DateTime(args.GetLong("maxDate"));
            mIsClientSpecified24HourTime = args.GetBoolean("isClientSpecified24HourTime");
            mIs24HourTime   = args.GetBoolean("is24HourTime");
            mTheme          = args.GetInt("theme");
            mIndicatorColor = args.GetInt("indicatorColor");
        }
Пример #3
0
        public override long Run(com.android.vending.billing.IMarketBillingService service)
        {
            Bundle request = makeRequestBundle("REQUEST_PURCHASE");

            request.PutString(Consts.BILLING_REQUEST_ITEM_ID, mProductId);
            request.PutString(Consts.BILLING_REQUEST_ITEM_TYPE, mProductType);
            // Note that the developer payload is optional.
            if (mDeveloperPayload != null)
            {
                request.PutString(Consts.BILLING_REQUEST_DEVELOPER_PAYLOAD, mDeveloperPayload);
            }

            Bundle response = service.SendBillingRequest(request);

            PendingIntent pendingIntent
                = response.GetParcelable(Consts.BILLING_RESPONSE_PURCHASE_INTENT) as PendingIntent;

            if (pendingIntent == null)
            {
                Log.Error("BillingService", "Error with requestPurchase");
                return(Consts.BILLING_RESPONSE_INVALID_REQUEST_ID);
            }

            Intent intent = new Intent();

            ResponseHandler.buyPageIntentResponse(pendingIntent, intent);
            return(response.GetLong(Consts.BILLING_RESPONSE_REQUEST_ID,
                                    Consts.BILLING_RESPONSE_INVALID_REQUEST_ID));
        }
Пример #4
0
        public override void OnRestoreInstanceState(Bundle savedInstanceState)
        {
            base.OnRestoreInstanceState(savedInstanceState);
            long duration = savedInstanceState.GetLong(DURATION);

            _durationInputView.Duration = duration;
        }
Пример #5
0
 public void OnRestoreInstanceState(Bundle savedInstanceState)
 {
     view.SetDate(savedInstanceState.GetLong(DATE_KEY));
     view.SetStartLocation(savedInstanceState.GetString(START_LOC_KEY));
     view.SetEndLocation(savedInstanceState.GetString(END_LOC_KEY));
     view.ShowTimeAsDeparture(savedInstanceState.GetBoolean(ARRIVE_DEPART_KEY));
 }
        protected override void OnRestoreInstanceState(Bundle state)
        {
            base.OnRestoreInstanceState(state);

            long id = state.GetLong(GESTURES_INFO_ID, -1);

            if (id != -1)
            {
                var  entries  = sStore.GestureEntries;
                bool breakOut = false;
                foreach (string name in entries)
                {
                    if (breakOut)
                    {
                        break;
                    }
                    foreach (Gesture gesture in sStore.GetGestures(name))
                    {
                        if (gesture.ID == id)
                        {
                            mCurrentRenameGesture         = new NamedGesture();
                            mCurrentRenameGesture.Name    = name;
                            mCurrentRenameGesture.Gesture = gesture;
                            breakOut = true;
                            break;
                        }
                    }
                }
            }
        }
Пример #7
0
        public static async Task <Bundle> RunTestsAsync(ITestEntryPoint testEntryPoint, Bundle arguments = null)
        {
            var resultsFileName = arguments?.GetString("results-file-name", DefaultTestResultsFilename) ?? DefaultTestResultsFilename;

            var bundle = new Bundle();

            var entryPoint = new TestEntryPoint(testEntryPoint, resultsFileName);

            entryPoint.TestsCompleted += (sender, results) =>
            {
                var message =
                    $"Tests run: {results.ExecutedTests} " +
                    $"Passed: {results.PassedTests} " +
                    $"Inconclusive: {results.InconclusiveTests} " +
                    $"Failed: {results.FailedTests} " +
                    $"Ignored: {results.SkippedTests}";
                bundle.PutString("test-execution-summary", message);

                bundle.PutLong("return-code", results.FailedTests == 0 ? 0 : 1);
            };

            await entryPoint.RunAsync();

            if (File.Exists(entryPoint.TestsResultsFinalPath))
            {
                bundle.PutString("test-results-path", entryPoint.TestsResultsFinalPath);
            }

            if (bundle.GetLong("return-code", -1) == -1)
            {
                bundle.PutLong("return-code", 1);
            }

            return(bundle);
        }
Пример #8
0
        public override async void OnStart()
        {
            base.OnStart();

            var bundle = new Bundle();

            var entryPoint = new TestsEntryPoint(resultsFileName);

            entryPoint.TestsCompleted += (sender, results) =>
            {
                var message =
                    $"Tests run: {results.ExecutedTests} " +
                    $"Passed: {results.PassedTests} " +
                    $"Inconclusive: {results.InconclusiveTests} " +
                    $"Failed: {results.FailedTests} " +
                    $"Ignored: {results.SkippedTests}";
                bundle.PutString("test-execution-summary", message);

                bundle.PutLong("return-code", results.FailedTests == 0 ? 0 : 1);
            };

            await entryPoint.RunAsync();

            if (File.Exists(entryPoint.TestsResultsFinalPath))
            {
                bundle.PutString("test-results-path", entryPoint.TestsResultsFinalPath);
            }

            if (bundle.GetLong("return-code", -1) == -1)
            {
                bundle.PutLong("return-code", 1);
            }

            Finish(Result.Ok, bundle);
        }
Пример #9
0
        private void BindFields(WizardFragment wizardFragment, Bundle args)
        {
            var fields = wizardFragment.GetType().GetFields(); //Scan the step for fields annotated with WizardState and bind value if found in step's arguments

            foreach (var field in fields)
            {
                if (field.CustomAttributes == null || !field.CustomAttributes.Any(a => a.AttributeType == typeof(WizardStateAttribute)))
                {
                    continue;
                }

                try {
                    if (field.GetType() == typeof(DateTime))
                    {
                        field.SetValue(wizardFragment, new DateTime(args.GetLong(field.Name)));
                    }
                    else
                    {
                        //var value = args.Get(field.Name); //This wont work when passed to field.SetValue
                        var value = args.GetValue(field.Name, field.FieldType); //Workaround
                        field.SetValue(wizardFragment, value);
                    }
                }
                catch (FieldAccessException f) {
                    throw new ArgumentException(string.Format("Unable to access the field: {0}. Only public fields are supported", field.Name), f);
                }
            }
        }
Пример #10
0
        private void BindFields(Bundle args)
        {
            var fields = this.GetType().GetFields();

            foreach (var field in fields)
            {
                if (field.CustomAttributes == null || !field.CustomAttributes.Any(a => a.AttributeType == typeof(WizardStateAttribute)))
                {
                    continue;
                }

                try {
                    if (field.GetType() == typeof(DateTime))
                    {
                        field.SetValue(this, new DateTime(args.GetLong(field.Name)));
                    }
                    else
                    {
                        //var value = args.GetString(field.Name);
                        var value = args.GetValue(field.Name, field.FieldType); //Workaround
                        field.SetValue(this, value);
                    }
                }
                catch (FieldAccessException f) {
                    throw new ArgumentException(string.Format("Unable to access the field: {0}. Only public fields are supported", field.Name), f);
                }
            }
        }
Пример #11
0
        public long run(IMarketBillingService mService)
        {
            Bundle request = makeRequestBundle();

            addParams(request);
            Bundle response = new Bundle();

            try
            {
                response = mService.sendBillingRequest(request);
            }
            catch (NullPointerException e)
            {
                Log.Error(typeof(BillingRequest).FullName, "Known IAB bug. See: http://code.google.com/p/marketbilling/issues/detail?id=25", e);
                return(IGNORE_REQUEST_ID);
            }

            if (validateResponse(response))
            {
                processOkResponse(response);
                return(response.GetLong(KEY_REQUEST_ID, IGNORE_REQUEST_ID));
            }
            else
            {
                return(IGNORE_REQUEST_ID);
            }
        }
Пример #12
0
        //public bool TryPop<T>(Bundle bundle, out T config) where T : class
        //{
        //    config = null;
        //    if (!this.Contains(bundle))
        //        return false;

        //    config = this.Pop<T>(bundle);
        //    return true;
        //}


        public T Pop <T>(Bundle bundle) where T : class
        {
            var id  = bundle.GetLong(this.BundleKey);
            var cfg = (T)this.configStore[id];

            this.configStore.Remove(id);
            return(cfg);
        }
Пример #13
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            MobileBarcodeScanner.Initialize(Application);

            Window.SetFlags(WindowManagerFlags.Secure, WindowManagerFlags.Secure);
            SetContentView(Resource.Layout.activityMain);

            if (savedInstanceState != null)
            {
                _isAuthenticated = savedInstanceState.GetBoolean("isAuthenticated");
                _pauseTime       = new DateTime(savedInstanceState.GetLong("pauseTime"));
            }
            else
            {
                _isAuthenticated = false;
                _pauseTime       = DateTime.MinValue;
            }

            _toolbar = FindViewById <MaterialToolbar>(Resource.Id.toolbar);
            SetSupportActionBar(_toolbar);
            SupportActionBar.SetTitle(Resource.String.categoryAll);

            var appBarLayout = FindViewById <AppBarLayout>(Resource.Id.appBarLayout);

            _bottomAppBar = FindViewById <BottomAppBar>(Resource.Id.bottomAppBar);
            _bottomAppBar.NavigationClick += OnBottomAppBarNavigationClick;
            _bottomAppBar.MenuItemClick   += delegate
            {
                _toolbar.Menu.FindItem(Resource.Id.actionSearch).ExpandActionView();
                appBarLayout.SetExpanded(true);
                _authList.SmoothScrollToPosition(0);
            };

            _coordinatorLayout = FindViewById <CoordinatorLayout>(Resource.Id.coordinatorLayout);
            _progressBar       = FindViewById <ProgressBar>(Resource.Id.appBarProgressBar);

            _addButton        = FindViewById <FloatingActionButton>(Resource.Id.buttonAdd);
            _addButton.Click += OnAddButtonClick;

            _authList               = FindViewById <RecyclerView>(Resource.Id.list);
            _emptyStateLayout       = FindViewById <LinearLayout>(Resource.Id.layoutEmptyState);
            _emptyMessageText       = FindViewById <TextView>(Resource.Id.textEmptyMessage);
            _viewGuideButton        = FindViewById <MaterialButton>(Resource.Id.buttonViewGuide);
            _viewGuideButton.Click += delegate { StartActivity(typeof(GuideActivity)); };

            _refreshOnActivityResume = false;

            DetectGoogleAPIsAvailability();

            var prefs       = PreferenceManager.GetDefaultSharedPreferences(this);
            var firstLaunch = prefs.GetBoolean("firstLaunch", true);

            if (firstLaunch)
            {
                StartActivity(typeof(IntroActivity));
            }
        }
Пример #14
0
 internal static object GetValue(this Bundle args, string key, Type type)
 {
     if (type == typeof(string))
     {
         return(args.GetString(key));
     }
     else if (type == typeof(int))
     {
         return(args.GetInt(key));
     }
     else if (type == typeof(bool))
     {
         return(args.GetBoolean(key));
     }
     else if (type == typeof(double))
     {
         return(args.GetDouble(key));
     }
     else if (type == typeof(float))
     {
         return(args.GetFloat(key));
     }
     else if (type == typeof(short))
     {
         return(args.GetShort(key));
     }
     else if (type == typeof(DateTime))
     {
         return(new DateTime(args.GetLong(key)));
     }
     else if (type == typeof(char))
     {
         return(args.GetChar(key));
     }
     else if (typeof(Parcelable).IsAssignableFrom(type))
     {
         return(args.GetParcelable(key));
     }
     else if (type is Java.IO.ISerializable)
     {
         return(args.GetSerializable(key));
     }
     else if (type.IsValueType == false)   //Runtime serialization for reference type.. use json.net serialization
     {
         var value = args.GetString(key);
         if (string.IsNullOrWhiteSpace(value))
         {
             return(null);
         }
         return(Newtonsoft.Json.JsonConvert.DeserializeObject(value, type));
     }
     else
     {
         //TODO: Add support for arrays
         throw new ArgumentException(string.Format("Unsuported type. Cannot pass value to variable {0} of step {1}. Variable type is unsuported.",
                                                   key, type.FullName));
     }
 }
Пример #15
0
        public long GetLong(long defaultValue = default, string?key = null)
        {
            if (string.IsNullOrWhiteSpace(key))
            {
                throw new ArgumentException("Value cannot be null or whitespace.", nameof(key));
            }

            return(_bundle.GetLong(key, defaultValue));
        }
Пример #16
0
        /// <inheritdoc />
        public long GetLong(long defaultValue = default, [CallerMemberName] string?key = null)
        {
            if (key == null)
            {
                throw new ArgumentNullException(nameof(key));
            }

            return(_bundle.GetLong(key, defaultValue));
        }
Пример #17
0
        protected async override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            if (string.IsNullOrWhiteSpace(_token))
            {
                _token       = Intent.GetStringExtra("Token");
                _userName    = Intent.GetStringExtra("UserName");
                _id          = Intent.GetLongExtra("Id", long.MinValue);
                _description = Intent.GetStringExtra("Description");
                _status      = Intent.GetStringExtra("Status");
            }

            if (savedInstanceState != null)
            {
                _token       = savedInstanceState.GetString("Token");
                _userName    = savedInstanceState.GetString("UserName");
                _id          = savedInstanceState.GetLong("Id");
                _description = savedInstanceState.GetString("Description");
                _status      = savedInstanceState.GetString("Status");
            }

            SetContentView(Resource.Layout.LabDetail);

            EvidenceDetail evidenceDetailItem;

            var evidenceDetailFragment = (EvidenceDetailFragment)FragmentManager.FindFragmentByTag("evidenceDetail");

            if (evidenceDetailFragment == null)
            {
                HackAtHome.SAL.EvidenceService evidenceService = new HackAtHome.SAL.EvidenceService();
                evidenceDetailItem = await evidenceService.GetItemByIdAsync(_token, (int)_id);

                evidenceDetailFragment = new EvidenceDetailFragment();
                evidenceDetailFragment.EvidenceDetail = evidenceDetailItem;
                FragmentManager.BeginTransaction().Add(evidenceDetailFragment, "evidenceDetail");
            }
            else
            {
                evidenceDetailItem = evidenceDetailFragment.EvidenceDetail;
            }

            var textViewDetailUserName       = FindViewById <TextView>(Resource.Id.textViewDetailUserName);
            var textViewLabDetailDescription = FindViewById <TextView>(Resource.Id.textViewLabDetailDescription);
            var textViewLabDetailStatus      = FindViewById <TextView>(Resource.Id.textViewLabDetailStatus);
            var webViewDetailDescription     = FindViewById <WebView>(Resource.Id.webViewDetailDescription);
            var resourcePosition             = IsLandScape(this) ? Resource.String.LandScapeText : Resource.String.Portrait;
            var imageViewContent             = FindViewById <ImageView>(Resource.Id.imageViewContent);

            textViewDetailUserName.Text       = _userName;
            textViewLabDetailDescription.Text = $"{_description} ({GetString(resourcePosition)})";
            textViewLabDetailStatus.Text      = _status;
            webViewDetailDescription.LoadDataWithBaseURL(null, $"<html><head><style type='text/css'>body{{color:#fff}}</style></head><body>{evidenceDetailItem.Description}</body></html>", "text/html", "utf-8", null);
            webViewDetailDescription.SetBackgroundColor(Android.Graphics.Color.Transparent);

            Koush.UrlImageViewHelper.SetUrlDrawable(imageViewContent, evidenceDetailItem.Url);
        }
Пример #18
0
 protected override void OnPostCreate(Bundle savedInstanceState)
 {
     if (savedInstanceState != null)
     {
         lastSyncInMillis = savedInstanceState.GetLong(LastSyncArgument);
         syncStatus       = savedInstanceState.GetInt(LastSyncResultArgument);
         UpdateSyncStatus();
     }
     base.OnPostCreate(savedInstanceState);
 }
Пример #19
0
        public override long Run(com.android.vending.billing.IMarketBillingService service)
        {
            Bundle request = makeRequestBundle("CONFIRM_NOTIFICATIONS");

            request.PutStringArray(Consts.BILLING_REQUEST_NOTIFY_IDS, mNotifyIds);
            Bundle response = service.SendBillingRequest(request);

            logResponseCode("confirmNotifications", response);
            return(response.GetLong(Consts.BILLING_RESPONSE_REQUEST_ID,
                                    Consts.BILLING_RESPONSE_INVALID_REQUEST_ID));
        }
Пример #20
0
        public void RestoreState(Bundle icicle)
        {
            SetMode(GameMode.Paused);

            apples         = Coordenadas.ArrayToList(icicle.GetIntArray("mCheeseList"));
            mDireccion     = (Direccion)icicle.GetInt("mDireccion");
            mSig_Direccion = (Direccion)icicle.GetInt("mSig_Direccion");
            mMoveDelay     = icicle.GetInt("mMoveDelay");
            mPuntos        = icicle.GetLong("mPuntos");
            snake_campo    = Coordenadas.ArrayToList(icicle.GetIntArray("mSnakeTrail"));
        }
Пример #21
0
        // Restore game state if our process is being relaunched
        public void RestoreState(Bundle icicle)
        {
            SetMode(GameMode.Paused);

            apples         = Coordinate.ArrayToList(icicle.GetIntArray("mAppleList"));
            mDirection     = (Direction)icicle.GetInt("mDirection");
            mNextDirection = (Direction)icicle.GetInt("mNextDirection");
            mMoveDelay     = icicle.GetInt("mMoveDelay");
            mScore         = icicle.GetLong("mScore");
            snake_trail    = Coordinate.ArrayToList(icicle.GetIntArray("mSnakeTrail"));
        }
Пример #22
0
        public override long Run(com.android.vending.billing.IMarketBillingService service)
        {
            mNonce = Security.generateNonce();

            Bundle request = makeRequestBundle("RESTORE_TRANSACTIONS");

            request.PutLong(Consts.BILLING_REQUEST_NONCE, mNonce);
            Bundle response = service.SendBillingRequest(request);

            logResponseCode("restoreTransactions", response);
            return(response.GetLong(Consts.BILLING_RESPONSE_REQUEST_ID,
                                    Consts.BILLING_RESPONSE_INVALID_REQUEST_ID));
        }
Пример #23
0
        protected override void OnRestoreInstanceState(IParcelable state)
        {
            Bundle      bundle     = (Bundle)state;
            IParcelable superState = (IParcelable)bundle.GetParcelable("superState");

            base.OnRestoreInstanceState(superState);

            mNeedleInitialized  = bundle.GetBoolean("needleInitialized");
            mNeedleVelocity     = bundle.GetFloat("needleVelocity");
            mNeedleAcceleration = bundle.GetFloat("needleAcceleration");
            mNeedleLastMoved    = bundle.GetLong("needleLastMoved");
            mCurrentValue       = bundle.GetFloat("currentValue");
            mTargetValue        = bundle.GetFloat("targetValue");
        }
Пример #24
0
        public override long Run(com.android.vending.billing.IMarketBillingService service)
        {
            mNonce = Security.generateNonce();

            Bundle request = makeRequestBundle("GET_PURCHASE_INFORMATION");

            request.PutLong(Consts.BILLING_REQUEST_NONCE, mNonce);
            request.PutStringArray(Consts.BILLING_REQUEST_NOTIFY_IDS, mNotifyIds);
            Bundle response = service.SendBillingRequest(request);

            logResponseCode("getPurchaseInformation", response);
            return(response.GetLong(Consts.BILLING_RESPONSE_REQUEST_ID,
                                    Consts.BILLING_RESPONSE_INVALID_REQUEST_ID));
        }
Пример #25
0
        protected override void OnRestoreInstanceState(Bundle savedInstanceState)
        {
            base.OnRestoreInstanceState(savedInstanceState);

            var response = savedInstanceState.GetString("response");

            SetResponseText(response);

            long requestId = savedInstanceState.GetLong("request");

            myRequest = VKRequest.GetRegisteredRequest(requestId);
            if (myRequest != null)
            {
                myRequest.UnregisterObject();
                myRequest.SetRequestListener(OnRequestComplete, OnRequestError, OnRequestProgress, OnRequestAttemptFailed);
            }
        }
Пример #26
0
 protected override void OnCreate(Bundle savedInstanceState)
 {
     base.OnCreate(savedInstanceState);
     SetContentView(Resource.Layout.Main);
     txtTimer        = FindViewById <TextView>(Resource.Id.txtTimer);
     btnTimer        = FindViewById <Button>(Resource.Id.btnTimer);
     btnHistory      = FindViewById <Button>(Resource.Id.btnHistory);
     timerDelegate   = new TimerCallback(UpdatetxtTimer);
     dialogDisplayer = new Classes.DialogDisplayer(this);
     AddHandlers();
     if (savedInstanceState != null)
     {
         timerOn   = savedInstanceState.GetBoolean("timerOn", false);
         startTime = new DateTime(savedInstanceState.GetLong("startTimeTicks"));
         ResumeTimer();
     }
     System.Diagnostics.Debug.WriteLine($"MainActivity - OnCreate {startTime}, {timerOn}");
 }
        private AuthenticationResultEx GetResultFromBrokerResponse(Bundle bundleResult)
        {
            if (bundleResult == null)
            {
                throw new AdalException("bundleResult");
            }

            int    errCode = bundleResult.GetInt(AccountManager.KeyErrorCode);
            string msg     = bundleResult.GetString(AccountManager.KeyErrorMessage);

            if (!string.IsNullOrEmpty(msg))
            {
                throw new AdalException(errCode.ToString(CultureInfo.InvariantCulture), msg);
            }
            else
            {
                bool initialRequest = bundleResult.ContainsKey(BrokerConstants.AccountInitialRequest);
                if (initialRequest)
                {
                    // Initial request from app to Authenticator needs to launch
                    // prompt. null resultEx means initial request
                    return(null);
                }

                // IDtoken is not present in the current broker user model
                UserInfo             userinfo = GetUserInfoFromBrokerResult(bundleResult);
                AuthenticationResult result   =
                    new AuthenticationResult("Bearer", bundleResult.GetString(AccountManager.KeyAuthtoken),
                                             ConvertFromTimeT(bundleResult.GetLong("account.expiredate", 0)))
                {
                    UserInfo = userinfo
                };

                result.UpdateTenantAndUserInfo(bundleResult.GetString(BrokerConstants.AccountUserInfoTenantId), null,
                                               userinfo);

                return(new AuthenticationResultEx
                {
                    Result = result,
                    RefreshToken = null,
                    ResourceInResponse = null,
                });
            }
        }
Пример #28
0
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            base.OnCreateView(inflater, container, savedInstanceState);
            View   view         = inflater.Inflate(Resource.Layout.PhoneVerification, container, true);
            Button verifyButton = view.FindViewById <Button>(Resource.Id.Verify);

            verifyButton.Click += VerifyButton_Click;
            if (savedInstanceState != null && savedInstanceState.ContainsKey(PRE_LOADED))
            {
                long     secondsLeft = savedInstanceState.GetLong(TIMER_COUNT);
                TextView textTimer   = view.FindViewById <TextView>(Resource.Id.countdownTimer);

                if (secondsLeft > 0)
                {
                    textTimer.Text = "00:" + secondsLeft.ToString();
                    Timer          = new VerificationCountDownTimer(textTimer, (int)secondsLeft, 1000);
                }
                else
                {
                    string[] formerValues = savedInstanceState.GetStringArray(INPUT_VALUES);
                    useTimer       = false;
                    textTimer.Text = "00:00";
                    ReadyInputs(formerValues);
                }
            }
            else
            {
                TextView textTimer = view.FindViewById <TextView>(Resource.Id.countdownTimer);
                textTimer.Text = "00:" + verificationTimeout.ToString();
                Timer          = new VerificationCountDownTimer(textTimer, verificationTimeout, 1000);
            }

            if (Dialog != null)
            {
                if (useTimer)
                {
                    Timer.FinishedCount += Timer_FinishedCount;
                    Timer.Start();
                }
            }
            return(view);
        }
Пример #29
0
        void HandleActivityStateChanged(Activity activity, ActivityState newState, Bundle savedData)
        {
            switch (newState)
            {
            case ActivityState.Created:
                if (activity != null && !savedData.ContainsKey(BundleIdentityKey))
                {
                    return;
                }
                var id = savedData.GetLong(BundleIdentityKey);
                if (id == activityIdentity)
                {
                    Instance = activity;
                }
                break;

            case ActivityState.SaveInstance:
                if (IsSameActivity(activity))
                {
                    savedData.PutLong(BundleIdentityKey, activityIdentity);
                }
                break;

            case ActivityState.Resumed:
            case ActivityState.Started:
                if (IsSameActivity(activity))
                {
                    SetAvailability(isAvailable: true);
                }
                break;

            case ActivityState.Stopped:
            case ActivityState.Destroyed:
            case ActivityState.Paused:
                if (IsSameActivity(activity))
                {
                    SetAvailability(isAvailable: false);
                }
                break;
            }
        }
Пример #30
0
        //////////////////////////////////////////////////////////////////////////////////////////////////
        // Private
        //////////////////////////////////////////////////////////////////////////////////////////////////

        private long FindOutDirectorId(Bundle bundle)
        {
            long returnValue;

            if (bundle != null)
            {
                returnValue = bundle.GetLong(SurfaceHelper.DirectorIdKey, long.MinValue);
                if (returnValue == long.MinValue)
                {
                    throw new Exception("Unable to read DirectorId from Android saved instance state.");
                }
            }
            else
            {
                returnValue = Intent.GetLongExtra(SurfaceHelper.DirectorIdKey, -1);
                if (returnValue == -1)
                {
                    throw new Exception("Unable to read DirectorId from Android intent.");
                }
            }

            return(returnValue);
        }
Пример #31
0
        public void RestoreState(Bundle icicle)
        {
            SetMode (GameMode.Paused);

            apples = Coordenadas.ArrayToList (icicle.GetIntArray ("mCheeseList"));
            mDireccion = (Direccion)icicle.GetInt ("mDireccion");
            mSig_Direccion = (Direccion)icicle.GetInt ("mSig_Direccion");
            mMoveDelay = icicle.GetInt ("mMoveDelay");
            mPuntos = icicle.GetLong ("mPuntos");
            snake_campo = Coordenadas.ArrayToList (icicle.GetIntArray ("mSnakeTrail"));
        }
Пример #32
0
        private void BindFields(Bundle args)
        {
            var fields = this.GetType().GetFields();

            foreach (var field in fields) {
                if (field.CustomAttributes == null || !field.CustomAttributes.Any(a => a.AttributeType == typeof(WizardStateAttribute)))
                    continue;

                try {
                    if (field.GetType() == typeof(DateTime)) {
                        field.SetValue(this, new DateTime(args.GetLong(field.Name)));
                    }
                    else {
                        //var value = args.GetString(field.Name);
                        var value = args.GetValue(field.Name, field.FieldType); //Workaround
                        field.SetValue(this, value);
                    }
                }
                catch (FieldAccessException f) {
                    throw new ArgumentException(string.Format("Unable to access the field: {0}. Only public fields are supported", field.Name), f);
                }
            }
        }
Пример #33
0
        private void BindFields(WizardFragment wizardFragment, Bundle args)
        {

            var fields = wizardFragment.GetType().GetFields(); //Scan the step for fields annotated with WizardState and bind value if found in step's arguments
            
            foreach (var field in fields) {
                if (field.CustomAttributes == null || !field.CustomAttributes.Any(a => a.AttributeType == typeof(WizardStateAttribute)))
                    continue;

                try {
                    if (field.GetType() == typeof(DateTime)) {
                        field.SetValue(wizardFragment, new DateTime(args.GetLong(field.Name)));
                    }
                    else {
                        //var value = args.Get(field.Name); //This wont work when passed to field.SetValue
                        var value = args.GetValue(field.Name, field.FieldType); //Workaround
                        field.SetValue(wizardFragment, value);
                    }
                }
                catch (FieldAccessException f) {
                    throw new ArgumentException(string.Format("Unable to access the field: {0}. Only public fields are supported", field.Name), f);
                }
            }
        }
Пример #34
0
        // Restore game state if our process is being relaunched
        public void RestoreState(Bundle icicle)
        {
            SetMode (GameMode.Paused);

            apples = Coordinate.ArrayToList (icicle.GetIntArray ("mAppleList"));
            mDirection = (Direction)icicle.GetInt ("mDirection");
            mNextDirection = (Direction)icicle.GetInt ("mNextDirection");
            mMoveDelay = icicle.GetInt ("mMoveDelay");
            mScore = icicle.GetLong ("mScore");
            snake_trail = Coordinate.ArrayToList (icicle.GetIntArray ("mSnakeTrail"));
        }
Пример #35
0
 protected override void OnPostCreate (Bundle savedInstanceState)
 {
     if (savedInstanceState != null) {
         lastSyncInMillis = savedInstanceState.GetLong (LastSyncArgument);
         syncStatus = savedInstanceState.GetInt (LastSyncResultArgument);
         UpdateSyncStatus ();
     }
     base.OnPostCreate (savedInstanceState);
 }
Пример #36
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            powerManager = (PowerManager)GetSystemService(Context.PowerService);
            wakeLock = powerManager.NewWakeLock(WakeLockFlags.Partial, "MyWakeLock");
            wakeLock.Acquire();

            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.Pedometer);

            chrono = FindViewById<Chronometer>(Resource.Id.chronometer1);
            sensorManager = (SensorManager)GetSystemService(Context.SensorService);
            stepsTextView = FindViewById<TextView>(Resource.Id.pedometer);
            caloriesTextView = FindViewById<TextView>(Resource.Id.calories);
            speedTextView = FindViewById<TextView>(Resource.Id.speed);
            distanceTextView = FindViewById<TextView>(Resource.Id.distance);
            timeTextView = FindViewById<TextView>(Resource.Id.time);

            if (savedInstanceState != null)
            {
                steps = savedInstanceState.GetInt("steps", 0);
                calories = savedInstanceState.GetFloat("calories", 0.0f);
                speed = savedInstanceState.GetFloat("speed", 0.0f);
                distance = savedInstanceState.GetFloat("distance", 0.0f);
                chrono.Base = savedInstanceState.GetLong("time", SystemClock.ElapsedRealtime());
                run = savedInstanceState.GetBoolean("run", false);
            }

            chrono.Format = "00:0%s";
            chrono.OnChronometerTickListener = this;

            int h = 480;
            mYOffset = h * 0.5f;
            mScale[0] = -(h * 0.5f * (1.0f / (SensorManager.StandardGravity * 2)));
            mScale[1] = -(h * 0.5f * (1.0f / (SensorManager.MagneticFieldEarthMax)));

            if (run)
            {
                refreshTextViews();
                sensorsListenerRegister();
                chrono.Start();
            }
        }