示例#1
0
        public override void OnBackPressed()
        {
            if (icon == null || quizFab == null)
            {
                base.OnBackPressed();
                return;
            }

            icon.Animate()
            .ScaleX(.7f)
            .ScaleY(.7f)
            .Alpha(0f)
            .SetInterpolator(interpolator)
            .Start();

            var listener = new AnimatorListener(this);

            listener.AnimationEnd += (sender, e) => {
                if (IsFinishing || IsDestroyed)
                {
                    return;
                }
                base.OnBackPressed();
            };

            quizFab.Animate()
            .ScaleX(0f)
            .ScaleY(0f)
            .SetInterpolator(interpolator)
            .SetStartDelay(100)
            .SetListener(listener)
            .Start();
        }
        /// <summary>
        /// Animates the guitar intro which should last 10 seconds.
        /// </summary>
        /// <param name="guitarImage">The object which contains the image of the guitar.</param>
        public void AnimateGuitarIntro(ImageView guitarImage)
        {
            int target_ScrollX = 230;
            int target_ScrollY = -5;
            float target_ScaleX = 4.5f; //5;
            float target_ScaleY = 4.5f; //5;
            int target_ScrollX_2nd = 150; //135;

            int msDuration = 4000;
			int msDelay = 1000;

            guitarImage.Animate()
                .SetDuration(msDuration)
                .SetStartDelay(msDelay)
                .ScrollX(guitarImage, target_ScrollX)
                .ScrollY(guitarImage, target_ScrollY)
                .ScaleX(target_ScaleX)
                .ScaleY(target_ScaleY)
                .WithEndAction(new Runnable(() =>
                {
                    guitarImage.Animate()
                        .SetDuration(msDuration)
                        .SetStartDelay(msDelay)
                        .ScrollX(guitarImage, target_ScrollX_2nd)
                        .WithEndAction(new Runnable(() => {
                            OnIntroAnimationFinished(this, new EventArgs());
                        }))
                        .Start();
                }))
                .Start();
        }
示例#3
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

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

            prevImageView = (ImageView)FindViewById(Resource.Id.prevImageView);
            nextImageView = (ImageView)FindViewById(Resource.Id.nextImageView);

            prevImageView.Animate().SetDuration(200);
            prevImageView.Animate().SetDuration(200);

            var drawables = new BitmapDrawable[drawableIDs.Length];

            for (int i = 0; i < drawableIDs.Length; ++i)
            {
                var bitmap = BitmapFactory.DecodeResource(Resources, drawableIDs[i]);
                drawables[i] = new BitmapDrawable(Resources, bitmap);
            }

            prevImageView.SetImageDrawable(drawables[0]);
            nextImageView.SetImageDrawable(drawables[1]);

            timer = new Timer(x => UpdateView(drawables), null, TimeSpan.FromSeconds(1), TimeSpan.FromSeconds(1));
        }
示例#4
0
        /// <summary>
        /// Animates the guitar intro which should last 10 seconds.
        /// </summary>
        /// <param name="guitarImage">The object which contains the image of the guitar.</param>
        public void AnimateGuitarIntro(ImageView guitarImage)
        {
            int   target_ScrollX     = 230;
            int   target_ScrollY     = -5;
            float target_ScaleX      = 4.5f; //5;
            float target_ScaleY      = 4.5f; //5;
            int   target_ScrollX_2nd = 150;  //135;

            int msDuration = 4000;
            int msDelay    = 1000;

            guitarImage.Animate()
            .SetDuration(msDuration)
            .SetStartDelay(msDelay)
            .ScrollX(guitarImage, target_ScrollX)
            .ScrollY(guitarImage, target_ScrollY)
            .ScaleX(target_ScaleX)
            .ScaleY(target_ScaleY)
            .WithEndAction(new Runnable(() =>
            {
                guitarImage.Animate()
                .SetDuration(msDuration)
                .SetStartDelay(msDelay)
                .ScrollX(guitarImage, target_ScrollX_2nd)
                .WithEndAction(new Runnable(() => {
                    OnIntroAnimationFinished(this, new EventArgs());
                }))
                .Start();
            }))
            .Start();
        }
示例#5
0
        //Robo move into specifice direction based on the instruction from user
        void CommandRoboToMoveSpecificDirection(String myDirection, int stepvalue)
        {
            try
            {
                if (myDirection.ToUpper() == "NORTH")
                {
                    if (CheckOutOfScreen(stepvalue, 0, 1) == true)
                    {
                        img_sweeper.Animate().X(Current_XPosition - stepvalue);
                    }
                    else
                    {
                        ShowValidationMessage("Current value go out side of the screen");
                    }
                }

                else if (myDirection.ToUpper() == "SOUTH")
                {
                    if (CheckOutOfScreen(stepvalue, 0, 0) == true)
                    {
                        img_sweeper.Animate().X(Current_XPosition + stepvalue);
                    }
                    else
                    {
                        ShowValidationMessage("Current value go out side of the screen");
                    }
                }

                else if (myDirection.ToUpper() == "EAST")
                {
                    if (CheckOutOfScreen(stepvalue, 1, 0) == true)
                    {
                        img_sweeper.Animate().Y(Current_YPosition + stepvalue);
                    }
                    else
                    {
                        ShowValidationMessage("Current value go out side of the screen");
                    }
                }
                else if (myDirection.ToUpper() == "WEST")
                {
                    if (CheckOutOfScreen(stepvalue, 1, 1) == true)
                    {
                        img_sweeper.Animate().Y(Current_YPosition - stepvalue);
                    }
                    else
                    {
                        ShowValidationMessage("Current value go out side of the screen");
                    }
                }
            }
            catch (Exception ex)
            {
            }
        }
