当前位置: 首页>>代码示例>>Java>>正文


Java StickyRecyclerHeadersDecoration类代码示例

本文整理汇总了Java中com.timehop.stickyheadersrecyclerview.StickyRecyclerHeadersDecoration的典型用法代码示例。如果您正苦于以下问题:Java StickyRecyclerHeadersDecoration类的具体用法?Java StickyRecyclerHeadersDecoration怎么用?Java StickyRecyclerHeadersDecoration使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


StickyRecyclerHeadersDecoration类属于com.timehop.stickyheadersrecyclerview包,在下文中一共展示了StickyRecyclerHeadersDecoration类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: initFragment

import com.timehop.stickyheadersrecyclerview.StickyRecyclerHeadersDecoration; //导入依赖的package包/类
@Override
    protected void initFragment(Bundle savedInstanceState) {
        super.initFragment(savedInstanceState);
        setLoadMoreEnable(true);
        ItemTouchHelperCallback callback = new ItemTouchHelperCallback(0,
                ItemTouchHelper.LEFT | ItemTouchHelper.RIGHT, this);
        itemTouchHelper = new ItemTouchHelper(callback);
        itemTouchHelper.attachToRecyclerView(recyclerView);
        StickyRecyclerHeadersDecoration headersDecor = new StickyRecyclerHeadersDecoration(adapter);
        recyclerView.addItemDecoration(headersDecor);

        StickyRecyclerHeadersTouchListener touchListener =
                new StickyRecyclerHeadersTouchListener(recyclerView, headersDecor);
        touchListener.setOnHeaderClickListener((header, position, headerId) -> {
            //wrong position returned
//            recyclerView.smoothScrollToPosition(mPresenter.getFirstItemByDate((Long) header.getTag()));
        });
        recyclerView.addOnItemTouchListener(touchListener);

    }
 
开发者ID:ThirtyDegreesRay,项目名称:OpenHub,代码行数:21,代码来源:TraceFragment.java

示例2: configureStickyHeaderDecoration

import com.timehop.stickyheadersrecyclerview.StickyRecyclerHeadersDecoration; //导入依赖的package包/类
public void configureStickyHeaderDecoration(RecyclerView recyclerView, final StickyRecyclerHeadersDecoration itemDecoration) {
    recyclerView.addItemDecoration(itemDecoration);
    registerAdapterDataObserver(new RecyclerView.AdapterDataObserver() {
        @Override
        public void onChanged() {
            itemDecoration.invalidateHeaders();
        }
    });

}
 
开发者ID:Polidea,项目名称:recycler-view-adapters,代码行数:11,代码来源:BaseStickySectionRecyclerViewAdapter.java

示例3: initUI

import com.timehop.stickyheadersrecyclerview.StickyRecyclerHeadersDecoration; //导入依赖的package包/类
@Override
public void initUI(View view) {
    ButterKnife.bind(this, view);
    mPresenter.attachView(this);
    LinearLayoutManager layoutManager =
            new LinearLayoutManager(getActivity().getApplicationContext());
    recyclerView.setLayoutManager(layoutManager);
    recyclerView.setAdapter(mAdapter);
    final StickyRecyclerHeadersDecoration headersDecor =
            new StickyRecyclerHeadersDecoration(mAdapter);
    recyclerView.addItemDecoration(headersDecor);
    refreshLayout.setEnabled(false);
    mAdapter.setOnItemClickListener(this);
}
 
开发者ID:gzsll,项目名称:TLint,代码行数:15,代码来源:ForumListFragment.java

示例4: initMessagesRecyclerView

import com.timehop.stickyheadersrecyclerview.StickyRecyclerHeadersDecoration; //导入依赖的package包/类
@Override
protected void initMessagesRecyclerView() {
    super.initMessagesRecyclerView();
    messagesRecyclerView.addItemDecoration(
            new StickyRecyclerHeadersDecoration(messagesAdapter));
    findLastFriendsRequest(true);

    messagesRecyclerView.setAdapter(messagesAdapter);
    scrollMessagesToBottom(0);
}
 
开发者ID:QuickBlox,项目名称:q-municate-android,代码行数:11,代码来源:PrivateDialogActivity.java

