Java Code Examples for android.support.v7.widget.GridLayoutManager#VERTICAL

The following examples show how to use android.support.v7.widget.GridLayoutManager#VERTICAL . 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: MapListActivity.java    From android-map_list with MIT License 6 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_list);

    mRecyclerView = (RecyclerView) findViewById(R.id.card_list);

    // Determine the number of columns to display, based on screen width.
    int rows = getResources().getInteger(R.integer.map_grid_cols);
    GridLayoutManager layoutManager = new GridLayoutManager(this, rows, GridLayoutManager.VERTICAL, false);
    mRecyclerView.setLayoutManager(layoutManager);

    mListAdapter = createMapListAdapter();

    // Delay attaching Adapter to RecyclerView until we can ensure that we have correct
    // Google Play service version (in onResume).
}
 
Example 2
Source File: ListMovieWatchedFragment.java    From Movie-Check with Apache License 2.0 5 votes vote down vote up
@Override
public void showWatchedMovies(final List<MovieWatched> movieWatchedList) {
    this.movieWatchedList = movieWatchedList;
    linearLayoutAnyFounded.setVisibility(View.GONE);
    recyclerViewMovieWatched.setVisibility(View.VISIBLE);
    final GridLayoutManager layoutManager = new GridLayoutManager(getActivity(), 1, GridLayoutManager.VERTICAL, false);
    recyclerViewMovieWatched.setLayoutManager(layoutManager);
    recyclerViewMovieWatched.setItemAnimator(new DefaultItemAnimator());
    movieWatchedListAdapter = new MovieWatchedListAdapter(movieWatchedList, new OnItemClickListener<MovieWatched>() {
        @Override
        public void onClick(MovieWatched movieWatched, View view) {
            startActivity(MovieProfileActivity.newIntent(getActivity(), movieWatched.getMovie()));
        }

        @Override
        public void onLongClick(final MovieWatched movieWatched, final View view) {
            new AlertDialog.Builder(new ContextThemeWrapper(getActivity(), R.style.DialogLight)).setItems(new CharSequence[]{getActivity().getString(R.string.listmoviewatchedfragment_remove)}, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    switch (which) {
                        case 0:
                            removeWatchedMovie(movieWatched);
                            break;
                    }
                }
            }).create().show();
        }
    });
    recyclerViewMovieWatched.setAdapter(movieWatchedListAdapter);
}
 
Example 3
Source File: VerticalGridRecyclerActivity.java    From CommonItemDecoration with Apache License 2.0 5 votes vote down vote up
private void initNormalAdapter(){
    List<BrandData> data = new ArrayList<>();
    for(int i = 0; i < 20; i++){
        BrandData brand = new BrandData("brand " + i);
        data.add(brand);
    }

    GridLayoutManager manager = new GridLayoutManager(this, 3, GridLayoutManager.VERTICAL, false);
    manager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() {
        @Override
        public int getSpanSize(int position) {
            if(position == 1 || position == 2){
                return 2;
            }
            if(position == 10){
                return 2;
            }
            return 1;
        }
    });
    mBrandRecyclerView.setLayoutManager(manager);

    mMyAdapter = new VerticalAdapter(data);
    mBrandRecyclerView.setAdapter(mMyAdapter);

    mBrandRecyclerView.addItemDecoration(
            SCommonItemDecoration.builder()
                    .type(VerticalAdapter.TYPE_1)
                    .prop(Utils.dip2px(this, 15), Utils.dip2px(this, 25), true, true)
                    .buildType()
                    .type(VerticalAdapter.TYPE_2)
                    .prop(Utils.dip2px(this, 5), Utils.dip2px(this, 5), true, true)
                    .buildType()
                    .build()
    );
}
 