示例#6
0
        /// <summary>
        /// Gets the next image and sets it to the image panel
        /// </summary>
        /// <param name="animation">if it should be animated(may not be animated if Settings.AnimationsEnabled is false)</param>
        public void GetNextImage(bool animate = true)
        {
            if (loading || downloading)
            {
                Toast.MakeText(this, "An Image Is Being Downloaded or Loading Please Be Patient", ToastLength.Short).Show();
                return;
            }

            loading = true;
            if (animate && Settings.Instance.AnimationsEnabled)
            {
                imagePanel.Animate().TranslationX(-PhoneWidth);
            }

            Task.Run(() =>
            {
                try
                {
                    imageStore.Forward();
                    if (animate && Settings.Instance.AnimationsEnabled)
                    {
                        Fix();
                    }

                    RunOnUiThread(() =>
                    {
                        ReloadImagePanel(() =>
                        {
                            CheckPreviousImageButton();

                            if (animate && Settings.Instance.AnimationsEnabled)
                            {
                                imagePanel.TranslationX = PhoneWidth;
                                imagePanel.Animate().TranslationX(0);
                            }
                        });
                    });
                }
                catch (Exception e)
                {
                    RunOnUiThread(() =>
                    {
                        Toast.MakeText(this, e.ToString(), ToastLength.Long).Show();
                    });
                }
                finally
                {
                    loading = false;
                }
            });
        }
示例#7
0
        /// <summary>
        /// Fades the content view into the screen.
        /// </summary>
        private void FadeIn(long duration)
        {
            progress.Visibility  = ViewStates.Visible;
            imageView.Visibility = ViewStates.Visible;
            imageView.Alpha      = 0f;
            arrow.Visibility     = ViewStates.Invisible;

            progress.Animate()
            .Alpha(0f)
            .SetDuration(duration)
            .SetListener(new AnimatorListenerActionAdapter()
            {
                onAnimationEnd = (a) => {
                    progress.Visibility = ViewStates.Invisible;
                },
            });

            imageView.Animate()
            .Alpha(1f)
            .SetDuration(duration)
            .SetListener(new AnimatorListenerActionAdapter()
            {
                onAnimationEnd = (a) => {
                    arrow.Visibility = ViewStates.Visible;
                    var lp           = arrow.LayoutParameters as AbsoluteLayout.LayoutParams;
                    lp.X             = (int)(imageView.Left + page.xPercent * imageView.Width - arrow.Width / 2);
                    lp.Y             = (int)(imageView.Top + page.yPercent * imageView.Height);
                    arrow.RequestLayout();
                },
            });
        }
示例#8
0
        public override void OnBackPressed()
        {
            if (categoryFab == null)
            {
                base.OnBackPressed();
                return;
            }
            else if (FindViewById(Resource.Id.task_view) != null)
            {
                Intent.AddFlags(ActivityFlags.ClearTop);
                StartActivity(Intent);
            }


            var listener = new AnimatorListener(this);

            listener.AnimationEnd += (sender, e) => {
                if (IsFinishing || IsDestroyed)
                {
                    return;
                }
                base.OnBackPressed();
            };

            categoryFab.Animate()
            .ScaleX(0f)
            .ScaleY(0f)
            .SetInterpolator(interpolator)
            .SetStartDelay(100)
            .SetListener(listener)
            .Start();
        }
示例#9
0
        public void SetValueRandom(int image, int rotate_count)
        {
            currentImage.Animate().SetDuration(ANIMATION_DUR).TranslationY(-Height).Start();

            nextImage.TranslationY = nextImage.Height;

            nextImage.Animate().TranslationY(0).SetDuration(ANIMATION_DUR).SetListener(new MyListener(this, image, rotate_count));
        }
        void shoot(object sender, EventArgs e)
        {
            ImageView   enemy     = FindViewById <ImageView>(Resource.Id.mini);
            ImageView   rocket    = FindViewById <ImageView>(Resource.Id.rocket);
            ImageView   laser     = FindViewById <ImageView>(Resource.Id.laser);
            ProgressBar enemyLife = FindViewById <ProgressBar>(Resource.Id.enemy_life);

            float eY = enemy.GetY();
            float rY = rocket.GetY();

            MediaPlayer player;

            player = MediaPlayer.Create(this, Resource.Raw.laser);
            player.Start();


            laser.SetY(rY + (rocket.Height / 2) - (laser.Height / 2));
            laser.SetImageResource(Resource.Drawable.laser);
            laser.Alpha = 10;
            laser.Animate()
            .SetDuration(1000)
            .Alpha(0);



            if ((rY + rocket.Height > eY && eY + enemy.Height > rY) || (eY + enemy.Height > rY && rY + rocket.Height > eY))
            {
                enemyLife.Progress -= 5;

                score += (100 - enemyLife.Progress);
                TextView scoreText = FindViewById <TextView>(Resource.Id.score);
                scoreText.Text = score.ToString();

                if (enemyLife.Progress == 0)
                {
                    etimer.Close();
                    AlertDialog.Builder alert = new AlertDialog.Builder(this);
                    alert.SetTitle("Level up");
                    alert.SetMessage("You have successfully completed level " + level);
                    alert.SetPositiveButton("Continue", (senderAlert, args) => {
                        FindViewById <ProgressBar>(Resource.Id.enemy_life).Progress = 100;
                        level++;
                        enemyMove();

                        float scalingFactor = (10 - 2 * level) / 10f;
                        enemy.ScaleX        = scalingFactor;
                        enemy.ScaleY        = scalingFactor;
                    });
                    alert.SetNegativeButton("Exit", (senderAlert, args) => {
                        Intent activity2 = new Intent(this, typeof(Android.Views.Menu));
                        this.StartActivity(activity2);
                        this.Finish();
                    });

                    alert.Show();
                }
            }
        }
示例#11
0
 void ShowIndeterminateSlider(bool paramBoolean)
 {
     if (paramBoolean)
     {
         indeterminateSlider.Animate().TranslationY(0f).SetDuration(300L);
         return;
     }
     indeterminateSlider.TranslationY = 0f;
 }
        public void OnAnimationEnd(Animation animation)
        {
            ImageView imageDisplay = owner.imageDisplay;

            animation = AnimationUtils.LoadAnimation(owner.Activity, Resource.Animation.scale_down);
            imageDisplay.Animation = animation;
            animation.SetAnimationListener(new ImageEndAnimation(owner));
            imageDisplay.Animate().SetDuration(3000).Start();
        }
