Skip to content

Commit 73bb73c

Browse files
authored
refactor: update Firebase BoM (26.5.0) and replace singleValueEventListener with Query.get() (#1912)
1 parent c7f188d commit 73bb73c

File tree

4 files changed

+20
-19
lines changed

4 files changed

+20
-19
lines changed

auth/src/test/java/com/firebase/ui/auth/viewmodel/GenericIdpSignInHandlerTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ public void testStartSignIn_normalSignInFlowWithRecoverableError_expectFailure()
152152
.build();
153153
FirebaseAuthUserCollisionException collisionException
154154
= new FirebaseAuthUserCollisionException("foo", "bar");
155-
collisionException.zza(EMAIL).zza(credential);
155+
collisionException.zza(EMAIL).zzb(credential);
156156

157157
when(mMockAuth.startActivityForSignInWithProvider(any(Activity.class), any(OAuthProvider.class)))
158158
.thenReturn(AutoCompleteTask.<AuthResult>forFailure(collisionException));
@@ -256,7 +256,7 @@ public void testStartSignIn_anonymousUpgradeFlowWithConflict_expectRecoverableEr
256256
.build();
257257
FirebaseAuthUserCollisionException collisionException
258258
= new FirebaseAuthUserCollisionException("foo", "bar");
259-
collisionException.zza(EMAIL).zza(credential);
259+
collisionException.zza(EMAIL).zzb(credential);
260260
when(mMockAuth.getCurrentUser().startActivityForLinkWithProvider(
261261
any(Activity.class), any(OAuthProvider.class)))
262262
.thenReturn(AutoCompleteTask.<AuthResult>forFailure(collisionException));
@@ -300,7 +300,7 @@ public void testStartSignIn_anonymousUpgradeFlowWithConflict_expectRecoverableLi
300300
.build();
301301
FirebaseAuthUserCollisionException collisionException
302302
= new FirebaseAuthUserCollisionException("foo", "bar");
303-
collisionException.zza(EMAIL).zza(credential);
303+
collisionException.zza(EMAIL).zzb(credential);
304304

305305
when(mMockAuth.getCurrentUser().startActivityForLinkWithProvider(
306306
any(Activity.class), any(OAuthProvider.class)))

auth/src/test/java/com/firebase/ui/auth/viewmodel/PhoneProviderResponseHandlerTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public class PhoneProviderResponseHandlerTest {
4949

5050
@Mock FirebaseAuth mMockAuth;
5151
@Mock FirebaseUser mMockUser;
52-
@Mock PhoneAuthCredential mCredential;
52+
PhoneAuthCredential mCredential;
5353
@Mock Observer<Resource<IdpResponse>> mResponseObserver;
5454

5555
private PhoneProviderResponseHandler mHandler;
@@ -58,6 +58,7 @@ public class PhoneProviderResponseHandlerTest {
5858
public void setUp() {
5959
TestHelper.initialize();
6060
MockitoAnnotations.initMocks(this);
61+
mCredential = PhoneAuthCredential.zzb("sessionInfo", "SmsCode");
6162

6263
mHandler = new PhoneProviderResponseHandler((Application) ApplicationProvider.getApplicationContext());
6364
FlowParameters testParams = TestHelper.getFlowParameters(Collections.singletonList(

buildSrc/src/main/kotlin/Config.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ object Config {
4444
}
4545

4646
object Firebase {
47-
const val bom = "com.google.firebase:firebase-bom:26.0.0"
47+
const val bom = "com.google.firebase:firebase-bom:26.5.0"
4848
const val auth = "com.google.firebase:firebase-auth"
4949
const val database = "com.google.firebase:firebase-database"
5050
const val firestore = "com.google.firebase:firebase-firestore"

database/src/main/java/com/firebase/ui/database/paging/FirebaseDataSource.java

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@
33
import android.annotation.SuppressLint;
44
import android.util.Log;
55

6+
import com.google.android.gms.tasks.OnFailureListener;
7+
import com.google.android.gms.tasks.OnSuccessListener;
68
import com.google.firebase.database.DataSnapshot;
79
import com.google.firebase.database.DatabaseError;
810
import com.google.firebase.database.Query;
9-
import com.google.firebase.database.ValueEventListener;
1011

1112
import java.util.ArrayList;
1213
import java.util.Iterator;
@@ -69,9 +70,9 @@ public void loadInitial(@NonNull final LoadInitialParams<String> params,
6970
mLoadingState.postValue(LoadingState.LOADING_INITIAL);
7071

7172
Query mInitQuery = mQuery.limitToFirst(params.requestedLoadSize);
72-
mInitQuery.addListenerForSingleValueEvent(new ValueEventListener() {
73+
mInitQuery.get().addOnSuccessListener(new OnSuccessListener<DataSnapshot>() {
7374
@Override
74-
public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
75+
public void onSuccess(DataSnapshot dataSnapshot) {
7576
if (dataSnapshot.exists()) {
7677

7778
//Make List of DataSnapshot
@@ -95,11 +96,11 @@ public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
9596
setDatabaseNotFoundError();
9697
}
9798
}
98-
99+
}).addOnFailureListener(new OnFailureListener() {
99100
@Override
100-
public void onCancelled(@NonNull DatabaseError databaseError) {
101+
public void onFailure(@NonNull Exception e) {
101102
mRetryRunnable = getRetryLoadInitial(params, callback);
102-
setError(databaseError);
103+
setError(e);
103104
}
104105
});
105106
}
@@ -118,9 +119,9 @@ public void loadAfter(@NonNull final LoadParams<String> params,
118119

119120
//Load params.requestedLoadSize+1 because, first data item is getting ignored.
120121
Query mNewQuery = mQuery.startAt(null, params.key).limitToFirst(params.requestedLoadSize + 1);
121-
mNewQuery.addListenerForSingleValueEvent(new ValueEventListener() {
122+
mNewQuery.get().addOnSuccessListener(new OnSuccessListener<DataSnapshot>() {
122123
@Override
123-
public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
124+
public void onSuccess(DataSnapshot dataSnapshot) {
124125
if (dataSnapshot.exists()) {
125126

126127
//Make List of DataSnapshot
@@ -157,13 +158,12 @@ public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
157158
mRetryRunnable = getRetryLoadAfter(params, callback);
158159
setDatabaseNotFoundError();
159160
}
160-
161161
}
162-
162+
}).addOnFailureListener(new OnFailureListener() {
163163
@Override
164-
public void onCancelled(@NonNull DatabaseError databaseError) {
164+
public void onFailure(@NonNull Exception e) {
165165
mRetryRunnable = getRetryLoadAfter(params, callback);
166-
setError(databaseError);
166+
setError(e);
167167
}
168168
});
169169
}
@@ -229,8 +229,8 @@ private void setDatabaseNotFoundError(){
229229
mLoadingState.postValue(LoadingState.ERROR);
230230
}
231231

232-
private void setError(DatabaseError databaseError){
233-
mError.postValue(databaseError);
232+
private void setError(Exception e){
233+
mError.postValue(DatabaseError.fromException(e));
234234
mLoadingState.postValue(LoadingState.ERROR);
235235
}
236236

0 commit comments

Comments
 (0)