Example 4
Source File: InstagramActivity.java    From AndroidSweetBehavior with Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_instagram);
    mRV = (RecyclerView) findViewById(R.id.rv);
    mAppBarLayout = (AppBarLayout) findViewById(R.id.appBarLayout);
    mContentIv = (ImageView) findViewById(R.id.contentIv);
    mCoordinatorLayout = (CoordinatorLayout) findViewById(R.id.coordinatorLY);
    mContentIv.setOnClickListener(this);


    List<ImageEntity> list = new ArrayList<>();
    list.add(new ImageEntity(randomIntArray[0]));
    for (int i = 0; i < 78; i++) {
        ImageEntity item = new ImageEntity();
        item.resId = randomIntArray[new Random().nextInt(8)];
        list.add(item);
    }

    gridLayoutManager = new GridLayoutManager(this, 4, GridLayoutManager.VERTICAL, false);

    mRV.setLayoutManager(gridLayoutManager);


    mRV.setAdapter(new ImageRVAdapter(list, this));
}
 
Example 5
Source File: ListNowPlayingMoviesActivity.java    From Movie-Check with Apache License 2.0 5 votes vote down vote up
@Override
public void showMovies(final List<Movie> newMovieList) {
    if (movieList == null) {
        movieList = newMovieList;
    } else {
        movieList.addAll(newMovieList);
    }
    linearLayoutAnyFounded.setVisibility(View.GONE);
    linearLayoutLoadFailed.setVisibility(View.GONE);
    recyclerViewMovies.setVisibility(View.VISIBLE);
    final GridLayoutManager layoutManager = new GridLayoutManager(this, columns, GridLayoutManager.VERTICAL, false);
    recyclerViewMovies.setLayoutManager(layoutManager);
    recyclerViewMovies.setItemAnimator(new DefaultItemAnimator());
    listViewAdapter = new ListViewAdapterWithPagination(
            new NowPlayingMovieListAdapter(movieList, new OnItemClickListener<Movie>() {
                @Override
                public void onClick(Movie movie, View view) {
                    startActivity(MovieProfileActivity.newIntent(ListNowPlayingMoviesActivity.this, movie), ActivityOptionsCompat.makeSceneTransitionAnimation(ListNowPlayingMoviesActivity.this, view.findViewById(R.id.imageview_backdrop), "movieBackdrop").toBundle());
                }

                @Override
                public void onLongClick(Movie movie, View view) {

                }
            }),
            new OnShowMoreListener() {
                @Override
                public void showMore() {
                    scrollToItem = layoutManager.findFirstVisibleItemPosition();
                    presenter.loadMovies(++page);
                }
            },
            itensPerPage);
    recyclerViewMovies.setAdapter(listViewAdapter);
    recyclerViewMovies.scrollToPosition(scrollToItem);
}
 
Example 6
Source File: RecyclerViewUtils.java    From UGank with GNU General Public License v3.0 5 votes vote down vote up
public static void setGridLayout(RecyclerView rv, int spanCount) {
    GridLayoutManager gridLayoutManager = new GridLayoutManager(rv.getContext(), spanCount, GridLayoutManager.VERTICAL, false) {
        @Override
        public void onLayoutChildren(RecyclerView.Recycler recycler, RecyclerView.State state) {
            try {
                super.onLayoutChildren(recycler, state);
            } catch (IndexOutOfBoundsException e) {
                Log.e(TAG, "meet an IndexOutOfBoundsException in RecyclerView");
            }
        }
    };
    rv.setLayoutManager(gridLayoutManager);
}
 
Example 7
Source File: ListReviewFragment.java    From Movie-Check with Apache License 2.0 5 votes vote down vote up
@Override
public void showReviews() {
    linearLayoutAnyFounded.setVisibility(View.GONE);
    linearLayoutLoadFailed.setVisibility(View.GONE);
    recyclerViewReviews.setVisibility(View.VISIBLE);
    final GridLayoutManager layoutManager = new GridLayoutManager(getActivity(), 1, GridLayoutManager.VERTICAL, false);
    recyclerViewReviews.setLayoutManager(layoutManager);
    recyclerViewReviews.setItemAnimator(new DefaultItemAnimator());
    listViewAdapter = new ListViewAdapterWithPagination(
            new ReviewListAdapter(this.reviewList, new OnItemClickListener<Review>() {
                @Override
                public void onClick(Review review, View view) {
                    Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(review.getUrl()));
                    startActivity(browserIntent);
                }

                @Override
                public void onLongClick(Review review, View view) {

                }
            }),
            new OnShowMoreListener() {
                @Override
                public void showMore() {
                    scrollToItem = layoutManager.findFirstVisibleItemPosition();
                    presenter.loadReviews(movie, ++page);
                }
            },
            itensPerPage);
    recyclerViewReviews.setAdapter(listViewAdapter);
    recyclerViewReviews.scrollToPosition(scrollToItem);
}
 
