Skip to content

Commit 930af6c

Browse files
authored
Merge pull request #2030 from firebase/version-8.0.1
Version 8.0.1 release
2 parents 980d0cc + 50779e5 commit 930af6c

File tree

9 files changed

+164
-16
lines changed

9 files changed

+164
-16
lines changed

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,16 +48,16 @@ libraries.
4848
```groovy
4949
dependencies {
5050
// FirebaseUI for Firebase Realtime Database
51-
implementation 'com.firebaseui:firebase-ui-database:8.0.0'
51+
implementation 'com.firebaseui:firebase-ui-database:8.0.1'
5252
5353
// FirebaseUI for Cloud Firestore
54-
implementation 'com.firebaseui:firebase-ui-firestore:8.0.0'
54+
implementation 'com.firebaseui:firebase-ui-firestore:8.0.1'
5555
5656
// FirebaseUI for Firebase Auth
57-
implementation 'com.firebaseui:firebase-ui-auth:8.0.0'
57+
implementation 'com.firebaseui:firebase-ui-auth:8.0.1'
5858
5959
// FirebaseUI for Cloud Storage
60-
implementation 'com.firebaseui:firebase-ui-storage:8.0.0'
60+
implementation 'com.firebaseui:firebase-ui-storage:8.0.1'
6161
}
6262
```
6363

