Ejemplo n.º 1
0
 private void SpinnerPoEnd_ItemSelected(object sender, AdapterView.ItemSelectedEventArgs e)
 {
     if (SpinnerPoEnd.SelectedItemPosition != -1)
     {
         LoaderView.Visibility = ViewStates.Visible;
         AnimationLoader.Start();
         new Thread(new ThreadStart(delegate //поток для загрузки данных
         {
             var cost = Prices.GetPrice(routs[SpinnerRouts.SelectedItemPosition].PromPynkt[SpinnerPoStart.SelectedItemPosition].id, ObratPO[SpinnerPoEnd.SelectedItemPosition].id, routs[SpinnerRouts.SelectedItemPosition].id);
             if (cost != "false")
             {
                 trips = Trips.GetTripsOnDate(TripDate.ToString("yyyy-MM-dd"), routs[SpinnerRouts.SelectedItemPosition].PromPynkt[SpinnerPoStart.SelectedItemPosition].id.ToString(), ObratPO[SpinnerPoEnd.SelectedItemPosition].id.ToString(), routs[SpinnerRouts.SelectedItemPosition].id.ToString());
                 ListViewTripsParmetr.Height = Convert.ToInt32(function.convertDpToPixel(90, this)) * trips.Count;
                 RunOnUiThread(() => ListViewTrips.Adapter = new TripsAdapter(this, trips));
                 RunOnUiThread(() => AnimationLoader.Stop());
                 RunOnUiThread(() => LoaderView.Visibility = ViewStates.Invisible);
             }
             else
             {
                 RunOnUiThread(() => ListViewTrips.Adapter = null);
                 RunOnUiThread(() => AnimationLoader.Stop());
                 RunOnUiThread(() => LoaderView.Visibility = ViewStates.Invisible);
                 RunOnUiThread(() => function.AlertDialogShow("Предупреждение", "Между выбранными пунктами не осуществляется перевозка.", this));
             }
         })).Start();
     }
 }
 private void StartColorButtonClick(object sender, EventArgs e)
 {
     _animation = (AnimationDrawable)_gradientImageView.Background;
     _animation.SetEnterFadeDuration(ms: 1000);
     _animation.SetExitFadeDuration(ms: 2000);
     _animation.Start();
 }
Ejemplo n.º 3
0
 void ShowProgress(bool busy)
 {
     if (error)
     {
         mapView.Visibility    = ViewStates.Invisible;
         errorImage.Visibility = ViewStates.Visible;
         pager.Visibility      = ViewStates.Gone;
     }
     else
     {
         errorImage.Visibility = ViewStates.Gone;
         mapView.Visibility    = busy ? ViewStates.Invisible : ViewStates.Visible;
         pager.Visibility      = busy ? ViewStates.Gone : ViewStates.Visible;
     }
     refresher.Enabled      = !busy;
     progressBar.Visibility = busy ? ViewStates.Visible : ViewStates.Gone;
     if (busy)
     {
         coffeeProgress.Start();
     }
     else
     {
         coffeeProgress.Stop();
     }
 }
Ejemplo n.º 4
0
        public void Start()
        {
            if (linearLayout != null)
            {
                linearLayout.SetBackgroundResource(drawableId);
            }
            else if (relativeLayout != null)
            {
                relativeLayout.SetBackgroundResource(drawableId);
            }
            else
            {
                imageView?.SetBackgroundResource(drawableId);
            }

            if (linearLayout != null)
            {
                frameAnimation = (AnimationDrawable)linearLayout.Background;
            }
            else if (relativeLayout != null)
            {
                frameAnimation = (AnimationDrawable)relativeLayout.Background;
            }
            else if (imageView != null)
            {
                frameAnimation = (AnimationDrawable)imageView.Background;
            }
            frameAnimation.SetEnterFadeDuration(duration);
            frameAnimation.SetExitFadeDuration(duration);
            frameAnimation.Start();
        }
