當前位置: 首頁>>代碼示例>>Java>>正文


Java RecyclerView.postDelayed方法代碼示例

本文整理匯總了Java中android.support.v7.widget.RecyclerView.postDelayed方法的典型用法代碼示例。如果您正苦於以下問題:Java RecyclerView.postDelayed方法的具體用法?Java RecyclerView.postDelayed怎麽用?Java RecyclerView.postDelayed使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.support.v7.widget.RecyclerView的用法示例。


在下文中一共展示了RecyclerView.postDelayed方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: initRecyclerWithIndicator

import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
private void initRecyclerWithIndicator(int recyclerViewId, int indicatorViewId, final int itemCount, int delay) {
	RecyclerView                 recyclerView           = findViewById(recyclerViewId);
	final OverflowPagerIndicator overflowPagerIndicator = findViewById(indicatorViewId);
	final Adapter                adapter                = new Adapter();

	recyclerView.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.HORIZONTAL, false));
	recyclerView.setAdapter(adapter);

	overflowPagerIndicator.attachToRecyclerView(recyclerView);

	new SimpleSnapHelper(overflowPagerIndicator).attachToRecyclerView(recyclerView);

	recyclerView.postDelayed(new Runnable() {
		@Override
		public void run() {
			adapter.updateItemCount(itemCount);
		}
	}, delay);
}
 
開發者ID:intik,項目名稱:overflow-pager-indicator,代碼行數:20,代碼來源:MainActivity.java

示例2: disableLoadMoreIfNotFullPage

import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
/**
 * check if full page after {@link #setNewData(List)}, if full, it will enable load more again.
 * <p>
 * 不是配置項!!
 * <p>
 * 這個方法是用來檢查是否滿一屏的,所以隻推薦在 {@link #setNewData(List)} 之後使用
 * 原理很簡單,先關閉 load more,檢查完了再決定是否開啟
 * <p>
 * 不是配置項!!
 *
 * @param recyclerView your recyclerView
 * @see #setNewData(List)
 */
