@@ -80,7 +80,7 @@ public void loadPrevPage() {
80
80
int lastUnloadedBefore = findLastOfState (PageState .UNLOADED , firstLoaded );
81
81
82
82
if (lastUnloadedBefore != -1 ) {
83
- Log . d ( TAG , "RELOADING " + lastUnloadedBefore );
83
+ logd ( "RELOADING " + lastUnloadedBefore );
84
84
85
85
Page page = mPages .get (lastUnloadedBefore );
86
86
DocumentSnapshot endBefore = getFirstOfPage (lastUnloadedBefore + 1 );
@@ -122,15 +122,15 @@ public void loadNextPage() {
122
122
Page nextPage = new Page (nextPageIndex );
123
123
mPages .add (nextPage );
124
124
125
- Log . d ( TAG , "LOADING " + nextPageIndex );
125
+ logd ( "LOADING " + nextPageIndex );
126
126
Query nextQuery = queryAfter (lastSnapshot );
127
127
nextPage .load (nextQuery );
128
128
} else {
129
129
// Case 2: Need to load a previously unloaded page
130
130
// Find the first UNLOADED page after the middle "core" of loaded pages
131
131
int firstUnloadedAfter = findFirstOfState (PageState .UNLOADED , lastLoaded );
132
132
133
- Log . d ( TAG , "RELOADING " + firstUnloadedAfter );
133
+ logd ( "RELOADING " + firstUnloadedAfter );
134
134
Page page = mPages .get (firstUnloadedAfter );
135
135
DocumentSnapshot endBefore = getFirstOfPage (firstUnloadedAfter + 1 );
136
136
Query query = queryBetween (page .getFirst (), endBefore );
@@ -185,15 +185,15 @@ private void unloadTopPage() {
185
185
int firstLoaded = findFirstOfState (PageState .LOADED );
186
186
if (firstLoaded != -1 ) {
187
187
mPages .get (firstLoaded ).unload ();
188
- Log . d ( TAG , "UNLOADING " + firstLoaded );
188
+ logd ( "UNLOADING " + firstLoaded );
189
189
}
190
190
}
191
191
192
192
private void unloadBottomPage () {
193
193
int lastLoaded = findLastOfState (PageState .LOADED );
194
194
if (lastLoaded != -1 ) {
195
195
mPages .get (lastLoaded ).unload ();
196
- Log . d ( TAG , "UNLOADING " + lastLoaded );
196
+ logd ( "UNLOADING " + lastLoaded );
197
197
}
198
198
}
199
199
@@ -304,6 +304,12 @@ private Query queryAfter(@Nullable DocumentSnapshot startAfter) {
304
304
return query ;
305
305
}
306
306
307
+ private void logd (String message ) {
308
+ if (Log .isLoggable (TAG , Log .DEBUG )) {
309
+ Log .d (TAG , message );
310
+ }
311
+ }
312
+
307
313
private enum PageState {
308
314
LOADING ,
309
315
LOADED ,
@@ -359,7 +365,7 @@ public void onComplete(@NonNull Task<QuerySnapshot> task) {
359
365
}
360
366
361
367
// Mark page as loaded
362
- Log . d ( TAG , "LOADED " + mIndex );
368
+ logd ( "LOADED " + mIndex );
363
369
mState = PageState .LOADED ;
364
370
onPageLoaded (mIndex , mSnapshots .size ());
365
371
}
0 commit comments