void extendRangeInto (int[] range,
int[] outRange,
int scrollHint)
Compute a wider range of items that will be loaded for smoother scrolling.
If there is no scroll hint, the default implementation extends the visible range by half
its length in both directions. If there is a scroll hint, the range is extended by
its full length in the scroll direction, and by half in the other direction.
For example, if range is {100, 200} and scrollHint
is HINT_SCROLL_ASC, then outRange will be {50, 300}.
However, if scrollHint is HINT_SCROLL_NONE, then
outRange will be {50, 250}
outRange[0] is the position of the first visible item (in the order of the backing
storage).
outRange[1] is the position of the last visible item (in the order of the backing
storage).
Negative positions and positions greater or equal to getItemCount() are invalid.
If the returned range contains invalid positions it is ignored (no item will be loaded).
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2025-02-10 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-02-10 UTC."],[],[],null,["# AsyncListUtil.ViewCallback\n\nadded in [version 24.1.0](/topic/libraries/support-library/revisions) \nbelongs to Maven artifact com.android.support:recyclerview-v7:28.0.0-alpha1 \nSummary: [Constants](#constants) \\| [Ctors](#pubctors) \\| [Methods](#pubmethods) \\| [Inherited Methods](#inhmethods) \\| [\\[Expand All\\]](#) \n\nAsyncListUtil.ViewCallback\n==========================\n\n| This package is part of the Android [support library](/topic/libraries/support-library) which is no longer maintained. The support library has been superseded by [AndroidX](/jetpack/androidx) which is part of [Jetpack](/jetpack). We recommend using the AndroidX libraries in all new projects. You should also consider [migrating](/jetpack/androidx/migrate) existing projects to AndroidX. To find the AndroidX class that maps to this deprecated class, see the AndroidX support library [class\n| mappings](/jetpack/androidx/migrate/class-mappings).\n\n\n`\npublic\nstatic\n\nabstract\nclass\nAsyncListUtil.ViewCallback\n`\n\n\n`\n\nextends Object\n\n\n`\n\n`\n\n\n`\n\n|---|----------------------------------------------------|\n| java.lang.Object ||\n| ↳ | android.support.v7.util.AsyncListUtil.ViewCallback |\n\n\u003cbr /\u003e\n\n*** ** * ** ***\n\nThe callback that links [AsyncListUtil](/reference/android/support/v7/util/AsyncListUtil) with the list view.\n\n\nAll methods are called on the main thread.\n\nSummary\n-------\n\n| ### Constants ||\n|-------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `int` | [HINT_SCROLL_ASC](/reference/android/support/v7/util/AsyncListUtil.ViewCallback#HINT_SCROLL_ASC) Scrolling in ascending order (from lower to higher positions in the order of the backing storage). |\n| `int` | [HINT_SCROLL_DESC](/reference/android/support/v7/util/AsyncListUtil.ViewCallback#HINT_SCROLL_DESC) Scrolling in descending order (from higher to lower positions in the order of the backing storage). |\n| `int` | [HINT_SCROLL_NONE](/reference/android/support/v7/util/AsyncListUtil.ViewCallback#HINT_SCROLL_NONE) No scroll direction hint available. |\n\n| ### Public constructors ||\n|----------------------------------------------------------------------------------------------------------------------------------|---|\n| ` `[AsyncListUtil.ViewCallback](/reference/android/support/v7/util/AsyncListUtil.ViewCallback#AsyncListUtil.ViewCallback())`() ` |\n\n| ### Public methods ||\n|------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| ` void` | ` `[extendRangeInto](/reference/android/support/v7/util/AsyncListUtil.ViewCallback#extendRangeInto(int[], int[], int))`(int[] range, int[] outRange, int scrollHint) ` Compute a wider range of items that will be loaded for smoother scrolling. |\n| ` abstract void` | ` `[getItemRangeInto](/reference/android/support/v7/util/AsyncListUtil.ViewCallback#getItemRangeInto(int[]))`(int[] outRange) ` Compute the range of visible item positions. |\n| ` abstract void` | ` `[onDataRefresh](/reference/android/support/v7/util/AsyncListUtil.ViewCallback#onDataRefresh())`() ` Called when the entire data set has changed. |\n| ` abstract void` | ` `[onItemLoaded](/reference/android/support/v7/util/AsyncListUtil.ViewCallback#onItemLoaded(int))`(int position) ` Called when an item at the given position is loaded. |\n\n| ### Inherited methods |\n|-----------------------|---|\n| From class ` java.lang.Object ` |-------------------|-------------------------------| | ` Object` | ` clone() ` | | ` boolean` | ` equals(Object arg0) ` | | ` void` | ` finalize() ` | | ` final Class\u003c?\u003e` | ` getClass() ` | | ` int` | ` hashCode() ` | | ` final void` | ` notify() ` | | ` final void` | ` notifyAll() ` | | ` String` | ` toString() ` | | ` final void` | ` wait(long arg0, int arg1) ` | | ` final void` | ` wait(long arg0) ` | | ` final void` | ` wait() ` | ||\n\nConstants\n---------\n\n### HINT_SCROLL_ASC\n\nadded in [version 24.1.0](/topic/libraries/support-library/revisions) \n\n```\nint HINT_SCROLL_ASC\n```\n\nScrolling in ascending order (from lower to higher positions in the order of the backing\nstorage).\n\n\u003cbr /\u003e\n\nConstant Value:\n\n2\n(0x00000002)\n\n\n### HINT_SCROLL_DESC\n\nadded in [version 24.1.0](/topic/libraries/support-library/revisions) \n\n```\nint HINT_SCROLL_DESC\n```\n\nScrolling in descending order (from higher to lower positions in the order of the backing\nstorage).\n\n\u003cbr /\u003e\n\nConstant Value:\n\n1\n(0x00000001)\n\n\n### HINT_SCROLL_NONE\n\nadded in [version 24.1.0](/topic/libraries/support-library/revisions) \n\n```\nint HINT_SCROLL_NONE\n```\n\nNo scroll direction hint available.\n\n\u003cbr /\u003e\n\nConstant Value:\n\n0\n(0x00000000)\n\n\nPublic constructors\n-------------------\n\n### AsyncListUtil.ViewCallback\n\nadded in [version 24.1.0](/topic/libraries/support-library/revisions) \n\n```\nAsyncListUtil.ViewCallback ()\n```\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\nPublic methods\n--------------\n\n### extendRangeInto\n\nadded in [version 24.1.0](/topic/libraries/support-library/revisions) \n\n```\nvoid extendRangeInto (int[] range, \n int[] outRange, \n int scrollHint)\n```\n\nCompute a wider range of items that will be loaded for smoother scrolling.\n\n\nIf there is no scroll hint, the default implementation extends the visible range by half\nits length in both directions. If there is a scroll hint, the range is extended by\nits full length in the scroll direction, and by half in the other direction.\n\n\nFor example, if `range` is `{100, 200}` and `scrollHint`\nis [HINT_SCROLL_ASC](/reference/android/support/v7/util/AsyncListUtil.ViewCallback#HINT_SCROLL_ASC), then `outRange` will be `{50, 300}`.\n\n\nHowever, if `scrollHint` is [HINT_SCROLL_NONE](/reference/android/support/v7/util/AsyncListUtil.ViewCallback#HINT_SCROLL_NONE), then\n`outRange` will be `{50, 250}`\n\n\u003cbr /\u003e\n\n| Parameters ||\n|--------------|------------------------------------------|\n| `range` | `int`: Visible item range. \u003cbr /\u003e |\n| `outRange` | `int`: Extended range. \u003cbr /\u003e |\n| `scrollHint` | `int`: The scroll direction hint. \u003cbr /\u003e |\n\n### getItemRangeInto\n\nadded in [version 24.1.0](/topic/libraries/support-library/revisions) \n\n```\nvoid getItemRangeInto (int[] outRange)\n```\n\nCompute the range of visible item positions.\n\n\noutRange\\[0\\] is the position of the first visible item (in the order of the backing\nstorage).\n\n\noutRange\\[1\\] is the position of the last visible item (in the order of the backing\nstorage).\n\n\nNegative positions and positions greater or equal to [getItemCount()](/reference/android/support/v7/util/AsyncListUtil#getItemCount()) are invalid.\nIf the returned range contains invalid positions it is ignored (no item will be loaded).\n\n\u003cbr /\u003e\n\n| Parameters ||\n|------------|---------------------------------------|\n| `outRange` | `int`: The visible item range. \u003cbr /\u003e |\n\n### onDataRefresh\n\nadded in [version 24.1.0](/topic/libraries/support-library/revisions) \n\n```\nvoid onDataRefresh ()\n```\n\nCalled when the entire data set has changed.\n\n\u003cbr /\u003e\n\n### onItemLoaded\n\nadded in [version 24.1.0](/topic/libraries/support-library/revisions) \n\n```\nvoid onItemLoaded (int position)\n```\n\nCalled when an item at the given position is loaded.\n\n\u003cbr /\u003e\n\n| Parameters ||\n|------------|------------------------------|\n| `position` | `int`: Item position. \u003cbr /\u003e |\n\n-\n\n Interfaces\n ----------\n\n - [ListUpdateCallback](/reference/android/support/v7/util/ListUpdateCallback)\n-\n\n Classes\n -------\n\n - [AdapterListUpdateCallback](/reference/android/support/v7/util/AdapterListUpdateCallback)\n - [AsyncListUtil](/reference/android/support/v7/util/AsyncListUtil)\n - [AsyncListUtil.DataCallback](/reference/android/support/v7/util/AsyncListUtil.DataCallback)\n - [AsyncListUtil.ViewCallback](/reference/android/support/v7/util/AsyncListUtil.ViewCallback)\n - [BatchingListUpdateCallback](/reference/android/support/v7/util/BatchingListUpdateCallback)\n - [DiffUtil](/reference/android/support/v7/util/DiffUtil)\n - [DiffUtil.Callback](/reference/android/support/v7/util/DiffUtil.Callback)\n - [DiffUtil.DiffResult](/reference/android/support/v7/util/DiffUtil.DiffResult)\n - [DiffUtil.ItemCallback](/reference/android/support/v7/util/DiffUtil.ItemCallback)\n - [SortedList](/reference/android/support/v7/util/SortedList)\n - [SortedList.BatchedCallback](/reference/android/support/v7/util/SortedList.BatchedCallback)\n - [SortedList.Callback](/reference/android/support/v7/util/SortedList.Callback)"]]