Beispiel #1
0
        private void SetRecyclerViewAdapters()
        {
            try
            {
                MAdapter = new CommentsAdapter(Activity)
                {
                    CommentList = new ObservableCollection <CommentObject>()
                };
                LayoutManager = new LinearLayoutManager(Activity);
                MRecycler.SetLayoutManager(LayoutManager);
                MRecycler.HasFixedSize = true;
                MRecycler.SetItemViewCacheSize(10);
                MRecycler.GetLayoutManager().ItemPrefetchEnabled = true;
                MRecycler.NestedScrollingEnabled = false;
                MRecycler.SetAdapter(MAdapter);

                RecyclerViewOnScrollListener xamarinRecyclerViewOnScrollListener = new RecyclerViewOnScrollListener(LayoutManager);
                MainScrollEvent = xamarinRecyclerViewOnScrollListener;
                MainScrollEvent.LoadMoreEvent += MainScrollEventOnLoadMoreEvent;
                MRecycler.AddOnScrollListener(xamarinRecyclerViewOnScrollListener);
                MainScrollEvent.IsLoading = false;
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
        private void SetRecyclerViewAdapters()
        {
            try
            {
                MAdapter = new CommentsAdapter(ActivityContext)
                {
                    CommentList = new ObservableCollection <CommentsDataObject>()
                };
                MAdapter.OnItemLongClick += MAdapterOnOnItemLongClick;
                MAdapter.OnAvatarClick   += CommentsAdapterOnAvatarClick;

                LayoutManager = new LinearLayoutManager(ActivityContext);
                MRecycler.SetLayoutManager(LayoutManager);
                MRecycler.HasFixedSize = true;
                MRecycler.SetItemViewCacheSize(10);
                MRecycler.GetLayoutManager().ItemPrefetchEnabled = true;
                var sizeProvider = new FixedPreloadSizeProvider(10, 10);
                var preLoader    = new RecyclerViewPreloader <CommentsDataObject>(ActivityContext, MAdapter, sizeProvider, 10);
                MRecycler.AddOnScrollListener(preLoader);
                MRecycler.SetAdapter(MAdapter);

                RecyclerViewOnScrollListener xamarinRecyclerViewOnScrollListener = new RecyclerViewOnScrollListener(LayoutManager);
                MainScrollEvent = xamarinRecyclerViewOnScrollListener;
                MainScrollEvent.LoadMoreEvent += MainScrollEventOnLoadMoreEvent;
                MRecycler.AddOnScrollListener(xamarinRecyclerViewOnScrollListener);
                MainScrollEvent.IsLoading = false;
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
            protected override void OnPostExecute(Java.Lang.Object result)
            {
                base.OnPostExecute(result);

                if (result != null)
                {
                    var madapter = new CommentsAdapter(eventfeed, activity);
                    lvComment.Adapter     = madapter;
                    btnSendComment.Click += delegate
                    {
                        string comment = txtComment.Text.Trim();
                        if (comment == "")
                        {
                            AlertBox.Create("Error", "Please enter Comment", activity);
                            return;
                        }
                        ;
                        EventFeedModel model  = new EventFeedModel();
                        int            userID = 0;
                        int.TryParse(GlobalClass.UserID.ToString(), out userID);
                        model.UserID  = userID;
                        model.EventID = eventID;
                        model.Message = comment;
                        new PostFeedData(txtComment, model, lvComment, activity, eventID, madapter).Execute();
                    };
                }
                else
                {
                    AlertBox.Create("Error", "Error", activity);
                }
            }
Beispiel #4
0
        private void SetRecyclerViewAdapters()
        {
            try
            {
                MAdapter       = new CommentsAdapter(Activity);
                MLayoutManager = new LinearLayoutManager(Activity);
                MRecycler.SetLayoutManager(MLayoutManager);
                MRecycler.SetAdapter(MAdapter);
                MRecycler.NestedScrollingEnabled = true;
                MAdapter.ReplyClick    += CommentsAdapter_ReplyClick;
                MAdapter.AvatarClick   += CommentsAdapter_AvatarClick;
                MAdapter.ItemLongClick += MAdapterOnItemLongClick;

                RecyclerViewOnScrollListener recyclerViewOnScrollListener = new RecyclerViewOnScrollListener(MLayoutManager);
                MainScrollEvent = recyclerViewOnScrollListener;
                MainScrollEvent.LoadMoreEvent += OnScroll_OnLoadMoreEvent;
                MRecycler.AddOnScrollListener(recyclerViewOnScrollListener);
                MainScrollEvent.IsLoading = false;

                MRecycler.Visibility        = ViewStates.Visible;
                EmptyStateLayout.Visibility = ViewStates.Gone;
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
 public PostFeedData(EditText txtComment, EventFeedModel model, ListView lvComment, Activity activity, long eventID, CommentsAdapter madapter)
 {
     this.txtComment = txtComment;
     this.model      = model;
     this.lvComment  = lvComment;
     this.activity   = activity;
     this.eventID    = eventID;
     this.madapter   = madapter;
     jresult         = new JsonResult();
 }
        private void InitComponent()
        {
            try
            {
                ImageDisplay = Mainview.FindViewById <ImageView>(Resource.Id.ImageDisplay);
                Fullname     = Mainview.FindViewById <TextView>(Resource.Id.username);
                UserAvatar   = Mainview.FindViewById <ImageView>(Resource.Id.userAvatar);
                MoreIcon     = Mainview.FindViewById <TextView>(Resource.Id.moreicon);
                LikeIcon     = Mainview.FindViewById <TextView>(Resource.Id.Like);
                CommentIcon  = Mainview.FindViewById <TextView>(Resource.Id.Comment);

                Favicon             = Mainview.FindViewById <TextView>(Resource.Id.fav);
                Description         = Mainview.FindViewById <AutoLinkTextView>(Resource.Id.description);
                TimeTextView        = Mainview.FindViewById <TextView>(Resource.Id.time_text);
                ViewCommentsButton  = Mainview.FindViewById <TextView>(Resource.Id.ViewMoreComment);
                LikeCount           = Mainview.FindViewById <TextView>(Resource.Id.Likecount);
                CommentCount        = Mainview.FindViewById <TextView>(Resource.Id.Commentcount);
                CommentRecyclerView = Mainview.FindViewById <RecyclerView>(Resource.Id.RecylerComment);
                ShareIcon           = Mainview.FindViewById <TextView>(Resource.Id.share);
                TypePost            = Mainview.FindViewById <TextView>(Resource.Id.Typepost);

                TextView ViewboxText = Mainview.FindViewById <TextView>(Resource.Id.searchviewbox);
                ViewboxText.SetTextColor(AppSettings.SetTabDarkTheme ? Color.White : Color.Black);

                //Set Adapter Data
                CommentsAdapter = new CommentsAdapter(Activity);
                LinearLayoutManager mLayoutManager = new LinearLayoutManager(Activity);
                CommentRecyclerView.SetLayoutManager(mLayoutManager);
                CommentRecyclerView.SetAdapter(CommentsAdapter);
                CommentRecyclerView.NestedScrollingEnabled = false;
                CommentsAdapter.AvatarClick += CommentsAdapter_AvatarClick;

                FontUtils.SetTextViewIcon(FontsIconFrameWork.IonIcons, MoreIcon, IonIconsFonts.More);
                FontUtils.SetTextViewIcon(FontsIconFrameWork.IonIcons, CommentIcon, IonIconsFonts.IosChatbubbleOutline);
                FontUtils.SetTextViewIcon(FontsIconFrameWork.IonIcons, Favicon, IonIconsFonts.IosStarOutline);
                FontUtils.SetTextViewIcon(FontsIconFrameWork.IonIcons, LikeIcon, IonIconsFonts.IosHeartOutline);
                FontUtils.SetTextViewIcon(FontsIconFrameWork.IonIcons, TypePost, IonIconsFonts.Image);
                FontUtils.SetTextViewIcon(FontsIconFrameWork.IonIcons, ShareIcon, IonIconsFonts.IosUndoOutline);

                ReadMoreOption = new ReadMoreOption.Builder(MainContext)
                                 .TextLength(200, ReadMoreOption.TypeCharacter)
                                 .MoreLabel(MainContext.GetText(Resource.String.Lbl_ReadMore))
                                 .LessLabel(MainContext.GetText(Resource.String.Lbl_ReadLess))
                                 .MoreLabelColor(Color.ParseColor(AppSettings.MainColor))
                                 .LessLabelColor(Color.ParseColor(AppSettings.MainColor))
                                 .LabelUnderLine(true)
                                 .Build();
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
Beispiel #7
0
 private void SetRecyclerViewAdapters()
 {
     try
     {
         CommentsAdapter = new CommentsAdapter(Activity);
         LinearLayoutManager mLayoutManager = new LinearLayoutManager(Activity);
         CommentRecyclerView.SetLayoutManager(mLayoutManager);
         CommentRecyclerView.SetAdapter(CommentsAdapter);
         CommentRecyclerView.NestedScrollingEnabled = false;
     }
     catch (Exception e)
     {
         Console.WriteLine(e);
     }
 }
        protected override void OnPostExecute(Java.Lang.Object result)
        {
            base.OnPostExecute(result);

            if (result != null && eventfeed.Count > 0)
            {
                emptyComment.Visibility = Android.Views.ViewStates.Gone;
                var madapter = new CommentsAdapter(eventfeed, activity);
                lvComment.Adapter = madapter;
            }
            else
            {
                emptyComment.Visibility = Android.Views.ViewStates.Visible;
            }
        }
                protected override void OnPostExecute(JsonResult result)
                {
                    base.OnPostExecute(result);
                    txtComment.Text = "";
                    if (result.Success == true)
                    {
                        var eventfeed = RestSharpCall.GetList <EventFeedModel>("Event/GetAllEventFeedDetails?eventId=" + eventID);
                        var madapter  = new CommentsAdapter(eventfeed, activity);
                        lvComment.Post(() =>
                        {
                            lvComment.SetSelection(madapter.Count - 1);
                        });

                        lvComment.Adapter = madapter;
                        lvComment.Invalidate();
                    }
                }
Beispiel #10
0
        //=================Public methods=============//

        public void SetData(string imageFile, List <string> comments, Location photoCaptureLocation)
        {
            mViewImageWithLocation.LoadImageFromFile(imageFile);

            if (photoCaptureLocation != null)
            {
                mViewImageWithLocation.SetLocation(
                    photoCaptureLocation.Latitude,
                    photoCaptureLocation.Longitude);
            }

            mAdapterComments = new CommentsAdapter(
                Context,
                comments);

            mListViewComments.Adapter = mAdapterComments;
        }
        private void SetRecyclerViewAdapters()
        {
            try
            {
                CommentsAdapter = new CommentsAdapter(Activity);
                MLayoutManager  = new LinearLayoutManager(Activity);
                CommentRecyclerView.SetLayoutManager(MLayoutManager);
                CommentRecyclerView.SetAdapter(CommentsAdapter);

                RecyclerViewOnScrollListener xamarinRecyclerViewOnScrollListener = new RecyclerViewOnScrollListener(MLayoutManager);
                MainScrollEvent = xamarinRecyclerViewOnScrollListener;
                MainScrollEvent.LoadMoreEvent += OnScroll_OnLoadMoreEvent;
                CommentRecyclerView.AddOnScrollListener(xamarinRecyclerViewOnScrollListener);
                MainScrollEvent.IsLoading = false;
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
Beispiel #12
0
        private void SetRecyclerViewAdapters()
        {
            try
            {
                MAdapter       = new CommentsAdapter(this);
                MLayoutManager = new LinearLayoutManager(this);
                MRecycler.SetLayoutManager(MLayoutManager);
                MRecycler.NestedScrollingEnabled = false;
                MRecycler.SetAdapter(MAdapter);

                RecyclerViewOnScrollListener recyclerViewOnScrollListener = new RecyclerViewOnScrollListener(MLayoutManager);
                MainScrollEvent = recyclerViewOnScrollListener;
                MainScrollEvent.LoadMoreEvent += OnScroll_OnLoadMoreEvent;
                MRecycler.AddOnScrollListener(recyclerViewOnScrollListener);
                MainScrollEvent.IsLoading = false;
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
Beispiel #13
0
        private async void SetupComments()
        {
            loadingCircle.Visibility = ViewStates.Visible;
            var response = await IdeaBagApi.Instance.GetCommentsAsync(GetDataId());

            if (response.Payload != null)
            {
                this.comments = response.Payload;
                if (response.Payload.Count == 0)
                {
                    ShowEmptyState();
                }
                else
                {
                    HideEmptyState();
                }

                commentsAdapter = new CommentsAdapter(response.Payload);
                commentsRecycler.SetLayoutManager(new LinearLayoutManager(this));
                commentsRecycler.SetAdapter(commentsAdapter);
                commentsRecycler.SetItemAnimator(new DefaultItemAnimator());

                commentsAdapter.OnDeleteComment += (position) =>
                {
                    var comment = comments[position];
                    RequestDeleteComment(comment.Id, position);
                };
            }
            else
            {
                Snackbar.Make(commentTb, response.ErrorMessage, Snackbar.LengthIndefinite)
                .SetAction("Retry", (v) => SetupComments())
                .Show();
            }

            loadingCircle.Visibility = ViewStates.Gone;
        }