public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { base.OnCreateView(inflater, container, savedInstanceState); View view = inflater.Inflate(Resource.Layout.basic_fragment_browse_answers, null); Activity.Title = "Task Detail"; ViewModel = new QuestionDetailViewModel(Arguments.GetString("questionId")); questionTitle = view.FindViewById <TextView>(Resource.Id.text_question_title); questionBody = view.FindViewById <TextView>(Resource.Id.text_question_body); tags = view.FindViewById <TextView>(Resource.Id.text_question_tags); status = view.FindViewById <TextView>(Resource.Id.text_status); answerCount = view.FindViewById <TextView>(Resource.Id.textAnswerCount); ownerFullName = view.FindViewById <TextView>(Resource.Id.text_full_name); ownerUsername = view.FindViewById <TextView>(Resource.Id.text_username); postedDate = view.FindViewById <TextView>(Resource.Id.text_posted_date); ownerHolder = view.FindViewById <RelativeLayout>(Resource.Id.owner_holder); helperBtn = view.FindViewById <Button>(Resource.Id.btnHelper); helpRequestHolder = view.FindViewById <LinearLayout>(Resource.Id.help_request_holder); requestSentHolder = view.FindViewById <LinearLayout>(Resource.Id.request_sent_holder); recyclerView = view.FindViewById <RecyclerView>(Resource.Id.recyclerView); recyclerView.HasFixedSize = false; recyclerView.AddItemDecoration(new DividerItemDecoration(recyclerView.Context, DividerItemDecoration.Vertical)); recyclerView.SetAdapter(adapter = new BrowseAnswerAdapter(Activity, ViewModel, FragmentManager)); refresher = view.FindViewById <SwipeRefreshLayout>(Resource.Id.refresher); refresher.SetColorSchemeColors(Resource.Color.accent); helperBtn.Click += async(sender, e) => { await ViewModel.SendHelperRequest(); Toast.MakeText(Context, "Your request was sent.", ToastLength.Short).Show(); helpRequestHolder.Visibility = ViewStates.Gone; requestSentHolder.Visibility = ViewStates.Visible; }; return(view); }
void Refresher_Refresh(object sender, EventArgs e) { ViewModel.LoadQuestionDetailCommand.Execute(null); recyclerView.SetAdapter(adapter = new BrowseAnswerAdapter(Activity, ViewModel, FragmentManager)); refresher.Refreshing = false; var count = ViewModel.Answers.Count; if (count == 0) { answerCount.Text = "NO RESPONSE YET"; } else if (count == 1) { answerCount.Text = count + " RESPONSE"; } else { answerCount.Text = count + " RESPONSES"; } }