From 3d8608f1548b76370c24e90f7316f660fbfb1d47 Mon Sep 17 00:00:00 2001 From: santimunin Date: Fri, 29 Jun 2012 23:10:25 +0000 Subject: [PATCH] =?UTF-8?q?2012-06-30=20Santiago=20Mun=C3=ADn=20=20=09*=20src/pandroid=5Fevent=5Fviewer/pandorafms/Ma?= =?UTF-8?q?in.java:=20Added=20a=20check=20in=20order=20to=20prevent=20prof?= =?UTF-8?q?ile=20overwritings.=20=09*=20src/pandroid=5Fevent=5Fviewer/pand?= =?UTF-8?q?orafms/Core.java:=20Added=20method=20which=20finds=20a=20string?= =?UTF-8?q?=20in=20a=20list=20(case=20insensitive).?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@6726 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- extras/pandroid_event_viewer/ChangeLog | 4 ++++ .../pandroid_event_viewer/pandorafms/Core.java | 18 ++++++++++++++++++ .../pandroid_event_viewer/pandorafms/Main.java | 15 +++++++-------- 3 files changed, 29 insertions(+), 8 deletions(-) diff --git a/extras/pandroid_event_viewer/ChangeLog b/extras/pandroid_event_viewer/ChangeLog index 031d81b880..ebd45d82f1 100644 --- a/extras/pandroid_event_viewer/ChangeLog +++ b/extras/pandroid_event_viewer/ChangeLog @@ -1,3 +1,7 @@ +2012-06-30 Santiago Munín + * src/pandroid_event_viewer/pandorafms/Main.java: Added a check in order to prevent profile overwritings. + * src/pandroid_event_viewer/pandorafms/Core.java: Added method which finds a string in a list (case insensitive). + 2012-06-29 Santiago Munín * src/pandroid_event_viewer/pandorafms/Main.java: Added a little hack to make it compatible with v4.0.2 * res/layout/main.xml: Added a little hack to make it compatible with v4.0.2 diff --git a/extras/pandroid_event_viewer/src/pandroid_event_viewer/pandorafms/Core.java b/extras/pandroid_event_viewer/src/pandroid_event_viewer/pandorafms/Core.java index c8c4c29a54..4b4483551b 100644 --- a/extras/pandroid_event_viewer/src/pandroid_event_viewer/pandorafms/Core.java +++ b/extras/pandroid_event_viewer/src/pandroid_event_viewer/pandorafms/Core.java @@ -31,6 +31,7 @@ import java.security.SecureRandom; import java.util.ArrayList; import java.util.Calendar; import java.util.HashMap; +import java.util.Iterator; import java.util.List; import java.util.Map; @@ -586,6 +587,23 @@ public class Core { Toast.LENGTH_SHORT).show(); } } + } + /** + * Checks if a string is inside the list (case insensitive). + * + * @param list + * List of strings. + * @param string + * Given value. + * @return If the string is inside the list. + */ + public static boolean containsIgnoreCase(List list, String string) { + Iterator it = list.iterator(); + while (it.hasNext()) { + if (it.next().equalsIgnoreCase(string)) + return true; + } + return false; } } diff --git a/extras/pandroid_event_viewer/src/pandroid_event_viewer/pandorafms/Main.java b/extras/pandroid_event_viewer/src/pandroid_event_viewer/pandorafms/Main.java index d204a14205..5d50864a4f 100644 --- a/extras/pandroid_event_viewer/src/pandroid_event_viewer/pandorafms/Main.java +++ b/extras/pandroid_event_viewer/src/pandroid_event_viewer/pandorafms/Main.java @@ -211,14 +211,13 @@ public class Main extends Activity { public void onClick(DialogInterface dialog, int which) { switch (which) { case DialogInterface.BUTTON_POSITIVE: - /* - * if (profiles.contains(profileName.getText() - * .toString())) { Toast.makeText(context, - * R.string.profile_already_exists, - * Toast.LENGTH_SHORT).show(); break; } - */ - // TODO Ask for a confirmation before rewriting the - // profile + if (Core.containsIgnoreCase(profiles, profileName + .getText().toString())) { + Toast.makeText(context, + R.string.profile_already_exists, + Toast.LENGTH_SHORT).show(); + break; + } if (profileName.getText().toString().contains("|")) { Toast.makeText( context,