Ejemplo n.º 5
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            SetContentView(Resource.Layout.Main);

            drawer        = FindViewById <DrawerLayout>(Resource.Id.drawer_layout);
            navView       = FindViewById <NavigationView>(Resource.Id.nav_view);
            LoaderView    = FindViewById <RelativeLayout>(Resource.Id.LoaderView);
            LoaderImage   = FindViewById <ImageView>(Resource.Id.LoaderImage);
            LoaderView    = FindViewById <RelativeLayout>(Resource.Id.LoaderView);
            ListViewMarsh = FindViewById <ListView>(Resource.Id.ListViewMarsh);
            ListViewPO    = FindViewById <ListView>(Resource.Id.ListViewPO);
            ImageView DrawerImage = FindViewById <ImageView>(Resource.Id.Button_menu);

            DrawerImage.Click += DrawerImage_Click;

            AnimationLoader = (AnimationDrawable)LoaderImage.Drawable;
            AnimationLoader.Start();

            HeaderView = LayoutInflater.From(this).Inflate(Resource.Layout.drawer_header, null, false);

            navView.AddHeaderView(HeaderView);
            navView.NavigationItemSelected += NavView_NavigationItemSelected;
            new Thread(new ThreadStart(delegate //поток для загрузки данных
            {
                var user      = User.GetInstance(0, "", "", GetString(Resource.String.token));
                var marshruts = Marshruts.GetMarshruts();
                marshruts[0].GetPromPynkt();
                RunOnUiThread(() => ListViewMarsh.Adapter = new ArrayAdapter <Marshrut> (this, Android.Resource.Layout.SimpleListItem1, marshruts));
                RunOnUiThread(() => AnimationLoader.Stop());
                RunOnUiThread(() => LoaderView.Visibility = ViewStates.Invisible);
            })).Start();
        }
        /**
         * 初始化加载动画
         */
        private void InitAnimation()
        {
            try
            {
                if (mVideoPrepareLayout == null)
                {
                    mPlayerView         = FindViewById <VideoPlayerView>(Resource.Id.playerView);
                    mBufferingIndicator = FindViewById <View>(Resource.Id.buffering_indicator);
                    mVideoPrepareLayout = FindViewById <RelativeLayout>(Resource.Id.video_start);
                    mAnimImageView      = FindViewById <ImageView>(Resource.Id.bili_anim);
                    mPrepareText        = FindViewById <TextView>(Resource.Id.video_start_info);
                }

                mVideoPrepareLayout.Visibility = ViewStates.Visible;// .SetVisibility(View.VISIBLE);

                startText = startText + "【完成】\n解析视频地址...";
                mPrepareText.SetText(startText, BufferType.Normal);
                mLoadingAnim = (AnimationDrawable)mAnimImageView.Background;// GetBackground();
                mLoadingAnim.Start();
            }
            catch (Java.Lang.Exception e)
            {
                Log.Error(TAG, "InitAnimation--" + e.ToString());
            }
        }
Ejemplo n.º 7
0
        public void startAnimation()
        {
            ImageView         imageView = FindViewById <ImageView>(Resource.Animation.anim_android);
            AnimationDrawable animation = (AnimationDrawable)imageView.Drawable;

            animation.Start();
        }
 public override void OnWindowFocusChanged(bool hasFocus)
 {
     base.OnWindowFocusChanged(hasFocus);
     if (hasFocus)
     {
         circleAnimation.Start();
     }
 }
Ejemplo n.º 9
0
        protected override async void OnResume()
        {
            _animation?.Start();
            base.OnResume();
            await Task.Delay(2000);

            this.StartActivity <MainActivity>();
        }
Ejemplo n.º 10
0
 public override void OnWindowFocusChanged(bool hasFocus)
 {
     if (hasFocus)
     {
         ImageView         imageView = FindViewById <ImageView>(Resource.Id.animated_android);
         AnimationDrawable animation = (AnimationDrawable)imageView.Drawable;
         animation.Start();
     }
 }
Ejemplo n.º 11
0
        private void AddBackgroundAnimations()
        {
            CoordinatorLayout rootLayout        = (CoordinatorLayout)FindViewById(Resource.Id.root_layout);
            AnimationDrawable animationDrawable = (AnimationDrawable)rootLayout.Background;

            animationDrawable.SetEnterFadeDuration(2000);
            animationDrawable.SetExitFadeDuration(4000);
            animationDrawable.Start();
        }
Ejemplo n.º 12
0
 public override void OnStartAnim()
 {
     Title.Text = MainContext.GetText(Resource.String.Lbl_Refreshing);
     if (animationLoading != null)
     {
         ImageIcon.SetImageDrawable(animationLoading);
         animationLoading.Start();
     }
 }
Ejemplo n.º 13
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            SetContentView(Resource.Layout.LaunchScreen);

            ImageView         imageView = FindViewById <ImageView>(Resource.Id.animated_android);
            AnimationDrawable animation = (AnimationDrawable)imageView.Drawable;

            animation.Start();
        }
Ejemplo n.º 14
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.BronLayout);
            //---Переменные для работы NAvigationView
            drawer      = FindViewById <DrawerLayout>(Resource.Id.drawer_layout);
            navView     = FindViewById <NavigationView>(Resource.Id.nav_view);
            DrawerImage = FindViewById <ImageView>(Resource.Id.Button_menu);
            LoaderView  = FindViewById <RelativeLayout>(Resource.Id.LoaderView);
            LoaderImage = FindViewById <ImageView>(Resource.Id.LoaderImage);
            //---Переменные для работы с Activity
            ListViewTrips  = FindViewById <ListView>(Resource.Id.ListViewTrips);
            SpinnerRouts   = FindViewById <Spinner>(Resource.Id.SpinnerRouts);
            SpinnerPoStart = FindViewById <Spinner>(Resource.Id.SpinnerPoStart);
            SpinnerPoEnd   = FindViewById <Spinner>(Resource.Id.SpinnerPoEnd);
            TextViewData   = FindViewById <TextView>(Resource.Id.TextViewData);

            TextViewData.Click          += TextViewData_Click;
            SpinnerRouts.ItemSelected   += SpinnerRouts_ItemSelected;
            SpinnerPoStart.ItemSelected += SpinnerPoStart_ItemSelected;
            SpinnerPoEnd.ItemSelected   += SpinnerPoEnd_ItemSelected;
            AnimationLoader              = (AnimationDrawable)LoaderImage.Drawable;
            AnimationLoader.Start();

            ListViewTrips.DividerHeight = 0;
            ListViewTripsParmetr        = ListViewTrips.LayoutParameters;
            ListViewTrips.ItemClick    += ListViewTrips_ItemClick;
            DrawerImage.Click          += DrawerImage_Click;
            HeaderView = LayoutInflater.From(this).Inflate(Resource.Layout.drawer_header, null, false);

            navView.AddHeaderView(HeaderView);
            navView.NavigationItemSelected += NavView_NavigationItemSelected;

            new Thread(new ThreadStart(delegate //поток для загрузки данных
            {
                ObratPO  = new List <IApi>();
                TripDate = DateTime.Today;
                RunOnUiThread(() => TextViewData.Text = TripDate.ToString("dd.MM.yyyy"));
                routs = Routs.GetMarshruts();
                routs[0].GetPromPynkt();
                for (int i = routs[0].PromPynkt.Count - 1; i >= 0; i--)
                {
                    ObratPO.Add(routs[0].PromPynkt[i]);
                }
                RunOnUiThread(() => SpinnerRouts.Adapter   = new RoutAdapter(this, routs));
                RunOnUiThread(() => SpinnerPoStart.Adapter = new PromPynktAdapter(this, routs[0].PromPynkt));
                RunOnUiThread(() => SpinnerPoEnd.Adapter   = new PromPynktAdapter(this, ObratPO));
                trips = Trips.GetTripsOnDate(TripDate.ToString("yyyy-MM-dd"), routs[0].PromPynkt[0].id.ToString(), ObratPO[0].id.ToString(), routs[0].id.ToString());
                ListViewTripsParmetr.Height = Convert.ToInt32(function.convertDpToPixel(90, this)) * trips.Count;
                RunOnUiThread(() => ListViewTrips.Adapter = new TripsAdapter(this, trips));
                RunOnUiThread(() => AnimationLoader.Stop());
                RunOnUiThread(() => LoaderView.Visibility = ViewStates.Invisible);
            })).Start();
        }