示例5: initMessagesRecyclerView

import com.timehop.stickyheadersrecyclerview.StickyRecyclerHeadersDecoration; //导入依赖的package包/类
@Override
protected void initMessagesRecyclerView() {
    super.initMessagesRecyclerView();
    messagesRecyclerView.addItemDecoration(
            new StickyRecyclerHeadersDecoration(messagesAdapter));
    messagesRecyclerView.setAdapter(messagesAdapter);

    scrollMessagesToBottom(0);
}
 
开发者ID:QuickBlox,项目名称:q-municate-android,代码行数:10,代码来源:GroupDialogActivity.java

示例6: displayInfo

import com.timehop.stickyheadersrecyclerview.StickyRecyclerHeadersDecoration; //导入依赖的package包/类
private void displayInfo() {
    if (recyclerView == null) {
        return;
    }
    final ArrayList<BaseInfoObject> items = InfoUtil.getFullInfo(getActivity());
    final InfoAdapter adapter = new InfoAdapter(getActivity().getApplicationContext(), items, this);
    recyclerView.setAdapter(adapter);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
        recyclerView.addItemDecoration(new StickyRecyclerHeadersDecoration(adapter));
    }
}
 
开发者ID:harri35,项目名称:res-check,代码行数:12,代码来源:SpecFragment.java

示例7: onCreate

import com.timehop.stickyheadersrecyclerview.StickyRecyclerHeadersDecoration; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    findViewById(android.R.id.content).setSystemUiVisibility(findViewById(android.R.id.content).getSystemUiVisibility() | View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_sample);

    // Handle Toolbar
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    getSupportActionBar().setTitle(R.string.sample_sticky_header);

    //style our ui
    new MaterializeBuilder().withActivity(this).build();

    //create our FastAdapter
    fastAdapter = new FastAdapter();
    fastAdapter.withSelectable(true);

    //create our adapters
    final StickyHeaderAdapter stickyHeaderAdapter = new StickyHeaderAdapter();
    final HeaderAdapter headerAdapter = new HeaderAdapter();
    final ItemAdapter itemAdapter = new ItemAdapter();

    //configure our fastAdapter
    //as we provide id's for the items we want the hasStableIds enabled to speed up things
    fastAdapter.setHasStableIds(true);

    //get our recyclerView and do basic setup
    RecyclerView rv = (RecyclerView) findViewById(R.id.rv);
    rv.setLayoutManager(new LinearLayoutManager(this));
    rv.setItemAnimator(new DefaultItemAnimator());
    rv.setAdapter(stickyHeaderAdapter.wrap(itemAdapter.wrap(headerAdapter.wrap(fastAdapter))));

    //this adds the Sticky Headers within our list
    final StickyRecyclerHeadersDecoration decoration = new StickyRecyclerHeadersDecoration(stickyHeaderAdapter);
    rv.addItemDecoration(decoration);

    //fill with some sample data
    headerAdapter.add(new SimpleItem().withName("Header").withIdentifier(1));
    List<IItem> items = new ArrayList<>();
    for (int i = 1; i <= 100; i++) {
        items.add(new SimpleItem().withName("Test " + i).withHeader(headers[i / 5]).withIdentifier(100 + i));
    }
    itemAdapter.add(items);

    //so the headers are aware of changes
    stickyHeaderAdapter.registerAdapterDataObserver(new RecyclerView.AdapterDataObserver() {
        @Override
        public void onChanged() {
            decoration.invalidateHeaders();
        }
    });

    //restore selections (this has to be done after the items were added
    fastAdapter.withSavedInstanceState(savedInstanceState);

    //set the back arrow in the toolbar
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setHomeButtonEnabled(false);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:61,代码来源:StickyHeaderSampleActivity.java

示例8: init

