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


Java LinearSnapHelper.attachToRecyclerView方法代碼示例

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


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

示例1: initSnapHelper

import android.support.v7.widget.LinearSnapHelper; //導入方法依賴的package包/類
/**
 * 初始化SnapHelper
 *
 * @param helper
 */
public void initSnapHelper(int helper) {
    switch (helper) {
        case GalleryRecyclerView.LinearySnapHelper:
            mLinearySnapHelper = new LinearSnapHelper();
            mLinearySnapHelper.attachToRecyclerView(mGalleryRecyclerView);
            break;
        case GalleryRecyclerView.PagerSnapHelper:
            mPagerSnapHelper = new PagerSnapHelper();
            mPagerSnapHelper.attachToRecyclerView(mGalleryRecyclerView);
            break;
    }
}
 
開發者ID:ryanlijianchang,項目名稱:Recyclerview-Gallery,代碼行數:18,代碼來源:ScrollManager.java

示例2: initView

import android.support.v7.widget.LinearSnapHelper; //導入方法依賴的package包/類
@Override
protected void initView() {
    mActivity = (AppCompatActivity) mContext;
    mToolbar = (Toolbar) mContext.findViewById(R.id.toolbar_daily_fragment);
    mActivity.setSupportActionBar(mToolbar);
    mActivity.setTitle(R.string.bottom_bar_gank);
    mToolbar.inflateMenu(R.menu.main_menu);
    mRecyclerView = (RecyclerView) mContext.findViewById(R.id.daily_recycler_view);
    LinearLayoutManager manager = new LinearLayoutManager(mContext);
    manager.setOrientation(LinearLayoutManager.HORIZONTAL);
    mRecyclerView.setLayoutManager(manager);
    mRecyclerView.setItemAnimator(new DefaultItemAnimator());
    mSnapHelper = new LinearSnapHelper();
    if (mRecyclerView.getOnFlingListener() == null) {
        mSnapHelper.attachToRecyclerView(mRecyclerView);
    }
    mRecyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
        @Override public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
            LinearLayoutManager layoutManager
                = (LinearLayoutManager) recyclerView.getLayoutManager();
            int totalItemCount = layoutManager.getItemCount();
            int lastVisibleItem = layoutManager.findLastVisibleItemPosition();
            if (totalItemCount <= lastVisibleItem + 1) {
                loadDailyData(mPage+=1);
            }

        }
    });
    mProgressBar = (ProgressBar) mContext.findViewById(R.id.daily_loading_progress_bar);
    mFailureTextView = (TextView) mContext.findViewById(R.id.daily_get_failure_tip);
}
 
開發者ID:wavever,項目名稱:GankLock,代碼行數:32,代碼來源:DailyGankFragment.java

示例3: onCreate

import android.support.v7.widget.LinearSnapHelper; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    // 1
    this.cardRecyclerView = (RecyclerView)findViewById(R.id.recycler_view);
    this.cardRecyclerView.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.HORIZONTAL, false));
    this.cardAdapter = new CardAdapter(this);
    this.cardRecyclerView.setAdapter(this.cardAdapter);

    // 4
    LinearSnapHelper snapHelper = new LinearSnapHelper();
    snapHelper.attachToRecyclerView(this.cardRecyclerView);
    this.cardRecyclerView.setOnFlingListener(snapHelper);
    this.cardRecyclerView.addItemDecoration(new VerticalOffsetDecoration(this)); // 9

    // 2
    List<LocationInformation> locations = new ArrayList<>();
    locations.add(LocationInformation.create("Appvation Pty. Ltd.", "202/147 Pirie St, Adelaide"));
    locations.add(LocationInformation.create("Appvation Pty. Ltd.", "202/147 Pirie St, Adelaide"));
    locations.add(LocationInformation.create("Appvation Pty. Ltd.", "202/147 Pirie St, Adelaide"));
    locations.add(LocationInformation.create("Appvation Pty. Ltd.", "202/147 Pirie St, Adelaide"));

    // 3
    this.cardAdapter.setItems(locations);
}
 
開發者ID:appvation,項目名稱:paged-cardview-android,代碼行數:28,代碼來源:MainActivity.java

示例4: showRecents

import android.support.v7.widget.LinearSnapHelper; //導入方法依賴的package包/類
private void showRecents() {
    final RootInfo root = roots.getRecentsRoot();
    recents.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            openRoot(root);
        }
    });

    mRecentsAdapter = new RecentsAdapter(getActivity(), null);
    mRecentsAdapter.setOnItemClickListener(new RecentsAdapter.OnItemClickListener() {
        @Override
        public void onItemClick(RecentsAdapter.ViewHolder item, int position) {
            openDocument(item.mDocumentInfo);
        }
    });
    mRecentsRecycler.setAdapter(mRecentsAdapter);
    LinearSnapHelper helper = new LinearSnapHelper();
    helper.attachToRecyclerView(mRecentsRecycler);

    final BaseActivity.State state = getDisplayState(this);
    mCallbacks = new LoaderManager.LoaderCallbacks<DirectoryResult>() {

        @Override
        public Loader<DirectoryResult> onCreateLoader(int id, Bundle args) {
            final RootsCache roots = DocumentsApplication.getRootsCache(getActivity());
            return new RecentLoader(getActivity(), roots, state);
        }

        @Override
        public void onLoadFinished(Loader<DirectoryResult> loader, DirectoryResult result) {
            if (!isAdded())
                return;
            if(null == result.cursor || (null != result.cursor && result.cursor.getCount() == 0)) {
                recents_container.setVisibility(View.GONE);
            } else {
                //recents_container.setVisibility(View.VISIBLE);
                mRecentsAdapter.swapCursor(new LimitCursorWrapper(result.cursor, MAX_RECENT_COUNT));
            }
        }

        @Override
        public void onLoaderReset(Loader<DirectoryResult> loader) {
            mRecentsAdapter.swapCursor(null);
        }
    };
    getLoaderManager().restartLoader(mLoaderId, null, mCallbacks);
}
 
開發者ID:kranthi0987,項目名稱:easyfilemanager,代碼行數:49,代碼來源:HomeFragment.java


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