Skip to content
Browse files

Modified the compare method on DeckPicker to not use parseFloat, for …

…more safety.
  • Loading branch information...
1 parent 29326b8 commit 28e7d986f90e47d997360b6303694de911f04560 @edu-zamora edu-zamora committed Jan 7, 2010
Showing with 10 additions and 10 deletions.
  1. +1 −1 AndroidManifest.xml
  2. +9 −9 src/com/ichi2/anki/DeckPicker.java
View
2 AndroidManifest.xml
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.ichi2.anki"
- android:versionName="0.3" android:versionCode="7">
+ android:versionName="0.3" android:versionCode="8">
<application android:label="@string/app_name" android:icon="@drawable/anki" android:debuggable="false">
<activity android:name=".Ankidroid" android:label="@string/app_name" android:theme="@android:style/Theme.NoTitleBar" android:configChanges="orientation"
>
View
18 src/com/ichi2/anki/DeckPicker.java
@@ -233,15 +233,15 @@ public boolean accept(File pathname)
private static final class HashMapCompare implements Comparator<HashMap<String, String>>
{
- public int compare(HashMap<String, String> object1, HashMap<String, String> object2)
- {
- //Order by last modification date (last deck modified first)
- if((Float.parseFloat(object2.get("mod")) - Float.parseFloat(object1.get("mod"))) != 0)
- return (int) (Float.parseFloat(object2.get("mod")) - Float.parseFloat(object1.get("mod")));
- //But if there are two decks with the same date of modification, order them in alphabetical order
- else
- return object1.get("filepath").compareToIgnoreCase(object2.get("filepath"));
- }
+ public int compare(HashMap<String, String> object1, HashMap<String, String> object2)
+ {
+ //Order by last modification date (last deck modified first)
+ if(object2.get("mod").compareToIgnoreCase(object1.get("mod")) != 0)
+ return object2.get("mod").compareToIgnoreCase(object1.get("mod"));
+ //But if there are two decks with the same date of modification, order them in alphabetical order
+ else
+ return object1.get("filepath").compareToIgnoreCase(object2.get("filepath"));
+ }
}
private void handleDeckSelection(int id)

0 comments on commit 28e7d98

Please sign in to comment.
Something went wrong with that request. Please try again.