Skip to content

Commit

Permalink
Merge pull request #27 from sematext/issue_26_arabic_number
Browse files Browse the repository at this point in the history
Fix for the issues with numbers for different Locale
  • Loading branch information
Rafał Kuć authored Aug 18, 2020
2 parents 847f77f + d4f612f commit 6d583cf
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 5 deletions.
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ android {
minSdkVersion 19
targetSdkVersion 28
versionCode 1
versionName "2.4.0"
versionName "2.4.1"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
Expand Down
2 changes: 1 addition & 1 deletion logseneandroid/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ android {
minSdkVersion 19
targetSdkVersion 28
versionCode 4
versionName "2.4.0"
versionName "2.4.1"

testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import java.util.concurrent.ConcurrentHashMap;

/**
Expand Down Expand Up @@ -142,9 +143,13 @@ public List<JSONObject> peek(int max) {
* @param n amount of elements to remove.
*/
public void remove(int n) {
// On android sqlite deletes with limit and order keywords are disabled so we have to workaround it
db.execSQL(String.format("DELETE FROM %s WHERE `id` IN (SELECT `id` FROM %s ORDER BY `id` ASC limit %d);",
TABLE_NAME, TABLE_NAME, n));
// On android sqlite deletes with limit and order keywords are disabled so we have to workaround it.
// In addition to that we need to remember about the Locale here - see:
// https://github.com/sematext/sematext-logsene-android/issues/26.
String deleteQuery = String.format(Utils.DEFAULT_LOCALE,
"DELETE FROM %s WHERE `id` IN (SELECT `id` FROM %s ORDER BY `id` ASC limit %d);",
TABLE_NAME, TABLE_NAME, n);
db.execSQL(deleteQuery);
SQLiteStatement stmt = db.compileStatement("SELECT CHANGES()");
long result = stmt.simpleQueryForLong();
if (sizeCache.get(ObjectDbHelper.DATABASE_NAME) != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,22 @@
import java.io.StringWriter;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;
import java.util.TimeZone;

public enum Utils {
INSTANCE, Utils;

private static final SimpleDateFormat ISO8601_FORMAT;

static {
TimeZone tz = TimeZone.getTimeZone("UTC");
ISO8601_FORMAT = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SZ");
ISO8601_FORMAT.setTimeZone(tz);
}

public static final Locale DEFAULT_LOCALE = new Locale("en", "US");

public static String iso8601() {
return ISO8601_FORMAT.format(new Date());
}
Expand Down

0 comments on commit 6d583cf

Please sign in to comment.