示例#13
0
 public override void OnAttach(Context context)
 {
     base.OnAttach(context);
     if (_dialogConfig.BlurConfig != null)
     {
         SetBlurWindowBackground(_dialogConfig.BlurConfig);
         _blurView.Animate().Alpha(1f).SetDuration(_dialogConfig.BlurConfig.FadeDuration)
         .Start();
     }
 }
示例#14
0
        void InitLayout(string categoryId)
        {
            SetContentView(Resource.Layout.activity_quiz);
            icon = FindViewById <ImageView> (Resource.Id.icon);
            int resId = Resources.GetIdentifier(ImageCategory + categoryId, CategoryAdapter.Drawable, ApplicationContext.PackageName);

            icon.SetImageResource(resId);
            icon.SetImageResource(resId);
            icon.Animate()
            .ScaleX(1)
            .ScaleY(1)
            .Alpha(1)
            .SetInterpolator(interpolator)
            .SetStartDelay(300)
            .Start();
            quizFab = FindViewById <FloatingActionButton> (Resource.Id.fab_quiz);
            quizFab.SetImageResource(Resource.Drawable.ic_play);
            quizFab.Visibility = savedStateIsPlaying ? ViewStates.Gone : ViewStates.Visible;
            quizFab.Click     += (sender, e) => {
                var view = (View)sender;
                switch (view.Id)
                {
                case Resource.Id.fab_quiz:
                    StartQuizFromClickOn(view);
                    break;

                case Resource.Id.submitAnswer:
                    SubmitAnswer();
                    break;

                case Resource.Id.quiz_done:
                    FinishAfterTransition();
                    break;

                case Undefined:
                    var contentDescription = view.ContentDescription;
                    if (contentDescription != null && contentDescription == GetString(Resource.String.up))
                    {
                        OnBackPressed();
                        break;
                    }
                    break;

                default:
                    throw new InvalidOperationException(
                              "OnClick has not been implemented for " + Resources.GetResourceName(view.Id));
                }
            };
            quizFab.Animate()
            .ScaleX(1)
            .ScaleY(1)
            .SetInterpolator(interpolator)
            .SetStartDelay(400)
            .Start();
        }
示例#15
0
 public void ChangeLoading(int logoResID, string text)
 {
     logoImage.Animate().Alpha(0).SetDuration(400).WithEndAction(new Runnable(() => {
         logoImage.SetImageResource(logoResID);
         logoImage.Animate().Alpha(1).SetDuration(300).Start();
         var length = View.Width;
         explanation.Animate().TranslationX(length).SetDuration(150).WithEndAction(new Runnable(() => {
             explanation.Text         = text;
             explanation.TranslationX = -length;
             explanation.Animate().TranslationX(0).SetDuration(150).Start();
         })).Start();
         if (extraExplanation.Visibility == ViewStates.Visible)
         {
             extraExplanation.Animate()
             .Alpha(0)
             .SetDuration(150)
             .WithEndAction(new Runnable(() => extraExplanation.Visibility = ViewStates.Invisible)).Start();
         }
     })).Start();
 }
        private static void Crossfade(Bitmap bitmap, ImageView fadeIn, ImageView fadeOut)
        {
            fadeIn.Alpha = 0f;

            fadeIn.SetImageBitmap(bitmap);
            fadeIn.Visibility = ViewStates.Visible;

            fadeOut.Animate().Alpha(0f).SetDuration(1200).SetInterpolator(new AccelerateInterpolator()).SetListener(new AnimationListener(fadeOut));
            fadeIn.Animate()
            .Alpha(1f)
            .SetDuration(1200).SetInterpolator(new AccelerateDecelerateInterpolator())
            .SetListener(null);
        }
示例#17
0
        private void OnTimedEvent(object sender, System.Timers.ElapsedEventArgs e)
        {
            var width = _currentImageView.Width;

            RunOnUiThread(() =>
            {
                _nextImageView.TranslationX = width;

                _currentImageView.Animate().SetDuration(300).TranslationX(-width).Start();

                _animator = _nextImageView.Animate().SetDuration(300).TranslationX(0).SetListener(_listener);
                _animator.Start();
            });
        }
示例#18
0
        void ViewModel_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
        {
            if (e.PropertyName == nameof(ViewModel.MessageSent))
            {
                Runnable end = new Runnable(() =>
                {
                    ViewModel.ExitCommand.Execute();
                });

                var x = image.GetX();
                var y = image.GetY();

                image.Animate().X(x + 600).Y(y - 600).ScaleX(0.5f).ScaleY(0.5f).SetDuration(1500).WithEndAction(end).Start();
            }
        }
示例#19
0
 private void UpdateView(BitmapDrawable[] drawables)
 {
     this.RunOnUiThread(() =>
     {
         prevImageView.Animate().Alpha(0).WithLayer();
         nextImageView.Animate().Alpha(1).WithLayer().WithEndAction(new Runnable(() =>
         {
             // When the animation ends, set up references to change the prev/next
             // associations
             _currentDrawableNo    = (_currentDrawableNo + 1) % drawables.Length;
             int nextDrawableIndex = (_currentDrawableNo + 1) % drawables.Length;
             prevImageView.SetImageDrawable(drawables[_currentDrawableNo]);
             nextImageView.SetImageDrawable(drawables[nextDrawableIndex]);
             nextImageView.Alpha = 0f;
             prevImageView.Alpha = 1f;
         }));
     });
 }
示例#20
0
 public void SetArtistImage(Bitmap bmp, bool immediate = false)
 {
     artistImage.SetImageBitmap(bmp);
     originalImage = bmp;
     blurredImage  = null;
     if (!immediate)
     {
         artistImageLoading.Visibility = ViewStates.Invisible;
         artistImage.Alpha             = 0;
         artistImage.Visibility        = ViewStates.Visible;
         artistImage.Animate().Alpha(1).Start();
     }
     else
     {
         artistImageLoading.Visibility = ViewStates.Invisible;
         artistImage.Visibility        = ViewStates.Visible;
     }
 }
