Skip to content

Commit 2a5f554

Browse files
committed
Make lint pass
Change-Id: I2264ada2d13cf9c667680f3a278f7b5e2edf0cb0
1 parent 6af779c commit 2a5f554

File tree

3 files changed

+18
-9
lines changed

3 files changed

+18
-9
lines changed

app/src/main/res/layout/activity_firestore_paging.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212
android:layout_width="match_parent"
1313
android:layout_height="wrap_content"
1414
android:layout_marginTop="-6dp"
15-
android:background="@android:color/transparent" />
15+
android:background="@android:color/transparent"
16+
tools:ignore="NegativeMargin" />
1617

1718
<android.support.v7.widget.RecyclerView
1819
android:id="@+id/paging_recycler"

app/src/main/res/layout/item_item.xml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,19 @@
44
xmlns:tools="http://schemas.android.com/tools"
55
android:layout_width="match_parent"
66
android:layout_height="wrap_content"
7+
android:layout_marginBottom="8dp"
78
android:paddingLeft="16dp"
89
android:paddingRight="16dp"
9-
android:paddingBottom="8dp"
1010
android:paddingTop="8dp"
11-
android:layout_marginBottom="8dp"
11+
android:paddingBottom="8dp"
1212
android:background="@drawable/ic_chat_message_background"
1313
android:orientation="vertical">
1414

1515
<TextView
1616
android:id="@+id/item_text"
1717
android:layout_width="wrap_content"
1818
android:layout_height="wrap_content"
19+
android:textIsSelectable="false"
1920
android:textSize="16sp"
2021
android:textStyle="bold"
2122
tools:text="My Text" />
@@ -24,6 +25,7 @@
2425
android:id="@+id/item_value"
2526
android:layout_width="wrap_content"
2627
android:layout_height="wrap_content"
28+
android:textIsSelectable="false"
2729
android:textSize="12sp"
2830
tools:text="1234" />
2931

firestore/src/main/java/com/firebase/ui/firestore/FirestorePagingAdapter.java

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ public void loadPrevPage() {
8080
int lastUnloadedBefore = findLastOfState(PageState.UNLOADED, firstLoaded);
8181

8282
if (lastUnloadedBefore != -1) {
83-
Log.d(TAG, "RELOADING " + lastUnloadedBefore);
83+
logd("RELOADING " + lastUnloadedBefore);
8484

8585
Page page = mPages.get(lastUnloadedBefore);
8686
DocumentSnapshot endBefore = getFirstOfPage(lastUnloadedBefore + 1);
@@ -122,15 +122,15 @@ public void loadNextPage() {
122122
Page nextPage = new Page(nextPageIndex);
123123
mPages.add(nextPage);
124124

125-
Log.d(TAG, "LOADING " + nextPageIndex);
125+
logd("LOADING " + nextPageIndex);
126126
Query nextQuery = queryAfter(lastSnapshot);
127127
nextPage.load(nextQuery);
128128
} else {
129129
// Case 2: Need to load a previously unloaded page
130130
// Find the first UNLOADED page after the middle "core" of loaded pages
131131
int firstUnloadedAfter = findFirstOfState(PageState.UNLOADED, lastLoaded);
132132

133-
Log.d(TAG, "RELOADING " + firstUnloadedAfter);
133+
logd("RELOADING " + firstUnloadedAfter);
134134
Page page = mPages.get(firstUnloadedAfter);
135135
DocumentSnapshot endBefore = getFirstOfPage(firstUnloadedAfter + 1);
136136
Query query = queryBetween(page.getFirst(), endBefore);
@@ -185,15 +185,15 @@ private void unloadTopPage() {
185185
int firstLoaded = findFirstOfState(PageState.LOADED);
186186
if (firstLoaded != -1) {
187187
mPages.get(firstLoaded).unload();
188-
Log.d(TAG, "UNLOADING " + firstLoaded);
188+
logd("UNLOADING " + firstLoaded);
189189
}
190190
}
191191

192192
private void unloadBottomPage() {
193193
int lastLoaded = findLastOfState(PageState.LOADED);
194194
if (lastLoaded != -1) {
195195
mPages.get(lastLoaded).unload();
196-
Log.d(TAG, "UNLOADING " + lastLoaded);
196+
logd("UNLOADING " + lastLoaded);
197197
}
198198
}
199199

@@ -304,6 +304,12 @@ private Query queryAfter(@Nullable DocumentSnapshot startAfter) {
304304
return query;
305305
}
306306

307+
private void logd(String message) {
308+
if (Log.isLoggable(TAG, Log.DEBUG)) {
309+
Log.d(TAG, message);
310+
}
311+
}
312+
307313
private enum PageState {
308314
LOADING,
309315
LOADED,
@@ -359,7 +365,7 @@ public void onComplete(@NonNull Task<QuerySnapshot> task) {
359365
}
360366

361367
// Mark page as loaded
362-
Log.d(TAG, "LOADED " + mIndex);
368+
logd("LOADED " + mIndex);
363369
mState = PageState.LOADED;
364370
onPageLoaded(mIndex, mSnapshots.size());
365371
}

0 commit comments

Comments
 (0)