Ejemplo n.º 15
0
        private void btn5Clicked(object sender, EventArgs e)
        {
            ImageView imageView = new ImageView(this);

            imageView.SetBackgroundResource(Resource.Drawable.spin_animation);
            AnimationDrawable drawable = (AnimationDrawable)imageView.Background;

            drawable.Start();
            hud = KK.Create(this).SetLabel("Loading...").SetCustomView(imageView);
            hud.Show();
            ScheduleDismiss();
        }
Ejemplo n.º 16
0
        public void mostrarViewLoadingSecurity()
        {
            customDialog.SetCancelable(false);
            customDialog.SetContentView(Resource.Layout.dialogoLoadingBcoSecurity);
            customDialog.Window.SetStatusBarColor(Color.Transparent);
            customDialog.OwnerActivity = activity;
            ivLoader = customDialog.FindViewById <ImageView>(Resource.Id.gifLoadingBcoSecurity);
            ivLoader.SetBackgroundResource(Resource.Animation.animationloader);
            AnimationDrawable frameAnimation = (AnimationDrawable)ivLoader.Background;

            frameAnimation.Start();
            customDialog.Show();
        }
        public override void OnWindowFocusChanged(bool hasFocus)
        {
            if (customProgressDialog == null)
            {
                return;
            }

            ImageView         imageView         = customProgressDialog.FindViewById <ImageView>(Resource.Id.loadingImageView);
            AnimationDrawable animationDrawable = (AnimationDrawable)imageView.Background;

            animationDrawable.Start();
            base.OnWindowFocusChanged(hasFocus);
        }
