From: Damyan Ivanov Date: Fri, 23 Apr 2021 20:21:39 +0000 (+0300) Subject: use a constant to indicate profile ID of no real profile X-Git-Tag: v0.18.0~36 X-Git-Url: https://git.ktnx.net/?a=commitdiff_plain;h=f5b6aa7aeb3b0af5c54e3395cb33b40e9e5b644b;p=mobile-ledger.git use a constant to indicate profile ID of no real profile --- 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();