コード例 #1
0
ファイル: ScanActivity.cs プロジェクト: Gokhu18/CSE
        public void ReceiveDetections(Detector.Detections detections)
        {
            //var canvas = _transparentView.Holder.LockCanvas();
            //canvas.DrawColor(Color.Transparent, PorterDuff.Mode.Clear);
            // _transparentView.Holder.UnlockCanvasAndPost(canvas);

            SparseArray items = detections.DetectedItems;

            if (items.Size() != 0)
            {
                _textView.Post(() =>
                {
                    try
                    {
                        //var tuple = ReceiptTextValidation.ValidateItems(items);
                        ItemList = ReceiptValidator.ValidateItems(items);
                        //ItemList = tuple.Item1;
                        StringBuilder sb = new StringBuilder();
                        _textView.SetTextColor(Android.Graphics.Color.Red);
                        foreach (var item in ItemList)
                        {
                            sb.Append("name: " + item.Name + "price" + item.Price + "\n");
                        }
                        //sb.Append(tuple.Item2);
                        _textView.Text = sb.ToString();

                        // test if item list size doesnt change between scanning frames threshold times
                        if (ItemList.Count == _prevCount && _prevCount != 0)
                        {
                            _numerator++;
                        }
                        else
                        {
                            _prevCount = ItemList.Count;
                            _numerator = 0;
                        }

                        if (_numerator >= _threshold)
                        {
                            _textView.SetTextColor(Android.Graphics.Color.White);
                            _textView.Text = sb.ToString();


                            Intent intent = new Intent(this, typeof(MainActivity))
                                            .SetFlags(ActivityFlags.ReorderToFront);
                            SetResult(Result.Ok, intent);
                            Finish();
                        }
                    }
                    catch (System.Exception e)
                    {
                        _textView.Text = e.ToString();
                    }
                });
            }
        }
コード例 #2
0
ファイル: IAPManager.cs プロジェクト: Fromfame/RED
        #pragma warning restore 0414

        // initialize IAPs, billing systems and database,
        // as well as shop components in this order
        void Awake()
        {
            //make sure we keep one instance of this script in the game
            if (instance)
            {
                Destroy(gameObject);
                return;
            }
            DontDestroyOnLoad(this);
            isDebug = Debug.isDebugBuild;

            //set static reference
            instance = this;
            //populate IAP dictionary and arrays with product ids
            InitIds();

			var module = StandardPurchasingModule.Instance();
			var builder = ConfigurationBuilder.Instance(module);
			RequestProductData(builder);

            builder.Configure<IGooglePlayConfiguration>().SetPublicKey(googleStoreKey);
            if(isDebug)
            {
                builder.Configure<IMicrosoftConfiguration>().useMockBillingSystem = true;
                // Write out our Amazon Sandbox JSON file.
                // This has no effect when the Amazon billing service is not in use.
                builder.Configure<IAmazonConfiguration>().WriteSandboxJSON(builder.products);
                // Enable "developer mode" for purchases, not requiring real-world money
                builder.Configure<ISamsungAppsConfiguration>().SetMode(SamsungAppsMode.AlwaysSucceed);
            }

            // Now we're ready to initialize Unity IAP.
            UnityPurchasing.Initialize(this, builder);

            //initialize database, remote and shop managers
            GetComponent<IAPListener>().Init();
            GetComponent<DBManager>().Init();
            StartCoroutine(RemoteDownload());
            validator = GetComponent<ReceiptValidator>();

            #if UNITY_5_4_OR_NEWER
                SceneManager.sceneLoaded += OnSceneWasLoaded;
            #endif
            OnSceneLoaded();
        }
コード例 #3
0
        public void ReceiptValidator_ThrowsOnInvalidKey()
        {
            var target = new ReceiptValidator();

            target.Validate("test", "Th!s$houldFa!l");
        }
コード例 #4
0
        public void ReceiptValidator_ThrowsOnNullValue()
        {
            var target = new ReceiptValidator();

            target.Validate("test", null);
        }
コード例 #5
0
        public void ReceiptValidator_WorksCorrectly()
        {
            var target = new ReceiptValidator();

            target.Validate("test", "yHKcl6eN0Gz9AXR22CAtslEVX8DxCc");  //Example receipt generated based on https://pushover.net/api#receipt
        }