auth/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ Gradle, add the dependency:
6565
```groovy
6666
dependencies {
6767
// ...
68-
implementation 'com.firebaseui:firebase-ui-auth:8.0.0'
68+
implementation 'com.firebaseui:firebase-ui-auth:8.0.1'
6969
7070
// Required only if Facebook login support is required
7171
// Find the latest Facebook SDK releases here: https://github.com/facebook/facebook-android-sdk/blob/master/CHANGELOG.md

auth/src/main/java/com/firebase/ui/auth/ui/phone/CountryListSpinner.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ public CountryListSpinner(Context context, AttributeSet attrs, int defStyle) {
8686
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
8787
CountryInfo info = mCountryListAdapter.getItem(position);
8888
if (info != null) {
89-
setText(info.toShortString());
89+
setSelectedForCountry(info.getCountryCode(), info.getLocale());
9090
}
9191

9292
onUnfocus();

buildSrc/src/main/kotlin/Config.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
object Config {
2-
const val version = "8.0.0"
2+
const val version = "8.0.1"
33
val submodules = listOf("auth", "common", "firestore", "database", "storage")
44

55
private const val kotlinVersion = "1.3.72"

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,13 @@ public Single<LoadResult<String, DataSnapshot>> loadSingle(@NonNull LoadParams<S
8888
details).toException();
8989
}
9090
} catch (ExecutionException e) {
91-
throw new Exception(e.getCause());
91+
if (e.getCause() instanceof Exception) {
92+
// throw the original Exception
93+
throw (Exception) e.getCause();
94+
}
95+
// Only throw a new Exception when the original
96+
// Throwable cannot be cast to Exception
97+
throw new Exception(e);
9298
}
9399
}).subscribeOn(Schedulers.io()).onErrorReturn(LoadResult.Error::new);
94100
}
Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
package com.firebase.ui.firestore.paging;
2+
3+
import com.google.android.gms.tasks.Tasks;
4+
import com.google.firebase.firestore.DocumentSnapshot;
5+
import com.google.firebase.firestore.Query;
6+
import com.google.firebase.firestore.QuerySnapshot;
7+
import com.google.firebase.firestore.Source;
8+
9+
import org.junit.Before;
10+
import org.junit.Test;
11+
import org.junit.runner.RunWith;
12+
import org.mockito.Mock;
13+
import org.mockito.MockitoAnnotations;
14+
15+
import java.util.ArrayList;
16+
import java.util.List;
17+
18+
import androidx.paging.PagingSource;
19+
import androidx.paging.PagingSource.LoadParams.Append;
20+
import androidx.paging.PagingSource.LoadParams.Refresh;
21+
import androidx.paging.PagingSource.LoadResult.Page;
22+
import androidx.test.ext.junit.runners.AndroidJUnit4;
23+
24+
import static org.junit.Assert.assertEquals;
25+
import static org.junit.Assert.assertTrue;
26+
import static org.mockito.ArgumentMatchers.any;
27+
import static org.mockito.ArgumentMatchers.anyLong;
28+
import static org.mockito.Mockito.mock;
29+
import static org.mockito.Mockito.when;
30+
31+
@RunWith(AndroidJUnit4.class)
32+
public class FirestorePagingSourceTest {
33+
34+
@Mock
35+
Query mMockQuery;
36+
37+
ArrayList<DocumentSnapshot> mMockSnapshots = new ArrayList<>();
38+
Exception mMockException = new Exception("Could not load Data");
39+
40+
@Before
41+
public void setUp() {
42+
MockitoAnnotations.initMocks(this);
43+
initMockQuery();
44+
45+
for (int i = 0; i < 2; i++) {
46+
mMockSnapshots.add(mock(DocumentSnapshot.class));
47+
}
48+
}
49+
50+
@Test
51+
public void testLoadInitial_success() {
52+
FirestorePagingSource pagingSource = new FirestorePagingSource(mMockQuery, Source.DEFAULT);
53+
mockQuerySuccess(mMockSnapshots);
54+
Page<PageKey, DocumentSnapshot> expected = new Page<>(mMockSnapshots, null, new PageKey(null, null));
55+
56+
Refresh<PageKey> refreshRequest = new Refresh<>(null, 2, false);
57+
PagingSource.LoadResult<PageKey, DocumentSnapshot> actual =
58+
pagingSource.loadSingle(refreshRequest).blockingGet();
59+
60+
assertTrue(actual instanceof Page);
61+
assertEquals(expected, actual);
62+
}
63+
64+
@Test
65+
public void testLoadInitial_failure() {
66+
FirestorePagingSource pagingSource = new FirestorePagingSource(mMockQuery, Source.DEFAULT);
67+
mockQueryFailure(mMockException);
68+
PagingSource.LoadResult.Error<PageKey, DocumentSnapshot> expected =
69+
new PagingSource.LoadResult.Error<>(mMockException);
70+
71+
Refresh<PageKey> refreshRequest = new Refresh<>(null, 2, false);
72+
PagingSource.LoadResult<PageKey, DocumentSnapshot> actual =
73+
pagingSource.loadSingle(refreshRequest).blockingGet();
74+
75+
assertEquals(expected, actual);
76+
}
77+
78+
@Test
79+
public void testLoadAfter_success() {
80+
FirestorePagingSource pagingSource = new FirestorePagingSource(mMockQuery, Source.DEFAULT);
81+
mockQuerySuccess(mMockSnapshots);
82+
PageKey pageKey = new PageKey(null, null);
83+
Page<PageKey, DocumentSnapshot> expected = new Page<>(mMockSnapshots, null, pageKey);
84+
85+
Append<PageKey> appendRequest = new Append<>(pageKey, 2, false);
86+
PagingSource.LoadResult<PageKey, DocumentSnapshot> actual =
87+
pagingSource.loadSingle(appendRequest).blockingGet();
88+
89+
assertTrue(actual instanceof Page);
90+
assertEquals(expected, actual);
91+
}
92+
93+
@Test
94+
public void testLoadAfter_failure() {
95+
FirestorePagingSource pagingSource = new FirestorePagingSource(mMockQuery, Source.DEFAULT);
96+
mockQueryFailure(mMockException);
97+
PageKey pageKey = new PageKey(null, null);
98+
PagingSource.LoadResult.Error<PageKey, DocumentSnapshot> expected =
99+
new PagingSource.LoadResult.Error<>(mMockException);
100+
101+
Append<PageKey> appendRequest = new Append<>(pageKey, 2, false);
102+
PagingSource.LoadResult<PageKey, DocumentSnapshot> actual =
103+
pagingSource.loadSingle(appendRequest).blockingGet();
104+
105+
assertEquals(expected, actual);
106+
}
107+
108+
private void initMockQuery() {
109+
when(mMockQuery.startAfter(any(DocumentSnapshot.class))).thenReturn(mMockQuery);
110+
when(mMockQuery.endBefore(any(DocumentSnapshot.class))).thenReturn(mMockQuery);
111+
when(mMockQuery.limit(anyLong())).thenReturn(mMockQuery);
112+
}
113+
114+
private void mockQuerySuccess(List<DocumentSnapshot> snapshots) {
115+
QuerySnapshot mockSnapshot = mock(QuerySnapshot.class);
116+
when(mockSnapshot.getDocuments()).thenReturn(snapshots);
117+
118+
when(mMockQuery.get(Source.DEFAULT)).thenReturn(Tasks.forResult(mockSnapshot));
119+
}
120+
121+
private void mockQueryFailure(Exception exception) {
122+
when(mMockQuery.get(Source.DEFAULT)).thenReturn(Tasks.forException(exception));
123+
}
124+
}

firestore/src/main/java/com/firebase/ui/firestore/paging/FirestorePagingSource.java

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,13 @@
88
import com.google.firebase.firestore.Source;
99

1010
import java.util.List;
11-
import java.util.concurrent.Callable;
11+
import java.util.concurrent.ExecutionException;
1212

1313
import androidx.annotation.NonNull;
1414
import androidx.annotation.Nullable;
1515
import androidx.paging.PagingState;
1616
import androidx.paging.rxjava3.RxPagingSource;
1717
import io.reactivex.rxjava3.core.Single;
18-
import io.reactivex.rxjava3.functions.Function;
1918
import io.reactivex.rxjava3.schedulers.Schedulers;
2019

2120
public class FirestorePagingSource extends RxPagingSource<PageKey, DocumentSnapshot> {
@@ -39,18 +38,24 @@ public Single<LoadResult<PageKey, DocumentSnapshot>> loadSingle(@NonNull LoadPar
3938
}
4039

4140
return Single.fromCallable(() -> {
42-
Tasks.await(task);
43-
if (task.isSuccessful()) {
41+
try {
42+
Tasks.await(task);
4443
QuerySnapshot snapshot = task.getResult();
4544
PageKey nextPage = getNextPageKey(snapshot);
4645
if (snapshot.getDocuments().isEmpty()) {
4746
return toLoadResult(snapshot.getDocuments(), null);
4847
}
4948
return toLoadResult(snapshot.getDocuments(), nextPage);
49+
} catch (ExecutionException e) {
50+
if (e.getCause() instanceof Exception) {
51+
// throw the original Exception
52+
throw (Exception) e.getCause();
53+
}
54+
// Only throw a new Exception when the original
55+
// Throwable cannot be cast to Exception
56+
throw new Exception(e);
5057
}
51-
throw task.getException();
52-
}).subscribeOn(Schedulers.io())
53-
.onErrorReturn(throwable -> new LoadResult.Error<>(throwable));
58+
}).subscribeOn(Schedulers.io()).onErrorReturn(LoadResult.Error::new);
5459
}
5560

5661
private LoadResult<PageKey, DocumentSnapshot> toLoadResult(

firestore/src/main/java/com/firebase/ui/firestore/paging/PageKey.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,19 @@ public Query getPageQuery(@NonNull Query baseQuery, int size) {
3838
return pageQuery;
3939
}
4040

41+
@Override
42+
public boolean equals(Object o) {
43+
if (this == o) return true;
44+
if (o == null || getClass() != o.getClass()) return false;
45+
PageKey key = (PageKey) o;
46+
if (mStartAfter == null && key.mStartAfter == null)
47+
return true;
48+
if (mEndBefore == null && key.mEndBefore == null)
49+
return true;
50+
return mStartAfter.getId() == key.mStartAfter.getId() &&
51+
mEndBefore.getId() == key.mEndBefore.getId();
52+
}
53+
4154
@Override
4255
@NonNull
4356
public String toString() {

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ android.useAndroidX=true
66
android.enableJetifier=true
77

88
GROUP=com.firebaseui
9-
VERSION_NAME=8.0.0
9+
VERSION_NAME=8.0.1
1010

1111
POM_PACKAGING=aar
1212
POM_DESCRIPTION=FirebaseUI for Android

0 commit comments

Comments
 (0)