From 52b4299985e748ce0a9340db51b0bea54109b509 Mon Sep 17 00:00:00 2001 From: osaama05 Date: Tue, 20 Sep 2022 09:33:09 +0300 Subject: [PATCH] Check for only white spaces in name --- TODO-app/TODO-app/MainActivity.cs | 21 +++------------------ 1 file changed, 3 insertions(+), 18 deletions(-) diff --git a/TODO-app/TODO-app/MainActivity.cs b/TODO-app/TODO-app/MainActivity.cs index 368bc10..52e032a 100644 --- a/TODO-app/TODO-app/MainActivity.cs +++ b/TODO-app/TODO-app/MainActivity.cs @@ -340,7 +340,7 @@ private void CloseCreateView(object sender, EventArgs e) DateTime dueDate; if (mainHeader.Visibility == ViewStates.Gone) { - if (IsNull(taskname)) + if (string.IsNullOrWhiteSpace((taskname))) { OpenPopup(GetString(Resource.String.invalidName), GetString(Resource.String.invalidNameDesc), "OK"); return; @@ -355,7 +355,7 @@ private void CloseCreateView(object sender, EventArgs e) } } - if (!IsNull(dayInput.Text) && !IsNull(monthInput.Text) && !IsNull(yearInput.Text)) + if (!string.IsNullOrWhiteSpace(dayInput.Text) && !string.IsNullOrWhiteSpace(monthInput.Text) && !string.IsNullOrWhiteSpace(yearInput.Text)) { try { @@ -1053,22 +1053,7 @@ private void DeleteTaskItem(string name) } - /// - /// Returns true if given string is null or empty - /// - /// - /// - private bool IsNull(string s) - { - if (s == "" || s == null || s == " ") - { - return true; - } - else - { - return false; - } - } + /// /// Checks if the given date is in the given month /// Returns true if the day is in the month