Example #1
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Main);

            // Add our touch handlers.
            PinchDetector    = new ScaleGestureDetector(this, this);
            MoveDetector     = new MoveGestureDetector(this, this);
            RotationDetector = new RotateGestureDetector(this, this);

            Detector = new GestureDetector(this, this);
            Detector.IsLongpressEnabled = false;

            MainLayout        = (RelativeLayout)FindViewById(Resource.Id.main);
            MainLayout.Touch += HandleTouch;

            // Disable touch handling by the views themselves.
            for (var i = 0; i < MainLayout.ChildCount; i++)
            {
                var view = MainLayout.GetChildAt(i);
                Log("OnCreate", "View {0} disabled.", i);
                view.Focusable            = true;
                view.FocusableInTouchMode = true;
                view.RequestFocus();
            }

            BootstrapDropbox();
        }
Example #2
0
        void UpdateDropbox()
        {
            Log("Updating Dropbox");

            var table = DropboxDatastore.GetTable("monkeys");

            // Update records in local cache.
            if (Records.Count == 0)
            {
                for (var i = 0; i < MainLayout.ChildCount; i++)
                {
                    var view   = (MonkeyView)MainLayout.GetChildAt(i);
                    var monkey = view.Monkey;
                    monkey.Z = i;
                    var record = table.GetOrInsert(monkey.Name, monkey.ToFields());
                    Records[monkey.Name] = record;
                }
            }
            else
            {
                for (var i = 0; i < MainLayout.ChildCount; i++)
                {
                    var view   = (MonkeyView)MainLayout.GetChildAt(i);
                    var monkey = view.Monkey;
                    monkey.Z = i;
                    DBRecord record;
                    var      hasValue = Records.TryGetValue(monkey.Name, out record);
                    if (hasValue)
                    {
                        record.SetAll(monkey.ToFields());
                    }
                    else
                    {
                        table.GetOrInsert(monkey.Name, monkey.ToFields());
                    }
                }
            }

            if (!VerifyStore())
            {
                RestartAuthFlow();
            }
            else
            {
                DropboxDatastore.Sync();
            }
        }
Example #3
0
        MonkeyView ViewRespondingToHitTest(Rect hit)
        {
            var currentView = default(MonkeyView);

            for (var i = MainLayout.ChildCount - 1; i > -1; i--)
            {
                var view = (MonkeyView)MainLayout.GetChildAt(i);

                if (IsWithinCircularBounds(hit, view.CurrentBounds))
                {
                    currentView = view;
                    currentView.RequestFocus();
                    break;
                }
            }
            return(currentView);
        }