X-Git-Url: https://git.ktnx.net/?p=mobile-ledger.git;a=blobdiff_plain;f=app%2Fsrc%2Fmain%2Fjava%2Fnet%2Fktnx%2Fmobileledger%2Futils%2FMLDB.java;h=5741a2e6fb45bf8357b7a8b07d66df3685ba1b62;hp=e769be4e8de61ae08491e5e69d42ee7c60a7495f;hb=aff298c5d65b279b40884cf8273bd4eeb054adaa;hpb=a32a16adfb536c1729f2761e7287a7ca6636d4fd diff --git a/app/src/main/java/net/ktnx/mobileledger/utils/MLDB.java b/app/src/main/java/net/ktnx/mobileledger/utils/MLDB.java index e769be4e..5741a2e6 100644 --- a/app/src/main/java/net/ktnx/mobileledger/utils/MLDB.java +++ b/app/src/main/java/net/ktnx/mobileledger/utils/MLDB.java @@ -136,10 +136,8 @@ public final class MLDB { @TargetApi(Build.VERSION_CODES.N) public static void hookAutocompletionAdapter(final Context context, final AutoCompleteTextView view, - final String table, final String field, - final boolean profileSpecific) { - hookAutocompletionAdapter(context, view, table, field, profileSpecific, null, null, - Data.profile.getValue()); + final String table, final String field) { + hookAutocompletionAdapter(context, view, table, field, true, null, null, null); } @TargetApi(Build.VERSION_CODES.N) public static void hookAutocompletionAdapter(final Context context, @@ -166,13 +164,15 @@ public final class MLDB { String sql; String[] params; if (profileSpecific) { + MobileLedgerProfile p = (profile == null) ? Data.profile.getValue() : profile; + if (p == null) throw new AssertionError(); sql = String.format("SELECT %s as a, case when %s_upper LIKE ?||'%%' then 1 " + "WHEN %s_upper LIKE '%%:'||?||'%%' then 2 " + "WHEN %s_upper LIKE '%% '||?||'%%' then 3 else 9 end " + "FROM %s " + "WHERE profile=? AND %s_upper LIKE '%%'||?||'%%' " + "ORDER BY 2, 1;", field, field, field, field, table, field); - params = new String[]{str, str, str, profile.getUuid(), str}; + params = new String[]{str, str, str, p.getUuid(), str}; } else { sql = String.format("SELECT %s as a, case when %s_upper LIKE ?||'%%' then 1 " +