示例#21
0
        void InitLayout(string categoryId)
        {
            SetContentView(Resource.Layout.activity_tasks);

            categoryFab = FindViewById <FloatingActionButton>(Resource.Id.fab_category);
            categoryFab.SetImageResource(Resource.Drawable.ic_play);
            categoryFab.Visibility = savedStateIsPlaying ? ViewStates.Gone : ViewStates.Visible;
            categoryFab.Click     += (sender, e) => {
                var view = (View)sender;
                StartCategoryFromClickOn(view);
                toolbar = FindViewById <Toolbar>(Resource.Id.toolbar_activity_category);
            };
            categoryFab.Animate()
            .ScaleX(1)
            .ScaleY(1)
            .SetInterpolator(interpolator)
            .SetStartDelay(400)
            .Start();
            PopulateTaskList();
        }
示例#22
0
        public void DisplayNextImage(object state)
        {
            using (SuspendPainting suspend = new SuspendPainting(_application.Root))
            {
                if (_background.ImageResource != null)
                {
                    // release old images
                    _background.ImageResource.Close();
                }
                _background.ImageResource = _foreground.ImageResource;

                _background.Transparency = 0;
                _foreground.Transparency = 1;

                _foreground.ImageResource = _application.GetImageResource(imageNames[_currentImageIndex]);

                _foreground.Animate(Animation.Fade(0, 0, FadeTime));
                _background.Animate(Animation.Fade(1, 0, FadeTime));
            }
            _currentImageIndex = (_currentImageIndex + 1) % imageNames.Count;
        }
示例#23
0
 private void ShowPassive(ImageView view)
 {
     view.Alpha    = 1f;
     _animatedView = null;
     view.Animate().ScaleX(1f).ScaleY(1f).Rotation(0).SetDuration(500).Start();
 }
示例#24
0
        public bool OnTouch(View v, MotionEvent e)
        {
            if (tilesArr.Contains((ImageView)v) && e.Action == MotionEventActions.Up && touchAllowed)
            {
                touchAllowed = false;


                ImageView thisTile = (ImageView)v;

                int indexOfTile = tilesArr.IndexOf(thisTile);
                int indexOfImage;

                if (indexOfTile >= gridSize * gridSize / 2)
                {
                    indexOfImage = indexOfTile - gridSize * gridSize / 2;
                }
                else
                {
                    indexOfImage = indexOfTile;
                }


                System.String nameOfImage = imgsArr[indexOfImage] as string;
                int           resourceID  = Resources.GetIdentifier(nameOfImage, "drawable", PackageName);
                thisTile.SetImageResource(resourceID);


                if (compareState)
                {
                    // second touch here
                    imgViewTwo = thisTile;
                    int dist = gridSize * gridSize / 2;

                    int thisDist = System.Math.Abs(tilesArr.IndexOf(imgViewOne) - tilesArr.IndexOf(imgViewTwo));

                    Handler compareHandler  = new Handler();
                    Action  myCompareAction = () =>
                    {
                        if (thisDist == dist)
                        {
                            // identical
                            imgViewOne.Animate()
                            .SetDuration(500)
                            .Alpha(0)
                            .WithEndAction(new Runnable(() =>
                            {
                                ImageView foundImgView = new ImageView(this);
                                GridLayout.LayoutParams foundParams = (GridLayout.LayoutParams)imgViewOne.LayoutParameters;

                                int foundResId = Resources.GetIdentifier("found", "drawable", PackageName);
                                foundImgView.SetImageResource(foundResId);

                                foundImgView.LayoutParameters = foundParams;
                                gameGridLayout.AddView(foundImgView);

                                gameGridLayout.RemoveView(imgViewOne);
                            }));

                            imgViewTwo.Animate()
                            .SetDuration(500)
                            .Alpha(0)
                            .WithEndAction(new Runnable(() =>
                            {
                                ImageView foundImgView = new ImageView(this);
                                GridLayout.LayoutParams foundParams = (GridLayout.LayoutParams)imgViewTwo.LayoutParameters;

                                int foundResId = Resources.GetIdentifier("found", "drawable", PackageName);
                                foundImgView.SetImageResource(foundResId);

                                foundImgView.LayoutParameters = foundParams;
                                gameGridLayout.AddView(foundImgView);

                                gameGridLayout.RemoveView(imgViewTwo);

                                touchAllowed = true;
                            }));

                            imgViewOne.Alpha = 0;
                            imgViewTwo.Alpha = 0;
                        }
                        else
                        {
                            //different
                            imgViewOne.SetImageResource(Resources.GetIdentifier("no_img", "drawable", PackageName));
                            imgViewTwo.SetImageResource(Resources.GetIdentifier("no_img", "drawable", PackageName));

                            touchAllowed = true;
                        }
                    };

                    compareHandler.PostDelayed(myCompareAction, 1000);

                    compareState = false;
                }
                else
                {
                    //first touch here.
                    imgViewOne = thisTile;

                    compareState = true;
                    touchAllowed = true;
                }
            }

            return(true);
        }
