Java Code Examples for androidx.swiperefreshlayout.widget.SwipeRefreshLayout#setOnRefreshListener()
The following examples show how to use
androidx.swiperefreshlayout.widget.SwipeRefreshLayout#setOnRefreshListener() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FavoriteFragment.java From memorize with MIT License | 6 votes |
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View root = inflater.inflate(R.layout.fragment_favorite, container, false); mRecyclerView = root.findViewById(R.id.fav_recycler_view); mRecyclerView.setHasFixedSize(true); mRecyclerView.setItemAnimator(new DefaultItemAnimator()); mRecyclerView.setLayoutManager(new LinearLayoutManager(AppMain.getContext(), LinearLayoutManager.VERTICAL, false)); SnapHelper snapHelper = new LinearSnapHelper(); snapHelper.attachToRecyclerView(mRecyclerView); mRecyclerView.setAdapter(mAdapter); swipeRefreshLayout = (SwipeRefreshLayout) root.findViewById(R.id.fav_swiper); swipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() { @Override public void onRefresh() { presenter.loadWords(false); } }); // animation = AnimationUtils.loadAnimation(AppMain.getContext(), R.anim.card_in); return root; }
Example 2
Source File: ItemFragment.java From materialistic with Apache License 2.0 | 6 votes |
@Override public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable final Bundle savedInstanceState) { if (isNewInstance()) { mFragmentView = inflater.inflate(R.layout.fragment_item, container, false); mEmptyView = mFragmentView.findViewById(R.id.empty); mRecyclerView = (RecyclerView) mFragmentView.findViewById(R.id.recycler_view); mRecyclerView.setLayoutManager(new SnappyLinearLayoutManager(getActivity(), true)); mItemDecoration = new CommentItemDecoration(getActivity()); mRecyclerView.addItemDecoration(mItemDecoration); mSwipeRefreshLayout = (SwipeRefreshLayout) mFragmentView.findViewById(R.id.swipe_layout); mSwipeRefreshLayout.setColorSchemeResources(R.color.white); mSwipeRefreshLayout.setProgressBackgroundColorSchemeResource(R.color.redA200); mSwipeRefreshLayout.setOnRefreshListener(() -> { if (TextUtils.isEmpty(mItemId)) { return; } mCacheMode = ItemManager.MODE_NETWORK; if (mAdapter != null) { mAdapter.setCacheMode(mCacheMode); } loadKidData(); }); } return mFragmentView; }
Example 3
Source File: MainActivity.java From android-bluetooth-serial with Apache License 2.0 | 5 votes |
@Override protected void onCreate(Bundle savedInstanceState) { // Setup our activity super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); // Setup our ViewModel viewModel = ViewModelProviders.of(this).get(MainActivityViewModel.class); // This method return false if there is an error, so if it does, we should close. if (!viewModel.setupViewModel()) { finish(); return; } // Setup our Views RecyclerView deviceList = findViewById(R.id.main_devices); SwipeRefreshLayout swipeRefreshLayout = findViewById(R.id.main_swiperefresh); // Setup the RecyclerView deviceList.setLayoutManager(new LinearLayoutManager(this)); DeviceAdapter adapter = new DeviceAdapter(); deviceList.setAdapter(adapter); // Setup the SwipeRefreshLayout swipeRefreshLayout.setOnRefreshListener(() -> { viewModel.refreshPairedDevices(); swipeRefreshLayout.setRefreshing(false); }); // Start observing the data sent to us by the ViewModel viewModel.getPairedDeviceList().observe(MainActivity.this, adapter::updateList); // Immediately refresh the paired devices list viewModel.refreshPairedDevices(); }
Example 4
Source File: MainFragment.java From ui with Apache License 2.0 | 5 votes |
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View myView = inflater.inflate(R.layout.fragment_main, container, false); mSwipeRefreshLayout = (SwipeRefreshLayout) myView.findViewById(R.id.activity_main_swipe_refresh_layout); mListView = (ListView) myView.findViewById(R.id.ListView01); String[] fakelist = getRandomList(); mAdapter = new ArrayAdapter<String>( getActivity(), android.R.layout.simple_list_item_1, fakelist); mListView.setAdapter(mAdapter); //setup some colors for the refresh circle. mSwipeRefreshLayout.setColorSchemeResources(R.color.orange, R.color.green, R.color.blue); //now setup the swiperefrestlayout listener where the main work is done. mSwipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() { @Override public void onRefresh() { //where we call the refresher parts. normally some kind of networking async task or web service. //this is a bad way to do this, I'm just redoing the adapter, normally, the adapter would update //and then use the mAdapter.notifyDataSetChanged(); /* normally something like this... but I want to slow it down for demo purposes, so * it's commented out. String[] fakelist = getRandomList(); mAdapter = new ArrayAdapter<String>( getActivity(), android.R.layout.simple_list_item_1, fakelist); mListView.setAdapter(mAdapter); //new turn off the refresh. mSwipeRefreshLayout.setRefreshing(false); */ refreshslower(); //this will be slower, for the demo. } }); return myView; }
Example 5
Source File: CourseOutlineFragment.java From edx-app-android with Apache License 2.0 | 5 votes |
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { final Bundle bundle; { if (savedInstanceState != null) { bundle = savedInstanceState; } else { bundle = getArguments(); } } final View view = inflater.inflate(R.layout.fragment_course_outline, container, false); listView = (ListView) view.findViewById(R.id.outline_list); swipeContainer = (SwipeRefreshLayout) view.findViewById(R.id.swipe_container); errorNotification = new FullScreenErrorNotification(swipeContainer); loadingIndicator = view.findViewById(R.id.loading_indicator); flBulkDownload = view.findViewById(R.id.fl_bulk_download_container); swipeContainer.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() { @Override public void onRefresh() { // Hide the progress bar as swipe layout has its own progress indicator loadingIndicator.setVisibility(View.GONE); errorNotification.hideError(); getCourseComponentFromServer(false); } }); UiUtil.setSwipeRefreshLayoutColors(swipeContainer); restore(bundle); initListView(view); fetchCourseComponent(); // Track CourseOutline for A/A test trackAATestCourseOutline(); getCourseUpgradeFirebaseConfig(); return view; }
Example 6
Source File: BlacklistFragment.java From hipda with GNU General Public License v2.0 | 5 votes |
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_blacklist, container, false); mInflater = inflater; mDrawable = new IconicsDrawable(getActivity(), GoogleMaterial.Icon.gmd_close) .color(Color.GRAY) .sizeDp(12); mOnClickListener = new OnSingleClickListener() { @Override public void onSingleClick(View v) { removeFromBlacklist((String) v.getTag()); v.setVisibility(View.INVISIBLE); } }; mSwipeLayout = (SwipeRefreshLayout) view.findViewById(R.id.swipe_container); mSwipeLayout.setOnRefreshListener(this); mSwipeLayout.setColorSchemeColors(ColorHelper.getSwipeColor(getActivity())); mSwipeLayout.setProgressBackgroundColorSchemeColor(ColorHelper.getSwipeBackgroundColor(getActivity())); RecyclerView recyclerView = (RecyclerView) view.findViewById(R.id.recyclerview); recyclerView.setHasFixedSize(true); recyclerView.setLayoutManager(new LinearLayoutManager(getActivity())); recyclerView.addItemDecoration(new SimpleDivider(getActivity())); mLoadingView = (ContentLoadingView) view.findViewById(R.id.content_loading); recyclerView.setAdapter(mAdapter); refresh(); setActionBarTitle("黑名单"); return view; }
Example 7
Source File: PaginationActivity.java From Carbon with Apache License 2.0 | 5 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); initToolbar(); SwipeRefreshLayout swipeRefresh = findViewById(R.id.swipeRefresh); final RecyclerView recyclerView = findViewById(R.id.recyclerView); LinearLayoutManager layoutManager = new LinearLayoutManager(this); recyclerView.setLayoutManager(layoutManager); fruitAdapter = new RowListAdapter<>(String.class, TextRow::new); recyclerView.setAdapter(fruitAdapter); recyclerView.setPagination(new RecyclerView.Pagination(layoutManager) { @Override protected boolean isLoading() { return swipeRefresh.isRefreshing(); } @Override protected boolean isLastPage() { return page == 10; } @Override protected void loadNextPage() { swipeRefresh.setRefreshing(true); PaginationActivity.this.loadNextPage(); swipeRefresh.setRefreshing(false); } }); swipeRefresh.setOnRefreshListener(() -> { fruitAdapter.setItems(new ArrayList<>()); page = 1; loadNextPage(); swipeRefresh.setRefreshing(false); }); }
Example 8
Source File: PostFragment.java From Girls with Apache License 2.0 | 5 votes |
@Nullable @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.activity_fragment, null); mRecyclerView = (RecyclerView) rootView.findViewById(R.id.activity_recycke_view); //设置adapter mRecyclerView.setAdapter(mGirlAdapter); //设置Item增加、移除动画 mRecyclerView.setItemAnimator(new DefaultItemAnimator()); mRecyclerView.setHasFixedSize(false); //设置布局管理器 LinearLayoutManager linearLayoutManager = new LinearLayoutManager(getActivity(), LinearLayoutManager.VERTICAL, false); mRecyclerView.setLayoutManager(linearLayoutManager); mCircularProgressBar = (CircularProgressBar) rootView.findViewById(R.id.circular_progressbar); swipeRefreshLayout = (SwipeRefreshLayout) rootView.findViewById(R.id.swipeRefreshLayout); swipeRefreshLayout.setColorSchemeColors( R.color.holo_red_light, R.color.holo_green_light, R.color.holo_blue_bright); //swipeRefreshLayout 设置下拉刷新事件 swipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() { @Override public void onRefresh() { getData(); //成功了 关闭刷新 swipeRefreshLayout.setRefreshing(false); } }); return rootView; }
Example 9
Source File: OpenChannelListFragment.java From SendBird-Android with MIT License | 5 votes |
@Nullable @Override public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_open_channel_list, container, false); setRetainInstance(true); setHasOptionsMenu(true); ((OpenChannelActivity) getActivity()).setActionBarTitle(getResources().getString(R.string.all_open_channels)); mRecyclerView = (RecyclerView) rootView.findViewById(R.id.recycler_open_channel_list); mChannelListAdapter = new OpenChannelListAdapter(getContext()); // Set color? mSwipeRefresh = (SwipeRefreshLayout) rootView.findViewById(R.id.swipe_layout_open_channel_list); // Swipe down to refresh channel list. mSwipeRefresh.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() { @Override public void onRefresh() { mSwipeRefresh.setRefreshing(true); refresh(); } }); mCreateChannelFab = (FloatingActionButton) rootView.findViewById(R.id.fab_open_channel_list); mCreateChannelFab.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(getActivity(), CreateOpenChannelActivity.class); startActivityForResult(intent, INTENT_REQUEST_NEW_OPEN_CHANNEL); } }); setUpRecyclerView(); setUpChannelListAdapter(); return rootView; }
Example 10
Source File: SwipeLoaderLayoutHandler.java From aptoide-client-v8 with GNU General Public License v3.0 | 4 votes |
@Override public void bindViews(View view) { super.bindViews(view); swipeContainer = (SwipeRefreshLayout) view.findViewById(R.id.swipe_container); swipeContainer.setOnRefreshListener(() -> ((ReloadInterface) loadInterface).reload()); }
Example 11
Source File: GroupChannelListFragment.java From SendBird-Android with MIT License | 4 votes |
@Nullable @Override public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { Log.d("LIFECYCLE", "GroupChannelListFragment onCreateView()"); View rootView = inflater.inflate(R.layout.fragment_group_channel_list, container, false); setRetainInstance(true); // Change action bar title ((GroupChannelActivity) getActivity()).setActionBarTitle(getResources().getString(R.string.all_group_channels)); mRecyclerView = (RecyclerView) rootView.findViewById(R.id.recycler_group_channel_list); mCreateChannelFab = (FloatingActionButton) rootView.findViewById(R.id.fab_group_channel_list); mSwipeRefresh = (SwipeRefreshLayout) rootView.findViewById(R.id.swipe_layout_group_channel_list); mSwipeRefresh.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() { @Override public void onRefresh() { mSwipeRefresh.setRefreshing(true); refresh(); } }); mCreateChannelFab.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(getContext(), CreateGroupChannelActivity.class); startActivityForResult(intent, INTENT_REQUEST_NEW_GROUP_CHANNEL); } }); mChannelListAdapter = new GroupChannelListAdapter(getActivity()); setUpRecyclerView(); setUpChannelListAdapter(); refresh(); return rootView; }
Example 12
Source File: GroupChannelListFragment.java From SendBird-Android with MIT License | 4 votes |
@Nullable @Override public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { Log.d("LIFECYCLE", "GroupChannelListFragment onCreateView()"); View rootView = inflater.inflate(R.layout.fragment_group_channel_list, container, false); setRetainInstance(true); // Change action bar title ((GroupChannelActivity) getActivity()).setActionBarTitle(getResources().getString(R.string.all_group_channels)); mRecyclerView = (RecyclerView) rootView.findViewById(R.id.recycler_group_channel_list); mCreateChannelFab = (FloatingActionButton) rootView.findViewById(R.id.fab_group_channel_list); mSwipeRefresh = (SwipeRefreshLayout) rootView.findViewById(R.id.swipe_layout_group_channel_list); mSwipeRefresh.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() { @Override public void onRefresh() { mSwipeRefresh.setRefreshing(true); refresh(); } }); mCreateChannelFab.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(getContext(), CreateGroupChannelActivity.class); startActivityForResult(intent, INTENT_REQUEST_NEW_GROUP_CHANNEL); } }); mChannelListAdapter = new GroupChannelListAdapter(getActivity()); mChannelListAdapter.load(); setUpRecyclerView(); setUpChannelListAdapter(); return rootView; }
Example 13
Source File: ViewPagerNestedActivity.java From AndroidAnimationExercise with Apache License 2.0 | 4 votes |
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_view_pager_nested, container, false); TextView textView = (TextView) rootView.findViewById(R.id.section_label); textView.setText(getString(R.string.section_format, getArguments().getInt(ARG_SECTION_NUMBER))); ViewPager mViewPager = (ViewPager) rootView.findViewById(R.id.viewpager); List<View> mViews = new ArrayList<>(); mViews.add(inflater.inflate(R.layout.layout_1, null, false)); mViews.add(inflater.inflate(R.layout.layout_2, null, false)); mViews.add(inflater.inflate(R.layout.layout_3, null, false)); MyAdapter mMyAdapter = new MyAdapter(mViews); mViewPager.setAdapter(mMyAdapter); // final SwipeRefreshLayout mSwipeRefreshLayout = (SwipeRefreshLayout) rootView.findViewById(R.id.swipeRefreshLayout); mSwipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() { @Override public void onRefresh() { new Handler().postDelayed(new Runnable() { @Override public void run() { mSwipeRefreshLayout.setRefreshing(false); } }, 1000); } }); final ImageView mImageView = rootView.findViewById(R.id.image); // mImageView.setPivotX(Tools.getScreenWidth(getContext())); // mImageView.setPivotY(Tools.getScreenHeight(getContext())); Button mButton = rootView.findViewById(R.id.button); mButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (flag) { mImageView.animate().scaleX(1.0f).setDuration(400); mImageView.animate().scaleY(1.0f).setDuration(400); } else { mImageView.animate().scaleX(0.5f).setDuration(400); mImageView.animate().scaleY(0.5f).setDuration(400); } flag = !flag; } }); return rootView; }
Example 14
Source File: ExperimentListFragment.java From science-journal with Apache License 2.0 | 4 votes |
@Override public View onCreateView( LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_experiment_list, container, false); final RecyclerView detailList = (RecyclerView) view.findViewById(R.id.details); experimentListAdapter = new ExperimentListAdapter(this); swipeLayout = (SwipeRefreshLayout) view.findViewById(R.id.swipe_container); swipeLayout.setOnRefreshListener(this); // TODO: Adjust the column count based on breakpoint specs when available. int column_count = 2; GridLayoutManager manager = new GridLayoutManager(getActivity(), column_count); manager.setSpanSizeLookup( new GridLayoutManager.SpanSizeLookup() { @Override public int getSpanSize(int position) { return experimentListAdapter.getItemViewType(position) == ExperimentListAdapter.VIEW_TYPE_EXPERIMENT ? 1 : column_count; } }); detailList.setLayoutManager(manager); detailList.setAdapter(experimentListAdapter); FloatingActionButton newExperimentButton = (FloatingActionButton) view.findViewById(R.id.new_experiment); if (claimExperimentsMode) { newExperimentButton.setVisibility(View.GONE); } else { newExperimentButton.setOnClickListener( v -> { if (getRecorderController().watchRecordingStatus().blockingFirst().isRecording()) { // This should never happen, but apparently it does on some Xperia devices? // b/117484248 return; } getDataController() .createExperiment( new LoggingConsumer<Experiment>(TAG, "Create a new experiment") { @Override public void success(final Experiment experiment) { WhistlePunkApplication.getUsageTracker(applicationContext) .trackEvent( TrackerConstants.CATEGORY_EXPERIMENTS, TrackerConstants.ACTION_CREATE, TrackerConstants.LABEL_EXPERIMENT_LIST, 0); launchExperimentActivity( v.getContext(), appAccount, experiment.getExperimentId(), false /* claimExperimentsMode */); } }); }); } return view; }
Example 15
Source File: BlockedUserListFragment.java From guanggoo-android with Apache License 2.0 | 4 votes |
private void initSwipeLayout(SwipeRefreshLayout swipeRefreshLayout) { swipeRefreshLayout.setOnRefreshListener(this); swipeRefreshLayout.setColorSchemeResources(R.color.main); }
Example 16
Source File: ReplyListFragment.java From guanggoo-android with Apache License 2.0 | 4 votes |
private void initSwipeLayout(SwipeRefreshLayout swipeRefreshLayout) { swipeRefreshLayout.setOnRefreshListener(this); swipeRefreshLayout.setColorSchemeResources(R.color.main); }
Example 17
Source File: TopicListFragment.java From guanggoo-android with Apache License 2.0 | 4 votes |
private void initSwipeLayout(SwipeRefreshLayout swipeRefreshLayout) { swipeRefreshLayout.setOnRefreshListener(this); swipeRefreshLayout.setColorSchemeResources(R.color.main); }
Example 18
Source File: SearchFragment.java From hipda with GNU General Public License v2.0 | 4 votes |
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_search, container, false); mRecyclerView = (XRecyclerView) view.findViewById(R.id.rv_threads); mRecyclerView.setHasFixedSize(true); mRecyclerView.setLayoutManager(new LinearLayoutManager(getActivity())); mRecyclerView.addItemDecoration(new SimpleDivider(getActivity())); mRecyclerView.addOnScrollListener(new OnScrollListener()); mRecyclerView.setAdapter(mSimpleListAdapter); mSearchFilterLayout = (RelativeLayout) view.findViewById(R.id.search_filter_layout); ViewCompat.setElevation(mSearchFilterLayout, Utils.dpToPx(4)); mSearchFilterLayout.setAlpha(0); mSpForum = (Spinner) view.findViewById(R.id.sp_forum); mSpAdapter = new KeyValueArrayAdapter(getActivity(), R.layout.spinner_row); mSpAdapter.setEntryValues(getForumIds()); mSpAdapter.setEntries(getForumNames()); mSpForum.setAdapter(mSpAdapter); mEtAuthor = (EditText) view.findViewById(R.id.et_author); mEtAuthor.setOnEditorActionListener(mSearchEditorActionListener); mCbFulltext = (CheckBox) view.findViewById(R.id.cb_fulltext); mCbFulltext.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if (mSearchView != null) { if (isChecked) { mSearchView.setQueryHint("搜索全文"); } else { mSearchView.setQueryHint("搜索标题"); } } } }); RecyclerView rvHistory = (RecyclerView) view.findViewById(R.id.rv_history); rvHistory.setHasFixedSize(true); rvHistory.setLayoutManager(new LinearLayoutManager(getActivity())); rvHistory.setAdapter(mHistoryAdapter); mHistoryAdapter.setDatas(mQueries); mSwipeLayout = (SwipeRefreshLayout) view.findViewById(R.id.swipe_container); mSwipeLayout.setOnRefreshListener(this); mSwipeLayout.setColorSchemeColors(ColorHelper.getSwipeColor(getActivity())); mSwipeLayout.setProgressBackgroundColorSchemeColor(ColorHelper.getSwipeBackgroundColor(getActivity())); mSwipeLayout.setEnabled(false); mLoadingView = (ContentLoadingView) view.findViewById(R.id.content_loading); mLoadingView.setState(ContentLoadingView.NO_DATA); new Handler().postDelayed(new Runnable() { @Override public void run() { //hide then show mSearchFilterLayout, cannot get it's height on first show //so I use a fixed value here, tell me if you know a better way mSearchFilterLayout.animate() .alpha(0) .setDuration(100) .translationYBy(-300) .setListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { super.onAnimationEnd(animation); mSearchFilterLayout.setVisibility(View.GONE); mSearchFilterAnimating = false; showSearchFilter(); } }); } }, 150); return view; }
Example 19
Source File: NotificationsFragment.java From guanggoo-android with Apache License 2.0 | 4 votes |
private void initSwipeLayout(SwipeRefreshLayout swipeRefreshLayout) { swipeRefreshLayout.setOnRefreshListener(this); swipeRefreshLayout.setColorSchemeResources(R.color.main); }
Example 20
Source File: GithubFragment.java From RendererRecyclerViewAdapter with Apache License 2.0 | 4 votes |
@Nullable @Override public View onCreateView(final LayoutInflater inflater, @Nullable final ViewGroup container, @Nullable final Bundle savedInstanceState) { View inflate = inflater.inflate(R.layout.fragment_github, container, false); mGithubPresenter = new GithubPresenter( getUIRouter(), getMenuController(), MainManager.getInstance().getStargazersManager(), MainManager.getInstance().getForksManager(), mMainPresenterView ); mSwipeToRefresh = (SwipeRefreshLayout) inflate.findViewById(R.id.refresh); mSwipeToRefresh.setOnRefreshListener(() -> mGithubPresenter.onRefresh()); mRecyclerViewAdapter = new RendererRecyclerViewAdapter(); mRecyclerViewAdapter.setDiffCallback(new ItemsDiffCallback()); mRecyclerViewAdapter.registerRenderer(new LoadMoreViewBinder(R.layout.item_load_more)); mRecyclerViewAdapter.registerRenderer(createStargazerRenderer(R.layout.item_user_full_width)); mRecyclerViewAdapter.registerRenderer(createListRenderer() .registerRenderer(createForkRenderer()) .registerRenderer(createStargazerRenderer(R.layout.item_user_150)) ); mRecyclerViewAdapter.registerRenderer(new ViewBinder<>( R.layout.item_category, CategoryModel.class, (model, finder, payloads) -> finder .find(R.id.title, (ViewProvider<TextView>) view -> view.setText(model.getName())) .setOnClickListener(R.id.viewAll, (v -> mGithubPresenter.onCategoryClicked(model))) )); mLayoutManager = new GridLayoutManager(getContext(), MAX_SPAN_COUNT); mLayoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() { @Override public int getSpanSize(final int position) { final Type type = mRecyclerViewAdapter.getType(position); if (type.equals(ForkModel.class) || type.equals(StargazerModel.class)) { return 1; } return 3; } }); mRecyclerView = (RecyclerView) inflate.findViewById(R.id.recycler_view); mRecyclerView.setLayoutManager(mLayoutManager); mRecyclerView.setAdapter(mRecyclerViewAdapter); mRecyclerView.addItemDecoration(new MyItemDecoration()); mRecyclerView.addOnScrollListener(new EndlessScrollListener() { @Override public void onLoadMore(final int page, final int totalItemsCount) { mGithubPresenter.onLoadMore(); } }); return inflate; }