-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #27 from Softeq/feature/new-release
Add changes for new release
- Loading branch information
Showing
53 changed files
with
787 additions
and
403 deletions.
There are no files selected for viewing
42 changes: 42 additions & 0 deletions
42
Softeq.XToolkit.Chat.Droid/Listeners/LoadMoreScrollListener.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// Developed by Softeq Development Corporation | ||
// http://www.softeq.com | ||
|
||
using System; | ||
using Android.Support.V7.Widget; | ||
using Softeq.XToolkit.Common; | ||
|
||
namespace Softeq.XToolkit.Chat.Droid.Listeners | ||
{ | ||
public class LoadMoreScrollListener : RecyclerView.OnScrollListener | ||
{ | ||
private const int VisibleThreshold = 5; | ||
|
||
private readonly TaskReference _onScrolled; | ||
|
||
private bool _isBusy; | ||
|
||
public LoadMoreScrollListener(TaskReference onScrolled) | ||
{ | ||
_onScrolled = onScrolled ?? throw new ArgumentNullException(nameof(onScrolled)); | ||
} | ||
|
||
public override async void OnScrolled(RecyclerView recyclerView, int dx, int dy) | ||
{ | ||
base.OnScrolled(recyclerView, dx, dy); | ||
|
||
var linearLayoutManager = (LinearLayoutManager)recyclerView.GetLayoutManager(); | ||
|
||
var totalItemCount = linearLayoutManager.ItemCount; | ||
var lastVisibleItem = linearLayoutManager.FindLastVisibleItemPosition(); | ||
|
||
if (!_isBusy && totalItemCount <= (lastVisibleItem + VisibleThreshold)) | ||
{ | ||
_isBusy = true; | ||
|
||
await _onScrolled.RunAsync(); | ||
|
||
_isBusy = false; | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.