示例#25
0
        private async void BootingZinaOS()
        {
            try
            {
                Random r = new Random(DateTime.Now.Second);

                ImageView   BootLogo        = FindViewById <ImageView>(Resource.Id.ZinaOSMainBootLogo);
                ProgressBar BootProgressBar = FindViewById <ProgressBar>(Resource.Id.ZinaOSLoadProgressBar);

                await Task.Delay(1000);

                string temp_text1 = "Zina Protocol OS [Ver. 1.0.1]\n";

                for (int i = 0; i < temp_text1.Length; ++i)
                {
                    bootView.Text += temp_text1[i];
                    await Task.Delay(5);
                }

                string temp_text2 = "# 20xx I.O.P & GRIFON Corporation #\n\n";

                for (int i = 0; i < temp_text2.Length; ++i)
                {
                    bootView.Text += temp_text2[i];
                    await Task.Delay(5);
                }

                await Task.Delay(1000);

                await AnimateText(bootView, "Checking Hardware", r.Next(3, 6), "Success");

                for (int i = 0; i < 10; ++i)
                {
                    await Task.Delay(r.Next(1, 10) * 100);

                    bootView.Text += "Load Boot Module..." + (i + 1) + " / 10\n";
                }

                await Task.Delay(1000);

                FindViewById <LinearLayout>(Resource.Id.ZinaOSBootTextLayout).Animate().Alpha(0.0f).SetDuration(500).Start();
                FindViewById <LinearLayout>(Resource.Id.ZinaOSBootViewLayout).Animate().Alpha(1.0f).SetDuration(500).Start();

                BootLogo.Animate().Alpha(1.0f).SetDuration(500).SetStartDelay(500).Start();

                await Task.Delay(1500);

                FindViewById <LinearLayout>(Resource.Id.ZinaOSLoadProgressLayout).Animate().Alpha(1.0f).SetDuration(500).Start();

                await Task.Delay(1000);

                BootProgressBar.Indeterminate = false;

                for (int i = 0; i <= 100; ++i)
                {
                    await Task.Delay(r.Next(1, 50));

                    BootProgressBar.Progress = i;
                }

                await Task.Delay(100);

                FindViewById <LinearLayout>(Resource.Id.ZinaOSLoadProgressLayout).Animate().Alpha(0.0f).SetDuration(500).Start();
                FindViewById <LinearLayout>(Resource.Id.ZinaOSBootViewLayout).Animate().Alpha(0.0f).SetDuration(500).SetStartDelay(800).Start();
                FindViewById <LinearLayout>(Resource.Id.ZinaOSMainMenuLayout).Animate().Alpha(1.0f).SetDuration(500).WithStartAction(new Java.Lang.Runnable(delegate { FindViewById <LinearLayout>(Resource.Id.ZinaOSMainMenuLayout).Visibility = ViewStates.Visible; })).SetStartDelay(1500).Start();
                FindViewById <LinearLayout>(Resource.Id.ZinaOSMainMenuLayout).BringToFront();
                SetHiddenMainMenuEvent(1);
            }
            catch (Exception ex)
            {
                ETC.LogError(ex, this);
            }
            finally
            {
                IsBooting = false;
            }
        }