import com.timehop.stickyheadersrecyclerview.StickyRecyclerHeadersDecoration; //导入依赖的package包/类
@Override
protected void init(Bundle savedInstanceState) {
    super.init(savedInstanceState);

    mAdapter = new FloatWatchedVideoAdapter(this, new WatchedVideoSelectCountCallback() {
        @Override
        public void onWatchedVideoSelect(int count) {
            mDeleteButton.setCount(count);
        }
    });
    LinearLayoutManager layoutManager = new LinearLayoutManager(this);
    mRecyclerView.setLayoutManager(layoutManager);
    mRecyclerView.setAdapter(mAdapter);

    final StickyRecyclerHeadersDecoration decoration = new StickyRecyclerHeadersDecoration((FloatWatchedVideoAdapter) mAdapter);
    mRecyclerView.addItemDecoration(decoration);
    mAdapter.registerAdapterDataObserver(new RecyclerView.AdapterDataObserver() {
        @Override
        public void onChanged() {
            decoration.invalidateHeaders();
        }
    });

    VideoCacheManager.INSTANCE.getWatchedVideo();

    RxBus.getDefault().toObservable(WatchedVideoGetEvent.class).observeOn(AndroidSchedulers.mainThread())
            .subscribe(new OnNextSubscriber<WatchedVideoGetEvent>() {
                @Override
                public void onNext(WatchedVideoGetEvent watchedVideoGetEvent) {
                    if (watchedVideoGetEvent.mSuccess) {
                        List<GreenWatchedVideo> videos = watchedVideoGetEvent.mGreenWatchedVideos;
                        if (videos.size() > 0) {
                            mAdapter.setData(videos);
                            mEmptyView.setVisibility(View.GONE);
                        } else {
                            showEmptyView();
                        }
                    } else {
                        showEmptyView();
                    }
                }
            });
}
 
开发者ID:uin3566,项目名称:Dota2Helper,代码行数:44,代码来源:WatchedVideoListActivity.java

示例9: onCreate

import com.timehop.stickyheadersrecyclerview.StickyRecyclerHeadersDecoration; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    recyclerView = (RecyclerView) findViewById(R.id.recyclerView);
    quickSideBarView = (QuickSideBarView) findViewById(R.id.quickSideBarView);
    quickSideBarTipsView = (QuickSideBarTipsView) findViewById(R.id.quickSideBarTipsView);

    //设置监听
    quickSideBarView.setOnQuickSideBarTouchListener(this);


    //设置列表数据和浮动header
    final LinearLayoutManager layoutManager = new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false);
    recyclerView.setLayoutManager(layoutManager);

    // Add the sticky headers decoration
    CityListWithHeadersAdapter adapter = new CityListWithHeadersAdapter();

    //GSON解释出来
    Type listType = new TypeToken<LinkedList<City>>(){}.getType();
    Gson gson = new Gson();
    LinkedList<City> cities = gson.fromJson(DataConstants.cityDataList, listType);

    ArrayList<String> customLetters = new ArrayList<>();

    int position = 0;
    for(City city: cities){
        String letter = city.getFirstLetter();
        //如果没有这个key则加入并把位置也加入
        if(!letters.containsKey(letter)){
            letters.put(letter,position);
            customLetters.add(letter);
        }
        position++;
    }

    //不自定义则默认26个字母
    quickSideBarView.setLetters(customLetters);
    adapter.addAll(cities);
    recyclerView.setAdapter(adapter);

    final StickyRecyclerHeadersDecoration headersDecor = new StickyRecyclerHeadersDecoration(adapter);
    recyclerView.addItemDecoration(headersDecor);

    // Add decoration for dividers between list items
    recyclerView.addItemDecoration(new DividerDecoration(this));
}
 
开发者ID:shenyunmeng0519,项目名称:Rapid-retrieval,代码行数:49,代码来源:MainActivity.java

示例10: onConfigureRecyclerView

import com.timehop.stickyheadersrecyclerview.StickyRecyclerHeadersDecoration; //导入依赖的package包/类
@Override
protected void onConfigureRecyclerView(RecyclerView recyclerView) {
    recyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
    getAdapter().configureStickyHeaderDecoration(recyclerView, new StickyRecyclerHeadersDecoration(getAdapter()));
}
 
开发者ID:Polidea,项目名称:recycler-view-adapters,代码行数:6,代码来源:LinearFragment.java


注:本文中的com.timehop.stickyheadersrecyclerview.StickyRecyclerHeadersDecoration类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。