Ejemplo n.º 18
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            SetContentView(Resource.Layout.Main);

            //MapView = FindViewById<WebView>(Resource.Id.MapView);
            drawer        = FindViewById <DrawerLayout>(Resource.Id.drawer_layout);
            navView       = FindViewById <NavigationView>(Resource.Id.nav_view);
            LoaderView    = FindViewById <RelativeLayout>(Resource.Id.LoaderView);
            LoaderImage   = FindViewById <ImageView>(Resource.Id.LoaderImage);
            ListViewMarsh = FindViewById <ListView>(Resource.Id.ListViewMarsh);
            ListViewPO    = FindViewById <ListView>(Resource.Id.ListViewPO);
            ImageView DrawerImage = FindViewById <ImageView>(Resource.Id.Button_menu);

            ButtonBron = FindViewById <Button>(Resource.Id.ButtonBron);

            DrawerImage.Click += DrawerImage_Click;
            ButtonBron.Click  += ButtonBron_Click;

            AnimationLoader = (AnimationDrawable)LoaderImage.Drawable;
            AnimationLoader.Start();

            HeaderView = LayoutInflater.From(this).Inflate(Resource.Layout.drawer_header, null, false);

            navView.AddHeaderView(HeaderView);
            navView.NavigationItemSelected += NavView_NavigationItemSelected;
            ListViewMarsh.ChoiceMode        = ChoiceMode.Single;
            ListViewMarsh.DividerHeight     = 0;
            ListViewMarsh.ItemClick        += ListViewMarsh_ItemClick;
            ListViewPO.DividerHeight        = 0;
            var paramMarsh = ListViewMarsh.LayoutParameters;
            var paramPO    = ListViewPO.LayoutParameters;

            //MapView.Settings.JavaScriptEnabled = true;
            new Thread(new ThreadStart(delegate //поток для загрузки данных
            {
                var user  = User.GetInstance(0, "", "", GetString(Resource.String.token));
                marshruts = Routs.GetMarshruts();
                foreach (var item in marshruts)
                {
                    item.GetPromPynkt();
                }
                //RunOnUiThread(() => MapView.LoadUrl("http://orion38.pro/maps/maps.php?url_map=" + marshruts[0].url_map));
                paramMarsh.Height = Convert.ToInt32(function.convertDpToPixel(45, this)) * marshruts.Count;
                paramPO.Height    = Convert.ToInt32(function.convertDpToPixel(35, this)) * (marshruts[0].PromPynkt.Count + 1);
                RunOnUiThread(() => ListViewMarsh.Adapter = new RoutAdapter(this, marshruts));
                RunOnUiThread(() => ListViewPO.Adapter    = new PromPynktAdapter(this, marshruts[0].PromPynkt));
                RunOnUiThread(() => AnimationLoader.Stop());
                RunOnUiThread(() => LoaderView.Visibility = ViewStates.Invisible);
            })).Start();
        }
 public void SetUiEnable(bool enable)
 {
     if (remoteSettings.SendVehicleDataToMailbox)
     {
         sliderLabel.Text = "Slider:";
     }
     else
     {
         sliderLabel.Text = "Motor:";
     }
     sensor1.Enabled = enable;
     sensor2.Enabled = enable;
     sensor3.Enabled = enable;
     sensor4.Enabled = enable;
     seekBar.Enabled = enable;
     circle.Enabled  = enable;
     Android.Graphics.Color color = new Android.Graphics.Color(0x99, 0x99, 0x99);
     if (!enable)
     {
         circle.SetImageResource(Resource.Drawable.aniGray);
         circleAnimation.Stop();
     }
     else
     {
         color = new Android.Graphics.Color(0xf2, 0x61, 0x00);
         circle.SetImageResource(Resource.Drawable.animation);
         circleAnimation = (AnimationDrawable)circle.Drawable;
         circleAnimation.Start();
         if (remoteSettings.SensorValueToSpeech)
         {
             sensor1.Enabled = true;
             sensor2.Enabled = true;
             sensor3.Enabled = true;
             sensor4.Enabled = true;
         }
         else
         {
             sensor1.Enabled = false;
             sensor2.Enabled = false;
             sensor3.Enabled = false;
             sensor4.Enabled = false;
         }
     }
     angleText.SetTextColor(color);
     speedText.SetTextColor(color);
     sliderText.SetTextColor(color);
     angleLabel.SetTextColor(color);
     speedLabel.SetTextColor(color);
     sliderLabel.SetTextColor(color);
 }
Ejemplo n.º 20
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            SetContentView(Resource.Layout.activity_imageandbutton);

            // Load the animation from resources
            _asteroidDrawable = (AnimationDrawable)Resources.GetDrawable(Resource.Drawable.spinning_asteroid);
            ImageView imageView = FindViewById <ImageView>(Resource.Id.imageView1);

            imageView.SetImageDrawable(_asteroidDrawable);

            Button spinAsteroidButton = FindViewById <Button>(Resource.Id.button1);

            spinAsteroidButton.Text   = Resources.GetString(Resource.String.title_spinasteroid);
            spinAsteroidButton.Click += (sender, args) => _asteroidDrawable.Start();
        }
Ejemplo n.º 21
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            SetContentView(Resource.Layout.activity_imageandbutton);

            _asteroidDrawable = (AnimationDrawable)Resources.GetDrawable(Resource.Drawable.spinning_asteroid);

            var imageView = FindViewById <ImageView> (Resource.Id.imageView1);

            imageView.SetImageDrawable(_asteroidDrawable);

            var spinAsteroidButton = FindViewById <Button> (Resource.Id.button1);

            spinAsteroidButton.Text   = Resources.GetString(Resource.String.title_spinasteroid);
            spinAsteroidButton.Click += (s, e) => _asteroidDrawable.Start();
        }
Ejemplo n.º 22
0
        /// <summary>
        /// Create an animated bitmap
        /// </summary>
        public static Drawable GetAnimatedDrawable(Resources res, string name, int frames, int duration, bool loop)
        {
            var animation    = new AnimationDrawable();
            var bitmapFrames = new List <Bitmap>(frames);

            for (var i = 0; i < frames; i++)
            {
                bitmapFrames.Add(GetAnimationFrameBitmap(name, i));
            }

            // TODO: Load drawable better, like from cache
            bitmapFrames.ForEach(f => animation.AddFrame(new BitmapDrawable(res, f), duration));

            animation.OneShot = !loop;
            animation.Start();
            return(animation);
        }
Ejemplo n.º 23
0
        /// <summary>
        ///     Gets the rect with animation.
        /// </summary>
        /// <returns>Drawable.</returns>
        public Drawable GetRectWithAnimation()
        {
            var builder = DrawableTextView.TextDrwableBuilder.Rect();


            var animationDrawable = new AnimationDrawable();

            for (var i = 10; i > 0; i--)
            {
                var frame = builder.Build(i.ToString(), RandomColor, RandomColor);
                animationDrawable.AddFrame(frame, 1200);
            }
            animationDrawable.OneShot = false;
            animationDrawable.Start();

            return(animationDrawable);
        }
Ejemplo n.º 24
0
        void SetAnimation()
        {
            var frameAnimation = new AnimationDrawable();

            foreach (var img in this.images)
            {
                frameAnimation.AddFrame(img, 1000);
            }


            this.RunOnUiThread(() => {
                var imageButton = FindViewById <Button> (Resource.Id.AllFilmsButton);

                imageButton.SetBackgroundDrawable(frameAnimation);

                frameAnimation.Start();
            });
        }
