Example #1
0
        public override void OnActivityResult(int requestCode, [GeneratedEnum] Result resultCode, Intent data)
        {
            base.OnActivityResult(requestCode, resultCode, data);

            switch (requestCode)
            {
            case 2:
                if (resultCode == Result.Ok && data != null)
                {
                    Android.Net.Uri uri = data.Data;
                    try
                    {
                        BackgroundFactory background = new BackgroundFactory();
                        background.SaveImagePath(uri);
                        background = null;
                        Log.Info("tag", "Path sent to BackgroundFactory");
                    }
                    catch
                    {
                    }
                }
                else
                {
                    Log.Info("LiveDisplay", "Data was null");
                    using (ConfigurationManager configurationManager = new ConfigurationManager(sharedPreferences))
                    {
                        configurationManager.SaveAValue(ConfigurationParameters.ChangeWallpaper, "0");
                    }
                }

                break;
            }
        }
Example #2
0
        protected override void OnActivityResult(int requestCode, [GeneratedEnum] Result resultCode, Intent data)
        {
            if (resultCode == Result.Ok && data != null)
            {
                Android.Net.Uri uri = data.Data;
                try
                {
                    BackgroundFactory background = new BackgroundFactory();
                    background.SaveImagePath(uri);
                    background = null;
                    Log.Info("tag", "Path sent to BackgroundFactory");
                    var imagePath = configurationManager.RetrieveAValue(ConfigurationParameters.ImagePath, "");
                    if (imagePath != "")
                    {
                        ThreadPool.QueueUserWorkItem(m =>
                        {
                            Bitmap bitmap = BitmapFactory.DecodeFile(configurationManager.RetrieveAValue(ConfigurationParameters.ImagePath, imagePath));

                            defaultBlurLevel    = configurationManager.RetrieveAValue(ConfigurationParameters.BlurLevel, 1);
                            defaultOpacityLevel = configurationManager.RetrieveAValue(ConfigurationParameters.OpacityLevel, 255);
                            BlurImage blurImage = new BlurImage(Application.Context);
                            blurImage.Load(bitmap).Intensity(defaultBlurLevel);
                            Drawable drawable = new BitmapDrawable(Resources, blurImage.GetImageBlur());
                            RunOnUiThread(() =>
                            {
                                wallpaperPreview.Background       = drawable;
                                wallpaperPreview.Background.Alpha = defaultBlurLevel;
                            }
                                          );
                        });
                    }
                }
                catch
                {
                    configurationManager.SaveAValue(ConfigurationParameters.ChangeWallpaper, "0"); //Black wallpaper.
                }
            }
            else
            {
                Log.Info("LiveDisplay", "Data was null");
                configurationManager.SaveAValue(ConfigurationParameters.ChangeWallpaper, "0"); //Black wallpaper.
            }

            base.OnActivityResult(requestCode, resultCode, data);
        }