private void LoadDataPost() { try { if (CommentObject != null) { var repliesCount = !string.IsNullOrEmpty(CommentObject.RepliesCount) ? CommentObject.RepliesCount : CommentObject.Replies ?? ""; ReplyCountTextView.Text = repliesCount + " " + GetString(Resource.String.Lbl_Replies); CommentLayout.LayoutResource = string.IsNullOrEmpty(CommentObject.CFile) ? Resource.Layout.Style_Comment : Resource.Layout.Style_Comment_Image; } CommentLayoutView = CommentLayout.Inflate(); var holder = new CommentAdapterViewHolder(CommentLayoutView, MAdapter, new CommentClickListener(this, "Reply"), CommentObject) { ReplyTextView = { Visibility = ViewStates.Gone } }; //Load data same as comment adapter var commentAdapter = new CommentAdapter(this); commentAdapter.LoadCommentData(CommentObject, holder); StartApiService(); } catch (Exception e) { Methods.DisplayReportResultTrack(e); } }
private void DestroyBasic() { try { Instance = null; MAdapter = null; SwipeRefreshLayout = null; MRecycler = null; TxtComment = null; LikeCountBox = null; ImgSent = null; ImgGallery = null; ImgBack = null; BtnVoice = null; PostObject = null; PostId = null; PathImage = null; PathVoice = null; TextRecorder = null; TopFragment = null; RecordSoundFragment = null; RecorderService = null; CommentLayout = null; } catch (Exception e) { Console.WriteLine(e); } }
public override void OnViewCreated(View view, Bundle savedInstanceState) { if (IsInitialized) { return; } base.OnViewCreated(view, savedInstanceState); _cancel.Text = AppSettings.LocalizationManager.GetText(LocalizationKeys.Cancel); _save.Text = AppSettings.LocalizationManager.GetText(LocalizationKeys.Save); _textInput.Hint = AppSettings.LocalizationManager.GetText(LocalizationKeys.PutYourComment); _viewTitle.Text = AppSettings.LocalizationManager.GetText(LocalizationKeys.Comments); _textInputShape = new GradientDrawable(); _textInputShape.SetCornerRadius(BitmapUtils.DpToPixel(20, Resources)); _textInputShape.SetColor(Color.White); _textInputShape.SetStroke((int)BitmapUtils.DpToPixel(1, Resources), Style.R244G244B246); _textInput.Background = _textInputShape; _textInput.TextChanged += TextInputOnTextChanged; _cancel.Typeface = Style.Semibold; _save.Typeface = Style.Semibold; _textInput.Typeface = Style.Regular; _viewTitle.Typeface = Style.Semibold; _backButton.Visibility = ViewStates.Visible; _backButton.Click += OnBack; _switcher.Visibility = ViewStates.Gone; _settings.Visibility = ViewStates.Gone; _postBtn.Click += OnPost; _rootLayout.Click += OnRootClick; _manager = new LinearLayoutManager(Context, LinearLayoutManager.Vertical, false); Presenter.SourceChanged += PresenterSourceChanged; _adapter = new CommentAdapter(Context, Presenter, _post); _adapter.CommentAction += CommentAction; _adapter.RootClickAction += HideKeyboard; _adapter.AutoLinkAction += AutoLinkAction; _comments.SetLayoutManager(_manager); _comments.SetAdapter(_adapter); _comments.Visibility = ViewStates.Visible; if (!AppSettings.User.IsAuthenticated) { _messagePanel.Visibility = ViewStates.Gone; } _cancel.Click += CommentEditCancelBtnOnClick; _save.Click += SaveOnClick; LoadComments(_post); if (_openKeyboard) { _openKeyboard = false; OpenKeyboard(); } }
private void SetRecyclerViewAdapters() { try { EmptyStateLayout = FindViewById <ViewStub>(Resource.Id.viewStub); MainRecyclerView = FindViewById <WRecyclerView>(Resource.Id.Recyler); MAdapter = new NativePostAdapter(this, "", MainRecyclerView, NativeFeedType.Global, SupportFragmentManager); SwipeRefreshLayout = FindViewById <SwipeRefreshLayout>(Resource.Id.swipeRefreshLayout); SwipeRefreshLayout.SetColorSchemeResources(Android.Resource.Color.HoloBlueLight, Android.Resource.Color.HoloGreenLight, Android.Resource.Color.HoloOrangeLight, Android.Resource.Color.HoloRedLight); SwipeRefreshLayout.Refreshing = true; SwipeRefreshLayout.Enabled = true; SwipeRefreshLayout.SetProgressBackgroundColorSchemeColor(AppSettings.SetTabDarkTheme ? Color.ParseColor("#424242") : Color.ParseColor("#f7f7f7")); MainRecyclerView.SetXAdapter(MAdapter, SwipeRefreshLayout); CommentsRecyclerView = FindViewById <RecyclerView>(Resource.Id.recycler_view); CommentsRecyclerView.NestedScrollingEnabled = false; CommentAdapter = new CommentAdapter(this) { CommentList = new ObservableCollection <CommentObjectExtra>() }; } catch (Exception e) { Console.WriteLine(e); } }
private void SetRecyclerViewAdapters() { try { MainRecyclerView = FindViewById <WRecyclerView>(Resource.Id.Recyler); NativeFeedAdapter = new NativePostAdapter(this, "", MainRecyclerView, NativeFeedType.Global); MainRecyclerView.SetXAdapter(NativeFeedAdapter, SwipeRefreshLayout); MAdapter = new CommentAdapter(this) { CommentList = new ObservableCollection <CommentObjectExtra>() }; LayoutManager = new LinearLayoutManager(this); MRecycler.SetLayoutManager(LayoutManager); MRecycler.HasFixedSize = true; MRecycler.SetItemViewCacheSize(10); MRecycler.GetLayoutManager().ItemPrefetchEnabled = true; var sizeProvider = new FixedPreloadSizeProvider(10, 10); var preLoader = new RecyclerViewPreloader <CommentObjectExtra>(this, 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) { Methods.DisplayReportResultTrack(e); } }
private void LoadDataPost() { try { if (CommentObject != null) { ReplyCountTextView.Text = CommentObject.Replies + " " + GetString(Resource.String.Lbl_Replies); CommentLayout.LayoutResource = string.IsNullOrEmpty(CommentObject.CFile) ? Resource.Layout.Style_Comment : Resource.Layout.Style_Comment_Image; } CommentLayoutView = CommentLayout.Inflate(); var holder = new CommentAdapterViewHolder(CommentLayoutView, MAdapter, new CommentClickListener(this, "Reply")) { ReplyTextView = { Visibility = ViewStates.Gone } }; //Load data same as comment adapter var commentAdapter = new CommentAdapter(this); commentAdapter.LoadCommentData(CommentObject, holder); StartApiService(); } catch (Exception e) { Console.WriteLine(e); } }
private void DestroyBasic() { try { Instance = null !; MAdapter = null !; SwipeRefreshLayout = null !; MRecycler = null !; TxtComment = null !; LikeCountBox = null !; ImgSent = null !; ImgGallery = null !; ImgBack = null !; BtnVoice = null !; PostObject = null !; PostId = null !; PathImage = null !; PathVoice = null !; TextRecorder = null !; TopFragment = null !; RecordSoundFragment = null !; RecorderService = null !; CommentLayout = null !; } catch (Exception e) { Methods.DisplayReportResultTrack(e); } }
private void SetRecyclerViewAdapters() { try { MAdapter = new CommentAdapter(this) { CommentList = new ObservableCollection <CommentObjectExtra>() }; LayoutManager = new LinearLayoutManager(this); MRecycler.SetLayoutManager(LayoutManager); MRecycler.HasFixedSize = true; MRecycler.SetItemViewCacheSize(10); MRecycler.GetLayoutManager().ItemPrefetchEnabled = true; var sizeProvider = new FixedPreloadSizeProvider(10, 10); var preLoader = new RecyclerViewPreloader <CommentObjectExtra>(this, 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); } }
private void SetRecyclerViewAdapters() { try { MainRecyclerView = FindViewById <RecyclerView>(Resource.Id.recycler_view); MAdapter = new CommentAdapter(this); } catch (Exception e) { Console.WriteLine(e); } }
private void SetRecyclerViewAdapters() { try { MainRecyclerView = FindViewById <RecyclerView>(Resource.Id.recycler_view); MAdapter = new CommentAdapter(this); } catch (Exception e) { Methods.DisplayReportResultTrack(e); } }
public override void OnViewCreated(View view, Bundle savedInstanceState) { if (IsInitialized) { return; } base.OnViewCreated(view, savedInstanceState); _commentEditMessage.Text = AppSettings.LocalizationManager.GetText(LocalizationKeys.EditComment); _textInput.Hint = AppSettings.LocalizationManager.GetText(LocalizationKeys.PutYourComment); _viewTitle.Text = AppSettings.LocalizationManager.GetText(LocalizationKeys.Comments); _commentEditMessage.Typeface = Style.Semibold; _commentEditText.Typeface = Style.Regular; _textInput.Typeface = Style.Regular; _viewTitle.Typeface = Style.Semibold; _backButton.Visibility = ViewStates.Visible; _backButton.Click += OnBack; _switcher.Visibility = ViewStates.Gone; _settings.Visibility = ViewStates.Gone; _postBtn.Click += OnPost; _rootLayout.Click += OnRootClick; _manager = new LinearLayoutManager(Context, LinearLayoutManager.Vertical, false); Presenter.SourceChanged += PresenterSourceChanged; _adapter = new CommentAdapter(Context, Presenter, _post); _adapter.CommentAction += CommentAction; _adapter.RootClickAction += HideKeyboard; _adapter.TagAction += TagAction; _comments.SetLayoutManager(_manager); _comments.SetAdapter(_adapter); _comments.Visibility = ViewStates.Visible; if (!AppSettings.User.IsAuthenticated) { _messagePanel.Visibility = ViewStates.Gone; } _commentEditCancelBtn.Click += CommentEditCancelBtnOnClick; LoadComments(_post); if (_openKeyboard) { _openKeyboard = false; OpenKeyboard(); } }
protected override void Dispose(bool disposing) { if (this.disposed) { return; } if (!disposing) { return; } this.adapter?.Dispose(); this.adapter = null; base.Dispose(true); }
private void InitComponent() { try { LikeCountBox = FindViewById <TextView>(Resource.Id.like_box); MainRecyclerView = FindViewById <RecyclerView>(Resource.Id.recycler_view); TxtComment = FindViewById <EditText>(Resource.Id.commenttext); ImgSent = FindViewById <ImageView>(Resource.Id.send); ImgGallery = FindViewById <ImageView>(Resource.Id.image); ImgBack = FindViewById <ImageView>(Resource.Id.back); CommentLayout = FindViewById <LinearLayout>(Resource.Id.commentLayout); SwipeRefreshLayout = (SwipeRefreshLayout)FindViewById(Resource.Id.swipeRefreshLayout); SwipeRefreshLayout.SetColorSchemeResources(Android.Resource.Color.HoloBlueLight, Android.Resource.Color.HoloGreenLight, Android.Resource.Color.HoloOrangeLight, Android.Resource.Color.HoloRedLight); SwipeRefreshLayout.Refreshing = true; SwipeRefreshLayout.Enabled = true; SwipeRefreshLayout.SetProgressBackgroundColorSchemeColor(AppSettings.SetTabDarkTheme ? Color.ParseColor("#424242") : Color.ParseColor("#f7f7f7")); BtnVoice = FindViewById <CircleButton>(Resource.Id.voiceButton); BtnVoice.LongClickable = true; BtnVoice.Tag = "Free"; BtnVoice.SetImageResource(Resource.Drawable.microphone); TopFragment = FindViewById <FrameLayout>(Resource.Id.TopFragmentHolder); TxtComment.Text = ""; PathImage = ""; TextRecorder = ""; RecordSoundFragment = new RecordSoundFragment(); SupportFragmentManager.BeginTransaction().Add(TopFragment.Id, RecordSoundFragment, RecordSoundFragment.Tag); CommentsAdapter = new CommentAdapter(this, MainRecyclerView, "Light", PostId) { CommentList = new ObservableCollection <CommentObjectExtra>() }; if (AppSettings.FlowDirectionRightToLeft) { ImgBack.SetImageResource(Resource.Drawable.ic_action_ic_back_rtl); } ImgGallery.SetImageDrawable(AppSettings.SetTabDarkTheme ? GetDrawable(Resource.Drawable.ic_action_addpost_Ligth) : GetDrawable(Resource.Drawable.ic_action_AddPost)); } catch (Exception e) { Console.WriteLine(e); } }
public override void OnViewCreated(View view, Bundle savedInstanceState) { if (IsInitialized) { return; } base.OnViewCreated(view, savedInstanceState); _textInput.Typeface = Style.Regular; _viewTitle.Typeface = Style.Semibold; _backButton.Visibility = ViewStates.Visible; _backButton.Click += OnBack; _switcher.Visibility = ViewStates.Gone; _settings.Visibility = ViewStates.Gone; _viewTitle.Text = Localization.Messages.Comments; _postBtn.Click += OnPost; _rootLayout.Click += OnRootClick; _manager = new LinearLayoutManager(Context, LinearLayoutManager.Vertical, false); Presenter.SourceChanged += PresenterSourceChanged; _adapter = new CommentAdapter(Context, Presenter, _post); _adapter.LikeAction += LikeAction; _adapter.UserAction += UserAction; _adapter.VotersClick += VotersAction; _adapter.FlagAction += FlagAction; _adapter.HideAction += HideAction; _adapter.ReplyAction += ReplyAction; _adapter.DeleteAction += DeleteAction; _adapter.RootClickAction += HideKeyboard; _adapter.TagAction += TagAction; _comments.SetLayoutManager(_manager); _comments.SetAdapter(_adapter); _comments.Visibility = ViewStates.Visible; if (!BasePresenter.User.IsAuthenticated) { _messagePanel.Visibility = ViewStates.Gone; } LoadComments(_uid); if (_openKeyboard) { _openKeyboard = false; OpenKeyboard(); } }
private void SetRecyclerViewAdapters() { try { CommentsRecyclerView = FindViewById <RecyclerView>(Resource.Id.recycler_view); CommentsRecyclerView.NestedScrollingEnabled = false; CommentsAdapter = new CommentAdapter(this, CommentsRecyclerView, "Light", PostId) { CommentList = new ObservableCollection <CommentObjectExtra>() }; StartApiService(); } catch (Exception e) { Console.WriteLine(e); } }
private void SetRecyclerViewAdapters() { try { CommentsRecyclerView = FindViewById <RecyclerView>(Resource.Id.recycler_view); CommentsRecyclerView.NestedScrollingEnabled = false; MAdapter = new CommentAdapter(this) { CommentList = new ObservableCollection <CommentObjectExtra>() }; StartApiService(); } catch (Exception e) { Methods.DisplayReportResultTrack(e); } }
public CommentRepository(IProgressConnection connection) { this.adapter = new CommentAdapter(connection); this.Cono = this.adapter.Cono; this.OnCreated(); }
/// <summary> /// This method is called when the activity is starting. /// All of the recipe info is shown here. /// </summary> /// <param name="savedInstanceState"> a Bundle that contains the data the activity most recently /// supplied if the activity is being re-initialized after previously being shut down. </param> protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.Recipe); var recipe = Intent.GetStringExtra("Recipe"); _recipe = JsonConvert.DeserializeObject <Recipe>(recipe); _loggedId = Intent.GetStringExtra("LoggedId"); // setting all the fields to axml file identities authorButton = FindViewById <Button>(Resource.Id.authorButton); rateButton = FindViewById <Button>(Resource.Id.rateButton); commentButton = FindViewById <Button>(Resource.Id.commentButton); shareButton = FindViewById <Button>(Resource.Id.shareButton); _recipePic = FindViewById <ImageView>(Resource.Id.recipePicture); recipeNameText = FindViewById <TextView>(Resource.Id.recipeNameText); authorText = FindViewById <TextView>(Resource.Id.authorText); dateText = FindViewById <TextView>(Resource.Id.dateText); dishTypeText = FindViewById <TextView>(Resource.Id.dishTypeText); dishTimeText = FindViewById <TextView>(Resource.Id.dishTimeText); portionsText = FindViewById <TextView>(Resource.Id.portionsText); durationText = FindViewById <TextView>(Resource.Id.durationText); difficultyText = FindViewById <TextView>(Resource.Id.difficultyText); dishTagsText = FindViewById <TextView>(Resource.Id.dishTagsText); priceText = FindViewById <TextView>(Resource.Id.priceText); scoreText = FindViewById <TextView>(Resource.Id.scoreText); scoreTimes = FindViewById <TextView>(Resource.Id.sTimesText); commentsText = FindViewById <TextView>(Resource.Id.commentsText); ingredientListView = FindViewById <ListView>(Resource.Id.ingredientListView); instructionsListView = FindViewById <ListView>(Resource.Id.instructionsListView); dishTagsListView = FindViewById <ListView>(Resource.Id.dishTagsListView); commentsListView = FindViewById <ListView>(Resource.Id.commentsListView); // Setting all the text values to the recipe attribute recipeNameText.Text = _recipe.name; authorText.Text = "Author: " + _recipe.authorName; dateText.Text = "Date posted: " + _recipe.postTimeString; dishTypeText.Text = "Dish type: " + _recipe.dishType; dishTimeText.Text = "Dish Time: " + _recipe.dishTime; portionsText.Text = "Portions: " + _recipe.portions; durationText.Text = "Duration: " + _recipe.duration + " minutes"; difficultyText.Text = "Difficulty: " + _recipe.difficulty; dishTagsText.Text = _recipe.dishTags.Count == 0 ? "Dish tags: none" : "Dish tags:"; priceText.Text = "Price: $" + _recipe.price; scoreText.Text = "Score: " + _recipe.score; scoreTimes.Text = "Number of Ratings: " + _recipe.scoreTimes; commentsText.Text = _recipe.comments.Count == 0 ? "Comments: none" : "Comments:"; if (!string.IsNullOrEmpty(_recipe.photo)) { picUrl = $"http://{MainActivity.Ipv4}:8080/CookTime_war/cookAPI/resources/getPicture?id={_recipe.photo}"; Bitmap bitmap = GetImageBitmapFromUrl(picUrl); _recipePic.SetImageBitmap(bitmap); } var adapter1 = new IngredientAdapter(this, _recipe.ingredientsList); ingredientListView.Adapter = adapter1; var adapter2 = new CompAdapter(this, _recipe.instructions); instructionsListView.Adapter = adapter2; var adapter3 = new CompAdapter(this, _recipe.dishTags); dishTagsListView.Adapter = adapter3; var adapter4 = new CommentAdapter(this, _recipe.comments); commentsListView.Adapter = adapter4; _recipePic.Click += (sender, args) => { if (!string.IsNullOrEmpty(_recipe.photo)) { var transaction = SupportFragmentManager.BeginTransaction(); var dialogPShow = new DialogPShow(); dialogPShow.Url = picUrl; dialogPShow.TypeText = "Recipe photo"; dialogPShow.Show(transaction, "recipe"); } }; shareButton.Click += (sender, args) => { using var webClient = new WebClient { BaseAddress = "http://" + MainActivity.Ipv4 + ":8080/CookTime_war/cookAPI/" }; var url = "resources/shareRecipe?id=" + _recipe.id + "&email=" + _loggedId; webClient.Headers[HttpRequestHeader.ContentType] = "application/json"; var send = webClient.DownloadString(url); string toastText; if (send == "0") { toastText = "You've already shared this recipe."; } else { toastText = "Recipe shared! Redirecting to MyProfile..."; url = "resources/getUser?id=" + _loggedId; webClient.Headers[HttpRequestHeader.ContentType] = "application/json"; var userJson = webClient.DownloadString(url); var intent = new Intent(this, typeof(MyProfileActivity)); intent.PutExtra("User", userJson); intent.SetFlags(ActivityFlags.NewTask | ActivityFlags.ClearTask); StartActivity(intent); OverridePendingTransition(Android.Resource.Animation.SlideInLeft, Android.Resource.Animation.SlideOutRight); } var toast = Toast.MakeText(this, toastText, ToastLength.Short); toast.Show(); }; commentButton.Click += (sender, args) => { //Brings dialog fragment forward var transaction = SupportFragmentManager.BeginTransaction(); var dialogComm = new DialogComment(); dialogComm.Show(transaction, "rate"); dialogComm.LoggedId = _loggedId; dialogComm.RecipeId = _recipe.id; dialogComm.EventHandlerComm += CommResult; }; rateButton.Click += (sender, args) => { //Brings dialog fragment forward var transaction = SupportFragmentManager.BeginTransaction(); var dialogRate = new DialogRate(); dialogRate.Show(transaction, "rate"); dialogRate.LoggedId = _loggedId; dialogRate.RecipeId = _recipe.id; dialogRate.Type = 0; dialogRate.EventHandlerRate += RateResult; }; authorButton.Click += (sender, args) => { Intent intent; using var webClient = new WebClient { BaseAddress = "http://" + MainActivity.Ipv4 + ":8080/CookTime_war/cookAPI/" }; string url; string send; if (_recipe.businessId == 0) { url = "resources/getUser?id=" + _recipe.authorEmail; webClient.Headers[HttpRequestHeader.ContentType] = "application/json"; send = webClient.DownloadString(url); if (_recipe.authorEmail == _loggedId) { intent = new Intent(this, typeof(MyProfileActivity)); intent.PutExtra("User", send); StartActivity(intent); OverridePendingTransition(Android.Resource.Animation.SlideInLeft, Android.Resource.Animation.SlideOutRight); } else { intent = new Intent(this, typeof(PrivProfileActivity)); intent.PutExtra("User", send); intent.PutExtra("LoggedId", _loggedId); StartActivity(intent); OverridePendingTransition(Android.Resource.Animation.SlideInLeft, Android.Resource.Animation.SlideOutRight); } } else { url = "resources/getBusiness?id=" + _recipe.businessId; webClient.Headers[HttpRequestHeader.ContentType] = "application/json"; send = webClient.DownloadString(url); url = "resources/isEmployee?email=" + _loggedId + "&id=" + _recipe.businessId; webClient.Headers[HttpRequestHeader.ContentType] = "application/json"; var result = webClient.DownloadString(url); if (result == "1") { intent = new Intent(this, typeof(MyBusiness)); intent.PutExtra("Bsns", send); intent.PutExtra("LoggedId", _loggedId); StartActivity(intent); OverridePendingTransition(Android.Resource.Animation.SlideInLeft, Android.Resource.Animation.SlideOutRight); } else { intent = new Intent(this, typeof(PrivateBusiness)); intent.PutExtra("Bsns", send); intent.PutExtra("LoggedId", _loggedId); StartActivity(intent); OverridePendingTransition(Android.Resource.Animation.SlideInLeft, Android.Resource.Animation.SlideOutRight); } } }; }