Ejemplo n.º 25
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

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

            // Get our button from the layout resource,
            // and attach an event to it
            Button    play      = FindViewById <Button>(Resource.Id.btn_paly);
            Button    stop      = (Button)FindViewById(Resource.Id.btn_stop);
            ImageView imageView = FindViewById <ImageView>(Resource.Id.anim);

            // 获取AnimationDrawable动画对象
            AnimationDrawable anim = (AnimationDrawable)imageView.Background;

            // 开始播放动画
            play.Click += delegate { anim.Start(); };

            // 停止播放动画
            stop.Click += delegate { anim.Stop(); };
        }
        public override void OnActivityCreated(Bundle savedInstanceState)
        {
            base.OnActivityCreated(savedInstanceState);
            queue           = new QueueThread(OnDequeue);
            brickController = BrickController.Instance;
            remoteSettings  = RemoteSettings.Instance;
            circle          = (ImageView)this.View.FindViewById <ImageView> (Resource.Id.circle);
            circleAnimation = (AnimationDrawable)circle.Drawable;
            //grayCircle = Resources.GetDrawable(Resource.Drawable.aniGray);
            seekBar     = (SeekBar)this.View.FindViewById <SeekBar> (Resource.Id.seekBar);
            seekBar.Max = 200;

            angleLabel  = (TextView)this.View.FindViewById <TextView> (Resource.Id.angleLabel);
            speedLabel  = (TextView)this.View.FindViewById <TextView> (Resource.Id.speedLabel);
            sliderLabel = (TextView)this.View.FindViewById <TextView> (Resource.Id.seekLabel);

            angleText  = (TextView)this.View.FindViewById <TextView> (Resource.Id.angleTextView);
            speedText  = (TextView)this.View.FindViewById <TextView> (Resource.Id.speedTextView);
            sliderText = (TextView)this.View.FindViewById <TextView> (Resource.Id.seekTextView);


            sensor1 = (Button)this.View.FindViewById <Button> (Resource.Id.sensor1Button);
            sensor2 = (Button)this.View.FindViewById <Button> (Resource.Id.sensor2Button);
            sensor3 = (Button)this.View.FindViewById <Button> (Resource.Id.sensor3Button);
            sensor4 = (Button)this.View.FindViewById <Button> (Resource.Id.sensor4Button);

            sensor1.Click += delegate {
                queue.AddToQueue(
                    delegate {
                    string s = brickController.NXT.Sensor1.ReadAsString();
                    Activity.RunOnUiThread(delegate() {
                        //this should not run in the gui thread
                        if (remoteSettings.SensorValueToSpeech && TabActivity.Speech != null)
                        {
                            TabActivity.Speech.Speak(s, Android.Speech.Tts.QueueMode.Flush, null);
                        }
                    });
                },
                    true, 1
                    );
            };

            sensor2.Click += delegate {
                queue.AddToQueue(
                    delegate {
                    string s = brickController.NXT.Sensor2.ReadAsString();
                    Activity.RunOnUiThread(delegate() {
                        //this should not run in the gui thread
                        if (remoteSettings.SensorValueToSpeech && TabActivity.Speech != null)
                        {
                            TabActivity.Speech.Speak(s, Android.Speech.Tts.QueueMode.Flush, null);
                        }
                    });
                },
                    true, 1
                    );
            };

            sensor3.Click += delegate {
                queue.AddToQueue(
                    delegate {
                    string s = brickController.NXT.Sensor3.ReadAsString();
                    Activity.RunOnUiThread(delegate() {
                        //this should not run in the gui thread
                        if (remoteSettings.SensorValueToSpeech && TabActivity.Speech != null)
                        {
                            TabActivity.Speech.Speak(s, Android.Speech.Tts.QueueMode.Flush, null);
                        }
                    });
                },
                    true, 1
                    );
            };

            sensor4.Click += delegate {
                queue.AddToQueue(
                    delegate {
                    string s = brickController.NXT.Sensor4.ReadAsString();
                    Activity.RunOnUiThread(delegate() {
                        //this should not run in the gui thread
                        if (remoteSettings.SensorValueToSpeech && TabActivity.Speech != null)
                        {
                            TabActivity.Speech.Speak(s, Android.Speech.Tts.QueueMode.Flush, null);
                        }
                    });
                },
                    true, 1
                    );
            };

            seekBar.Progress = 100;
            sliderText.Text  = progress.ToString();

            seekBar.StopTrackingTouch += delegate(object sender, SeekBar.StopTrackingTouchEventArgs e) {
                e.SeekBar.Progress = 100;
                progress           = 0;
                Activity.RunOnUiThread(delegate() {
                    sliderText.Text = progress.ToString();
                });
                if (remoteSettings.SendVehicleDataToMailbox)
                {
                    queue.AddToQueue(
                        delegate {
                        SendDataToMailbox();
                    },
                        true, 2
                        );
                }
                else
                {
                    queue.AddToQueue(
                        delegate {
                        additionalMotor.Off();
                    },
                        true, 2
                        );
                }
            };
            seekBar.ProgressChanged += delegate(object sender, SeekBar.ProgressChangedEventArgs e) {
                progress = e.Progress - 100;
                Activity.RunOnUiThread(delegate() {
                    sliderText.Text = progress.ToString();
                });
                if (remoteSettings.SendVehicleDataToMailbox)
                {
                    queue.AddToQueue(
                        delegate {
                        SendDataToMailbox();
                    },
                        true, 2
                        );
                }
                else
                {
                    queue.AddToQueue(
                        delegate {
                        additionalMotor.On((sbyte)(e.Progress - 100));
                    },
                        true, 2
                        );
                }
            };
            circle.Touch += delegate(object sender, View.TouchEventArgs e) {
                if (e.Event.Action == MotionEventActions.Up)
                {
                    angleText.Text    = "0.0";
                    speedText.Text    = "0.0";
                    angle             = 0.0f;
                    speed             = 0.0f;
                    wasRunningForward = true;
                    if (remoteSettings.SendVehicleDataToMailbox)
                    {
                        queue.AddToQueue(
                            delegate {
                            SendDataToMailbox();
                        },
                            true, 2
                            );
                    }
                    else
                    {
                        queue.AddToQueue(
                            delegate {
                            brickController.NXT.Vehicle.Off();
                        },
                            true, 3
                            );
                    }
                    circle.SetImageResource(Resource.Drawable.animation);
                    circleAnimation = (AnimationDrawable)circle.Drawable;
                    circleAnimation.Start();
                }
                if (e.Event.Action == MotionEventActions.Move || e.Event.Action == MotionEventActions.Down)
                {
                    //movingOnCircle = true;
                    if (diameter == 0)
                    {
                        diameter = circle.Width / 2;
                    }
                    x = e.Event.GetX() - diameter;
                    y = -(e.Event.GetY() - diameter);
                    float outside = diameter * (float)1.06;
                    if (!(x > outside || x < -outside || y > outside || y < -outside))
                    {
                        if (x > 0.0)
                        {
                            angle = Math.Atan(y / x);
                            if (y < 0.0)
                            {
                                angle = Math.Atan(y / x) + 2 * Math.PI;
                            }
                        }
                        else
                        {
                            angle = Math.Atan(y / x) + Math.PI;
                        }
                        angle = angle + remoteSettings.DegreeOffset;
                        //convert radians to degree
                        angle = (angle * (180.0 / Math.PI)) % 360;
                        speed = (float)Math.Sqrt(x * x + y * y);
                        speed = speed / diameter * 100;
                        if (speed > 100.0)
                        {
                            speed = (float)100.0;
                        }
                    }
                    else
                    {
                        speed = 0.0f;
                        angle = 0.0f;
                    }

                    int intSpeed = (int)speed;
                    Activity.RunOnUiThread(delegate() {
                        if (intSpeed < 10)
                        {
                            circle.SetImageResource(Resource.Drawable.ani0);
                        }
                        else if (intSpeed < 20)
                        {
                            circle.SetImageResource(Resource.Drawable.ani1);
                        }
                        else if (intSpeed < 30)
                        {
                            circle.SetImageResource(Resource.Drawable.ani2);
                        }
                        else if (intSpeed < 40)
                        {
                            circle.SetImageResource(Resource.Drawable.ani3);
                        }
                        else if (intSpeed < 50)
                        {
                            circle.SetImageResource(Resource.Drawable.ani4);
                        }
                        else if (intSpeed < 60)
                        {
                            circle.SetImageResource(Resource.Drawable.ani5);
                        }
                        else if (intSpeed < 70)
                        {
                            circle.SetImageResource(Resource.Drawable.ani6);
                        }
                        else if (intSpeed < 80)
                        {
                            circle.SetImageResource(Resource.Drawable.ani7);
                        }
                        else if (intSpeed < 90)
                        {
                            circle.SetImageResource(Resource.Drawable.ani8);
                        }
                        else
                        {
                            circle.SetImageResource(Resource.Drawable.ani9);
                        }
                        circleAnimation.Stop();
                        //angleText.Text = "Angle: " + string.Format("{0,5:###.0}", angle).PadLeft(7);
                        //speedText.Text = "Speed: " + string.Format("{0,5:###.0}", speed).PadLeft(7);
                        angleText.Text = string.Format("{0,5:###.0}", angle);
                        speedText.Text = string.Format("{0,5:###.0}", speed);
                    });
                    if (remoteSettings.SendVehicleDataToMailbox)
                    {
                        queue.AddToQueue(
                            delegate {
                            SendDataToMailbox();
                        },
                            true, 2
                            );
                    }
                    else
                    {
                        queue.AddToQueue(
                            delegate {
                            if (angle >= 10.0f && angle < 80.0f)
                            {
                                brickController.NXT.Vehicle.TurnLeftForward((sbyte)speed, (sbyte)(100.0f - (angle - 10.0f) / 70.0f * 100.0f));
                                wasRunningForward = true;
                                return;
                            }
                            if (angle >= 100.0f && angle < 170.0f)
                            {
                                brickController.NXT.Vehicle.TurnLeftReverse((sbyte)speed, (sbyte)(100.0f - (170 - (angle - 10.0f)) / 70.0f * 100.0f));
                                wasRunningForward = false;
                                return;
                            }
                            if (angle >= 190.0f && angle < 260.0f)
                            {
                                brickController.NXT.Vehicle.TurnRightReverse((sbyte)speed, (sbyte)(100.0f - ((angle - 10.0f) - 190) / 70.0f * 100.0f));
                                wasRunningForward = false;
                                return;
                            }
                            if (angle >= 280.0f && angle <= 350.0f)
                            {
                                brickController.NXT.Vehicle.TurnRightForward((sbyte)speed, (sbyte)(100.0f - (350 - (angle - 10.0f)) / 70.0f * 100.0f));
                                wasRunningForward = true;
                                return;
                            }
                            if ((angle < 10.0f && angle >= 0.0f) || (angle > 350.0f))
                            {
                                brickController.NXT.Vehicle.Forward((sbyte)speed);
                                return;
                            }
                            if (angle >= 170.0f && angle < 190.0f)
                            {
                                brickController.NXT.Vehicle.Backward((sbyte)speed);
                                return;
                            }
                            if (angle >= 80.0f && angle < 100.0f)
                            {
                                if (wasRunningForward)
                                {
                                    brickController.NXT.Vehicle.SpinLeft((sbyte)speed);
                                }
                                else
                                {
                                    brickController.NXT.Vehicle.SpinRight((sbyte)speed);
                                }
                                return;
                            }
                            if (angle >= 260.0f && angle < 280.0f)
                            {
                                if (wasRunningForward)
                                {
                                    brickController.NXT.Vehicle.SpinRight((sbyte)speed);
                                }
                                else
                                {
                                    brickController.NXT.Vehicle.SpinLeft((sbyte)speed);
                                }
                                return;
                            }
                        },
                            true, 3
                            );
                    }
                }
            };
            circleAnimation.Start();
        }
