]> git.ktnx.net Git - mobile-ledger.git/commitdiff
use a constant to indicate profile ID of no real profile
authorDamyan Ivanov <dam+mobileledger@ktnx.net>
Fri, 23 Apr 2021 20:21:39 +0000 (23:21 +0300)
committerDamyan Ivanov <dam+mobileledger@ktnx.net>
Sun, 25 Apr 2021 17:07:58 +0000 (17:07 +0000)
app/src/main/java/net/ktnx/mobileledger/db/AccountAutocompleteAdapter.java

index 9b6d41ba9505ccc413e0c9f4982289333ef34fd9..76673edfb7f6667c082d52843a99a482c6142f3b 100644 (file)
@@ -29,11 +29,13 @@ import net.ktnx.mobileledger.utils.Logger;
 import java.util.ArrayList;
 import java.util.List;
 
+import static net.ktnx.mobileledger.db.Profile.NO_PROFILE_ID;
+
 public class AccountAutocompleteAdapter extends ArrayAdapter<String> {
     private final AccountFilter filter = new AccountFilter();
     private final AccountDAO dao = DB.get()
                                      .getAccountDAO();
-    private long profileId;
+    private long profileId = NO_PROFILE_ID;
     public AccountAutocompleteAdapter(Context context) {
         super(context, android.R.layout.simple_dropdown_item_1line, new ArrayList<>());
     }
@@ -72,11 +74,12 @@ public class AccountAutocompleteAdapter extends ArrayAdapter<String> {
             }
 
             Logger.debug("acc", String.format("Looking for account '%s'", constraint));
-            final List<String> matches = AccountDAO.unbox((profileId == 0) ? dao.lookupByNameSync(
-                    String.valueOf(constraint)
-                          .toUpperCase()) : dao.lookupInProfileByNameSync(profileId,
-                    String.valueOf(constraint)
-                          .toUpperCase()));
+            final List<String> matches = AccountDAO.unbox(
+                    (profileId == NO_PROFILE_ID) ? dao.lookupByNameSync(String.valueOf(constraint)
+                                                                              .toUpperCase())
+                                                 : dao.lookupInProfileByNameSync(profileId,
+                                                         String.valueOf(constraint)
+                                                               .toUpperCase()));
             results.values = matches;
             results.count = matches.size();