Example 8
Source File: RecyclerViewUtils.java    From LLApp with Apache License 2.0 5 votes vote down vote up
public static void setGridLayout(RecyclerView rv, int spanCount) {
    GridLayoutManager gridLayoutManager = new GridLayoutManager(rv.getContext(), spanCount, GridLayoutManager.VERTICAL, false) {
        @Override
        public void onLayoutChildren(RecyclerView.Recycler recycler, RecyclerView.State state) {
            try {
                super.onLayoutChildren(recycler, state);
            } catch (IndexOutOfBoundsException e) {
                Log.e(TAG, "meet an IndexOutOfBoundsException in RecyclerView");
            }
        }
    };
    rv.setLayoutManager(gridLayoutManager);
}
 
Example 9
Source File: LookupItemMasterListDialogFragment.java    From stockita-point-of-sale with MIT License 4 votes vote down vote up
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    // Initialize the view
    final View view = inflater.inflate(R.layout.dialog_lookup_item_master, container, false);

    // Initialize the ButterKnife
    ButterKnife.bind(this, view);

    // Set more efficient
    mItemMasterList.setHasFixedSize(true);


    /**
     * Code below is for the number of span depend device (Phone / tablet)
     * and orientation (portrait / landscape)
     */
    int columnCount;
    boolean isTablet = getResources().getBoolean(R.bool.isTablet);
    boolean isLandscape = getResources().getBoolean(R.bool.isLandscape);

    if (isTablet && isLandscape) {
        columnCount = 4;
    } else if (!isTablet && isLandscape) {
        columnCount = 3;
    } else if (isTablet && !isLandscape) {
        columnCount = 3;
    } else {
        columnCount = 2;
    }


    // Initialize the LayoutManager for item master
    GridLayoutManager layoutManager =
            new GridLayoutManager(getActivity(), columnCount, GridLayoutManager.VERTICAL, false);

    // Set the layout manager for the item master
    mItemMasterList.setLayoutManager(layoutManager);

    // Return the view object
    return view;

}
 
Example 10
Source File: SearchMovieActivity.java    From Movie-Check with Apache License 2.0 4 votes vote down vote up
@Override
public void showMovies(final List<Movie> newMovieList) {
    if (movieList == null) {
        movieList = newMovieList;
    } else {
        movieList.addAll(newMovieList);
    }
    linearLayoutAnyFounded.setVisibility(View.GONE);
    linearLayoutLoadFailed.setVisibility(View.GONE);
    recyclerViewMovies.setVisibility(View.VISIBLE);
    final GridLayoutManager layoutManager = new GridLayoutManager(this, columns, GridLayoutManager.VERTICAL, false);
    layoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() {
        @Override
        public int getSpanSize(int position) {
            return position >= movieList.size() ? columns : 1;
        }
    });
    recyclerViewMovies.setLayoutManager(layoutManager);
    recyclerViewMovies.setItemAnimator(new DefaultItemAnimator());
    listViewAdapter = new ListViewAdapterWithPagination(
            new MovieListAdapter(movieList, new OnItemClickListener<Movie>() {
                @Override
                public void onClick(Movie movie, View view) {
                    startActivity(MovieProfileActivity.newIntent(SearchMovieActivity.this, movie), ActivityOptionsCompat.makeSceneTransitionAnimation(SearchMovieActivity.this, view.findViewById(R.id.imageview_poster), "moviePoster").toBundle());
                }

                @Override
                public void onLongClick(Movie movie, View view) {

                }
            }
            ),
            new OnShowMoreListener() {
                @Override
                public void showMore() {
                    scrollToItem = layoutManager.findFirstVisibleItemPosition();
                    presenter.search(query, ++page);
                }
            },
            itensPerPage);
    recyclerViewMovies.setAdapter(listViewAdapter);
    recyclerViewMovies.scrollToPosition(scrollToItem);
}
 
Example 11
Source File: VerticalGridFragment.java    From recyclerview-playground with MIT License 4 votes vote down vote up
@Override
protected RecyclerView.LayoutManager getLayoutManager() {
    return new GridLayoutManager(getActivity(), 2, GridLayoutManager.VERTICAL, false);
}
 
Example 12
Source File: ListTopRatedMoviesActivity.java    From Movie-Check with Apache License 2.0 4 votes vote down vote up
@Override
public void showMovies(final List<Movie> newMovieList) {
    if (movieList == null) {
        movieList = newMovieList;
    } else {
        movieList.addAll(newMovieList);
    }
    linearLayoutAnyFounded.setVisibility(View.GONE);
    linearLayoutLoadFailed.setVisibility(View.GONE);
    recyclerViewMovies.setVisibility(View.VISIBLE);
    final GridLayoutManager layoutManager = new GridLayoutManager(this, columns, GridLayoutManager.VERTICAL, false);
    layoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() {
        @Override
        public int getSpanSize(int position) {
            return position >= movieList.size() ? columns : 1;
        }
    });
    recyclerViewMovies.setLayoutManager(layoutManager);
    recyclerViewMovies.setItemAnimator(new DefaultItemAnimator());
    listViewAdapter = new ListViewAdapterWithPagination(
            new TopRatedMovieListAdapter(movieList, new OnItemClickListener<Movie>() {
                @Override
                public void onClick(Movie movie, View view) {
                    startActivity(MovieProfileActivity.newIntent(ListTopRatedMoviesActivity.this, movie), ActivityOptionsCompat.makeSceneTransitionAnimation(ListTopRatedMoviesActivity.this, view.findViewById(R.id.imageview_poster), "moviePoster").toBundle());
                }

                @Override
                public void onLongClick(Movie movie, View view) {

                }
            }
            ),
            new OnShowMoreListener() {
                @Override
                public void showMore() {
                    scrollToItem = layoutManager.findFirstVisibleItemPosition();
                    presenter.loadMovies(++page);
                }
            },
            itensPerPage);
    recyclerViewMovies.setAdapter(listViewAdapter);
    recyclerViewMovies.scrollToPosition(scrollToItem);
}
 
Example 13
Source File: ListPopularMoviesActivity.java    From Movie-Check with Apache License 2.0 4 votes vote down vote up
@Override
public void showMovies(final List<Movie> newMovieList) {
    if (movieList == null) {
        movieList = newMovieList;
    } else {
        movieList.addAll(newMovieList);
    }
    linearLayoutAnyFounded.setVisibility(View.GONE);
    linearLayoutLoadFailed.setVisibility(View.GONE);
    recyclerViewMovies.setVisibility(View.VISIBLE);
    final GridLayoutManager layoutManager = new GridLayoutManager(this, columns, GridLayoutManager.VERTICAL, false);
    layoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() {
        @Override
        public int getSpanSize(int position) {
            return position >= movieList.size() ? columns : 1;
        }
    });
    recyclerViewMovies.setLayoutManager(layoutManager);
    recyclerViewMovies.setItemAnimator(new DefaultItemAnimator());
    listViewAdapter = new ListViewAdapterWithPagination(
            new MovieListAdapter(movieList, new OnItemClickListener<Movie>() {
                @Override
                public void onClick(Movie movie, View view) {
                    startActivity(MovieProfileActivity.newIntent(ListPopularMoviesActivity.this, movie), ActivityOptionsCompat.makeSceneTransitionAnimation(ListPopularMoviesActivity.this, view.findViewById(R.id.imageview_poster), "moviePoster").toBundle());
                }

                @Override
                public void onLongClick(Movie movie, View view) {

                }
            }
            ),
            new OnShowMoreListener() {
                @Override
                public void showMore() {
                    scrollToItem = layoutManager.findFirstVisibleItemPosition();
                    presenter.loadMovies(++page);
                }
            },
            itensPerPage);
    recyclerViewMovies.setAdapter(listViewAdapter);
    recyclerViewMovies.scrollToPosition(scrollToItem);
}
 