Ejemplo n.º 27
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.BronForm);
            //---Переменные для работы NAvigationView
            drawer      = FindViewById <DrawerLayout>(Resource.Id.drawer_layout);
            navView     = FindViewById <NavigationView>(Resource.Id.nav_view);
            DrawerImage = FindViewById <ImageView>(Resource.Id.Button_menu);
            LoaderView  = FindViewById <RelativeLayout>(Resource.Id.LoaderView);
            LoaderImage = FindViewById <ImageView>(Resource.Id.LoaderImage);
            //---Переменные для работы Activity
            m1                 = FindViewById <Button>(Resource.Id.m1);
            m2                 = FindViewById <Button>(Resource.Id.m2);
            m3                 = FindViewById <Button>(Resource.Id.m3);
            m4                 = FindViewById <Button>(Resource.Id.m4);
            m5                 = FindViewById <Button>(Resource.Id.m5);
            m6                 = FindViewById <Button>(Resource.Id.m6);
            m7                 = FindViewById <Button>(Resource.Id.m7);
            m8                 = FindViewById <Button>(Resource.Id.m8);
            m9                 = FindViewById <Button>(Resource.Id.m9);
            m10                = FindViewById <Button>(Resource.Id.m10);
            m11                = FindViewById <Button>(Resource.Id.m11);
            m12                = FindViewById <Button>(Resource.Id.m12);
            m14                = FindViewById <Button>(Resource.Id.m14);
            ButtonBron         = FindViewById <Button>(Resource.Id.ButtonBron);
            SpinnerTypeTicket  = FindViewById <Spinner>(Resource.Id.SpinnerTypeTicket);
            SpinnerSpots       = FindViewById <Spinner>(Resource.Id.SpinnerSpots);
            TextViewSelectRout = FindViewById <TextView>(Resource.Id.TextViewSelectRout);
            TextViewData       = FindViewById <TextView>(Resource.Id.TextViewData);
            TextViewCost       = FindViewById <TextView>(Resource.Id.TextViewCost);
            TextViewPoStart    = FindViewById <TextView>(Resource.Id.TextViewPoStart);
            TextViewPoEnd      = FindViewById <TextView>(Resource.Id.TextViewPoEnd);
            EditTextFIO        = FindViewById <EditText>(Resource.Id.EditTextFIO);
            EditTextPhone      = FindViewById <EditText>(Resource.Id.EditTextPhone);
            FinishLayout       = FindViewById <RelativeLayout>(Resource.Id.FinishLayout);
            ButtonBronFinish   = FindViewById <Button>(Resource.Id.ButtonBronFinish);
            ButtonFullFinish   = FindViewById <Button>(Resource.Id.ButtonFullFinish);
            //----------------------------

            FinishLayout.Visibility = ViewStates.Invisible;
            ButtonBronFinish.Click += ButtonBronFinish_Click;
            ButtonFullFinish.Click += ButtonFullFinish_Click;;
            AnimationLoader         = (AnimationDrawable)LoaderImage.Drawable;
            AnimationLoader.Start();

            DrawerImage.Click += DrawerImage_Click;
            HeaderView         = LayoutInflater.From(this).Inflate(Resource.Layout.drawer_header, null, false);

            navView.AddHeaderView(HeaderView);
            navView.NavigationItemSelected += NavView_NavigationItemSelected;
            EditTextPhone.TextChanged      += EditTextPhone_TextChanged;
            ButtonBron.Click += ButtonBron_Click;

            RoutsID     = Intent.GetStringExtra("RoutsID");
            TripID      = Intent.GetStringExtra("TripID");
            TripDate    = Intent.GetStringExtra("TripDate");
            StartPOText = Intent.GetStringExtra("StartPOText");
            StartPOId   = Intent.GetStringExtra("StartPOId");
            EndPOText   = Intent.GetStringExtra("EndPOText");
            EndPOId     = Intent.GetStringExtra("EndPOId");

            TextViewPoStart.Text = StartPOText;
            TextViewPoEnd.Text   = EndPOText;

            //---Массив мест
            SpisokForSpinnerSpots = new List <int>();
            ObratPO = new List <IApi>();
            spots   = new List <Button>();
            spots.Add(m1);
            spots.Add(m2);
            spots.Add(m3);
            spots.Add(m4);
            spots.Add(m5);
            spots.Add(m6);
            spots.Add(m7);
            spots.Add(m8);
            spots.Add(m9);
            spots.Add(m10);
            spots.Add(m11);
            spots.Add(m12);
            spots.Add(m14);

            new Thread(new ThreadStart(delegate //поток для загрузки данных
            {
                bilets = TypeBilets.GetTypeBilets();
                routs  = Routs.GetMarshruts();
                foreach (var item in routs)
                {
                    if (item.id.ToString() == RoutsID)
                    {
                        SelectRout = item;
                        break;
                    }
                }
                GetsSpots = Trips.GetMesta(Convert.ToInt32(TripID), Convert.ToInt32(RoutsID), Convert.ToInt32(StartPOId), Convert.ToInt32(EndPOId));
                RunOnUiThread(() => CheckSvMestaOnShema(GetsSpots, spots, SpisokForSpinnerSpots));
                RunOnUiThread(() => SpinnerSpots.Adapter      = new SpotsAdapter(this, SpisokForSpinnerSpots));
                RunOnUiThread(() => SpinnerTypeTicket.Adapter = new TicketAdapter(this, bilets));
                cost = Prices.GetPrice(Convert.ToInt32(StartPOId), Convert.ToInt32(EndPOId), Convert.ToInt32(RoutsID));
                if (bilets[0].fix == 1)
                {
                    cost = bilets[0].cost.ToString();
                }
                else
                {
                    cost = (Convert.ToDouble(cost) * bilets[0].cost).ToString();
                }
                RunOnUiThread(() => TextViewCost.Text       = cost);
                RunOnUiThread(() => TextViewSelectRout.Text = SelectRout.name);
                RunOnUiThread(() => TextViewData.Text       = DateTime.ParseExact(TripDate, "yyyy-MM-dd", CultureInfo.InvariantCulture).ToString("dd.MM.yyyy"));
                RunOnUiThread(() => AnimationLoader.Stop());
                RunOnUiThread(() => LoaderView.Visibility           = ViewStates.Invisible);
                RunOnUiThread(() => SpinnerTypeTicket.ItemSelected += SpinnerTypeTicket_ItemSelected);
            })).Start();
        }
 protected override void OnResume()
 {
     base.OnResume();
     _alarmDrawable.Start();
 }
