Beispiel #1
0
        public override void OnViewCreated(View view, Bundle savedInstanceState)
        {
            base.OnViewCreated(view, savedInstanceState);
            mHandler                 = new Handler();
            progressBarLL            = view.FindViewById <LinearLayout>(Resource.Id.LLPleaseWait);
            progressBarLL.Visibility = ViewStates.Gone;
            ActionLayout             = view.FindViewById <FrameLayout>(Resource.Id.ActionLayout);
            ActionLayout.Visibility  = ViewStates.Gone;
            mRecycleView             = view.FindViewById <RecyclerView>(Resource.Id.recyclerView);
            linearButton             = view.FindViewById <LinearLayout>(Resource.Id.linearButton);
            linearButton.Enabled     = true;
            mLayoutManager           = new CenterLayoutManager(context, LinearLayoutManager.Horizontal, false);
            mRecycleView.SetLayoutManager(mLayoutManager);
            mRecycleView.AddOnScrollListener(new CustomScrollListener(this));
            buttonFlipcamera = view.FindViewById <Button>(Resource.Id.buttonFlipcamera);
            BackLobby        = view.FindViewById <Button>(Resource.Id.buttonGoLobby);
            buttonRetake     = view.FindViewById <Button>(Resource.Id.buttonRetake);
            SnapHelper helper = new LinearSnapHelpers();

            helper.AttachToRecyclerView(mRecycleView);
            //logoImageView = (ImageView)view.FindViewById(Resource.Id.logoImageView);
            //logoImageView.SetOnTouchListener(this);
            //ViewImage = (View)view.FindViewById(Resource.Id.logoImageView);
            takenImage             = (ImageView)view.FindViewById(Resource.Id.ImageViewtaken);
            imageLayout            = (RelativeLayout)view.FindViewById(Resource.Id.containerTaken);
            containerImg           = (RelativeLayout)view.FindViewById(Resource.Id.containerImg);
            imageLayout.Visibility = ViewStates.Gone;
            back                = (Button)view.FindViewById(Resource.Id.buttonBack);
            save                = (Button)view.FindViewById(Resource.Id.buttonSave);
            layoutManager       = ((CenterLayoutManager)mRecycleView.GetLayoutManager());
            linearButton.Click += delegate
            {
                if (bitmap != null)
                {
                    progressBarLL.Visibility = ViewStates.Visible;
                    context.matrix.Set(matrixConfig.transform);
                    OnCAptureClick(bitmap, linearButton);
                }
            };

            buttonFlipcamera.Click += (object sender, EventArgs e) =>
            {
                ChangeCameraFace(true);
            };

            BackLobby.Click += (object sender, EventArgs e) =>
            {
                BackPressEvent(true);
            };

            buttonRetake.Click += (object sender, EventArgs e) =>
            {
                imageLayout.Visibility  = ViewStates.Gone;
                ActionLayout.Visibility = ViewStates.Visible;
                ResetAcitivity(true);
                containerImg.RemoveAllViews();
                if (matrixConfig == null)
                {
                    matrixConfig = new MatrixConfig();
                }
                containerImg.AddView(new SandboxView(context, bitmap, matrixConfig));
            };

            back.Click += delegate
            {
                BackPressEvent(true);
            };

            save.Click += delegate
            {
                if (bitmapToSave == null)
                {
                    return;
                }
                try
                {
                    MediaStore.Images.Media.InsertImage(context.ContentResolver, bitmapToSave, Long.ToString(JavaSystem.CurrentTimeMillis()) + ".jpg", "Adda52");
                }
                catch (System.Exception e)
                {
                    Log.Debug("In Saving File", e + "");
                }
                bitmapToSave.Recycle();
                bitmapToSave.Dispose();
                bitmapToSave = null;
                System.GC.Collect();
            };

            Dialog dialog = Dialog;

            if (dialog != null)
            {
                int ScreenHeight = (int)(Resources.DisplayMetrics.HeightPixels);
                int ScreenWidth  = (int)(Resources.DisplayMetrics.WidthPixels);
                screenWidth  = ScreenWidth;
                screenHeight = ScreenHeight;

                Window window = Dialog.Window;
                WindowManagerLayoutParams windowParams = window.Attributes;
                windowParams.DimAmount = 0.0f;
                window.Attributes      = (windowParams);

                int actual         = Resources.GetDimensionPixelSize(Resource.Dimension.dimen90);
                int numberofImages = ScreenWidth / actual;
                int increase       = 0;
                if (numberofImages % 2 == 0)
                {
                    increase = (numberofImages / 2) + 1;
                }
                else
                {
                    increase = (numberofImages / 2) + 2;
                }
                ExtraItem               = increase;
                mPhotoAlbum             = new PhotoAlbum(increase, context.BaseContext, TrophyName);
                mAdapter                = new HorizontalTrouphyAdaptor(mPhotoAlbum);
                ActionLayout.Visibility = ViewStates.Visible;
                mRecycleView.SetAdapter(mAdapter);
                mAdapter.ItemClick += (sender, e) =>
                {
                    if (e > ExtraItem - 1 && e - 1 < mPhotoAlbum.numPhoto - ExtraItem)
                    {
                        mRecycleView.SmoothScrollToPosition(e);
                        for (int i = 0; i < mPhotoAlbum.numPhoto; i++)
                        {
                            if (mPhotoAlbum[i].SelectedId != 0)
                            {
                                mPhotoAlbum[i].SelectedId = 0;
                                mAdapter.NotifyItemChanged(i);
                            }
                        }
                        mPhotoAlbum[e].SelectedId = e;
                        linearButton.SetBackgroundResource(Resource.Drawable.solid_circle_background_trophy);
                        mAdapter.NotifyItemChanged(e);
                        context.LastSelectedIndex = e - ExtraItem;
                        bitmap = mPhotoAlbum[e].bitmap;
                        containerImg.RemoveAllViews();
                        if (matrixConfig == null)
                        {
                            matrixConfig = new MatrixConfig();
                        }
                        sandboxView = new SandboxView(context, bitmap, matrixConfig);
                        containerImg.AddView(sandboxView);
                    }
                };
            }
        }