Exemple #1
0
            protected override void OnPostExecute(Java.Lang.Void result)
            {
                base.OnPostExecute(result);
                try
                {
                    if (_Tag == "S")
                    {
                        if (!OutPutString.Contains("ErrorMsg"))
                        {
                            _imageView.SetImageBitmap(_context.webServer.GetImageBitmap());
                            _context.Title = OutPutString;
                            _progressDialog.Dismiss();
                            _context.ApplyAnimationToView(_imageView);
                        }
                        else
                        {
                            _progressDialog.Dismiss();
                            _context.ApplyHexColor(_imageView, "", "S", "", true);
                            _context.AlertMessageShowing(OutPutString);
                        }

                        if (_IntializeOrUpdate == "ADD")
                        {
                            _progressDialog.Dismiss();
                            _imageView.Click += _context._imageView_Click;
                            _viewGroup.AddView(_imageView);
                            _context.ApplyAnimationToView(_imageView);
                        }
                    }
                    else
                    {
                        if (!OutPutString.Contains("ErrorMsg"))
                        {
                            _progressDialog.Dismiss();
                            _context.ApplyHexColor(_imageView, _context.webServer.GetImageHexColor(), "C", OutPutString, true);
                        }
                        else if (OutPutString.Contains("ErrorMsg"))
                        {
                            _progressDialog.Dismiss();
                            _context.ApplyHexColor(_imageView, "", "C", "", true);

                            _context.AlertMessageShowing(OutPutString);
                        }
                        if (_IntializeOrUpdate == "ADD")
                        {
                            _progressDialog.Dismiss();
                            _imageView.Click += _context._imageView_Click;
                            _viewGroup.AddView(_imageView);
                            _context.ApplyAnimationToView(_imageView);
                        }
                    }
                }
                catch (Exception ex)
                {
                }

                if (_progressDialog.IsShowing)
                {
                    _progressDialog.Dismiss();
                }
            }
Exemple #2
0
            public bool OnTouch(View view, MotionEvent even)
            {
                try
                {
                    switch (even.Action)
                    {
                    case MotionEventActions.Down:
                        /* geting touching X & Y position of the layout*/
                        xPosition = (int)even.GetX();
                        yPosition = (int)even.GetY();

                        // Getting Relative layout parameters for adding a view
                        RelativeLayout.LayoutParams relativeLayoutParams = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WrapContent,
                                                                                                           RelativeLayout.LayoutParams.WrapContent);

                        //create a new imageview to added into the relative layout
                        ImageView generateView = new ImageView(_context);

                        //Generate the Random number of creating a imageview shape based on MODULO value
                        if (_context.myRandomnumberGenerator.Next() % 2 == 0)
                        {
                            /*if generated randumber which is EVEN number then Generate the new ImageView in Square Shape */
                            relativeLayoutParams.SetMargins(xPosition, yPosition, 0, 0);
                            generateView.LayoutParameters        = relativeLayoutParams;
                            generateView.LayoutParameters.Width  = 100;
                            generateView.LayoutParameters.Height = 100;
                            generateView.Tag = "S";            // set tag value as 'S' for Square
                            generateView.SetImageResource(Resource.Drawable.squareimg);
                            if (_context.isNetWorkAvailable()) // check if network aviable is yes then apply get image from server and apply to imageview
                            {
                                new LoadingImgeFromServerAsync(_context, generateView, "S", "ADD", ((ViewGroup)view)).Execute();
                            }
                            else
                            {
                                generateView.Click += _context._imageView_Click;
                                ((ViewGroup)view).AddView(generateView);
                                _context.ApplyHexColor(generateView, "", "S", "", false);
                                _context.ApplyAnimationToView(generateView);
                            }
                        }
                        else
                        {
                            /*if generated randumber which is ODD number then Generate the new ImageView in Circle Shape */
                            relativeLayoutParams.SetMargins(xPosition, yPosition, 0, 0);
                            generateView.LayoutParameters        = relativeLayoutParams;
                            generateView.LayoutParameters.Width  = 100;
                            generateView.LayoutParameters.Height = 100;
                            generateView.Tag = "C";     // set tag value as 'C' for Circle
                            generateView.SetImageResource(Resource.Drawable.circleimg);

                            // check if network aviable is yes then apply hex color pattern from server
                            if (_context.isNetWorkAvailable())
                            {
                                new LoadingImgeFromServerAsync(_context, generateView, "C", "ADD", ((ViewGroup)view)).Execute();
                            }
                            else
                            {
                                generateView.Click += _context._imageView_Click;
                                ((ViewGroup)view).AddView(generateView);
                                _context.ApplyHexColor(generateView, "", "C", "", false);
                                _context.ApplyAnimationToView(generateView);
                            }
                        }

                        generateView.Touch += generateView_Touch;

                        break;


                    case MotionEventActions.Move:


                        break;

                    default:
                        return(false);
                    }
                }
                catch (Exception ex) { }
                return(true);
            }