projects
/
pub
/
Android
/
ownCloud.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
fix #1110: accents not sorted
[pub/Android/ownCloud.git]
/
src
/
third_parties
/
daveKoeller
/
AlphanumComparator.java
diff --git
a/src/third_parties/daveKoeller/AlphanumComparator.java
b/src/third_parties/daveKoeller/AlphanumComparator.java
index
e6bd6f3
..
e86c3c4
100644
(file)
--- a/
src/third_parties/daveKoeller/AlphanumComparator.java
+++ b/
src/third_parties/daveKoeller/AlphanumComparator.java
@@
-23,6
+23,7
@@
*/
\r
\r
package third_parties.daveKoeller;
\r
*/
\r
\r
package third_parties.daveKoeller;
\r
+import java.text.Collator;
\r
import java.util.Comparator;
\r
\r
import com.owncloud.android.datamodel.OCFile;
\r
import java.util.Comparator;
\r
\r
import com.owncloud.android.datamodel.OCFile;
\r
@@
-48,14
+49,12
@@
public class AlphanumComparator implements Comparator<OCFile>
}
\r
\r
/** Length of string is passed in for improved efficiency (only need to calculate it once) **/
\r
}
\r
\r
/** Length of string is passed in for improved efficiency (only need to calculate it once) **/
\r
- private final String getChunk(String s, int slength, int marker)
\r
- {
\r
+ private final String getChunk(String s, int slength, int marker){
\r
StringBuilder chunk = new StringBuilder();
\r
char c = s.charAt(marker);
\r
chunk.append(c);
\r
marker++;
\r
StringBuilder chunk = new StringBuilder();
\r
char c = s.charAt(marker);
\r
chunk.append(c);
\r
marker++;
\r
- if (isDigit(c))
\r
- {
\r
+ if (isDigit(c)){
\r
while (marker < slength)
\r
{
\r
c = s.charAt(marker);
\r
while (marker < slength)
\r
{
\r
c = s.charAt(marker);
\r
@@
-64,8
+63,7
@@
public class AlphanumComparator implements Comparator<OCFile>
chunk.append(c);
\r
marker++;
\r
}
\r
chunk.append(c);
\r
marker++;
\r
}
\r
- } else
\r
- {
\r
+ } else {
\r
while (marker < slength)
\r
{
\r
c = s.charAt(marker);
\r
while (marker < slength)
\r
{
\r
c = s.charAt(marker);
\r
@@
-78,8
+76,7
@@
public class AlphanumComparator implements Comparator<OCFile>
return chunk.toString();
\r
}
\r
\r
return chunk.toString();
\r
}
\r
\r
- public int compare(OCFile o1, OCFile o2)
\r
- {
\r
+ public int compare(OCFile o1, OCFile o2){
\r
String s1 = (String)o1.getRemotePath().toLowerCase();
\r
String s2 = (String)o2.getRemotePath().toLowerCase();
\r
\r
String s1 = (String)o1.getRemotePath().toLowerCase();
\r
String s2 = (String)o2.getRemotePath().toLowerCase();
\r
\r
@@
-88,8
+85,7
@@
public class AlphanumComparator implements Comparator<OCFile>
int s1Length = s1.length();
\r
int s2Length = s2.length();
\r
\r
int s1Length = s1.length();
\r
int s2Length = s2.length();
\r
\r
- while (thisMarker < s1Length && thatMarker < s2Length)
\r
- {
\r
+ while (thisMarker < s1Length && thatMarker < s2Length) {
\r
String thisChunk = getChunk(s1, s1Length, thisMarker);
\r
thisMarker += thisChunk.length();
\r
\r
String thisChunk = getChunk(s1, s1Length, thisMarker);
\r
thisMarker += thisChunk.length();
\r
\r
@@
-98,26
+94,24
@@
public class AlphanumComparator implements Comparator<OCFile>
\r
// If both chunks contain numeric characters, sort them numerically
\r
int result = 0;
\r
\r
// If both chunks contain numeric characters, sort them numerically
\r
int result = 0;
\r
- if (isDigit(thisChunk.charAt(0)) && isDigit(thatChunk.charAt(0)))
\r
- {
\r
+ if (isDigit(thisChunk.charAt(0)) && isDigit(thatChunk.charAt(0))) {
\r
// Simple chunk comparison by length.
\r
int thisChunkLength = thisChunk.length();
\r
result = thisChunkLength - thatChunk.length();
\r
// If equal, the first different number counts
\r
// Simple chunk comparison by length.
\r
int thisChunkLength = thisChunk.length();
\r
result = thisChunkLength - thatChunk.length();
\r
// If equal, the first different number counts
\r
- if (result == 0)
\r
- {
\r
- for (int i = 0; i < thisChunkLength; i++)
\r
- {
\r
+ if (result == 0) {
\r
+ for (int i = 0; i < thisChunkLength; i++) {
\r
result = thisChunk.charAt(i) - thatChunk.charAt(i);
\r
result = thisChunk.charAt(i) - thatChunk.charAt(i);
\r
- if (result != 0)
\r
- {
\r
+ if (result != 0) {
\r
return result;
\r
}
\r
}
\r
}
\r
return result;
\r
}
\r
}
\r
}
\r
- } else
\r
- {
\r
- result = thisChunk.compareTo(thatChunk);
\r
+ } else {
\r
+ Collator collator = Collator.getInstance();
\r
+ collator.setStrength(Collator.PRIMARY);
\r
+ result = collator.compare(thisChunk, thatChunk);
\r
+// result = thisChunk.compareTo(thatChunk);
\r
}
\r
\r
if (result != 0)
\r
}
\r
\r
if (result != 0)
\r