Esempio n. 1
0
        //public override void OnPause()
        //{
        //    if (_isEnableSaveState)
        //    {
        //        SaveGalleryTemp();
        //        SavePreparePostTemp();
        //    }

        //    base.OnPause();
        //}

        //private void TitleOnFocusChange(object sender, View.FocusChangeEventArgs e)
        //{
        //    if (!e.HasFocus)
        //        SavePreparePostTemp();
        //}

        //private void LocalTagsChanged(object sender, NotifyCollectionChangedEventArgs e)
        //{
        //    Model.Tags = LocalTagsAdapter.LocalTags.ToArray();
        //    SavePreparePostTemp();
        //}

        //private void TitleChanged(object sender, Android.Text.TextChangedEventArgs e)
        //{
        //    Model.Title = Title.Text;
        //}

        //private void DescriptionChanged(object sender, Android.Text.TextChangedEventArgs e)
        //{
        //    Model.Description = Description.Text;
        //}

        protected virtual async void InitData()
        {
            if (_isSingleMode)
            {
                Photos.Visibility           = ViewStates.Gone;
                PreviewContainer.Visibility = ViewStates.Visible;
                Preview.CornerRadius        = Style.CornerRadius5;
                RatioBtn.Visibility         = ViewStates.Gone;
                RotateBtn.Visibility        = ViewStates.Gone;

                var previewSize  = BitmapUtils.CalculateImagePreviewSize(Media[0].Parameters, Style.ScreenWidth - Style.Margin15 * 2);
                var layoutParams = new RelativeLayout.LayoutParams(previewSize.Width, previewSize.Height);
                layoutParams.SetMargins(Style.Margin15, 0, Style.Margin15, Style.Margin15);
                PreviewContainer.LayoutParameters = layoutParams;
                Preview.Touch += PreviewOnTouch;

                if (Media[0].UploadState >= UploadState.Saved)
                {
                    Preview.SetImageBitmap(Media[0]);
                }
            }
            else
            {
                Photos.Visibility           = ViewStates.Visible;
                PreviewContainer.Visibility = ViewStates.Gone;
                Photos.SetLayoutManager(new LinearLayoutManager(Activity, LinearLayoutManager.Horizontal, false));
                Photos.AddItemDecoration(new ListItemDecoration(Style.Margin10));
                Photos.LayoutParameters.Height = Style.GalleryHorizontalHeight;

                Photos.SetAdapter(_galleryAdapter);
            }

            await ConvertAndSave();

            if (!IsInitialized)
            {
                return;
            }

            await CheckOnSpam();

            if (!IsInitialized)
            {
                return;
            }

            if (IsSpammer == true)
            {
                return;
            }

            StartUploadMedia(true);
        }
        public override void OnViewCreated(View view, Bundle savedInstanceState)
        {
            if (IsInitialized)
            {
                return;
            }

            base.OnViewCreated(view, savedInstanceState);
            _galleryAdapter = new MediaAdapter(_editPost);

            SetEditPost();

            RatioBtn.Visibility = RotateBtn.Visibility = ViewStates.Gone;
            if (_editPost.Media.Length > 1)
            {
                Photos.Visibility           = ViewStates.Visible;
                PreviewContainer.Visibility = ViewStates.Gone;
                Photos.SetLayoutManager(new LinearLayoutManager(Activity, LinearLayoutManager.Horizontal, false));
                Photos.SetAdapter(_galleryAdapter);
                Photos.AddItemDecoration(new ListItemDecoration((int)TypedValue.ApplyDimension(ComplexUnitType.Dip, 10, Resources.DisplayMetrics)));
            }
            else
            {
                Photos.Visibility           = ViewStates.Gone;
                PreviewContainer.Visibility = ViewStates.Visible;
                var margin       = (int)BitmapUtils.DpToPixel(15, Resources);
                var previewSize  = BitmapUtils.CalculateImagePreviewSize(_editPost.Media[0].Size.Width, _editPost.Media[0].Size.Height, Style.ScreenWidth - margin * 2, int.MaxValue);
                var layoutParams = new RelativeLayout.LayoutParams(previewSize.Width, previewSize.Height);
                layoutParams.SetMargins(margin, 0, margin, margin);
                PreviewContainer.LayoutParameters = layoutParams;
                Preview.CornerRadius = Style.CornerRadius5;

                var url = _editPost.Media[0].Thumbnails.Mini;
                Picasso.With(Activity).Load(url).CenterCrop()
                .Resize(PreviewContainer.LayoutParameters.Width, PreviewContainer.LayoutParameters.Height)
                .Into(Preview);

                Preview.Touch += PreviewOnTouch;
            }

            SearchTextChanged();
        }