package com.rehivetech.beeeon;

import android.text.TextUtils;

import java.util.Comparator;

public class IdentifierComparator implements Comparator<IIdentifier> {

	@Override
	public int compare(IIdentifier lhs, IIdentifier rhs) {
		return compareNumericIds(lhs, rhs);
	}

	public static int compareNumericIds(IIdentifier lhs, IIdentifier rhs) {
		String lhsId = lhs.getId();
		String rhsId = rhs.getId();

		if (TextUtils.isDigitsOnly(lhsId) && TextUtils.isDigitsOnly(rhsId)) {
			// Numeric comparison
			return Integer.valueOf(lhsId).compareTo(Integer.valueOf(rhsId));
		} else {
			// String comparison
			return lhsId.compareTo(rhsId);
		}
	}

}

@@ -509,23 +509,20 @@
 %09return 
-Integer
+Long
 .valueOf
@@ -543,15 +543,12 @@
 eTo(
-Integer
+Long
 .val

Fix overflow of device ids