code stringlengths 25 201k | docstring stringlengths 19 96.2k | func_name stringlengths 0 235 | language stringclasses 1 value | repo stringlengths 8 51 | path stringlengths 11 314 | url stringlengths 62 377 | license stringclasses 7 values |
|---|---|---|---|---|---|---|---|
public void testPrepareFailure() throws Exception {
tm.begin();
tm.setTransactionTimeout(10); // TX must not timeout
Connection connection1 = poolingDataSource1.getConnection();
connection1.createStatement();
Connection connection2 = poolingDataSource2.getConnection();
PooledConnectionProxy handle = (PooledConnectionProxy) connection2;
XAConnection xaConnection2 = (XAConnection) AbstractMockJdbcTest.getWrappedXAConnectionOf(handle.getPooledConnection());
connection2.createStatement();
Connection connection3 = poolingDataSource2.getConnection();
connection3.createStatement();
MockXAResource mockXAResource2 = (MockXAResource) xaConnection2.getXAResource();
mockXAResource2.setPrepareException(createXAException("resource 2 prepare failed", XAException.XAER_RMERR));
try {
tm.commit();
fail("TM should have thrown an exception");
} catch (RollbackException ex) {
assertTrue(ex.getMessage().matches("transaction failed to prepare: a Bitronix Transaction with GTRID (.*?) status=ROLLEDBACK, 3 resource\\(s\\) enlisted (.*?)"));
assertTrue(ex.getCause().getMessage().matches("transaction failed during prepare of a Bitronix Transaction with GTRID (.*?), status=PREPARING, 3 resource\\(s\\) enlisted (.*?): resource\\(s\\) \\[pds2\\] threw unexpected exception"));
assertEquals("collected 1 exception(s):" + System.getProperty("line.separator") +
" [pds2 - javax.transaction.xa.XAException(XAER_RMERR) - resource 2 prepare failed]", ex.getCause().getCause().getMessage());
}
log.info(EventRecorder.dumpToString());
// we should find a ROLLEDBACK status in the journal log
// and 3 prepare tries (1 successful for resources 1 and 3, 1 failed for resource 2)
// and 3 rollback tries (1 successful for each resource)
int journalRollbackEventCount = 0;
int prepareEventCount = 0;
int rollbackEventCount = 0;
List events = EventRecorder.getOrderedEvents();
for (int i = 0; i < events.size(); i++) {
Event event = (Event) events.get(i);
if (event instanceof XAResourceRollbackEvent)
rollbackEventCount++;
if (event instanceof XAResourcePrepareEvent)
prepareEventCount++;
if (event instanceof JournalLogEvent) {
if (((JournalLogEvent) event).getStatus() == Status.STATUS_ROLLEDBACK)
journalRollbackEventCount++;
}
}
assertEquals("TM should have journaled 1 ROLLEDBACK status", 1, journalRollbackEventCount);
assertEquals("TM haven't properly tried to prepare", 3, prepareEventCount);
assertEquals("TM haven't properly tried to rollback", 3, rollbackEventCount);
} | Test scenario:
XAResources: 3
TX timeout: 10s
TX resolution: rollback
@throws Exception if any error happens. | testPrepareFailure | java | scalar-labs/btm | btm/src/test/java/bitronix/tm/twopc/Phase1FailureTest.java | https://github.com/scalar-labs/btm/blob/master/btm/src/test/java/bitronix/tm/twopc/Phase1FailureTest.java | Apache-2.0 |
@Override
protected ReactActivityDelegate createReactActivityDelegate() {
return new ReactActivityDelegateWrapper(this, BuildConfig.IS_NEW_ARCHITECTURE_ENABLED, new DefaultReactActivityDelegate(
this,
getMainComponentName(),
// If you opted-in for the New Architecture, we enable the Fabric Renderer.
DefaultNewArchitectureEntryPoint.getFabricEnabled()));
} | Returns the instance of the {@link ReactActivityDelegate}. Here we use a util class {@link
DefaultReactActivityDelegate} which allows you to easily enable Fabric and Concurrent React
(aka React 18) with two boolean flags. | createReactActivityDelegate | java | a7medev/react-native-ml-kit | example/android/app/src/main/java/com/rnmlkitexample/MainActivity.java | https://github.com/a7medev/react-native-ml-kit/blob/master/example/android/app/src/main/java/com/rnmlkitexample/MainActivity.java | MIT |
public static void initializeFlipper(Context context, ReactInstanceManager reactInstanceManager) {
// Do nothing as we don't want to initialize Flipper on Release.
} | Class responsible of loading Flipper inside your React Native application. This is the release
flavor of it so it's empty as we don't want to load Flipper. | initializeFlipper | java | a7medev/react-native-ml-kit | example/android/app/src/release/java/com/rnmlkitexample/ReactNativeFlipper.java | https://github.com/a7medev/react-native-ml-kit/blob/master/example/android/app/src/release/java/com/rnmlkitexample/ReactNativeFlipper.java | MIT |
public int getCurrentPosition() {
return mCurrentViewIndex - getChildCount();
} | Returns the current adapter position.
@return The current position. | getCurrentPosition | java | flschweiger/SwipeStack | library/src/main/java/link/fls/swipestack/SwipeStack.java | https://github.com/flschweiger/SwipeStack/blob/master/library/src/main/java/link/fls/swipestack/SwipeStack.java | Apache-2.0 |
public Adapter getAdapter() {
return mAdapter;
} | Returns the adapter currently in use in this SwipeStack.
@return The adapter currently used to display data in this SwipeStack. | getAdapter | java | flschweiger/SwipeStack | library/src/main/java/link/fls/swipestack/SwipeStack.java | https://github.com/flschweiger/SwipeStack/blob/master/library/src/main/java/link/fls/swipestack/SwipeStack.java | Apache-2.0 |
public void setAdapter(Adapter adapter) {
if (mAdapter != null) mAdapter.unregisterDataSetObserver(mDataObserver);
mAdapter = adapter;
mAdapter.registerDataSetObserver(mDataObserver);
} | Sets the data behind this SwipeView.
@param adapter The Adapter which is responsible for maintaining the
data backing this list and for producing a view to represent an
item in that data set.
@see #getAdapter() | setAdapter | java | flschweiger/SwipeStack | library/src/main/java/link/fls/swipestack/SwipeStack.java | https://github.com/flschweiger/SwipeStack/blob/master/library/src/main/java/link/fls/swipestack/SwipeStack.java | Apache-2.0 |
public int getAllowedSwipeDirections() {
return mAllowedSwipeDirections;
} | Returns the allowed swipe directions.
@return The currently allowed swipe directions. | getAllowedSwipeDirections | java | flschweiger/SwipeStack | library/src/main/java/link/fls/swipestack/SwipeStack.java | https://github.com/flschweiger/SwipeStack/blob/master/library/src/main/java/link/fls/swipestack/SwipeStack.java | Apache-2.0 |
public void setAllowedSwipeDirections(int directions) {
mAllowedSwipeDirections = directions;
} | Sets the allowed swipe directions.
@param directions One of {@link #SWIPE_DIRECTION_BOTH},
{@link #SWIPE_DIRECTION_ONLY_LEFT}, or {@link #SWIPE_DIRECTION_ONLY_RIGHT}. | setAllowedSwipeDirections | java | flschweiger/SwipeStack | library/src/main/java/link/fls/swipestack/SwipeStack.java | https://github.com/flschweiger/SwipeStack/blob/master/library/src/main/java/link/fls/swipestack/SwipeStack.java | Apache-2.0 |
public void setListener(@Nullable SwipeStackListener listener) {
mListener = listener;
} | Register a callback to be invoked when the user has swiped the top view
left / right or when the stack gets empty.
@param listener The callback that will run | setListener | java | flschweiger/SwipeStack | library/src/main/java/link/fls/swipestack/SwipeStack.java | https://github.com/flschweiger/SwipeStack/blob/master/library/src/main/java/link/fls/swipestack/SwipeStack.java | Apache-2.0 |
public void setSwipeProgressListener(@Nullable SwipeProgressListener listener) {
mProgressListener = listener;
} | Register a callback to be invoked when the user starts / stops interacting
with the top view of the stack.
@param listener The callback that will run | setSwipeProgressListener | java | flschweiger/SwipeStack | library/src/main/java/link/fls/swipestack/SwipeStack.java | https://github.com/flschweiger/SwipeStack/blob/master/library/src/main/java/link/fls/swipestack/SwipeStack.java | Apache-2.0 |
public View getTopView() {
return mTopView;
} | Get the view from the top of the stack.
@return The view if the stack is not empty or null otherwise. | getTopView | java | flschweiger/SwipeStack | library/src/main/java/link/fls/swipestack/SwipeStack.java | https://github.com/flschweiger/SwipeStack/blob/master/library/src/main/java/link/fls/swipestack/SwipeStack.java | Apache-2.0 |
public void swipeTopViewToRight() {
if (getChildCount() == 0) return;
mSwipeHelper.swipeViewToRight();
} | Programmatically dismiss the top view to the right. | swipeTopViewToRight | java | flschweiger/SwipeStack | library/src/main/java/link/fls/swipestack/SwipeStack.java | https://github.com/flschweiger/SwipeStack/blob/master/library/src/main/java/link/fls/swipestack/SwipeStack.java | Apache-2.0 |
public void swipeTopViewToLeft() {
if (getChildCount() == 0) return;
mSwipeHelper.swipeViewToLeft();
} | Programmatically dismiss the top view to the left. | swipeTopViewToLeft | java | flschweiger/SwipeStack | library/src/main/java/link/fls/swipestack/SwipeStack.java | https://github.com/flschweiger/SwipeStack/blob/master/library/src/main/java/link/fls/swipestack/SwipeStack.java | Apache-2.0 |
public void resetStack() {
mCurrentViewIndex = 0;
removeAllViewsInLayout();
requestLayout();
} | Resets the current adapter position and repopulates the stack. | resetStack | java | flschweiger/SwipeStack | library/src/main/java/link/fls/swipestack/SwipeStack.java | https://github.com/flschweiger/SwipeStack/blob/master/library/src/main/java/link/fls/swipestack/SwipeStack.java | Apache-2.0 |
@Override
public void registerComponents(@NonNull Context context,
@NonNull Glide glide,
@NonNull Registry registry) {
// Register FirebaseImageLoader to handle StorageReference
registry.append(StorageReference.class, InputStream.class,
new FirebaseImageLoader.Factory());
} | Glide module to register {@link com.firebase.ui.storage.images.FirebaseImageLoader}.
See: http://bumptech.github.io/glide/doc/generatedapi.html | registerComponents | java | firebase/FirebaseUI-Android | app/src/main/java/com/firebase/uidemo/storage/MyAppGlideModule.java | https://github.com/firebase/FirebaseUI-Android/blob/master/app/src/main/java/com/firebase/uidemo/storage/MyAppGlideModule.java | Apache-2.0 |
@Override
public void onComplete(@NonNull Task<AuthResult> task) {
if (task.isSuccessful()) {
Toast.makeText(mContext, R.string.signed_in, Toast.LENGTH_SHORT).show();
} else {
Toast.makeText(mContext, R.string.anonymous_auth_failed_msg, Toast.LENGTH_LONG).show();
}
} | Notifies the user of sign in successes or failures beyond the lifecycle of an activity. | onComplete | java | firebase/FirebaseUI-Android | app/src/main/java/com/firebase/uidemo/util/SignInResultNotifier.java | https://github.com/firebase/FirebaseUI-Android/blob/master/app/src/main/java/com/firebase/uidemo/util/SignInResultNotifier.java | Apache-2.0 |
public AuthMethodPickerLayout.Builder setGoogleButtonId(@IdRes int googleBtn) {
providersMapping.put(GoogleAuthProvider.PROVIDER_ID, googleBtn);
return this;
} | Set the ID of the Google sign in button in the custom layout. | setGoogleButtonId | java | firebase/FirebaseUI-Android | auth/src/main/java/com/firebase/ui/auth/AuthMethodPickerLayout.java | https://github.com/firebase/FirebaseUI-Android/blob/master/auth/src/main/java/com/firebase/ui/auth/AuthMethodPickerLayout.java | Apache-2.0 |
public AuthMethodPickerLayout.Builder setFacebookButtonId(@IdRes int facebookBtn) {
providersMapping.put(FacebookAuthProvider.PROVIDER_ID, facebookBtn);
return this;
} | Set the ID of the Facebook sign in button in the custom layout. | setFacebookButtonId | java | firebase/FirebaseUI-Android | auth/src/main/java/com/firebase/ui/auth/AuthMethodPickerLayout.java | https://github.com/firebase/FirebaseUI-Android/blob/master/auth/src/main/java/com/firebase/ui/auth/AuthMethodPickerLayout.java | Apache-2.0 |
public AuthMethodPickerLayout.Builder setTwitterButtonId(@IdRes int twitterBtn) {
providersMapping.put(TwitterAuthProvider.PROVIDER_ID, twitterBtn);
return this;
} | Set the ID of the Twitter sign in button in the custom layout. | setTwitterButtonId | java | firebase/FirebaseUI-Android | auth/src/main/java/com/firebase/ui/auth/AuthMethodPickerLayout.java | https://github.com/firebase/FirebaseUI-Android/blob/master/auth/src/main/java/com/firebase/ui/auth/AuthMethodPickerLayout.java | Apache-2.0 |
public AuthMethodPickerLayout.Builder setEmailButtonId(@IdRes int emailButton) {
providersMapping.put(EmailAuthProvider.PROVIDER_ID, emailButton);
return this;
} | Set the ID of the Email sign in button in the custom layout. | setEmailButtonId | java | firebase/FirebaseUI-Android | auth/src/main/java/com/firebase/ui/auth/AuthMethodPickerLayout.java | https://github.com/firebase/FirebaseUI-Android/blob/master/auth/src/main/java/com/firebase/ui/auth/AuthMethodPickerLayout.java | Apache-2.0 |
public AuthMethodPickerLayout.Builder setPhoneButtonId(@IdRes int phoneButton) {
providersMapping.put(PhoneAuthProvider.PROVIDER_ID, phoneButton);
return this;
} | Set the ID of the Phone Number sign in button in the custom layout. | setPhoneButtonId | java | firebase/FirebaseUI-Android | auth/src/main/java/com/firebase/ui/auth/AuthMethodPickerLayout.java | https://github.com/firebase/FirebaseUI-Android/blob/master/auth/src/main/java/com/firebase/ui/auth/AuthMethodPickerLayout.java | Apache-2.0 |
@NonNull
public static AuthUI getInstance() {
return getInstance(FirebaseApp.getInstance());
} | Retrieves the {@link AuthUI} instance associated with the default app, as returned by {@code
FirebaseApp.getInstance()}.
@throws IllegalStateException if the default app is not initialized. | getInstance | java | firebase/FirebaseUI-Android | auth/src/main/java/com/firebase/ui/auth/AuthUI.java | https://github.com/firebase/FirebaseUI-Android/blob/master/auth/src/main/java/com/firebase/ui/auth/AuthUI.java | Apache-2.0 |
@NonNull
public static AuthUI getInstance(@NonNull String appName) {
return getInstance(FirebaseApp.getInstance(appName));
} | Retrieves the {@link AuthUI} instance associated the the specified app name.
@throws IllegalStateException if the app is not initialized. | getInstance | java | firebase/FirebaseUI-Android | auth/src/main/java/com/firebase/ui/auth/AuthUI.java | https://github.com/firebase/FirebaseUI-Android/blob/master/auth/src/main/java/com/firebase/ui/auth/AuthUI.java | Apache-2.0 |
public static boolean canHandleIntent(@NonNull Intent intent) {
if (intent == null || intent.getData() == null) {
return false;
}
String link = intent.getData().toString();
return FirebaseAuth.getInstance().isSignInWithEmailLink(link);
} | Returns true if AuthUI can handle the intent.
<p>
AuthUI handle the intent when the embedded data is an email link. If it is, you can then
specify the link in {@link SignInIntentBuilder#setEmailLink(String)} before starting AuthUI
and it will be handled immediately. | canHandleIntent | java | firebase/FirebaseUI-Android | auth/src/main/java/com/firebase/ui/auth/AuthUI.java | https://github.com/firebase/FirebaseUI-Android/blob/master/auth/src/main/java/com/firebase/ui/auth/AuthUI.java | Apache-2.0 |
@StyleRes
public static int getDefaultTheme() {
return R.style.FirebaseUI_DefaultMaterialTheme;
} | Default theme used by {@link SignInIntentBuilder#setTheme(int)} if no theme customization is
required. | getDefaultTheme | java | firebase/FirebaseUI-Android | auth/src/main/java/com/firebase/ui/auth/AuthUI.java | https://github.com/firebase/FirebaseUI-Android/blob/master/auth/src/main/java/com/firebase/ui/auth/AuthUI.java | Apache-2.0 |
@NonNull
public Task<Void> signOut(@NonNull Context context) {
boolean playServicesAvailable = GoogleApiUtils.isPlayServicesAvailable(context);
if (!playServicesAvailable) {
Log.w(TAG, "Google Play services not available during signOut");
}
signOutIdps(context);
Executor singleThreadExecutor = Executors.newSingleThreadExecutor();
return clearCredentialState(context, singleThreadExecutor).continueWith(task -> {
task.getResult(); // Propagate exceptions if any.
mAuth.signOut();
return null;
});
} | Signs the current user out, if one is signed in.
@param context the context requesting the user be signed out
@return A task which, upon completion, signals that the user has been signed out ({@link
Task#isSuccessful()}, or that the sign-out attempt failed unexpectedly !{@link
Task#isSuccessful()}). | signOut | java | firebase/FirebaseUI-Android | auth/src/main/java/com/firebase/ui/auth/AuthUI.java | https://github.com/firebase/FirebaseUI-Android/blob/master/auth/src/main/java/com/firebase/ui/auth/AuthUI.java | Apache-2.0 |
@NonNull
public Task<Void> delete(@NonNull final Context context) {
final FirebaseUser currentUser = mAuth.getCurrentUser();
if (currentUser == null) {
return Tasks.forException(new FirebaseAuthInvalidUserException(
String.valueOf(CommonStatusCodes.SIGN_IN_REQUIRED),
"No currently signed in user."));
}
signOutIdps(context);
Executor singleThreadExecutor = Executors.newSingleThreadExecutor();
return clearCredentialState(context, singleThreadExecutor).continueWithTask(task -> {
task.getResult(); // Propagate exceptions if any.
return currentUser.delete();
});
} | Delete the user from FirebaseAuth.
<p>Any associated saved credentials are not explicitly deleted with the new APIs.
@param context the calling {@link Context}. | delete | java | firebase/FirebaseUI-Android | auth/src/main/java/com/firebase/ui/auth/AuthUI.java | https://github.com/firebase/FirebaseUI-Android/blob/master/auth/src/main/java/com/firebase/ui/auth/AuthUI.java | Apache-2.0 |
@NonNull
public SignInIntentBuilder createSignInIntentBuilder() {
return new SignInIntentBuilder();
} | Starts the process of creating a sign in intent, with the mandatory application context
parameter. | createSignInIntentBuilder | java | firebase/FirebaseUI-Android | auth/src/main/java/com/firebase/ui/auth/AuthUI.java | https://github.com/firebase/FirebaseUI-Android/blob/master/auth/src/main/java/com/firebase/ui/auth/AuthUI.java | Apache-2.0 |
@NonNull
public EmailBuilder setAllowNewAccounts(boolean allow) {
getParams().putBoolean(ExtraConstants.ALLOW_NEW_EMAILS, allow);
return this;
} | Enables or disables creating new accounts in the email sign in flows.
<p>
Account creation is enabled by default. | setAllowNewAccounts | java | firebase/FirebaseUI-Android | auth/src/main/java/com/firebase/ui/auth/AuthUI.java | https://github.com/firebase/FirebaseUI-Android/blob/master/auth/src/main/java/com/firebase/ui/auth/AuthUI.java | Apache-2.0 |
@NonNull
public EmailBuilder setRequireName(boolean requireName) {
getParams().putBoolean(ExtraConstants.REQUIRE_NAME, requireName);
return this;
} | Configures the requirement for the user to enter first and last name in the email
sign up flow.
<p>
Name is required by default. | setRequireName | java | firebase/FirebaseUI-Android | auth/src/main/java/com/firebase/ui/auth/AuthUI.java | https://github.com/firebase/FirebaseUI-Android/blob/master/auth/src/main/java/com/firebase/ui/auth/AuthUI.java | Apache-2.0 |
@NonNull
public EmailBuilder enableEmailLinkSignIn() {
setProviderId(EMAIL_LINK_PROVIDER);
return this;
} | Enables email link sign in instead of password based sign in. Once enabled, you must
pass a valid {@link ActionCodeSettings} object using
{@link #setActionCodeSettings(ActionCodeSettings)}
<p>
You must enable Firebase Dynamic Links in the Firebase Console to use email link
sign in.
@throws IllegalStateException if {@link ActionCodeSettings} is null or not
provided with email link enabled. | enableEmailLinkSignIn | java | firebase/FirebaseUI-Android | auth/src/main/java/com/firebase/ui/auth/AuthUI.java | https://github.com/firebase/FirebaseUI-Android/blob/master/auth/src/main/java/com/firebase/ui/auth/AuthUI.java | Apache-2.0 |
@NonNull
public EmailBuilder setActionCodeSettings(ActionCodeSettings actionCodeSettings) {
getParams().putParcelable(ExtraConstants.ACTION_CODE_SETTINGS, actionCodeSettings);
return this;
} | Sets the {@link ActionCodeSettings} object to be used for email link sign in.
<p>
{@link ActionCodeSettings#canHandleCodeInApp()} must be set to true, and a valid
continueUrl must be passed via {@link ActionCodeSettings.Builder#setUrl(String)}.
This URL must be allowlisted in the Firebase Console.
@throws IllegalStateException if canHandleCodeInApp is set to false
@throws NullPointerException if ActionCodeSettings is null | setActionCodeSettings | java | firebase/FirebaseUI-Android | auth/src/main/java/com/firebase/ui/auth/AuthUI.java | https://github.com/firebase/FirebaseUI-Android/blob/master/auth/src/main/java/com/firebase/ui/auth/AuthUI.java | Apache-2.0 |
@NonNull
public EmailBuilder setForceSameDevice() {
getParams().putBoolean(ExtraConstants.FORCE_SAME_DEVICE, true);
return this;
} | Disables allowing email link sign in to occur across different devices.
<p>
This cannot be disabled with anonymous upgrade. | setForceSameDevice | java | firebase/FirebaseUI-Android | auth/src/main/java/com/firebase/ui/auth/AuthUI.java | https://github.com/firebase/FirebaseUI-Android/blob/master/auth/src/main/java/com/firebase/ui/auth/AuthUI.java | Apache-2.0 |
@NonNull
public PhoneBuilder setDefaultNumber(@NonNull String number) {
Preconditions.checkUnset(getParams(),
"Cannot overwrite previously set phone number",
ExtraConstants.PHONE,
ExtraConstants.COUNTRY_ISO,
ExtraConstants.NATIONAL_NUMBER);
if (!PhoneNumberUtils.isValid(number)) {
throw new IllegalStateException("Invalid phone number: " + number);
}
getParams().putString(ExtraConstants.PHONE, number);
return this;
} | @param number the phone number in international format
@see #setDefaultNumber(String, String) | setDefaultNumber | java | firebase/FirebaseUI-Android | auth/src/main/java/com/firebase/ui/auth/AuthUI.java | https://github.com/firebase/FirebaseUI-Android/blob/master/auth/src/main/java/com/firebase/ui/auth/AuthUI.java | Apache-2.0 |
@NonNull
public PhoneBuilder setDefaultNumber(@NonNull String iso, @NonNull String number) {
Preconditions.checkUnset(getParams(),
"Cannot overwrite previously set phone number",
ExtraConstants.PHONE,
ExtraConstants.COUNTRY_ISO,
ExtraConstants.NATIONAL_NUMBER);
if (!PhoneNumberUtils.isValidIso(iso)) {
throw new IllegalStateException("Invalid country iso: " + iso);
}
getParams().putString(ExtraConstants.COUNTRY_ISO, iso);
getParams().putString(ExtraConstants.NATIONAL_NUMBER, number);
return this;
} | Set the default phone number that will be used to populate the phone verification
sign-in flow.
@param iso the phone number's country code
@param number the phone number in local format | setDefaultNumber | java | firebase/FirebaseUI-Android | auth/src/main/java/com/firebase/ui/auth/AuthUI.java | https://github.com/firebase/FirebaseUI-Android/blob/master/auth/src/main/java/com/firebase/ui/auth/AuthUI.java | Apache-2.0 |
@NonNull
public PhoneBuilder setDefaultCountryIso(@NonNull String iso) {
Preconditions.checkUnset(getParams(),
"Cannot overwrite previously set phone number",
ExtraConstants.PHONE,
ExtraConstants.COUNTRY_ISO,
ExtraConstants.NATIONAL_NUMBER);
if (!PhoneNumberUtils.isValidIso(iso)) {
throw new IllegalStateException("Invalid country iso: " + iso);
}
getParams().putString(ExtraConstants.COUNTRY_ISO,
iso.toUpperCase(Locale.getDefault()));
return this;
} | Set the default country code that will be used in the phone verification sign-in
flow.
@param iso country iso | setDefaultCountryIso | java | firebase/FirebaseUI-Android | auth/src/main/java/com/firebase/ui/auth/AuthUI.java | https://github.com/firebase/FirebaseUI-Android/blob/master/auth/src/main/java/com/firebase/ui/auth/AuthUI.java | Apache-2.0 |
public PhoneBuilder setAllowedCountries(
@NonNull List<String> countries) {
if (getParams().containsKey(ExtraConstants.BLOCKLISTED_COUNTRIES)) {
throw new IllegalStateException(
"You can either allowlist or blocklist country codes for phone " +
"authentication.");
}
String message = "Invalid argument: Only non-%s allowlists are valid. " +
"To specify no allowlist, do not call this method.";
Preconditions.checkNotNull(countries, String.format(message, "null"));
Preconditions.checkArgument(!countries.isEmpty(), String.format
(message, "empty"));
addCountriesToBundle(countries, ExtraConstants.ALLOWLISTED_COUNTRIES);
return this;
} | Sets the country codes available in the country code selector for phone
authentication. Takes as input a List of both country isos and codes.
This is not to be called with
{@link #setBlockedCountries(List)}.
If both are called, an exception will be thrown.
<p>
Inputting an e-164 country code (e.g. '+1') will include all countries with
+1 as its code.
Example input: {'+52', 'us'}
For a list of country iso or codes, see Alpha-2 isos here:
https://en.wikipedia.org/wiki/ISO_3166-1
and e-164 codes here: https://en.wikipedia.org/wiki/List_of_country_calling_codes
@param countries a non empty case insensitive list of country codes
and/or isos to be allowlisted
@throws IllegalArgumentException if an empty allowlist is provided.
@throws NullPointerException if a null allowlist is provided. | setAllowedCountries | java | firebase/FirebaseUI-Android | auth/src/main/java/com/firebase/ui/auth/AuthUI.java | https://github.com/firebase/FirebaseUI-Android/blob/master/auth/src/main/java/com/firebase/ui/auth/AuthUI.java | Apache-2.0 |
private void validateWebClientId() {
Preconditions.checkConfigured(getApplicationContext(),
"Check your google-services plugin configuration, the" +
" default_web_client_id string wasn't populated.",
R.string.default_web_client_id);
} | {@link IdpConfig} builder for the Google provider. | validateWebClientId | java | firebase/FirebaseUI-Android | auth/src/main/java/com/firebase/ui/auth/AuthUI.java | https://github.com/firebase/FirebaseUI-Android/blob/master/auth/src/main/java/com/firebase/ui/auth/AuthUI.java | Apache-2.0 |
@NonNull
public GoogleBuilder setScopes(@NonNull List<String> scopes) {
GoogleSignInOptions.Builder builder =
new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
.requestEmail();
for (String scope : scopes) {
builder.requestScopes(new Scope(scope));
}
return setSignInOptions(builder.build());
} | Set the scopes that your app will request when using Google sign-in. See all <a
href="https://developers.google.com/identity/protocols/googlescopes">available
scopes</a>.
@param scopes additional scopes to be requested | setScopes | java | firebase/FirebaseUI-Android | auth/src/main/java/com/firebase/ui/auth/AuthUI.java | https://github.com/firebase/FirebaseUI-Android/blob/master/auth/src/main/java/com/firebase/ui/auth/AuthUI.java | Apache-2.0 |
@NonNull
public FacebookBuilder setPermissions(@NonNull List<String> permissions) {
getParams().putStringArrayList(
ExtraConstants.FACEBOOK_PERMISSIONS, new ArrayList<>(permissions));
return this;
} | Specifies the additional permissions that the application will request in the
Facebook Login SDK. Available permissions can be found <a
href="https://developers.facebook.com/docs/facebook-login/permissions">here</a>. | setPermissions | java | firebase/FirebaseUI-Android | auth/src/main/java/com/firebase/ui/auth/AuthUI.java | https://github.com/firebase/FirebaseUI-Android/blob/master/auth/src/main/java/com/firebase/ui/auth/AuthUI.java | Apache-2.0 |
@Deprecated
@NonNull
public GitHubBuilder setPermissions(@NonNull List<String> permissions) {
setScopes(permissions);
return this;
} | Specifies the additional permissions to be requested.
<p> Available permissions can be found
<ahref="https://developer.github.com/apps/building-oauth-apps/scopes-for-oauth-apps/#available-scopes">here</a>.
@deprecated Please use {@link #setScopes(List)} instead. | setPermissions | java | firebase/FirebaseUI-Android | auth/src/main/java/com/firebase/ui/auth/AuthUI.java | https://github.com/firebase/FirebaseUI-Android/blob/master/auth/src/main/java/com/firebase/ui/auth/AuthUI.java | Apache-2.0 |
@NonNull
public T setTheme(@StyleRes int theme) {
mTheme = Preconditions.checkValidStyle(
mApp.getApplicationContext(),
theme,
"theme identifier is unknown or not a style definition");
return (T) this;
} | Specifies the theme to use for the application flow. If no theme is specified, a
default theme will be used. | setTheme | java | firebase/FirebaseUI-Android | auth/src/main/java/com/firebase/ui/auth/AuthUI.java | https://github.com/firebase/FirebaseUI-Android/blob/master/auth/src/main/java/com/firebase/ui/auth/AuthUI.java | Apache-2.0 |
@NonNull
public T setLogo(@DrawableRes int logo) {
mLogo = logo;
return (T) this;
} | Specifies the logo to use for the {@link AuthMethodPickerActivity}. If no logo is
specified, none will be used. | setLogo | java | firebase/FirebaseUI-Android | auth/src/main/java/com/firebase/ui/auth/AuthUI.java | https://github.com/firebase/FirebaseUI-Android/blob/master/auth/src/main/java/com/firebase/ui/auth/AuthUI.java | Apache-2.0 |
@NonNull
@Deprecated
public T setTosUrl(@Nullable String tosUrl) {
mTosUrl = tosUrl;
return (T) this;
} | Specifies the terms-of-service URL for the application.
@deprecated Please use {@link #setTosAndPrivacyPolicyUrls(String, String)} For the Tos
link to be displayed a Privacy Policy url must also be provided. | setTosUrl | java | firebase/FirebaseUI-Android | auth/src/main/java/com/firebase/ui/auth/AuthUI.java | https://github.com/firebase/FirebaseUI-Android/blob/master/auth/src/main/java/com/firebase/ui/auth/AuthUI.java | Apache-2.0 |
@NonNull
public T setAvailableProviders(@NonNull List<IdpConfig> idpConfigs) {
Preconditions.checkNotNull(idpConfigs, "idpConfigs cannot be null");
if (idpConfigs.size() == 1 &&
idpConfigs.get(0).getProviderId().equals(ANONYMOUS_PROVIDER)) {
throw new IllegalStateException("Sign in as guest cannot be the only sign in " +
"method. In this case, sign the user in anonymously your self; " +
"no UI is needed.");
}
mProviders.clear();
for (IdpConfig config : idpConfigs) {
if (mProviders.contains(config)) {
throw new IllegalArgumentException("Each provider can only be set once. "
+ config.getProviderId()
+ " was set twice.");
} else {
mProviders.add(config);
}
}
return (T) this;
} | Specifies the set of supported authentication providers. At least one provider must
be specified. There may only be one instance of each provider. Anonymous provider cannot
be the only provider specified.
<p>
<p>If no providers are explicitly specified by calling this method, then the email
provider is the default supported provider.
@param idpConfigs a list of {@link IdpConfig}s, where each {@link IdpConfig} contains the
configuration parameters for the IDP.
@throws IllegalStateException if anonymous provider is the only specified provider.
@see IdpConfig | setAvailableProviders | java | firebase/FirebaseUI-Android | auth/src/main/java/com/firebase/ui/auth/AuthUI.java | https://github.com/firebase/FirebaseUI-Android/blob/master/auth/src/main/java/com/firebase/ui/auth/AuthUI.java | Apache-2.0 |
@NonNull
public T setDefaultProvider(@Nullable IdpConfig config) {
if (config != null) {
if (!mProviders.contains(config)) {
throw new IllegalStateException(
"Default provider not in available providers list.");
}
if (mAlwaysShowProviderChoice) {
throw new IllegalStateException(
"Can't set default provider and always show provider choice.");
}
}
mDefaultProvider = config;
return (T) this;
} | Specifies the default authentication provider, bypassing the provider selection screen.
The provider here must already be included via {@link #setAvailableProviders(List)}, and
this method is incompatible with {@link #setAlwaysShowSignInMethodScreen(boolean)}.
@param config the default {@link IdpConfig} to use. | setDefaultProvider | java | firebase/FirebaseUI-Android | auth/src/main/java/com/firebase/ui/auth/AuthUI.java | https://github.com/firebase/FirebaseUI-Android/blob/master/auth/src/main/java/com/firebase/ui/auth/AuthUI.java | Apache-2.0 |
@NonNull
public T setCredentialManagerEnabled(boolean enableCredentials) {
mEnableCredentials = enableCredentials;
return (T) this;
} | Enables or disables the use of Credential Manager for Passwords credential selector
<p>
<p>Is enabled by default.
@param enableCredentials enables credential selector before signup | setCredentialManagerEnabled | java | firebase/FirebaseUI-Android | auth/src/main/java/com/firebase/ui/auth/AuthUI.java | https://github.com/firebase/FirebaseUI-Android/blob/master/auth/src/main/java/com/firebase/ui/auth/AuthUI.java | Apache-2.0 |
@NonNull
public T setAuthMethodPickerLayout(@NonNull AuthMethodPickerLayout authMethodPickerLayout) {
mAuthMethodPickerLayout = authMethodPickerLayout;
return (T) this;
} | Set a custom layout for the AuthMethodPickerActivity screen.
See {@link AuthMethodPickerLayout}.
@param authMethodPickerLayout custom layout descriptor object. | setAuthMethodPickerLayout | java | firebase/FirebaseUI-Android | auth/src/main/java/com/firebase/ui/auth/AuthUI.java | https://github.com/firebase/FirebaseUI-Android/blob/master/auth/src/main/java/com/firebase/ui/auth/AuthUI.java | Apache-2.0 |
@NonNull
public T setAlwaysShowSignInMethodScreen(boolean alwaysShow) {
if (alwaysShow && mDefaultProvider != null) {
throw new IllegalStateException(
"Can't show provider choice with a default provider.");
}
mAlwaysShowProviderChoice = alwaysShow;
return (T) this;
} | Forces the sign-in method choice screen to always show, even if there is only
a single provider configured.
<p>
<p>This is false by default.
@param alwaysShow if true, force the sign-in choice screen to show. | setAlwaysShowSignInMethodScreen | java | firebase/FirebaseUI-Android | auth/src/main/java/com/firebase/ui/auth/AuthUI.java | https://github.com/firebase/FirebaseUI-Android/blob/master/auth/src/main/java/com/firebase/ui/auth/AuthUI.java | Apache-2.0 |
@NonNull
public T setLockOrientation(boolean lockOrientation) {
mLockOrientation = lockOrientation;
return (T) this;
} | Enable or disables the orientation for small devices to be locked in
Portrait orientation
<p>
<p>This is false by default.
@param lockOrientation if true, force the activities to be in Portrait orientation. | setLockOrientation | java | firebase/FirebaseUI-Android | auth/src/main/java/com/firebase/ui/auth/AuthUI.java | https://github.com/firebase/FirebaseUI-Android/blob/master/auth/src/main/java/com/firebase/ui/auth/AuthUI.java | Apache-2.0 |
@NonNull
public SignInIntentBuilder setEmailLink(@NonNull final String emailLink) {
mEmailLink = emailLink;
return this;
} | Specifies the email link to be used for sign in. When set, a sign in attempt will be
made immediately. | setEmailLink | java | firebase/FirebaseUI-Android | auth/src/main/java/com/firebase/ui/auth/AuthUI.java | https://github.com/firebase/FirebaseUI-Android/blob/master/auth/src/main/java/com/firebase/ui/auth/AuthUI.java | Apache-2.0 |
@NonNull
@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
public static String toFriendlyMessage(@Code int code) {
switch (code) {
case UNKNOWN_ERROR:
return "Unknown error";
case NO_NETWORK:
return "No internet connection";
case PLAY_SERVICES_UPDATE_CANCELLED:
return "Play Services update cancelled";
case DEVELOPER_ERROR:
return "Developer error";
case PROVIDER_ERROR:
return "Provider error";
case ANONYMOUS_UPGRADE_MERGE_CONFLICT:
return "User account merge conflict";
case EMAIL_MISMATCH_ERROR:
return "You are are attempting to sign in a different email than previously " +
"provided";
case INVALID_EMAIL_LINK_ERROR:
return "You are are attempting to sign in with an invalid email link";
case EMAIL_LINK_PROMPT_FOR_EMAIL_ERROR:
return "Please enter your email to continue signing in";
case EMAIL_LINK_WRONG_DEVICE_ERROR:
return "You must open the email link on the same device.";
case EMAIL_LINK_CROSS_DEVICE_LINKING_ERROR:
return "You must determine if you want to continue linking or complete the sign in";
case EMAIL_LINK_DIFFERENT_ANONYMOUS_USER_ERROR:
return "The session associated with this sign-in request has either expired or " +
"was cleared";
case ERROR_USER_DISABLED:
return "The user account has been disabled by an administrator.";
case ERROR_GENERIC_IDP_RECOVERABLE_ERROR:
return "Generic IDP recoverable error.";
default:
throw new IllegalArgumentException("Unknown code: " + code);
}
} | Recoverable error occurred during the Generic IDP flow. | toFriendlyMessage | java | firebase/FirebaseUI-Android | auth/src/main/java/com/firebase/ui/auth/ErrorCodes.java | https://github.com/firebase/FirebaseUI-Android/blob/master/auth/src/main/java/com/firebase/ui/auth/ErrorCodes.java | Apache-2.0 |
@ErrorCodes.Code
public final int getErrorCode() {
return mErrorCode;
} | @return error code associated with this exception
@see com.firebase.ui.auth.ErrorCodes | getErrorCode | java | firebase/FirebaseUI-Android | auth/src/main/java/com/firebase/ui/auth/FirebaseUiException.java | https://github.com/firebase/FirebaseUI-Android/blob/master/auth/src/main/java/com/firebase/ui/auth/FirebaseUiException.java | Apache-2.0 |
@Nullable
public String getProviderType() {
return mUser != null ? mUser.getProviderId() : null;
} | Get the type of provider. e.g. {@link GoogleAuthProvider#PROVIDER_ID} | getProviderType | java | firebase/FirebaseUI-Android | auth/src/main/java/com/firebase/ui/auth/IdpResponse.java | https://github.com/firebase/FirebaseUI-Android/blob/master/auth/src/main/java/com/firebase/ui/auth/IdpResponse.java | Apache-2.0 |
public boolean isNewUser() {
return mIsNewUser;
} | Returns true if this user has just signed up, false otherwise. | isNewUser | java | firebase/FirebaseUI-Android | auth/src/main/java/com/firebase/ui/auth/IdpResponse.java | https://github.com/firebase/FirebaseUI-Android/blob/master/auth/src/main/java/com/firebase/ui/auth/IdpResponse.java | Apache-2.0 |
@Nullable
public String getEmail() {
return mUser != null ? mUser.getEmail() : null;
} | Get the email used to sign in. | getEmail | java | firebase/FirebaseUI-Android | auth/src/main/java/com/firebase/ui/auth/IdpResponse.java | https://github.com/firebase/FirebaseUI-Android/blob/master/auth/src/main/java/com/firebase/ui/auth/IdpResponse.java | Apache-2.0 |
@Nullable
public String getPhoneNumber() {
return mUser != null ? mUser.getPhoneNumber() : null;
} | Get the phone number used to sign in. | getPhoneNumber | java | firebase/FirebaseUI-Android | auth/src/main/java/com/firebase/ui/auth/IdpResponse.java | https://github.com/firebase/FirebaseUI-Android/blob/master/auth/src/main/java/com/firebase/ui/auth/IdpResponse.java | Apache-2.0 |
@Nullable
public String getIdpToken() {
return mToken;
} | Get the token received as a result of logging in with the specified IDP | getIdpToken | java | firebase/FirebaseUI-Android | auth/src/main/java/com/firebase/ui/auth/IdpResponse.java | https://github.com/firebase/FirebaseUI-Android/blob/master/auth/src/main/java/com/firebase/ui/auth/IdpResponse.java | Apache-2.0 |
@Nullable
public String getIdpSecret() {
return mSecret;
} | Twitter only. Return the token secret received as a result of logging in with Twitter. | getIdpSecret | java | firebase/FirebaseUI-Android | auth/src/main/java/com/firebase/ui/auth/IdpResponse.java | https://github.com/firebase/FirebaseUI-Android/blob/master/auth/src/main/java/com/firebase/ui/auth/IdpResponse.java | Apache-2.0 |
@Nullable
public IdpResponse getIdpResponse() {
return idpResponse;
} | The contained {@link IdpResponse} returned from the Firebase library | getIdpResponse | java | firebase/FirebaseUI-Android | auth/src/main/java/com/firebase/ui/auth/data/model/FirebaseAuthUIAuthenticationResult.java | https://github.com/firebase/FirebaseUI-Android/blob/master/auth/src/main/java/com/firebase/ui/auth/data/model/FirebaseAuthUIAuthenticationResult.java | Apache-2.0 |
public PendingIntent getPendingIntent() {
return mPendingIntent;
} | Returns the PendingIntent, if available.
@return The PendingIntent or null if not available. | getPendingIntent | java | firebase/FirebaseUI-Android | auth/src/main/java/com/firebase/ui/auth/data/model/PendingIntentRequiredException.java | https://github.com/firebase/FirebaseUI-Android/blob/master/auth/src/main/java/com/firebase/ui/auth/data/model/PendingIntentRequiredException.java | Apache-2.0 |
public String getPhoneNumber() {
return mPhoneNumber;
} | Returns phone number without country code | getPhoneNumber | java | firebase/FirebaseUI-Android | auth/src/main/java/com/firebase/ui/auth/data/model/PhoneNumber.java | https://github.com/firebase/FirebaseUI-Android/blob/master/auth/src/main/java/com/firebase/ui/auth/data/model/PhoneNumber.java | Apache-2.0 |
@NonNull
public String getPhoneNumber() {
return mPhoneNumber;
} | @return the phone number requiring verification | getPhoneNumber | java | firebase/FirebaseUI-Android | auth/src/main/java/com/firebase/ui/auth/data/model/PhoneNumberVerificationRequiredException.java | https://github.com/firebase/FirebaseUI-Android/blob/master/auth/src/main/java/com/firebase/ui/auth/data/model/PhoneNumberVerificationRequiredException.java | Apache-2.0 |
@NonNull
public static <T> Resource<T> forFailure(@NonNull Exception e) {
return new Resource<>(State.FAILURE, null, e);
} | Creates a failed resource with an exception. | forFailure | java | firebase/FirebaseUI-Android | auth/src/main/java/com/firebase/ui/auth/data/model/Resource.java | https://github.com/firebase/FirebaseUI-Android/blob/master/auth/src/main/java/com/firebase/ui/auth/data/model/Resource.java | Apache-2.0 |
@Override
public Task<AuthResult> then(@NonNull Task<AuthResult> task) {
final AuthResult authResult = task.getResult();
FirebaseUser firebaseUser = authResult.getUser();
String name = firebaseUser.getDisplayName();
Uri photoUri = firebaseUser.getPhotoUrl();
if (!TextUtils.isEmpty(name) && photoUri != null) {
return Tasks.forResult(authResult);
}
User user = mResponse.getUser();
if (TextUtils.isEmpty(name)) { name = user.getName(); }
if (photoUri == null) { photoUri = user.getPhotoUri(); }
return firebaseUser.updateProfile(
new UserProfileChangeRequest.Builder()
.setDisplayName(name)
.setPhotoUri(photoUri)
.build())
.addOnFailureListener(new TaskFailureLogger(TAG, "Error updating profile"))
.continueWithTask(task1 -> Tasks.forResult(authResult));
} | Merges an existing account's profile with the new user's profile.
<p>
<b>Note:</b> This operation always returns a successful task to minimize login interruptions. | then | java | firebase/FirebaseUI-Android | auth/src/main/java/com/firebase/ui/auth/data/remote/ProfileMerger.java | https://github.com/firebase/FirebaseUI-Android/blob/master/auth/src/main/java/com/firebase/ui/auth/data/remote/ProfileMerger.java | Apache-2.0 |
public void startSaveCredentials(
FirebaseUser firebaseUser,
IdpResponse response,
@Nullable String password) {
// Extract email; if null, fallback to the phone number.
String email = firebaseUser.getEmail();
if (email == null) {
email = firebaseUser.getPhoneNumber();
}
// Start the dedicated CredentialManager Activity.
Intent intent = CredentialSaveActivity.createIntent(
this, getFlowParams(), email, password, response);
startActivityForResult(intent, RequestCodes.CRED_SAVE_FLOW);
} | Starts the CredentialManager save flow.
<p>Instead of building a SmartLock {@link com.google.android.gms.auth.api.credentials.Credential},
we now extract the user's email (or phone number as a fallback) and pass it along with the
password and response.</p>
@param firebaseUser the currently signed-in user.
@param response the IdP response.
@param password the password used during sign-in (may be {@code null}). | startSaveCredentials | java | firebase/FirebaseUI-Android | auth/src/main/java/com/firebase/ui/auth/ui/HelperActivityBase.java | https://github.com/firebase/FirebaseUI-Android/blob/master/auth/src/main/java/com/firebase/ui/auth/ui/HelperActivityBase.java | Apache-2.0 |
protected boolean isOffline() {
ConnectivityManager manager = (ConnectivityManager) getApplicationContext()
.getSystemService(Context.CONNECTIVITY_SERVICE);
return !(manager != null
&& manager.getActiveNetworkInfo() != null
&& manager.getActiveNetworkInfo().isConnectedOrConnecting());
} | Check if there is an active or soon-to-be-active network connection.
@return true if there is no network connection, false otherwise. | isOffline | java | firebase/FirebaseUI-Android | auth/src/main/java/com/firebase/ui/auth/ui/HelperActivityBase.java | https://github.com/firebase/FirebaseUI-Android/blob/master/auth/src/main/java/com/firebase/ui/auth/ui/HelperActivityBase.java | Apache-2.0 |
private void doAfterTimeout(Runnable runnable) {
long currentTime = System.currentTimeMillis();
long diff = currentTime - mLastShownTime;
// 'diff' is how long it's been since we showed the spinner, so in the
// case where diff is greater than our minimum spinner duration then our
// remaining wait time is 0.
long remaining = Math.max(MIN_SPINNER_MS - diff, 0);
mHandler.postDelayed(runnable, remaining);
} | For certain actions (like finishing or hiding the progress dialog) we want to make sure
that we have shown the progress state for at least MIN_SPINNER_MS to prevent flickering.
This method performs some action after the window has passed, or immediately if we have
already waited longer than that. | doAfterTimeout | java | firebase/FirebaseUI-Android | auth/src/main/java/com/firebase/ui/auth/ui/InvisibleActivityBase.java | https://github.com/firebase/FirebaseUI-Android/blob/master/auth/src/main/java/com/firebase/ui/auth/ui/InvisibleActivityBase.java | Apache-2.0 |
protected void doAfterTimeout(Runnable runnable) {
long currentTime = System.currentTimeMillis();
long diff = currentTime - mLastShownTime;
// 'diff' is how long it's been since we showed the spinner, so in the
// case where diff is greater than our minimum spinner duration then our
// remaining wait time is 0.
long remaining = Math.max(MIN_SPINNER_MS - diff, 0);
mHandler.postDelayed(runnable, remaining);
} | For certain actions (like finishing or hiding the progress dialog) we want to make sure
that we have shown the progress state for at least MIN_SPINNER_MS to prevent flickering.
<p>
This method performs some action after the window has passed, or immediately if we have
already waited longer than that. | doAfterTimeout | java | firebase/FirebaseUI-Android | auth/src/main/java/com/firebase/ui/auth/ui/InvisibleFragmentBase.java | https://github.com/firebase/FirebaseUI-Android/blob/master/auth/src/main/java/com/firebase/ui/auth/ui/InvisibleFragmentBase.java | Apache-2.0 |
public void fetchCredential() {
// Build a sign-in request that supports password-based sign in,
// which will trigger the hint picker UI for email addresses.
SignInClient signInClient = Identity.getSignInClient(getApplication());
BeginSignInRequest signInRequest = BeginSignInRequest.builder()
.setPasswordRequestOptions(
BeginSignInRequest.PasswordRequestOptions.builder()
.setSupported(true)
.build())
.build();
signInClient.beginSignIn(signInRequest)
.addOnSuccessListener(result -> {
// The new API returns a PendingIntent to launch the hint picker.
PendingIntent pendingIntent = result.getPendingIntent();
setResult(Resource.forFailure(
new PendingIntentRequiredException(pendingIntent, RequestCodes.CRED_HINT)));
})
.addOnFailureListener(e -> {
Log.e(TAG, "beginSignIn failed", e);
setResult(Resource.forFailure(e));
});
} | Initiates a hint picker flow using the new Identity API.
This replaces the deprecated Credentials API call. | fetchCredential | java | firebase/FirebaseUI-Android | auth/src/main/java/com/firebase/ui/auth/ui/email/CheckEmailHandler.java | https://github.com/firebase/FirebaseUI-Android/blob/master/auth/src/main/java/com/firebase/ui/auth/ui/email/CheckEmailHandler.java | Apache-2.0 |
public void fetchProvider(final String email) {
setResult(Resource.forLoading());
ProviderUtils.fetchTopProvider(getAuth(), getArguments(), email)
.addOnCompleteListener(task -> {
if (task.isSuccessful()) {
setResult(Resource.forSuccess(
new User.Builder(task.getResult(), email).build()));
} else {
setResult(Resource.forFailure(task.getException()));
}
});
} | Fetches the top provider for the given email. | fetchProvider | java | firebase/FirebaseUI-Android | auth/src/main/java/com/firebase/ui/auth/ui/email/CheckEmailHandler.java | https://github.com/firebase/FirebaseUI-Android/blob/master/auth/src/main/java/com/firebase/ui/auth/ui/email/CheckEmailHandler.java | Apache-2.0 |
public void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
if (requestCode != RequestCodes.CRED_HINT || resultCode != Activity.RESULT_OK) {
return;
}
setResult(Resource.forLoading());
SignInClient signInClient = Identity.getSignInClient(getApplication());
try {
// Retrieve the SignInCredential from the returned intent.
SignInCredential credential = signInClient.getSignInCredentialFromIntent(data);
final String email = credential.getId();
ProviderUtils.fetchTopProvider(getAuth(), getArguments(), email)
.addOnCompleteListener(task -> {
if (task.isSuccessful()) {
setResult(Resource.forSuccess(new User.Builder(task.getResult(), email)
.setName(credential.getDisplayName())
.setPhotoUri(credential.getProfilePictureUri())
.build()));
} else {
setResult(Resource.forFailure(task.getException()));
}
});
} catch (ApiException e) {
Log.e(TAG, "getSignInCredentialFromIntent failed", e);
setResult(Resource.forFailure(e));
}
} | Handles the result from the hint picker launched via the new Identity API. | onActivityResult | java | firebase/FirebaseUI-Android | auth/src/main/java/com/firebase/ui/auth/ui/email/CheckEmailHandler.java | https://github.com/firebase/FirebaseUI-Android/blob/master/auth/src/main/java/com/firebase/ui/auth/ui/email/CheckEmailHandler.java | Apache-2.0 |
public void fetchCredential(final Activity activity) {
GetPhoneNumberHintIntentRequest request = GetPhoneNumberHintIntentRequest.builder().build();
Identity.getSignInClient(activity)
.getPhoneNumberHintIntent(request)
.addOnSuccessListener(result -> {
try {
// The new API returns an IntentSender.
IntentSender intentSender = result.getIntentSender();
// Update your exception to accept an IntentSender.
setResult(Resource.forFailure(new PendingIntentRequiredException(intentSender, RequestCodes.CRED_HINT)));
} catch (Exception e) {
Log.e(TAG, "Launching the IntentSender failed", e);
setResult(Resource.forFailure(e));
}
})
.addOnFailureListener(e -> {
Log.e(TAG, "Phone Number Hint failed", e);
setResult(Resource.forFailure(e));
});
} | Initiates the Phone Number Hint flow using the new API.
<p>This method creates a GetPhoneNumberHintIntentRequest and calls
Identity.getSignInClient(activity).getPhoneNumberHintIntent(request) to retrieve an
IntentSender. The IntentSender is then wrapped in a PendingIntentRequiredException so that
the caller can launch the hint flow.
<p><strong>Note:</strong> Update your PendingIntentRequiredException to accept an IntentSender
rather than a PendingIntent.
@param activity The activity used to retrieve the Phone Number Hint IntentSender. | fetchCredential | java | firebase/FirebaseUI-Android | auth/src/main/java/com/firebase/ui/auth/ui/phone/CheckPhoneHandler.java | https://github.com/firebase/FirebaseUI-Android/blob/master/auth/src/main/java/com/firebase/ui/auth/ui/phone/CheckPhoneHandler.java | Apache-2.0 |
public void onActivityResult(Activity activity, int requestCode, int resultCode, @Nullable Intent data) {
if (requestCode != RequestCodes.CRED_HINT || resultCode != Activity.RESULT_OK) {
return;
}
try {
String phoneNumber = Identity.getSignInClient(activity).getPhoneNumberFromIntent(data);
String formattedPhone = PhoneNumberUtils.formatUsingCurrentCountry(phoneNumber, getApplication());
if (formattedPhone != null) {
setResult(Resource.forSuccess(PhoneNumberUtils.getPhoneNumber(formattedPhone)));
} else {
setResult(Resource.forFailure(new Exception("Failed to format phone number")));
}
} catch (Exception e) {
Log.e(TAG, "Phone Number Hint failed", e);
setResult(Resource.forFailure(e));
}
} | Handles the result from the Phone Number Hint flow.
<p>Call this method from your Activity's onActivityResult. It extracts the phone number from the
returned Intent and formats it.
@param activity The activity used to process the returned Intent.
@param requestCode The request code (should match RequestCodes.CRED_HINT).
@param resultCode The result code from the hint flow.
@param data The Intent data returned from the hint flow. | onActivityResult | java | firebase/FirebaseUI-Android | auth/src/main/java/com/firebase/ui/auth/ui/phone/CheckPhoneHandler.java | https://github.com/firebase/FirebaseUI-Android/blob/master/auth/src/main/java/com/firebase/ui/auth/ui/phone/CheckPhoneHandler.java | Apache-2.0 |
@NonNull
public static CredentialData buildCredentialDataOrThrow(@NonNull FirebaseUser user,
@Nullable String password) {
CredentialData credentialData = buildCredentialData(user, password);
if (credentialData == null) {
throw new IllegalStateException("Unable to build credential data");
}
return credentialData;
} | Same as {@link #buildCredentialData(FirebaseUser, String)} but throws an exception if data cannot be built.
@param user the FirebaseUser.
@param password the password the user signed in with.
@return a non-null {@link CredentialData} instance.
@throws IllegalStateException if credential data cannot be constructed. | buildCredentialDataOrThrow | java | firebase/FirebaseUI-Android | auth/src/main/java/com/firebase/ui/auth/util/CredentialUtils.java | https://github.com/firebase/FirebaseUI-Android/blob/master/auth/src/main/java/com/firebase/ui/auth/util/CredentialUtils.java | Apache-2.0 |
@NonNull
public static <T> T checkNotNull(
@Nullable T val,
@NonNull String errorMessageTemplate,
@Nullable Object... errorMessageArgs) {
if (val == null) {
if (errorMessageArgs == null) {
throw new NullPointerException(errorMessageTemplate);
} else {
throw new NullPointerException(String.format(errorMessageTemplate, errorMessageArgs));
}
}
return val;
} | Ensures that the provided value is not null, and throws a {@link NullPointerException} if it
is null, with a message constructed from the provided error template and arguments. | checkNotNull | java | firebase/FirebaseUI-Android | auth/src/main/java/com/firebase/ui/auth/util/Preconditions.java | https://github.com/firebase/FirebaseUI-Android/blob/master/auth/src/main/java/com/firebase/ui/auth/util/Preconditions.java | Apache-2.0 |
public static void checkArgument(boolean expression, String errorMessage) {
if (!expression) {
throw new IllegalArgumentException(errorMessage);
}
} | Ensures the truth of an expression involving parameters to the calling method.
@param expression a boolean expression
@param errorMessage the exception message to use if the check fails
@throws IllegalArgumentException if {@code expression} is false | checkArgument | java | firebase/FirebaseUI-Android | auth/src/main/java/com/firebase/ui/auth/util/Preconditions.java | https://github.com/firebase/FirebaseUI-Android/blob/master/auth/src/main/java/com/firebase/ui/auth/util/Preconditions.java | Apache-2.0 |
public static String format(@NonNull String phoneNumber, @NonNull CountryInfo countryInfo) {
if (phoneNumber.startsWith("+")) {
return phoneNumber;
} else {
return "+"
+ String.valueOf(countryInfo.getCountryCode())
+ phoneNumber.replaceAll("[^\\d.]", "");
}
} | This method works as follow: <ol><li>When the android version is LOLLIPOP or greater, the
reliable {{@link android.telephony.PhoneNumberUtils#formatNumberToE164}} is used to
format.</li> <li>For lower versions, we construct a value with the input phone number
stripped of non numeric characters and prefix it with a "+" and country code</li> </ol>
@param phoneNumber that may or may not itself have country code
@param countryInfo must have locale with ISO 3166 2-letter code for country | format | java | firebase/FirebaseUI-Android | auth/src/main/java/com/firebase/ui/auth/util/data/PhoneNumberUtils.java | https://github.com/firebase/FirebaseUI-Android/blob/master/auth/src/main/java/com/firebase/ui/auth/util/data/PhoneNumberUtils.java | Apache-2.0 |
public static String generateRandomAlphaNumericString(int length) {
StringBuilder sb = new StringBuilder();
Random random = new Random();
for (int i = 0; i < length; i++) {
sb.append(VALID_CHARS.charAt(random.nextInt(length)));
}
return sb.toString();
} | Generates a random alpha numeric string.
@param length the desired length of the generated string.
@return a randomly generated string with the desired number of characters. | generateRandomAlphaNumericString | java | firebase/FirebaseUI-Android | auth/src/main/java/com/firebase/ui/auth/util/data/SessionUtils.java | https://github.com/firebase/FirebaseUI-Android/blob/master/auth/src/main/java/com/firebase/ui/auth/util/data/SessionUtils.java | Apache-2.0 |
public LiveData<O> getOperation() {
return mOperation;
} | Get the observable state of the operation. | getOperation | java | firebase/FirebaseUI-Android | auth/src/main/java/com/firebase/ui/auth/viewmodel/OperableViewModel.java | https://github.com/firebase/FirebaseUI-Android/blob/master/auth/src/main/java/com/firebase/ui/auth/viewmodel/OperableViewModel.java | Apache-2.0 |
public ProviderSignInBase<T> initWith(T args) {
super.init(args);
return this;
} | Just a convenience method that makes certain chaining logic easier. | initWith | java | firebase/FirebaseUI-Android | auth/src/main/java/com/firebase/ui/auth/viewmodel/ProviderSignInBase.java | https://github.com/firebase/FirebaseUI-Android/blob/master/auth/src/main/java/com/firebase/ui/auth/viewmodel/ProviderSignInBase.java | Apache-2.0 |
public void startSignIn(@NonNull final String email,
@NonNull final String password,
@NonNull final IdpResponse inputResponse,
@Nullable final AuthCredential credential) {
setResult(Resource.forLoading());
// Store the password before signing in so it can be used for later credential building
mPendingPassword = password;
// Build appropriate IDP response based on inputs
final IdpResponse outputResponse;
if (credential == null) {
// New credential for the email provider
outputResponse = new IdpResponse.Builder(
new User.Builder(EmailAuthProvider.PROVIDER_ID, email).build())
.build();
} else {
// New credential for an IDP (Phone or Social)
outputResponse = new IdpResponse.Builder(inputResponse.getUser())
.setPendingCredential(inputResponse.getCredentialForLinking())
.setToken(inputResponse.getIdpToken())
.setSecret(inputResponse.getIdpSecret())
.build();
}
final AuthOperationManager authOperationManager = AuthOperationManager.getInstance();
if (authOperationManager.canUpgradeAnonymous(getAuth(), getArguments())) {
final AuthCredential credToValidate = EmailAuthProvider.getCredential(email, password);
// Check to see if we need to link (for social providers with the same email)
if (AuthUI.SOCIAL_PROVIDERS.contains(inputResponse.getProviderType())) {
// Add the provider to the same account before triggering a merge failure.
authOperationManager.safeLink(credToValidate, credential, getArguments())
.addOnSuccessListener(result -> handleMergeFailure(credToValidate))
.addOnFailureListener(e -> setResult(Resource.forFailure(e)));
} else {
// The user has not tried to log in with a federated IDP containing the same email.
// In this case, we just need to verify that the credential they provided is valid.
// No linking is done for non-federated IDPs.
// A merge failure occurs because the account exists and the user is anonymous.
authOperationManager.validateCredential(credToValidate, getArguments())
.addOnCompleteListener(
task -> {
if (task.isSuccessful()) {
handleMergeFailure(credToValidate);
} else {
setResult(Resource.forFailure(task.getException()));
}
});
}
} else {
// Kick off the flow including signing in, linking accounts, and saving with SmartLock
getAuth().signInWithEmailAndPassword(email, password)
.continueWithTask(task -> {
// Forward task failure by asking for result
AuthResult result = task.getResult(Exception.class);
// Task succeeded, link user if necessary
if (credential == null) {
return Tasks.forResult(result);
} else {
return result.getUser()
.linkWithCredential(credential)
.continueWithTask(new ProfileMerger(outputResponse))
.addOnFailureListener(new TaskFailureLogger(TAG,
"linkWithCredential+merge failed."));
}
})
.addOnSuccessListener(result -> handleSuccess(outputResponse, result))
.addOnFailureListener(e -> setResult(Resource.forFailure(e)))
.addOnFailureListener(
new TaskFailureLogger(TAG, "signInWithEmailAndPassword failed."));
}
} | Kick off the sign-in process. | startSignIn | java | firebase/FirebaseUI-Android | auth/src/main/java/com/firebase/ui/auth/viewmodel/email/WelcomeBackPasswordHandler.java | https://github.com/firebase/FirebaseUI-Android/blob/master/auth/src/main/java/com/firebase/ui/auth/viewmodel/email/WelcomeBackPasswordHandler.java | Apache-2.0 |
public String getPendingPassword() {
return mPendingPassword;
} | Get the most recent pending password. | getPendingPassword | java | firebase/FirebaseUI-Android | auth/src/main/java/com/firebase/ui/auth/viewmodel/email/WelcomeBackPasswordHandler.java | https://github.com/firebase/FirebaseUI-Android/blob/master/auth/src/main/java/com/firebase/ui/auth/viewmodel/email/WelcomeBackPasswordHandler.java | Apache-2.0 |
@Override
public void onCreate() {
super.onCreate();
setTheme(R.style.FirebaseUI);
} | Used when Robolectric testing UI components which depend on the theme.s | onCreate | java | firebase/FirebaseUI-Android | auth/src/test/java/com/firebase/ui/auth/TestApplication.java | https://github.com/firebase/FirebaseUI-Android/blob/master/auth/src/test/java/com/firebase/ui/auth/TestApplication.java | Apache-2.0 |
public static <T, F> void setPrivateField(
T obj,
Class<T> objClass,
Class<F> fieldClass,
F fieldValue) {
Field targetField = null;
Field[] classFields = objClass.getDeclaredFields();
for (Field field : classFields) {
if (field.getType().equals(fieldClass)) {
if (targetField != null) {
throw new IllegalStateException("Class " + objClass + " has multiple fields of type " + fieldClass);
}
targetField = field;
}
}
if (targetField == null) {
throw new IllegalStateException("Class " + objClass + " has no fields of type " + fieldClass);
}
targetField.setAccessible(true);
try {
targetField.set(obj, fieldValue);
} catch (IllegalAccessException e) {
Log.w(TAG, "Error setting field", e);
}
} | Set a private, obfuscated field of an object.
@param obj the object to modify.
@param objClass the object's class.
@param fieldClass the class of the target field.
@param fieldValue the value to use for the field. | setPrivateField | java | firebase/FirebaseUI-Android | auth/src/test/java/com/firebase/ui/auth/testhelpers/TestHelper.java | https://github.com/firebase/FirebaseUI-Android/blob/master/auth/src/test/java/com/firebase/ui/auth/testhelpers/TestHelper.java | Apache-2.0 |
private void testSpacing(String expectedSpacedText, String expectedOriginalText,
SpacedEditText editText) {
final Editable editable = editText.getText();
final ScaleXSpan[] spans = editable.getSpans(0, editText.length(), ScaleXSpan.class);
assertEquals(expectedSpacedText, editable.toString());
assertEquals(expectedOriginalText, editText.getUnspacedText().toString());
for (ScaleXSpan span : spans) {
assertEquals(SPACING_PROPORTION, span.getScaleX());
final int spanStart = editable.getSpanStart(span);
final int spanEnd = editable.getSpanEnd(span);
assertEquals(" ", editable.toString().substring(spanStart, spanEnd));
}
} | 1. Tests whether the content is set to the expected value.
2. Tests whether the original content is set to the original value.
3. Tests that the styles applied have the expected proportion
4. Tests that the styles have been applied only on the spaces to preserve fonts appearance. | testSpacing | java | firebase/FirebaseUI-Android | auth/src/test/java/com/firebase/ui/auth/ui/phone/SpacedEditTextTest.java | https://github.com/firebase/FirebaseUI-Android/blob/master/auth/src/test/java/com/firebase/ui/auth/ui/phone/SpacedEditTextTest.java | Apache-2.0 |
@NonNull
@Override
public T parseSnapshot(@NonNull S snapshot) {
String id = getId(snapshot);
T result = mObjectCache.get(id);
if (result == null) {
T object = mParser.parseSnapshot(snapshot);
mObjectCache.put(id, object);
result = object;
}
return result;
} | Get a unique identifier for a snapshot, should not depend on snapshot content. | parseSnapshot | java | firebase/FirebaseUI-Android | common/src/main/java/com/firebase/ui/common/BaseCachingSnapshotParser.java | https://github.com/firebase/FirebaseUI-Android/blob/master/common/src/main/java/com/firebase/ui/common/BaseCachingSnapshotParser.java | Apache-2.0 |
@NonNull
public S getSnapshot(int index) {
return getSnapshots().get(index);
} | Returns the snapshot at the specified position in this list.
@param index index of the snapshot to return
@return the snapshot at the specified position in this list
@throws IndexOutOfBoundsException if the index is out of range (<tt>index < 0 || index
>= size()</tt>) | getSnapshot | java | firebase/FirebaseUI-Android | common/src/main/java/com/firebase/ui/common/BaseObservableSnapshotArray.java | https://github.com/firebase/FirebaseUI-Android/blob/master/common/src/main/java/com/firebase/ui/common/BaseObservableSnapshotArray.java | Apache-2.0 |
@CallSuper
@NonNull
public L addChangeEventListener(@NonNull L listener) {
Preconditions.checkNotNull(listener);
boolean wasListening = isListening();
mListeners.add(listener);
// Catch up new listener to existing state
for (int i = 0; i < size(); i++) {
listener.onChildChanged(ChangeEventType.ADDED, getSnapshot(i), i, -1);
}
if (mHasDataChanged) {
listener.onDataChanged();
}
if (!wasListening) { onCreate(); }
return listener;
} | Attach a {@link BaseChangeEventListener} to this array. The listener will receive one {@link
ChangeEventType#ADDED} event for each item that already exists in the array at the time of
attachment, a {@link BaseChangeEventListener#onDataChanged()} event if one has occurred, and
then receive all future child events.
<p>
If this is the first listener, {@link #onCreate()} will be called. | addChangeEventListener | java | firebase/FirebaseUI-Android | common/src/main/java/com/firebase/ui/common/BaseObservableSnapshotArray.java | https://github.com/firebase/FirebaseUI-Android/blob/master/common/src/main/java/com/firebase/ui/common/BaseObservableSnapshotArray.java | Apache-2.0 |
@CallSuper
public void removeChangeEventListener(@NonNull L listener) {
Preconditions.checkNotNull(listener);
boolean wasListening = isListening();
mListeners.remove(listener);
if (!isListening() && wasListening) { onDestroy(); }
} | Remove a listener from the array.
<p>
If no listeners remain, {@link #onDestroy()} will be called. | removeChangeEventListener | java | firebase/FirebaseUI-Android | common/src/main/java/com/firebase/ui/common/BaseObservableSnapshotArray.java | https://github.com/firebase/FirebaseUI-Android/blob/master/common/src/main/java/com/firebase/ui/common/BaseObservableSnapshotArray.java | Apache-2.0 |
@CallSuper
public void removeAllListeners() {
for (L listener : mListeners) {
removeChangeEventListener(listener);
}
} | Remove all listeners from the array and reset its state. | removeAllListeners | java | firebase/FirebaseUI-Android | common/src/main/java/com/firebase/ui/common/BaseObservableSnapshotArray.java | https://github.com/firebase/FirebaseUI-Android/blob/master/common/src/main/java/com/firebase/ui/common/BaseObservableSnapshotArray.java | Apache-2.0 |
@CallSuper
protected void onCreate() {} | Called when the {@link BaseObservableSnapshotArray} is active and should start listening to
the Firebase database. | onCreate | java | firebase/FirebaseUI-Android | common/src/main/java/com/firebase/ui/common/BaseObservableSnapshotArray.java | https://github.com/firebase/FirebaseUI-Android/blob/master/common/src/main/java/com/firebase/ui/common/BaseObservableSnapshotArray.java | Apache-2.0 |
@CallSuper
protected void onDestroy() {
mHasDataChanged = false;
getSnapshots().clear();
mCachingParser.clear();
} | Called when the {@link BaseObservableSnapshotArray} is inactive and should stop listening to
the Firebase database.
<p>
All data and saved state should also be cleared here. | onDestroy | java | firebase/FirebaseUI-Android | common/src/main/java/com/firebase/ui/common/BaseObservableSnapshotArray.java | https://github.com/firebase/FirebaseUI-Android/blob/master/common/src/main/java/com/firebase/ui/common/BaseObservableSnapshotArray.java | Apache-2.0 |
public boolean isListening() {
return !mListeners.isEmpty();
} | @return true if the array is listening for change events from the Firebase database, false
otherwise | isListening | java | firebase/FirebaseUI-Android | common/src/main/java/com/firebase/ui/common/BaseObservableSnapshotArray.java | https://github.com/firebase/FirebaseUI-Android/blob/master/common/src/main/java/com/firebase/ui/common/BaseObservableSnapshotArray.java | Apache-2.0 |
public boolean isListening(@NonNull L listener) {
return mListeners.contains(listener);
} | @return true if the provided listener is listening for changes | isListening | java | firebase/FirebaseUI-Android | common/src/main/java/com/firebase/ui/common/BaseObservableSnapshotArray.java | https://github.com/firebase/FirebaseUI-Android/blob/master/common/src/main/java/com/firebase/ui/common/BaseObservableSnapshotArray.java | Apache-2.0 |
@NonNull
@Override
public String getId(@NonNull DataSnapshot snapshot) {
return snapshot.getKey();
} | Implementation of {@link BaseCachingSnapshotParser} for {@link DataSnapshot}. | getId | java | firebase/FirebaseUI-Android | database/src/main/java/com/firebase/ui/database/CachingSnapshotParser.java | https://github.com/firebase/FirebaseUI-Android/blob/master/database/src/main/java/com/firebase/ui/database/CachingSnapshotParser.java | Apache-2.0 |
@Nullable
@Override
public T parseSnapshot(@NonNull DataSnapshot snapshot) {
// In FirebaseUI controlled usages, we can guarantee that our getValue calls will be nonnull
// because we check for nullity with ValueEventListeners and use ChildEventListeners.
// However, since this API is public, devs could use it for any snapshot including null
// ones. Hence the nullability discrepancy.
return snapshot.getValue(mClass);
} | A convenience implementation of {@link SnapshotParser} that converts a {@link DataSnapshot} to
the parametrized class via {@link DataSnapshot#getValue(Class)}.
@param <T> the POJO class to create from snapshots. | parseSnapshot | java | firebase/FirebaseUI-Android | database/src/main/java/com/firebase/ui/database/ClassSnapshotParser.java | https://github.com/firebase/FirebaseUI-Android/blob/master/database/src/main/java/com/firebase/ui/database/ClassSnapshotParser.java | Apache-2.0 |
@LayoutRes
public int getLayout() {
return mLayout;
} | Get the resource ID of the layout file for a list item. | getLayout | java | firebase/FirebaseUI-Android | database/src/main/java/com/firebase/ui/database/FirebaseListOptions.java | https://github.com/firebase/FirebaseUI-Android/blob/master/database/src/main/java/com/firebase/ui/database/FirebaseListOptions.java | Apache-2.0 |
@NonNull
public Builder<T> setSnapshotArray(@NonNull ObservableSnapshotArray<T> snapshots) {
assertNull(mSnapshots, ERR_SNAPSHOTS_SET);
mSnapshots = snapshots;
return this;
} | Directly set the {@link ObservableSnapshotArray} to observe.
<p>
Do not call this method after calling {@code setQuery}. | setSnapshotArray | java | firebase/FirebaseUI-Android | database/src/main/java/com/firebase/ui/database/FirebaseListOptions.java | https://github.com/firebase/FirebaseUI-Android/blob/master/database/src/main/java/com/firebase/ui/database/FirebaseListOptions.java | Apache-2.0 |
@NonNull
public Builder<T> setQuery(@NonNull Query query, @NonNull SnapshotParser<T> parser) {
assertNull(mSnapshots, ERR_SNAPSHOTS_SET);
mSnapshots = new FirebaseArray<>(query, parser);
return this;
} | Set the query to listen on and a {@link SnapshotParser} to parse data snapshots.
<p>
Do not call this method after calling {@link #setSnapshotArray(ObservableSnapshotArray)}. | setQuery | java | firebase/FirebaseUI-Android | database/src/main/java/com/firebase/ui/database/FirebaseListOptions.java | https://github.com/firebase/FirebaseUI-Android/blob/master/database/src/main/java/com/firebase/ui/database/FirebaseListOptions.java | Apache-2.0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.