From f5b6aa7aeb3b0af5c54e3395cb33b40e9e5b644b Mon Sep 17 00:00:00 2001 From: Damyan Ivanov Date: Fri, 23 Apr 2021 23:21:39 +0300 Subject: [PATCH] use a constant to indicate profile ID of no real profile --- .../db/AccountAutocompleteAdapter.java | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/net/ktnx/mobileledger/db/AccountAutocompleteAdapter.java b/app/src/main/java/net/ktnx/mobileledger/db/AccountAutocompleteAdapter.java index 9b6d41ba..76673edf 100644 --- a/app/src/main/java/net/ktnx/mobileledger/db/AccountAutocompleteAdapter.java +++ b/app/src/main/java/net/ktnx/mobileledger/db/AccountAutocompleteAdapter.java @@ -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 { 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 { } Logger.debug("acc", String.format("Looking for account '%s'", constraint)); - final List matches = AccountDAO.unbox((profileId == 0) ? dao.lookupByNameSync( - String.valueOf(constraint) - .toUpperCase()) : dao.lookupInProfileByNameSync(profileId, - String.valueOf(constraint) - .toUpperCase())); + final List 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(); -- 2.39.5