示例#26
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.activity_main);

            CheckForPermissions();

            Instance = this;

            //Window.AddFlags(WindowManagerFlags.Fullscreen); //to show

            Settings.LoadFromFile();
            imageStore.LoadFavorites();

            AdView adView = new AdView(this)
            {
                AdSize   = AdSize.SmartBanner,
                AdUnitId = "ca-app-pub-3940256099942544/6300978111"
            };

            CoordinatorLayout cLayout = FindViewById <CoordinatorLayout>(Resource.Id.coordinatorLayout);

            cLayout.AddView(adView);
            adView.TranslationY = (PhoneHeight - adView.AdSize.GetHeightInPixels(this) - GetStatusBarHeight());

            //SetAdView
            MobileAds.Initialize(this, "ca-app-pub-3940256099942544~3347511713");
            adView.LoadAd(adRequest);

            CrossConnectivity.Current.ConnectivityChanged += (o, e) =>
            {
                RunOnUiThread(() =>
                {
                    //SetAdView when the connection changes
                    MobileAds.Initialize(this, "ca-app-pub-3940256099942544~3347511713");
                    adView.LoadAd(adRequest);
                });
            };

            //Finding Resources
            tagSpinner          = FindViewById <Spinner>(Resource.Id.apiEndPoints);
            imagePanel          = FindViewById <ImageView>(Resource.Id.imageView);
            imageInfoButton     = FindViewById <FloatingActionButton>(Resource.Id.imageInfoButton);
            nextImageButton     = FindViewById <FloatingActionButton>(Resource.Id.nextImageButton);
            previousImageButton = FindViewById <FloatingActionButton>(Resource.Id.previousImageButton);
            Android.Support.V7.Widget.Toolbar toolbar = FindViewById <Android.Support.V7.Widget.Toolbar>(Resource.Id.toolbar);

            imageInfoButton.Animate().TranslationY(PhoneHeight);

            //Toolbar Configurations
            SetSupportActionBar(toolbar);
            SupportActionBar.Title = null;

            //Spinner
            tagSpinner.Adapter       = new TagsAdapter(this, Android.Resource.Layout.SimpleListItem1, NekosLife.Instance);
            tagSpinner.ItemSelected += (o, e) =>
            {
                if (Settings.Instance.GenerateNewImageOnTagChange)
                {
                    imageStore.Tag = SelectedTag;
                    Toast.MakeText(this, $"Selected '{SelectedTag}'", ToastLength.Short).Show();
                    //GetNextImage();
                }
            };

            bool infoButtonIsUp = false;

            //Request image download vvv
            imagePanel.LongClick += (o, e) =>
            {
                if (!infoButtonIsUp)
                {
                    infoButtonIsUp = true;
                    imageInfoButton.Animate().TranslationY(-100);
                    Task.Run(() =>
                    {
                        Thread.Sleep(3000);
                        RunOnUiThread(() =>
                        {
                            imageInfoButton.Animate().TranslationY(PhoneHeight);
                            infoButtonIsUp = false;
                        });
                    });
                }
            };

            imageInfoButton.Click += (o, e) =>
            {
                if (imagePanel.Drawable == null)
                {
                    Toast.MakeText(this, "No Images Were Found!", ToastLength.Short).Show();
                    return;
                }

                Android.App.AlertDialog.Builder aDialog;
                aDialog = new Android.App.AlertDialog.Builder(this);
                aDialog.SetTitle("Image Options");
                aDialog.SetPositiveButton("Download Image", delegate
                {
                    Bitmap image = imageStore.GetImage();
                    string path  = Android.Provider.MediaStore.Images.Media.InsertImage(ContentResolver, image, ImageName, "A neko from NekoViewer app");
                    if (path == null)
                    {
                        Toast.MakeText(this, "Couldn't download image", ToastLength.Short).Show();
                        return;
                    }
                    Toast.MakeText(this, $"Downloaded {ImageName}!", ToastLength.Short).Show();
                    NotificationController.CreateDownloadNotification(this, "Download Completed!", ImageName, path, image);
                });
                aDialog.SetNeutralButton("Set As Wallpaper", delegate
                {
                    WallpaperManager.GetInstance(this).SetBitmap(imageStore.GetImage());
                    Toast.MakeText(this, "Wallpaper has been applied!", ToastLength.Short).Show();
                });
                aDialog.Show();
            };

            //Buttons Functions
            nextImageButton.LongClick += (o, e) =>
            {
                Android.App.AlertDialog.Builder aDialog;
                aDialog = new Android.App.AlertDialog.Builder(this);
                aDialog.SetTitle("Choose An Option");
                aDialog.SetNegativeButton("Auto Mode", delegate
                {
                    AutoSlideEnabled = !AutoSlideEnabled;
                    Toast.MakeText(this, $"Auto Mode Is '{AutoSlideEnabled.ToString()}'", ToastLength.Short).Show();
                    DoAutoSlide();
                });
                aDialog.SetPositiveButton("Last Image", delegate
                {
                    if (loading || downloading || AutoSlideEnabled)
                    {
                        Toast.MakeText(this, "An Image Is Being Downloaded or Loading Please Be Patient", ToastLength.Short).Show();
                        return;
                    }

                    Toast.MakeText(this, "Last image", ToastLength.Short).Show();
                    loading = true;
                    imagePanel.Animate().TranslationX(-PhoneWidth);
                    Task.Run(() =>
                    {
                        imageStore.GotoLast();
                        Fix();
                        RunOnUiThread(() =>
                        {
                            ReloadImagePanel(() =>
                            {
                                CheckPreviousImageButton();
                                imagePanel.TranslationX = PhoneWidth;
                                imagePanel.Animate().TranslationX(0);
                            });
                        });
                        loading = false;
                    });
                });
                aDialog.Show();
            };

            nextImageButton.Click += (o, e) =>
            {
                if (AutoSlideEnabled)
                {
                    return;
                }

                GetNextImage();
            };
            previousImageButton.Click += (o, e) =>
            {
                if (AutoSlideEnabled)
                {
                    return;
                }

                GetPreviousImage();
            };

            Settings.Instance.AnimationsEnabled.OnChange += delegate
            {
                //Do something to disable system animations
            };

            previousImageButton.Visibility = ViewStates.Invisible;
        }
        public void enemyMove()
        {
            etimer          = new System.Timers.Timer();
            etimer.Interval = 24 - (level * 4);
            etimer.Elapsed += (sender, e) =>
            {
                RunOnUiThread(() =>
                {
                    ImageView enemy  = FindViewById <ImageView>(Resource.Id.mini);
                    ImageView rocket = FindViewById <ImageView>(Resource.Id.rocket);

                    var metrics = Resources.DisplayMetrics;


                    int width  = metrics.WidthPixels - enemy.Width;
                    int height = metrics.HeightPixels - (enemy.Width * 2);

                    if (bx > width)
                    {
                        dx = -1;
                    }
                    if (bx < 20)
                    {
                        dx = 1;
                    }


                    if (by > height)
                    {
                        dy = -1;
                    }
                    if (by < 0)
                    {
                        dy = 1;
                    }



                    if ((rocket.GetY() + (rocket.Height / 2) <= by + enemy.Height || (rocket.GetY() + (rocket.Height / 2) <= by) && by >= rocket.GetY()) && rocket.GetX() + rocket.Width >= bx)
                    {
                        ProgressBar userLife = FindViewById <ProgressBar>(Resource.Id.user_life);
                        userLife.Progress   -= 20;


                        rocket.Alpha = 0;
                        rocket.Animate()
                        .SetDuration(5000)
                        .Alpha(10);


                        MediaPlayer player1;
                        player1 = MediaPlayer.Create(this, Resource.Raw.blast);
                        player1.Start();
                        player1.SetVolume(SoundSetup.sound_level, SoundSetup.sound_level);


                        by = 0;
                        bx = width;

                        if (userLife.Progress == 0)
                        {
                            etimer.Close();
                            AlertDialog.Builder alert = new AlertDialog.Builder(this);
                            alert.SetTitle("Game Over");
                            alert.SetMessage("Unfortunately enemy has hit your rocket.");
                            alert.SetPositiveButton("Continue", (senderAlert, args) => {
                                Intent activity2 = new Intent(this, typeof(GameOver));
                                string score     = FindViewById <TextView>(Resource.Id.score).Text;
                                activity2.PutExtra("score", score);
                                this.StartActivity(activity2);
                                this.Finish();
                            });

                            alert.Show();
                        }
                    }

                    bx = bx + dx;
                    enemy.SetX(bx);

                    by = by + dy;
                    enemy.SetY(by);
                });
            };
            etimer.Enabled = true;
        }
示例#28
0
 void InitLayout(string categoryId) {
     SetContentView(Resource.Layout.activity_quiz);
     icon = FindViewById<ImageView>(Resource.Id.icon);
     int resId = Resources.GetIdentifier(ImageCategory + categoryId, CategoryAdapter.Drawable,
         ApplicationContext.PackageName);
     icon.SetImageResource(resId);
     icon.SetImageResource(resId);
     icon.Animate()
         .ScaleX(1)
         .ScaleY(1)
         .Alpha(1)
         .SetInterpolator(interpolator)
         .SetStartDelay(300)
         .Start();
     quizFab = FindViewById<FloatingActionButton>(Resource.Id.fab_quiz);
     quizFab.SetImageResource(Resource.Drawable.ic_play);
     quizFab.Visibility = savedStateIsPlaying ? ViewStates.Gone : ViewStates.Visible;
     quizFab.Click += (sender, e) => {
         var view = (View)sender;
         switch (view.Id) {
             case Resource.Id.fab_quiz:
                 StartQuizFromClickOn(view);
                 break;
             case Resource.Id.submitAnswer:
                 SubmitAnswer();
                 break;
             case Resource.Id.quiz_done:
                 FinishAfterTransition();
                 break;
             case Undefined:
                 var contentDescription = view.ContentDescription;
                 if (contentDescription != null && contentDescription == GetString(Resource.String.up)) {
                     OnBackPressed();
                     break;
                 }
                 break;
             default:
                 throw new InvalidOperationException(
                     "OnClick has not been implemented for " + Resources.GetResourceName(view.Id));
         }
     };
     quizFab.Animate()
         .ScaleX(1)
         .ScaleY(1)
         .SetInterpolator(interpolator)
         .SetStartDelay(400)
         .Start();
 }
