Created
July 29, 2017 21:31
-
-
Save izmajlowiczl/70ae740436de124ee027e2599add5533 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// From Plaid app [DesignerNewsLogin.class] | |
private void setupAccountAutocomplete() { | |
if (ContextCompat.checkSelfPermission(this, Manifest.permission.GET_ACCOUNTS) == | |
PackageManager.PERMISSION_GRANTED) { | |
permissionPrimer.setVisibility(View.GONE); | |
final Account[] accounts = AccountManager.get(this).getAccounts(); | |
final Set<String> emailSet = new HashSet<>(); | |
for (Account account : accounts) { | |
if (Patterns.EMAIL_ADDRESS.matcher(account.name).matches()) { | |
emailSet.add(account.name); | |
} | |
} | |
username.setAdapter(new ArrayAdapter<>(this, | |
R.layout.account_dropdown_item, new ArrayList<>(emailSet))); | |
} else { | |
if (shouldShowRequestPermissionRationale(Manifest.permission.GET_ACCOUNTS)) { | |
setupPermissionPrimer(); | |
} else { | |
permissionPrimer.setVisibility(View.GONE); | |
shouldPromptForPermission = true; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment