Search in sources :

Example 1 with LayoutManager

use of android.support.v7.widget.RecyclerView.LayoutManager in project Onboarding by eoinfogarty.

the class SceneThreeFragment method scrollRecycleViewTo.

private void scrollRecycleViewTo(RecyclerView recyclerView, int offset) {
    LinearLayoutManager layoutManager = ((LinearLayoutManager) recyclerView.getLayoutManager());
    layoutManager.scrollToPositionWithOffset(2, offset);
}
Also used : LinearLayoutManager(android.support.v7.widget.LinearLayoutManager)

Example 2 with LayoutManager

use of android.support.v7.widget.RecyclerView.LayoutManager in project MultiType by drakeet.

the class MultiSelectActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_multi_select);
    RecyclerView recyclerView = (RecyclerView) findViewById(R.id.list);
    final GridLayoutManager layoutManager = new GridLayoutManager(this, SPAN_COUNT);
    layoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() {

        @Override
        public int getSpanSize(int position) {
            return (items.get(position) instanceof Category) ? SPAN_COUNT : 1;
        }
    });
    selectedSet = new TreeSet<>();
    recyclerView.setLayoutManager(layoutManager);
    adapter = new MultiTypeAdapter();
    adapter.applyGlobalMultiTypePool();
    adapter.register(Square.class, new SquareViewBinder(selectedSet));
    loadData();
    assertAllRegistered(adapter, items);
    recyclerView.setAdapter(adapter);
    setupFAB();
}
Also used : Category(me.drakeet.multitype.sample.common.Category) GridLayoutManager(android.support.v7.widget.GridLayoutManager) RecyclerView(android.support.v7.widget.RecyclerView) MultiTypeAdapter(me.drakeet.multitype.MultiTypeAdapter)

Example 3 with LayoutManager

use of android.support.v7.widget.RecyclerView.LayoutManager in project philm by chrisbanes.

the class MovieDetailFragment method populateUi.

private void populateUi() {
    if (mMovie == null) {
        return;
    }
    if (mBackdropImageView != null) {
        if (mMovie.hasBackdropUrl()) {
            mBackdropImageView.loadBackdrop(mMovie);
        }
    }
    if (mCollapsingToolbarLayout != null) {
        mCollapsingToolbarLayout.setTitle(mMovie.getTitle());
    }
    mAdapter = new GroupAdapter();
    mAdapter.add(new TitleItem());
    mAdapter.add(new ButtonsItem());
    if (!TextUtils.isEmpty(mMovie.getOverview())) {
        mAdapter.add(new SummaryItem());
    }
    mAdapter.add(new RatingItem());
    mAdapter.add(new DetailsGroup());
    //
    //        if (!PhilmCollections.isEmpty(mMovie.getTrailers())) {
    //            mItems.add(DetailItemType.TRAILERS);
    //        }
    //
    //        if (!PhilmCollections.isEmpty(mMovie.getCast())) {
    //            mItems.add(DetailItemType.CAST);
    //        }
    //
    //        if (!PhilmCollections.isEmpty(mMovie.getCrew())) {
    //            mItems.add(DetailItemType.CREW);
    //        }
    //
    //        if (!PhilmCollections.isEmpty(mMovie.getRelated())) {
    //            mItems.add(DetailItemType.RELATED);
    //        }
    GridLayoutManager layoutManager = new GridLayoutManager(getContext(), mAdapter.getSpanCount());
    layoutManager.setSpanSizeLookup(mAdapter.getSpanSizeLookup());
    mRecyclerView.setLayoutManager(layoutManager);
    mRecyclerView.setAdapter(mAdapter);
}
Also used : GroupAdapter(com.genius.groupie.GroupAdapter) GridLayoutManager(android.support.v7.widget.GridLayoutManager)

Example 4 with LayoutManager

use of android.support.v7.widget.RecyclerView.LayoutManager in project baseAdapter by hongyangAndroid.

the class WrapperUtils method onAttachedToRecyclerView.

public static void onAttachedToRecyclerView(RecyclerView.Adapter innerAdapter, RecyclerView recyclerView, final SpanSizeCallback callback) {
    innerAdapter.onAttachedToRecyclerView(recyclerView);
    RecyclerView.LayoutManager layoutManager = recyclerView.getLayoutManager();
    if (layoutManager instanceof GridLayoutManager) {
        final GridLayoutManager gridLayoutManager = (GridLayoutManager) layoutManager;
        final GridLayoutManager.SpanSizeLookup spanSizeLookup = gridLayoutManager.getSpanSizeLookup();
        gridLayoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() {

            @Override
            public int getSpanSize(int position) {
                return callback.getSpanSize(gridLayoutManager, spanSizeLookup, position);
            }
        });
        gridLayoutManager.setSpanCount(gridLayoutManager.getSpanCount());
    }
}
Also used : GridLayoutManager(android.support.v7.widget.GridLayoutManager) StaggeredGridLayoutManager(android.support.v7.widget.StaggeredGridLayoutManager) RecyclerView(android.support.v7.widget.RecyclerView)

Example 5 with LayoutManager

use of android.support.v7.widget.RecyclerView.LayoutManager in project android-oss by kickstarter.

the class ThanksActivity method onCreate.

@Override
protected void onCreate(@Nullable final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.thanks_layout);
    ButterKnife.bind(this);
    ((KSApplication) getApplication()).component().inject(this);
    shareDialog = new ShareDialog(this);
    final LinearLayoutManager layoutManager = new LinearLayoutManager(this);
    layoutManager.setOrientation(LinearLayoutManager.HORIZONTAL);
    recommendedProjectsRecyclerView.setLayoutManager(layoutManager);
    adapter = new ThanksAdapter(viewModel);
    recommendedProjectsRecyclerView.setAdapter(adapter);
    Observable.timer(500L, TimeUnit.MILLISECONDS, Schedulers.newThread()).compose(ignoreValues()).compose(bindToLifecycle()).observeOn(AndroidSchedulers.mainThread()).subscribe(__ -> animateBackground());
    RxView.clicks(shareButton).compose(bindToLifecycle()).observeOn(AndroidSchedulers.mainThread()).subscribe(__ -> viewModel.inputs.shareClick());
    RxView.clicks(shareOnFacebookButton).compose(bindToLifecycle()).observeOn(AndroidSchedulers.mainThread()).subscribe(__ -> viewModel.inputs.shareOnFacebookClick());
    RxView.clicks(shareOnTwitterButton).compose(bindToLifecycle()).observeOn(AndroidSchedulers.mainThread()).subscribe(__ -> viewModel.inputs.shareOnTwitterClick());
    viewModel.outputs.projectName().compose(bindToLifecycle()).observeOn(AndroidSchedulers.mainThread()).subscribe(this::showBackedProject);
    viewModel.outputs.showConfirmGamesNewsletterDialog().compose(bindToLifecycle()).observeOn(AndroidSchedulers.mainThread()).subscribe(__ -> showConfirmGamesNewsletterDialog());
    viewModel.outputs.showGamesNewsletterDialog().compose(bindToLifecycle()).take(1).delay(700L, TimeUnit.MILLISECONDS).observeOn(AndroidSchedulers.mainThread()).subscribe(__ -> showGamesNewsletterDialog());
    viewModel.outputs.showRatingDialog().compose(bindToLifecycle()).take(1).delay(700L, TimeUnit.MILLISECONDS).observeOn(AndroidSchedulers.mainThread()).subscribe(__ -> showRatingDialog());
    viewModel.outputs.showRecommendations().compose(bindToLifecycle()).observeOn(AndroidSchedulers.mainThread()).subscribe(this::showRecommendations);
    viewModel.outputs.startDiscovery().compose(bindToLifecycle()).observeOn(AndroidSchedulers.mainThread()).subscribe(this::startDiscovery);
    viewModel.outputs.startProject().compose(bindToLifecycle()).observeOn(AndroidSchedulers.mainThread()).subscribe(this::startProject);
    viewModel.outputs.startShare().compose(bindToLifecycle()).observeOn(AndroidSchedulers.mainThread()).subscribe(this::startShare);
    viewModel.outputs.startShareOnFacebook().compose(bindToLifecycle()).observeOn(AndroidSchedulers.mainThread()).subscribe(this::startShareOnFacebook);
    viewModel.outputs.startShareOnTwitter().compose(bindToLifecycle()).observeOn(AndroidSchedulers.mainThread()).subscribe(this::startShareOnTwitter);
}
Also used : ThanksAdapter(com.kickstarter.ui.adapters.ThanksAdapter) ShareDialog(com.facebook.share.widget.ShareDialog) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager)

Aggregations

LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)430 RecyclerView (android.support.v7.widget.RecyclerView)371 View (android.view.View)261 GridLayoutManager (android.support.v7.widget.GridLayoutManager)128 TextView (android.widget.TextView)113 DefaultItemAnimator (android.support.v7.widget.DefaultItemAnimator)79 StaggeredGridLayoutManager (android.support.v7.widget.StaggeredGridLayoutManager)73 ImageView (android.widget.ImageView)71 SwipeRefreshLayout (android.support.v4.widget.SwipeRefreshLayout)47 Intent (android.content.Intent)46 ArrayList (java.util.ArrayList)43 Bundle (android.os.Bundle)37 Nullable (android.support.annotation.Nullable)33 Context (android.content.Context)29 DividerItemDecoration (android.support.v7.widget.DividerItemDecoration)28 BindView (butterknife.BindView)28 Toolbar (android.support.v7.widget.Toolbar)25 ViewGroup (android.view.ViewGroup)25 Handler (android.os.Handler)22 FloatingActionButton (android.support.design.widget.FloatingActionButton)21