示例#29
0
        public async Task LoadImage(ImageView imageView, string userID, string picture, bool isLarge = false, bool temp = false)
        {
            try
            {
                string subFolder;

                if (isLarge)
                {
                    subFolder = Constants.LargeImageSize.ToString();
                }
                else
                {
                    subFolder = Constants.SmallImageSize.ToString();
                }

                string saveName = userID + "_" + subFolder + "_" + picture;
                string imgID    = imageView.ToString().Split("{")[1].Substring(0, 7);

                if (Exists(saveName))
                {
                    if (context is ProfileViewActivity && (((ProfileViewActivity)context).currentID.ToString() != userID || ((ProfileViewActivity)context).cancelImageLoading))
                    {
                        return;
                    }

                    //context.c.Log("Exists " + userID + " at " + imgID);

                    lock (lockObj)
                    {
                        //context.c.Log("locking existing at " + userID);

                        if (imageViewToLoadLater.ContainsKey(imageView))
                        {
                            imageViewToLoadLater.Remove(imageView);
                        }
                    }

                    context.RunOnUiThread(() => {
                        imageView.SetImageBitmap(Load(saveName)); //takes 3-4 ms

                        if (context is ChatListActivity)          //only necessary because in the list the pictures appear on the wrong place for a moment
                        {
                            imageView.Alpha = 0;
                            imageView.Animate().Alpha(1).SetDuration(context.tweenTime).Start();
                        }
                    });
                }
                else
                {
                    if (context is ProfileViewActivity && (((ProfileViewActivity)context).currentID.ToString() != userID || ((ProfileViewActivity)context).cancelImageLoading))
                    {
                        return;
                    }

                    context.RunOnUiThread(() => {
                        imageView.SetImageResource(Resource.Drawable.color_loadingimage_light_dfdfdf);
                    });

                    string url;
                    if (!temp)
                    {
                        url = Constants.HostName + Constants.UploadFolder + "/" + userID + "/" + subFolder + "/" + picture;
                    }
                    else
                    {
                        url = Constants.HostName + Constants.TempUploadFolder + "/" + userID + "/" + subFolder + "/" + picture;
                    }

                    lock (lockObj)
                    {
                        //context.c.Log("locking new at " + userID);

                        if (imagesInProgress.IndexOf(saveName) != -1) //saveName must be used, not userID, because on the profile edit page there are multiple pictures from the same user.
                        {
                            //context.c.Log("Cancelled loading " + userID + " at " + imgID);

                            //For a chatlist with 3 items, 4 imageViews are used. The first is called 13 times (with all 3 IDs), the second called once, the third once, and the fourth 24 times (with all 3 IDs).
                            try
                            {
                                imageViewToLoadLater[imageView] = saveName;
                            }
                            catch (Exception ex)
                            {
                                context.c.ReportErrorSilent("imageViewToLoadLater cannot add ID " + userID + ": " + ex.Message + " - imageViewToLoadLater " + imageViewToLoadLater);
                            }

                            return;
                        }

                        imagesInProgress.Add(saveName);
                    }

                    //context.c.Log("Requesting " + userID + " at " + imgID); //+ " arr " + string.Join('|', imagesInProgress) if used at Completed, "Collection was modified; enumeration operation may not execute" error may occur.

                    byte[] bytes = null;

                    var task = CommonMethods.GetImageDataFromUrlAsync(url);
                    CancellationTokenSource cts = new CancellationTokenSource();

                    if (await Task.WhenAny(task, Task.Delay(Constants.RequestTimeout, cts.Token)) == task)
                    {
                        cts.Cancel();
                        bytes = await task;
                    }

                    lock (lockObj)
                    {
                        int index = imagesInProgress.IndexOf(saveName);
                        if (index != -1)
                        {
                            try
                            {
                                imagesInProgress.Remove(saveName);
                            }
                            catch
                            {
                                context.c.ReportErrorSilent("imagesInProgress remove error at index " + index + ", ID " + userID + " Length " + imagesInProgress.Count);
                            }
                        }
                    }

                    //context.c.Log("Completed " + userID + " at " + imgID);

                    if (bytes != null)
                    {
                        Save(saveName, bytes);
                        Bitmap bmp = BitmapFactory.DecodeByteArray(bytes, 0, bytes.Length);

                        if (context is ProfileViewActivity && (((ProfileViewActivity)context).currentID.ToString() != userID || ((ProfileViewActivity)context).cancelImageLoading))
                        {
                            return;
                        }
                        context.RunOnUiThread(() =>
                        {
                            bool found = false;

                            //string str = "Bitmap loaded: " + userID + " original " + imageView.ToString().Split("{")[1].Substring(0,7);
                            foreach (KeyValuePair <ImageView, string> pair in imageViewToLoadLater)
                            {
                                //there might be more than one ImageView that set this ID
                                if (pair.Value == saveName)
                                {
                                    found = true;
                                    pair.Key.SetImageBitmap(bmp);
                                    //str += " newer " + pair.Key.ToString().Split("{")[1].Substring(0, 7);
                                }
                            }

                            if (!found)
                            {
                                imageView.SetImageBitmap(bmp);
                            }
                            //context.c.Log(str);
                        });
                    }
                    else
                    {
                        if (context is ProfileViewActivity && (((ProfileViewActivity)context).currentID.ToString() != userID || ((ProfileViewActivity)context).cancelImageLoading))
                        {
                            return;
                        }
                        context.RunOnUiThread(() =>
                        {
                            if (isLarge)
                            {
                                imageView.SetImageResource(Resource.Drawable.noimage_hd);
                            }
                            else
                            {
                                imageView.SetImageResource(Resource.Drawable.noimage);
                            }
                        });
                    }
                }
            }
            catch (Exception ex)
            {
                context.c.ReportErrorSilent("ImageCache error at userID " + userID + ": " + ex.Message + System.Environment.NewLine + ex.StackTrace);
            }
        }