Example 14
Source File: VideoFrameActivity.java    From PLDroidShortVideo with Apache License 2.0 4 votes vote down vote up
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
            WindowManager.LayoutParams.FLAG_FULLSCREEN);

    setContentView(R.layout.activity_video_frame);
    mRecyclerView = (RecyclerView) findViewById(R.id.recycler_view);
    mLayoutManager = new GridLayoutManager(this, 3, GridLayoutManager.VERTICAL, false);
    mRecyclerView.setLayoutManager(mLayoutManager);
    ((SimpleItemAnimator) mRecyclerView.getItemAnimator()).setSupportsChangeAnimations(false);

    ArrayList<String> arrayList = getIntent().getStringArrayListExtra(DATA_EXTRA_PATHS);
    mVideoPaths = (arrayList == null) ? new ArrayList<String>() : arrayList;

    mDragItemAdapter = new DragItemAdapter(mVideoPaths);
    mDragItemAdapter.setOnItemMovedListener(new DragItemAdapter.OnItemMovedListener() {
        @Override
        public void onMoveItem(int fromPosition, int toPosition) {
            String movedItem = mVideoPaths.remove(fromPosition);
            mVideoPaths.add(toPosition, movedItem);
        }
    });

    RecyclerViewDragDropManager dragDropManager = new RecyclerViewDragDropManager();
    dragDropManager.setInitiateOnMove(false);
    dragDropManager.setInitiateOnLongPress(true);

    RecyclerView.Adapter adapter = dragDropManager.createWrappedAdapter(mDragItemAdapter);
    mRecyclerView.setAdapter(adapter);
    dragDropManager.attachRecyclerView(mRecyclerView);

    mShortVideoComposer = new PLShortVideoComposer(this);
    mProcessingDialog = new CustomProgressDialog(this);
    mProcessingDialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
        @Override
        public void onCancel(DialogInterface dialog) {
            mShortVideoComposer.cancelComposeVideos();
        }
    });
}
 
Example 15
Source File: OpenSalesDetailFragmentUI.java    From stockita-point-of-sale with MIT License 4 votes vote down vote up
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    // Initialize the view
    View view = inflater.inflate(R.layout.fragment_list_of_open_sales_detail, container, false);

    // Initialize the ButterKnife
    ButterKnife.bind(this, view);

    // Set more efficient
    mList.setHasFixedSize(true);

    // Initialize the adapter
    mAdapter = new Adapter(getActivity(), mUserUid, mSalesHeaderKey);

    // set the adapter
    mList.setAdapter(mAdapter);


    // Initialize the toolbar to display the invoice total
    initCashToolbar();


    /**
     * Code below is for the number of span depend device (Phone / tablet)
     * and orientation (portrait / landscape)
     */
    int columnCount;
    boolean isTablet = getResources().getBoolean(R.bool.isTablet);
    boolean isLandscape = getResources().getBoolean(R.bool.isLandscape);

    if (isTablet && isLandscape) {
        columnCount = 3;
    } else if (!isTablet && isLandscape) {
        columnCount = 2;
    } else if (isTablet && !isLandscape) {
        columnCount = 2;
    } else {
        columnCount = 1;
    }

    // Initialize the LayoutManager for item master
    GridLayoutManager gridLayoutManager = new GridLayoutManager(getActivity(), columnCount, GridLayoutManager.VERTICAL, false);

    // Set the layout manager
    mList.setLayoutManager(gridLayoutManager);

    // Return the view
    return view;
}
 
