2012-06-30 Santiago Munín <burning1@gmail.com>

* 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).


git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@6726 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
santimunin 2012-06-29 23:10:25 +00:00
parent c5d1412395
commit 3d8608f154
3 changed files with 29 additions and 8 deletions

View File

@ -1,3 +1,7 @@
2012-06-30 Santiago Munín <burning1@gmail.com>
* 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 <burning1@gmail.com>
* 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

View File

@ -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<String> list, String string) {
Iterator<String> it = list.iterator();
while (it.hasNext()) {
if (it.next().equalsIgnoreCase(string))
return true;
}
return false;
}
}

View File

@ -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,