示例#30
0
 private void ShowActive(ImageView view)
 {
     _animatedView = view;
     view.Alpha    = 1f;
     view.Animate().Rotation(15f).ScaleX(1.1f).ScaleY(1.1f).SetDuration(500).WithEndAction(RotateLeft()).Start();
 }
示例#31
0
 private void ShowInactive(ImageView view)
 {
     view.Alpha = .85f;
     view.Animate().ScaleX(1f).ScaleY(1f).Rotation(0).SetDuration(500).Start();
 }
示例#32
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.event_view);

            eventName          = FindViewById <TextView>(Resource.Id.txtEventName);
            eventDistance      = FindViewById <TextView>(Resource.Id.txtEventDistance);
            eventAddress       = FindViewById <TextView>(Resource.Id.txtEventAddress);
            eventLocate        = FindViewById <ImageView>(Resource.Id.imgLocate);
            eventImages        = FindViewById <LinearLayout>(Resource.Id.lnlImages);
            eventDescription   = FindViewById <TextView>(Resource.Id.txtDescription);
            horizontalScroll   = FindViewById <HorizontalScrollView>(Resource.Id.scrIEventImages);
            eventNewComment    = FindViewById <EditText>(Resource.Id.edtNewComment);
            eventSubmitComment = FindViewById <ImageButton>(Resource.Id.btnSubmitComment);

            commentListView = FindViewById <RecyclerView>(Resource.Id.commentRecyclerView);

            // Get event info
            eventID = Intent.GetIntExtra("eventID", 0);
            var @event = RequestSender.GetFullEvent(eventID);

            // Setting the distance
            eventLatitude  = @event.Latitude;
            eventLongitude = @event.Longitude;
            var    userLocation = Geolocation.GetLastKnownLocationAsync();
            double distance     = MathSupplement.Distance(eventLatitude, eventLongitude, userLocation.Result.Latitude, userLocation.Result.Longitude);

            if (userLocation != null)
            {
                if (distance < 1000.0)
                {
                    eventDistance.Text = $"{distance:0}m";
                }
                else
                {
                    eventDistance.Text = $"{distance / 1000.0:0.0}km";
                }
            }

            // Event name and address
            eventName.Text    = @event.Name;
            eventAddress.Text = @event.Address.Address;

            // Images
            int   imageWidth  = 700;
            int   imageHeight = 450;
            float aspect;

            foreach (var item in @event.Images)
            {
                Bitmap img;
                Bitmap scaledImg = Bitmap.CreateBitmap(imageWidth, imageHeight, Bitmap.Config.Argb8888);

                ImageView imgView = new ImageView(this);
                imgView.SetImageBitmap(scaledImg);
                LinearLayout.LayoutParams imgViewParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MatchParent, LinearLayout.LayoutParams.WrapContent, 0.0f);
                imgViewParams.SetMargins(16, 16, 16, 16);
                imgView.LayoutParameters = imgViewParams;
                eventImages.AddView(imgView);

                Thread imageLoader = new Thread(new ThreadStart(() =>
                {
                    try
                    {
                        using var webClient = new WebClient();

                        var imageBytes = webClient.DownloadData(item);
                        if (imageBytes != null && imageBytes.Length > 0)
                        {
                            img           = BitmapFactory.DecodeByteArray(imageBytes, 0, imageBytes.Length);
                            scaledImg     = Helper.ScaleBitmap(img, imageWidth, imageHeight);
                            imgView.Alpha = 0.0f;
                            imgView.SetImageBitmap(scaledImg);
                            imgView.Animate().Alpha(1.0f);
                        }
                    }
                    catch { }
                }));
                imageLoader.Start();
            }

            // Event description
            eventDescription.Text = @event.Description;

            // Check if eligible to comment
            if (!RequestSender.ThisAccount().Can((uint)WebApi.Classes.Permissions.SEND_CHAT_MESSAGES))
            {
                eventNewComment.Enabled    = false;
                eventSubmitComment.Enabled = false;
            }
            else
            {
                eventNewComment.Enabled    = true;
                eventSubmitComment.Enabled = true;
            }

            // Print comment amount
            Toast.MakeText(this, RequestSender.GetComments(eventID).Count.ToString(), ToastLength.Short).Show();

            // Send comment button
            eventSubmitComment.Click += (o, e) =>
            {
                RequestSender.CreateComment(eventID, eventNewComment.Text);
                eventNewComment.Text = "";
                Toast.MakeText(this, "Comment submited!", ToastLength.Short).Show();
            };

            // Load comments
            List <WebApi.Classes.Message> comments = RequestSender.GetComments(eventID);
            var tempMsg = new WebApi.Classes.Message()
            {
                Content  = "baaaaaadd ddddddddd ddddddddd ddddddddd ddddddddddaaaa ababooe",
                Sender   = 1,
                SendTime = DateTime.Now,
                Id       = 1
            };

            comments.Add(tempMsg);
            tempMsg = new WebApi.Classes.Message()
            {
                Content  = "KRINDŽAS 🤣🤣🤣🤣",
                Sender   = 2,
                SendTime = DateTime.Now,
                Id       = 2
            };
            comments.Add(tempMsg);
            tempMsg = new WebApi.Classes.Message()
            {
                Content  = "baaaaaadd",
                Sender   = 3,
                SendTime = DateTime.Now,
                Id       = 3
            };
            comments.Add(tempMsg);
            commentListView.HasFixedSize = true;
            commentListLayout            = new LinearLayoutManager(this);
            commentListView.SetLayoutManager(commentListLayout);
            commentListAdapter = new CommentListAdapter(comments);
            commentListView.SetAdapter(commentListAdapter);
        }