public void disableLoadMoreIfNotFullPage(RecyclerView recyclerView) {
    setEnableLoadMore(false);
    if (recyclerView == null) return;
    RecyclerView.LayoutManager manager = recyclerView.getLayoutManager();
    if (manager == null) return;
    if (manager instanceof LinearLayoutManager) {
        final LinearLayoutManager linearLayoutManager = (LinearLayoutManager) manager;
        recyclerView.postDelayed(new Runnable() {
            @Override
            public void run() {
                if ((linearLayoutManager.findLastCompletelyVisibleItemPosition() + 1) != getItemCount()) {
                    setEnableLoadMore(true);
                }
            }
        }, 50);
    } else if (manager instanceof StaggeredGridLayoutManager) {
        final StaggeredGridLayoutManager staggeredGridLayoutManager = (StaggeredGridLayoutManager) manager;
        recyclerView.postDelayed(new Runnable() {
            @Override
            public void run() {
                final int[] positions = new int[staggeredGridLayoutManager.getSpanCount()];
                staggeredGridLayoutManager.findLastCompletelyVisibleItemPositions(positions);
                int pos = getTheBiggestNumber(positions) + 1;
                if (pos != getItemCount()) {
                    setEnableLoadMore(true);
                }
            }
        }, 50);
    }
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:44,代碼來源:BaseQuickAdapter.java

示例3: disableLoadMoreIfNotFullPage

import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
/**
 * check if full page after {@link #setNewData(List)}, if full, it will enable load more again.
 *
 * @param recyclerView your recyclerView
 * @see #setNewData(List)
 */
public void disableLoadMoreIfNotFullPage(RecyclerView recyclerView) {
    setEnableLoadMore(false);
    if (recyclerView == null) return;
    RecyclerView.LayoutManager manager = recyclerView.getLayoutManager();
    if (manager == null) return;
    if (manager instanceof LinearLayoutManager) {
        final LinearLayoutManager linearLayoutManager = (LinearLayoutManager) manager;
        recyclerView.postDelayed(new Runnable() {
            @Override
            public void run() {
                if ((linearLayoutManager.findLastCompletelyVisibleItemPosition() + 1) != getItemCount()) {
                    setEnableLoadMore(true);
                }
            }
        }, 50);
    } else if (manager instanceof StaggeredGridLayoutManager) {
        final StaggeredGridLayoutManager staggeredGridLayoutManager = (StaggeredGridLayoutManager) manager;
        recyclerView.postDelayed(new Runnable() {
            @Override
            public void run() {
                final int[] positions = new int[staggeredGridLayoutManager.getSpanCount()];
                staggeredGridLayoutManager.findLastCompletelyVisibleItemPositions(positions);
                int pos = getTheBiggestNumber(positions) + 1;
                if (pos != getItemCount()) {
                    setEnableLoadMore(true);
                }
            }
        }, 50);
    }
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:37,代碼來源:BaseQuickAdapter.java

示例4: disableLoadMoreIfNotFullPage

import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
/**
 * check if full page after {@link #setNewData(List)}, if full, it will enable load more again.
 *
 * @param recyclerView your recyclerView
 * @see #setNewData(List)
 */
public void disableLoadMoreIfNotFullPage(RecyclerView recyclerView) {
    if (recyclerView == null) return;
    RecyclerView.LayoutManager manager = recyclerView.getLayoutManager();
    if (manager == null) return;
    if (manager instanceof LinearLayoutManager) {
        final LinearLayoutManager linearLayoutManager = (LinearLayoutManager) manager;
        recyclerView.postDelayed(new Runnable() {
            @Override
            public void run() {
                if ((linearLayoutManager.findLastCompletelyVisibleItemPosition() + 1) != getItemCount()) {
                    setEnableLoadMore(true);
                }
            }
        }, 50);
    } else if (manager instanceof StaggeredGridLayoutManager) {
        final StaggeredGridLayoutManager staggeredGridLayoutManager = (StaggeredGridLayoutManager) manager;
        recyclerView.postDelayed(new Runnable() {
            @Override
            public void run() {
                final int[] positions = new int[staggeredGridLayoutManager.getSpanCount()];
                staggeredGridLayoutManager.findLastCompletelyVisibleItemPositions(positions);
                int pos = getTheBiggestNumber(positions) + 1;
                if (pos != getItemCount()) {
                    setEnableLoadMore(true);
                }
            }
        }, 50);
    }
}
 
開發者ID:liu-xiao-dong,項目名稱:JD-Test,代碼行數:36,代碼來源:BaseQuickAdapter.java

示例5: initializeRecyclerView

import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
@SuppressWarnings({"ConstantConditions", "NullableProblems"})
private void initializeRecyclerView(Bundle savedInstanceState) {
	//Get copy of the Database list
	List<AbstractFlexibleItem> items = DatabaseService.getInstance().getDatabaseList();

	// Initialize Adapter and RecyclerView
	// ExampleAdapter makes use of stableIds, I strongly suggest to implement 'item.hashCode()'
	mAdapter = new ExampleAdapter(items, getActivity());
	mAdapter.setNotifyChangeOfUnfilteredItems(true) //This will rebind new item when refreshed
			.setMode(SelectableAdapter.MODE_SINGLE);

	// Experimenting NEW features (v5.0.0)
	mRecyclerView = (RecyclerView) getView().findViewById(R.id.recycler_view);
	mRecyclerView.setLayoutManager(createNewLinearLayoutManager());
	mRecyclerView.setAdapter(mAdapter);
	mRecyclerView.setHasFixedSize(true); //Size of RV will not change
	// NOTE: Use default item animator 'canReuseUpdatedViewHolder()' will return true if
	// a Payload is provided. FlexibleAdapter is actually sending Payloads onItemChange.
	mRecyclerView.setItemAnimator(new DefaultItemAnimator());
	// Divider item decorator with DrawOver enabled
	mRecyclerView.addItemDecoration(new DividerItemDecoration(getActivity(), R.drawable.divider)
			.withDrawOver(true));
	mRecyclerView.postDelayed(new Runnable() {
		@Override
		public void run() {
			Snackbar.make(getView(), "Selection MODE_SINGLE is enabled", Snackbar.LENGTH_SHORT).show();
		}
	}, 1500L);

	// Add FastScroll to the RecyclerView, after the Adapter has been attached the RecyclerView!!!
	mAdapter.setFastScroller((FastScroller) getView().findViewById(R.id.fast_scroller),
			Utils.getColorAccent(getActivity()), (MainActivity) getActivity());

	SwipeRefreshLayout swipeRefreshLayout = (SwipeRefreshLayout) getView().findViewById(R.id.swipeRefreshLayout);
	swipeRefreshLayout.setEnabled(true);
	mListener.onFragmentChange(swipeRefreshLayout, mRecyclerView, SelectableAdapter.MODE_SINGLE);

	// Add 2 Scrollable Headers
	mAdapter.addUserLearnedSelection(savedInstanceState == null);
	mAdapter.addScrollableHeaderWithDelay(new ScrollableUseCaseItem(
			getString(R.string.selection_modes_use_case_title),
			getString(R.string.selection_modes_use_case_description)), 1100L, true
	);
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:45,代碼來源:FragmentSelectionModes.java

示例6: initializeRecyclerView

import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
@SuppressWarnings({"ConstantConditions", "NullableProblems"})
private void initializeRecyclerView(Bundle savedInstanceState) {
	// Initialize Adapter and RecyclerView
	// OverallAdapter makes use of stableIds, I strongly suggest to implement 'item.hashCode()'

	// In this example the Adapter make uses of METHOD B and extends FlexibleAdapter: items
	// don't implement the AutoMap and don't implement create and binding methods: The Adapter
	// remains responsible to handling all view types.
	mAdapter = new OverallAdapter(getActivity());

	// Experimenting NEW features (v5.0.0)
	mAdapter.setOnlyEntryAnimation(true)
			.setAnimationInterpolator(new DecelerateInterpolator())
			.setAnimationInitialDelay(500L)
			.setAnimationDelay(70L);

	// Prepare the RecyclerView and attach the Adapter to it
	mRecyclerView = (RecyclerView) getView().findViewById(R.id.recycler_view);
	mRecyclerView.setItemViewCacheSize(0); //Setting ViewCache to 0 (default=2) will animate items better while scrolling down+up with LinearLayout
	mRecyclerView.setLayoutManager(createNewStaggeredGridLayoutManager());
	mRecyclerView.setAdapter(mAdapter);
	mRecyclerView.setHasFixedSize(true); //Size of RV will not change

	// After Adapter is attached to RecyclerView
	mAdapter.setLongPressDragEnabled(true);
	mRecyclerView.postDelayed(new Runnable() {
		@Override
		public void run() {
			if (getView() != null) { //Fix NPE when closing app before the execution of Runnable
				Snackbar.make(getView(), "Long press drag is enabled", Snackbar.LENGTH_SHORT).show();
			}
		}
	}, 4000L);

	SwipeRefreshLayout swipeRefreshLayout = (SwipeRefreshLayout) getView().findViewById(R.id.swipeRefreshLayout);
	swipeRefreshLayout.setEnabled(true);
	mListener.onFragmentChange(swipeRefreshLayout, mRecyclerView, SelectableAdapter.MODE_IDLE);

	// Add 2 Scrollable Headers
	mAdapter.showLayoutInfo(savedInstanceState == null);
	mAdapter.addScrollableHeader(new ScrollableUseCaseItem(
			getString(R.string.overall_use_case_title),
			getString(R.string.overall_use_case_description)));
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:45,代碼來源:FragmentOverall.java


注:本文中的android.support.v7.widget.RecyclerView.postDelayed方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。