question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

onLoadMoreComplete(null) call from noMoreLoad() cause infinite loop

See original GitHub issue

According to documentation of onLoadMoreComplete(@Nullable List<T> newItems)

When noMoreLoad OR onError OR onCancel, pass empty list or null to hide the progressItem.

If null or empty list is passed in onLoadMoreComplete() the last if clause is executed and noMoreLoad is called again.

v5.0.0-rc1

public void onLoadMoreComplete(@Nullable List<T> newItems, @IntRange(from = -1) long delay) {
		// 1. Calculate new items count
		int newItemsSize = newItems == null ? 0 : newItems.size();
		int totalItemCount = newItemsSize + getMainItemCount();
		// 2. Add any new items
		if (newItemsSize > 0) {
			if (DEBUG)
				Log.v(TAG, "onLoadMore     performing adding " + newItemsSize + " new items on Page=" + getEndlessCurrentPage());
			//TODO: 0 + headers for Endless Top Scrolling
			addItems(getGlobalPositionOf(mProgressItem), newItems);
		}
		// 3. Check if features are enabled and the limits have been reached
		if (mEndlessPageSize > 0 && newItemsSize < mEndlessPageSize || // Is feature enabled and Not enough items?
				mEndlessTargetCount > 0 && totalItemCount >= mEndlessTargetCount) { // Is feature enabled and Max limit has been reached?
			// Disable the EndlessScroll feature
			setEndlessProgressItem(null);
		}
		// 4. Remove the progressItem if needed
		if (delay > 0 && (newItemsSize == 0 || !isEndlessScrollEnabled())) {
			if (DEBUG)
				Log.v(TAG, "onLoadMore     enqueued removing progressItem (" + delay + "ms)");
			mHandler.sendEmptyMessageDelayed(LOAD_MORE_COMPLETE, delay);
		} else if (isEndlessScrollEnabled()) {
			hideProgressItem();
		}
		// 5. Reset the loading status
		endlessLoading = false;
		// 6. Eventually notify noMoreLoad
		if (newItemsSize == 0 || !isEndlessScrollEnabled()) {
			noMoreLoad(newItemsSize);
		}
	}

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
KyrychenkoOleksandrcommented, Feb 17, 2017

@davideas progressItem is not automatically hidden inside void onLoadMoreComplete(@Nullable List<T> newItems, @IntRange(from = -1) long delay)

// 3. Check if features are enabled and the limits have been reached
		if (mEndlessPageSize > 0 && newItemsSize < mEndlessPageSize || // Is feature enabled and Not enough items?
				mEndlessTargetCount > 0 && totalItemCount >= mEndlessTargetCount) { // Is feature enabled and Max limit has been reached?
			// Disable the EndlessScroll feature
			setEndlessProgressItem(null);
		}

setEndlessProgressItem(null); is called. inside

public FlexibleAdapter setEndlessProgressItem(@Nullable T progressItem) {
		endlessScrollEnabled = progressItem != null;
		if (progressItem != null) {
			setEndlessScrollThreshold(mEndlessScrollThreshold);
			mProgressItem = progressItem;
			if (DEBUG) {
				Log.i(TAG, "Set progressItem=" + getClassName(progressItem));
				Log.i(TAG, "Enabled EndlessScrolling");
			}
		} else if (DEBUG) {
			Log.i(TAG, "Disabled EndlessScrolling");
		}
		return this;
	}

endlessScrollEnabled is set to false. than inside void onLoadMoreComplete(@Nullable List<T> newItems, @IntRange(from = -1) long delay)

// 4. Remove the progressItem if needed
		if (delay > 0 && (newItemsSize == 0 || !isEndlessScrollEnabled())) {
			if (DEBUG)
				Log.v(TAG, "onLoadMore     enqueued removing progressItem (" + delay + "ms)");
			mHandler.sendEmptyMessageDelayed(LOAD_MORE_COMPLETE, delay);
		} else if (isEndlessScrollEnabled()) {
			hideProgressItem();
		}

hideProgressItem(); can’t be called because isEndlessScrollEnabled() returns false.

0reactions
davideascommented, Feb 23, 2017

@eemihauk, removing the else condition should then work also when no items and no delay.

Read more comments on GitHub >

github_iconTop Results From Across the Web

RowSetIterator next() never returns null, causing infinite loop
I'm using JDeveloper 11.1.1.6. One tricky issue we found is looping through a view object using RowSetIterator. next() of RowSetIterator ...
Read more >
why free function causes infinite loop? - Stack Overflow
You mustn't access to freed objects. In the delete_last functon, you called free() for one of the nodes, but you didn't update any...
Read more >
Solved: Infinite loop caused by CDS Update trigger
I have a simple flow that when a CDS record is updated it updates an API. When updated that API responce with an...
Read more >
How to change the limit of infinite loop iterations in Rational ...
Cause. The run-to-completion semantics of the Rational Rhapsody framework check for an infinite loop of NULL transitions.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found