Created
October 10, 2016 10:52
-
-
Save janishar/80d4e0edfac03c2e25c6a88dfb325629 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| @Layout(R.layout.load_more_view) | |
| public class LoadMoreView { | |
| public static final int LOAD_VIEW_SET_COUNT = 6; | |
| private InfinitePlaceHolderView mLoadMoreView; | |
| private List<InfiniteFeedInfo> mFeedList; | |
| public LoadMoreView(InfinitePlaceHolderView loadMoreView, List<InfiniteFeedInfo> feedList) { | |
| this.mLoadMoreView = loadMoreView; | |
| this.mFeedList = feedList; | |
| } | |
| @LoadMore | |
| private void onLoadMore(){ | |
| Log.d("DEBUG", "onLoadMore"); | |
| new ForcedWaitedLoading(); | |
| } | |
| class ForcedWaitedLoading implements Runnable{ | |
| public ForcedWaitedLoading() { | |
| new Thread(this).start(); | |
| } | |
| @Override | |
| public void run() { | |
| try { | |
| Thread.currentThread().sleep(2000); | |
| }catch (InterruptedException e){ | |
| e.printStackTrace(); | |
| } | |
| new Handler(Looper.getMainLooper()).post(new Runnable() { | |
| @Override | |
| public void run() { | |
| int count = mLoadMoreView.getViewCount(); | |
| Log.d("DEBUG", "count " + count); | |
| for (int i = count - 1; | |
| i < (count - 1 + LoadMoreView.LOAD_VIEW_SET_COUNT) && mFeedList.size() > i; | |
| i++) { | |
| mLoadMoreView.addView(new ItemView(mLoadMoreView.getContext(), mFeedList.get(i))); | |
| if(i == mFeedList.size() - 1){ | |
| mLoadMoreView.noMoreToLoad(); | |
| break; | |
| } | |
| } | |
| mLoadMoreView.loadingDone(); | |
| } | |
| }); | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment