public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { var view = inflater.Inflate(Resource.Layout.Profile, null); var postView = inflater.Inflate(Resource.Layout.Post, null); if (userId == null) { userId = new UserSettings(this.Activity).getUserID(); } profileViewModel = new ProfileViewModel(userId); // if (!postViewActive) //{ var avtrView = view.FindViewById <AbdulAris.Civ.CircleImageView>(Resource.Id.profileIcon); if (profileViewModel.Avatar != "") { Glide.With(this.Activity) .Load(profileViewModel.Avatar) .Into(avtrView); } else { Glide.With(this.Activity) .Load("https://st3.depositphotos.com/1156795/35622/v/600/depositphotos_356226476-stock-illustration-profile-placeholder-image-gray-silhouette.jpg") .Into(avtrView); } view.FindViewById <TextView>(Resource.Id.profileUserName).Text = profileViewModel.Name; view.FindViewById <TextView>(Resource.Id.profilePostsCount).Text = profileViewModel.PhotoPosts.Count.ToString(); view.FindViewById <TextView>(Resource.Id.profileSubscribers).Text = profileViewModel.Subscribers.ToString(); view.FindViewById <TextView>(Resource.Id.profileSubscribings).Text = profileViewModel.Subscribings.ToString(); view.FindViewById <TextView>(Resource.Id.profileAbouUser).Text = profileViewModel.TextAbout; var recView = view.FindViewById <AndroidX.RecyclerView.Widget.RecyclerView>(Resource.Id.profilePosts); var galleryPhotos = profileViewModel.PhotoPosts.Select(p => p.Images.FirstOrDefault()).ToList(); var imgAdapter = new ImageShortCutAdapter(this.Activity, galleryPhotos); var grid = new AndroidX.RecyclerView.Widget.GridLayoutManager(this.Activity, 3); recView.HasFixedSize = true; recView.SetLayoutManager(grid); recView.SetAdapter(imgAdapter); imgAdapter.ItemClick += (sender, e) => { int position = e; postViewActive = true; var mfFragment = new MainFlowFragment(userId); mfFragment.specPosition = position; var mngr = this.Activity.SupportFragmentManager; var tag = "profile"; var replacing = mngr.BeginTransaction().Replace(Resource.Id.fragmContainer, mfFragment); if (mngr.BackStackEntryCount == 0 || mngr.GetBackStackEntryAt(mngr.BackStackEntryCount - 1).Name != tag) { replacing.AddToBackStack(tag); } replacing.Commit(); }; return(view); }
public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { first = inflater.Inflate(Resource.Layout.NewPost, null); second = inflater.Inflate(Resource.Layout.NewPost2, null); userId = new UserSettings(this.Activity).getUserID(); if (!activeSecond) { if (ContextCompat.CheckSelfPermission(this.Activity, Manifest.Permission.ReadExternalStorage) == (int)Permission.Granted) { addViewModel = new AddViewModel(); ImageButton takePctrBtn = first.FindViewById <ImageButton>(Resource.Id.takePictureBtn); ImageButton chooseFewBtn = first.FindViewById <ImageButton>(Resource.Id.fewPictures); takePctrBtn.Click += (sender, e) => StartCameraActivity(); chooseFewBtn.Click += (sender, e) => ShowCheckCircles(); recView = first.FindViewById <AndroidX.RecyclerView.Widget.RecyclerView>(Resource.Id.recView); var galleryPhotos = getPhotosFromGallery(); var imgAdapter = new ImageShortCutAdapter(this.Activity, galleryPhotos); var grid = new AndroidX.RecyclerView.Widget.GridLayoutManager(this.Activity, 3); recView.HasFixedSize = true; recView.SetLayoutManager(grid); recView.SetAdapter(imgAdapter); imgAdapter.ItemClick += (sender, e) => { int position = e; if (imgAdapter.fewSelectActive) { var view = recView.GetChildAt(position); var vh = recView.FindViewHolderForLayoutPosition(position); if (view == null) { view = vh.ItemView; } if (!imgAdapter.CheckedPositions.Contains(position)) { if (imgAdapter.CheckedPositions.Count >= 10) { Toast.MakeText(this.Activity, "You could clip up to 10 photos", ToastLength.Short).Show(); } else { imgAdapter.CheckedPositions.Add(position); } } else { imgAdapter.CheckedPositions.Remove(position); } imgAdapter.BindViewHolder(vh, position); } else { SelectedImgsFromGallery(new List <string>() { galleryPhotos[position] }); } }; } else { ActivityCompat.RequestPermissions(this.Activity, new string[] { Manifest.Permission.ReadExternalStorage }, 200); OnCreateView(inflater, container, savedInstanceState); } return(first); } else { return(second); } }