Example 16
Source File: PaidSalesDetailFragmentUI.java    From stockita-point-of-sale with MIT License 4 votes vote down vote up
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    // Inflate the view
    View view = inflater.inflate(R.layout.fragment_list_of_paid_sales_detail, container, false);

    // Initialize the ButterKnife
    ButterKnife.bind(this, view);


    /**
     * The code below is for the sales detail recycler view
     */

    // Set more efficient
    mList.setHasFixedSize(true);

    // Initialize the cash toolbar
    initCashToolbar();

    // Initialize the adapter
    mAdapter = new Adapter(getActivity(), mUserUid, mPaidSalesHeaderKey);

    // set the adapter
    mList.setAdapter(mAdapter);



    /**
     * Code below is for the number of span depend device (Phone / tablet)
     * and orientation (portrait / landscape)
     */
    int columnCount;
    boolean isTablet = getResources().getBoolean(R.bool.isTablet);
    boolean isLandscape = getResources().getBoolean(R.bool.isLandscape);

    if (isTablet && isLandscape) {
        columnCount = 3;
    } else if (!isTablet && isLandscape) {
        columnCount = 2;
    } else if (isTablet && !isLandscape) {
        columnCount = 2;
    } else {
        columnCount = 1;
    }

    // Initialize the LayoutManager for item master
    GridLayoutManager gridLayoutManager = new GridLayoutManager(getActivity(), columnCount, GridLayoutManager.VERTICAL, false);

    // Set the layout manager
    mList.setLayoutManager(gridLayoutManager);

    return view;
}
 
Example 17
Source File: SetMyServiceActivity.java    From Android-Application-ZJB with Apache License 2.0 4 votes vote down vote up
private void initView() {
    mAddedAdapter = new EditServiceAdapter(R.drawable.service_delete, false);
    mSelectAdapter = new EditServiceAdapter(R.drawable.service_add, false);

    GridLayoutManager mAddedLayoutManager = new GridLayoutManager(this, 4, GridLayoutManager.VERTICAL, false);
    GridLayoutManager mSelectLayoutManager = new GridLayoutManager(this, 4, GridLayoutManager.VERTICAL, false);
    mAddedRecyclerView.setLayoutManager(mAddedLayoutManager);
    mSelectRecyclerView.setLayoutManager(mSelectLayoutManager);

    mAddedRecyclerView.setItemAnimator(new DefaultItemAnimator());
    mSelectRecyclerView.setItemAnimator(new DefaultItemAnimator());

    mAddedRecyclerView.setEmptyView(mAddEmptyView);
    mSelectRecyclerView.setEmptyView(mSelectEmptyView);

    mAddedRecyclerView.addItemDecoration(new ServiceItemDecoration((int) PixelUtil.dp2px(10)));
    mSelectRecyclerView.addItemDecoration(new ServiceItemDecoration((int) PixelUtil.dp2px(10)));

    mAddedRecyclerView.setAdapter(mAddedAdapter);
    mSelectRecyclerView.setAdapter(mSelectAdapter);

    mAddedAdapter.setOnItemClickListener((services, position) -> {
        if (position < 0)
            return;
        mViewModel.computeValues(-services.getId());
        mAddedAdapter.getData().remove(position);
        mAddedAdapter.notifyItemRemoved(position);

        mSelectAdapter.getData().add(services);
        mSelectAdapter.notifyDataSetChanged();
    });
    mSelectAdapter.setOnItemClickListener((services, position) -> {
        if (position < 0)
            return;
        mViewModel.computeValues(services.getId());
        mSelectAdapter.getData().remove(position);
        mSelectAdapter.notifyItemRemoved(position);

        mAddedAdapter.getData().add(services);
        mAddedAdapter.notifyDataSetChanged();
    });
}
 
Example 18
Source File: SearchPersonActivity.java    From Movie-Check with Apache License 2.0 4 votes vote down vote up
@Override
public void showPerson(final List<Person> personList) {
    if (this.personList == null) {
        this.personList = personList;
    } else {
        this.personList.addAll(personList);
    }
    linearLayoutAnyFounded.setVisibility(View.GONE);
    linearLayoutLoadFailed.setVisibility(View.GONE);
    recyclerViewMovies.setVisibility(View.VISIBLE);
    final GridLayoutManager layoutManager = new GridLayoutManager(this, columns, GridLayoutManager.VERTICAL, false);
    layoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() {
        @Override
        public int getSpanSize(int position) {
            return position >= SearchPersonActivity.this.personList.size() ? columns : 1;
        }
    });
    recyclerViewMovies.setLayoutManager(layoutManager);
    recyclerViewMovies.setItemAnimator(new DefaultItemAnimator());
    listViewAdapter = new ListViewAdapterWithPagination(
            new PersonListAdapter(this.personList, new OnItemClickListener<Person>() {
                @Override
                public void onClick(Person person, View view) {
                    startActivity(PersonProfileActivity.newIntent(SearchPersonActivity.this, person), ActivityOptionsCompat.makeSceneTransitionAnimation(SearchPersonActivity.this, view.findViewById(R.id.imageview_photo), "personPhoto").toBundle());
                }

                @Override
                public void onLongClick(Person person, View view) {

                }
            }
            ),
            new OnShowMoreListener() {
                @Override
                public void showMore() {
                    scrollToItem = layoutManager.findFirstVisibleItemPosition();
                    presenter.search(query, ++page);
                }
            },
            itensPerPage);
    recyclerViewMovies.setAdapter(listViewAdapter);
    recyclerViewMovies.scrollToPosition(scrollToItem);
}
 