Ejemplo n.º 29
0
 public void Run()
 {
     animDrawable.Start();
 }
        protected override async void OnCreate
        (
            Bundle bundle
        )
        {
            //AndroidCrapApplication.ApplicationLogger.LogDebug("MEMORY 4 : {0}",
            //                                                  GC.GetTotalMemory(false));

            base.OnCreate(bundle);

            SetContentView(Resource.Layout.SplashScreenLayout);

            _progressCount = FindViewById <TextView>(Resource.Id.ProgressCount);

            ImageView splashProgress = FindViewById <ImageView>(Resource.Id.SplashProgress);

            splashProgress.SetBackgroundResource(Resource.Drawable.ProgressSphere);

            AnimationDrawable splashAnimation  = splashProgress.Background as AnimationDrawable;
            Exception         loadingException = null;

            //AndroidCrapApplication.ApplicationLogger.LogDebug("MEMORY 5 : {0}",
            //                                                  GC.GetTotalMemory(false));

            splashAnimation?.Start();
            _loadingContext = this;

            if (_loadingTask == null)
            {
                _loadingTask = CreateLoadingTask
                               (
                    GetString(Resource.String.SplashTextFormat),

                    updateText: (progressText) => UpdateText(progressText),

                    getContext: () => { return(GetContext()); }
                               );
            }

            //AndroidCrapApplication.ApplicationLogger.LogDebug("MEMORY 6 : {0}",
            //                                                  GC.GetTotalMemory(false));

            try
            {
                await _loadingTask;
            }
            catch (Exception exception)
            {
                loadingException = exception;
            }
            finally
            {
                _loadingTask = null;

                splashAnimation?.Stop();
                splashAnimation?.Dispose();
                splashAnimation = null;
                splashProgress  = null;
            }

            /*// http://stackoverflow.com/questions/477572/strange-out-of-memory-issue-while-loading-an-image-to-a-bitmap-object
             *
             * Java.Lang.JavaSystem.RunFinalization();
             * Java.Lang.JavaSystem.Gc();
             * Java.Lang.JavaSystem.RunFinalization();
             * System.Runtime.GCSettings.LargeObjectHeapCompactionMode
             *  = System.Runtime.GCLargeObjectHeapCompactionMode.CompactOnce;
             * GC.Collect();*/

            if (loadingException != null)
            {
                AndroidCrapApplication.ShowExceptionAndExit(this,
                                                            loadingException);
                return;
            }

            //AndroidCrapApplication.ApplicationLogger.LogDebug("MEMORY 7 : {0}",
            //                                                  GC.GetTotalMemory(false));
        }