Example 19
Source File: AllAppsGridAdapter.java    From LaunchEnr with GNU General Public License v3.0 4 votes vote down vote up
AppsGridLayoutManager(Context context) {
    super(context, 1, GridLayoutManager.VERTICAL, false);
}
 
Example 20
Source File: MarginFragment.java    From recycler-view-margin-decoration with Apache License 2.0 4 votes vote down vote up
@SuppressWarnings( "UnusedParameters" )
private void initInstance( View rootView ){
    int orientation = getResources().getConfiguration().orientation;
    int orientationLinear;
    int orientationGrid;
    int orientationStaggeredGrid;
    if( orientation == Configuration.ORIENTATION_PORTRAIT ){
        orientationLinear = LinearLayoutManager.VERTICAL;
        orientationGrid = GridLayoutManager.VERTICAL;
        orientationStaggeredGrid = StaggeredGridLayoutManager.VERTICAL;
    }else{
        orientationLinear = LinearLayoutManager.HORIZONTAL;
        orientationGrid = GridLayoutManager.HORIZONTAL;
        orientationStaggeredGrid = StaggeredGridLayoutManager.HORIZONTAL;
    }

    rvMargin = (RecyclerView) rootView.findViewById( R.id.rv_margin );
    int itemSpace = getSpace();
    int layout = getArguments().getInt( KEY_LAYOUT );
    if( layout == LINEAR ){
        rvMargin.removeItemDecoration( linearMargin );
        LinearLayoutManager layout1 = new LinearLayoutManager( getContext(), orientationLinear, false );
        rvMargin.setLayoutManager( layout1 );
        linearMargin = new LayoutMarginDecoration( itemSpace );
        linearMargin.setPadding( rvMargin, getMarginTop(), getMarginBottom(), getMarginLeft(), getMarginRight() );
        linearMargin.setOnClickLayoutMarginItemListener( onClickItem() );
        rvMargin.addItemDecoration( linearMargin );
    }else if( layout == GRID ){
        int gridSpan = 3;
        rvMargin.removeItemDecoration( gridMargin );
        rvMargin.setLayoutManager( new GridLayoutManager( getContext(), gridSpan, orientationGrid, false ) );
        gridMargin = new LayoutMarginDecoration( gridSpan, itemSpace );
        gridMargin.setPadding( rvMargin, getMarginTop(), getMarginBottom(), getMarginLeft(), getMarginRight() );
        gridMargin.setOnClickLayoutMarginItemListener( onClickItem() );
        rvMargin.addItemDecoration( gridMargin );
    }else if( layout == STAGGERED_GRID ){
        int stagSpan = 3;
        rvMargin.removeItemDecoration( stagMargin );
        rvMargin.setLayoutManager( new StaggeredGridLayoutManager( stagSpan, orientationStaggeredGrid ) );
        stagMargin = new LayoutMarginDecoration( stagSpan, itemSpace );
        stagMargin.setPadding( rvMargin, getMarginTop(), getMarginBottom(), getMarginLeft(), getMarginRight() );
        stagMargin.setOnClickLayoutMarginItemListener( onClickItem() );
        rvMargin.addItemDecoration( stagMargin );
    }
    rvMargin.setAdapter( new MarginAdapter( getContext() ) );
}