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

The following examples show how to use android.support.v7.widget.GridLayoutManager. These examples are extracted from open source projects. 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 Project: PageMenuLayout   Author: xiaohaibin   File: PageMenuLayout.java    License: Apache License 2.0 6 votes vote down vote up
public void setPageDatas(int rowCount, int spanCount, @NonNull List<T> datas, @NonNull PageMenuViewHolderCreator creator) {
    if (datas == null) {
        datas = new ArrayList<>();
    }
    mRowCount = rowCount;
    mSpanCount = spanCount;
    if (mRowCount == 0 || mSpanCount == 0) {
        return;
    }
    int pageSize = mRowCount * mSpanCount;
    int pageCount = (int) Math.ceil(datas.size() * 1.0 / pageSize);
    List<View> viewList = new ArrayList<>();
    for (int index = 0; index < pageCount; index++) {
        RecyclerView recyclerView = new RecyclerView(this.getContext());
        recyclerView.setLayoutParams(new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
        recyclerView.setLayoutManager(new GridLayoutManager(this.getContext(), mSpanCount));
        EntranceAdapter<T> entranceAdapter = new EntranceAdapter<>(creator, datas, index, pageSize);
        recyclerView.setAdapter(entranceAdapter);
        viewList.add(recyclerView);
    }
    PageViewPagerAdapter adapter = new PageViewPagerAdapter(viewList);
    mViewPager.setAdapter(adapter);
}
 
Example #2
Source Project: meiShi   Author: sungerk   File: MGridLayoutManager.java    License: Apache License 2.0 6 votes vote down vote up
public MGridLayoutManager(Context context, final int spanCount, final BaseLoadMoreRecyclerAdapter mAdapter) {
    super(context, spanCount);
    setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() {
        @Override
        public int getSpanSize(int position) {
            switch (mAdapter.getItemViewType(position)) {
                case BaseLoadMoreRecyclerAdapter.TYPE_FOOTER:
                    return spanCount;
                case BaseLoadMoreRecyclerAdapter.TYPE_ITEM:
                    return 1;
                default:
                    return -1;
            }
        }

    });
}
 
Example #3
Source Project: CoordinatorLayoutExample   Author: gdutxiaoxu   File: DividerGridItemDecoration.java    License: Apache License 2.0 6 votes vote down vote up
private boolean isLastColum(RecyclerView parent, int pos, int spanCount,
                            int childCount) {
    LayoutManager layoutManager = parent.getLayoutManager();
    if (layoutManager instanceof GridLayoutManager) {
        if ((pos + 1) % spanCount == 0)
        // 如果是最后一列,则不需要绘制右边
        {
            return true;
        }
    } else if (layoutManager instanceof StaggeredGridLayoutManager) {
        int orientation = ((StaggeredGridLayoutManager) layoutManager)
                .getOrientation();
        if (orientation == StaggeredGridLayoutManager.VERTICAL) {
            if ((pos + 1) % spanCount == 0)// 如果是最后一列,则不需要绘制右边
            {
                return true;
            }
        } else {
            childCount = childCount - childCount % spanCount;
            if (pos >= childCount)// 如果是最后一列,则不需要绘制右边
                return true;
        }
    }
    return false;
}
 
Example #4
Source Project: Album   Author: yanzhenjie   File: AlbumActivity.java    License: Apache License 2.0 6 votes vote down vote up
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_album);
    mToolbar = findViewById(R.id.toolbar);
    setSupportActionBar(mToolbar);

    mTvMessage = findViewById(R.id.tv_message);
    RecyclerView recyclerView = findViewById(R.id.recycler_view);
    recyclerView.setLayoutManager(new GridLayoutManager(this, 3));
    Divider divider = new Api21ItemDivider(Color.TRANSPARENT, 10, 10);
    recyclerView.addItemDecoration(divider);

    mAdapter = new Adapter(this, new OnItemClickListener() {
        @Override
        public void onItemClick(View view, int position) {
            previewAlbum(position);
        }
    });
    recyclerView.setAdapter(mAdapter);
}
 
Example #5
Source Project: Mobike   Author: yiwent   File: PayActivity.java    License: Apache License 2.0 6 votes vote down vote up
private void initView() {
    mIntegers.add(100);
    mIntegers.add(50);
    mIntegers.add(20);
    mIntegers.add(10);
    mIntegers.add(5);

    final List<String> mData = new ArrayList<>();
    for (int i = 0; i < chargetext.length; i++) {
        mData.add(chargetext[i]);
    }
    mAdapter = new ChargeAmountAdapter(this, mData);
    mRecyclerview.setAdapter(mAdapter);
    mRecyclerview.setLayoutManager(new GridLayoutManager(this, 2));
    mAdapter.setOnItemClickListener(new BaseAdapter.OnItemClickListener() {
        @Override
        public void onClick(View v, int position) {
            mAdapter.setSelectPosition(position);
        }
    });

}
 
Example #6
Source Project: ImagePicker   Author: jeasonlzy   File: ImageGridActivity.java    License: Apache License 2.0 6 votes vote down vote up
@Override
    public void onImagesLoaded(List<ImageFolder> imageFolders) {
        this.mImageFolders = imageFolders;
        imagePicker.setImageFolders(imageFolders);
        if (imageFolders.size() == 0) {
//            mImageGridAdapter.refreshData(null);
            mRecyclerAdapter.refreshData(null);
        } else {
//            mImageGridAdapter.refreshData(imageFolders.get(0).images);
            mRecyclerAdapter.refreshData(imageFolders.get(0).images);
        }
//        mImageGridAdapter.setOnImageItemClickListener(this);
        mRecyclerAdapter.setOnImageItemClickListener(this);
        mRecyclerView.setLayoutManager(new GridLayoutManager(this, 3));
        mRecyclerView.addItemDecoration(new GridSpacingItemDecoration(3, Utils.dp2px(this, 2), false));
        mRecyclerView.setAdapter(mRecyclerAdapter);
        mImageFolderAdapter.refreshData(imageFolders);
    }
 
Example #7
Source Project: YTS   Author: MuhamedFathy   File: MainActivity.java    License: MIT License 6 votes vote down vote up
private void activateEndlessScroll(RecyclerView recyclerView, GridLayoutManager manager) {
  RxRecyclerView.scrollEvents(recyclerView)
      .subscribe(scrollEvent -> {
        visibleItemCount = recyclerView.getChildCount();
        totalItemCount = manager.getItemCount();
        firstVisibleItem = manager.findFirstVisibleItemPosition();
        if (loading) {
          if (totalItemCount > previousTotal) {
            loading = false;
            previousTotal = totalItemCount;
          }
        }
        if (!loading && (totalItemCount - visibleItemCount)
            <= (firstVisibleItem + visibleThreshold)) {
          pageNum++;
          presenter.loadMoviesList(getContext(), pageNum, false);
          loading = true;
        }
      });
}
 
Example #8
Source Project: luckly_recyclerview   Author: MrGaoGang   File: LRecyclerView.java    License: MIT License 6 votes vote down vote up
@Override
public void onAttachedToRecyclerView(RecyclerView recyclerView) {
    super.onAttachedToRecyclerView(recyclerView);
    LayoutManager layoutManager = recyclerView.getLayoutManager();

    if (layoutManager instanceof GridLayoutManager) {
        GridLayoutManager gridLayoutManager = (GridLayoutManager) layoutManager;
        final int spanCount = gridLayoutManager.getSpanCount();
        gridLayoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() {
            @Override
            public int getSpanSize(int position) {
                // 如果当前是footer的位置,那么该item占据一行的个单元格,正常情况下占据1个单元格
                if (getItemViewType(position) == FOOTER_TYPE) {
                    return spanCount;
                } else if (isRefreshHeader(position) || getItemViewType(position) == getHeaderTypeByPosition(position - 1)) {
                    return spanCount;
                } else {
                    return 1;
                }
            }
        });
    }
    mAdapter.onAttachedToRecyclerView(recyclerView);
}
 
Example #9
Source Project: FastWaiMai   Author: zion223   File: IndexTabDelegate.java    License: MIT License 6 votes vote down vote up
@Override
public void onBindView(@Nullable Bundle savedInstanceState, @NonNull View view) {
    RestClient.builder()
            .url("api/youlike")
            .loader(getContext())
            .success(new ISuccess() {
                @Override
                public void onSuccess(String response) {
                    final GridLayoutManager gridLayoutManager = new GridLayoutManager(getContext(),2);
                    mTabReclclerView.setLayoutManager(gridLayoutManager);
                    final List<MultipleItemEntity> data = new ShopCartLikeConverter().setJsonData(response).convert();
                    final ShopCartLikeAdapter likeAdapter = new ShopCartLikeAdapter(data);
                    mTabReclclerView.setAdapter(likeAdapter);
                 mTabReclclerView.addOnItemTouchListener(IndexItemClickListener.create(IndexTabDelegate.this));
                }
            })
            .build()
            .get();

}
 
Example #10
Source Project: LoadMoreRecyclerView   Author: alicx   File: LoadMoreRecyclerView.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * 获取第一条展示的位置
 *
 * @return
 */
private int getFirstVisiblePosition() {
    int position;
    if (getLayoutManager() instanceof LinearLayoutManager) {
        position = ((LinearLayoutManager) getLayoutManager()).findFirstVisibleItemPosition();
    } else if (getLayoutManager() instanceof GridLayoutManager) {
        position = ((GridLayoutManager) getLayoutManager()).findFirstVisibleItemPosition();
    } else if (getLayoutManager() instanceof StaggeredGridLayoutManager) {
        StaggeredGridLayoutManager layoutManager = (StaggeredGridLayoutManager) getLayoutManager();
        int[] lastPositions = layoutManager.findFirstVisibleItemPositions(new int[layoutManager.getSpanCount()]);
        position = getMinPositions(lastPositions);
    } else {
        position = 0;
    }
    return position;
}
 
Example #11
Source Project: RecyclerView_Divider   Author: ChoicesWang   File: GridFragment.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
    mRecyclerView = (RecyclerView) view;
    GridLayoutManager layoutManager = new GridLayoutManager(view.getContext(), span);
    mRecyclerView.setLayoutManager(layoutManager);
    adapter = new GridAdapter(list);
    mRecyclerView.setAdapter(adapter);
    DividerItemDecoration itemDecoration = new DividerItemDecoration();
    itemDecoration.setDividerLookup(new AgileDividerLookup());
    mRecyclerView.addItemDecoration(itemDecoration);

    if (type == MainActivity.TYPE_AGILE) {
        layoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() {
            @Override
            public int getSpanSize(int position) {
                return span / adapter.getItemViewType(position);
            }
        });
    }

}
 
Example #12
Source Project: Album   Author: yanzhenjie   File: VideoActivity.java    License: Apache License 2.0 6 votes vote down vote up
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_album);
    mToolbar = findViewById(R.id.toolbar);
    setSupportActionBar(mToolbar);

    mTvMessage = findViewById(R.id.tv_message);
    RecyclerView recyclerView = findViewById(R.id.recycler_view);
    recyclerView.setLayoutManager(new GridLayoutManager(this, 3));
    Divider divider = new Api21ItemDivider(Color.TRANSPARENT, 10, 10);
    recyclerView.addItemDecoration(divider);

    mAdapter = new Adapter(this, new OnItemClickListener() {
        @Override
        public void onItemClick(View view, int position) {
            previewVideo(position);
        }
    });
    recyclerView.setAdapter(mAdapter);
}
 
Example #13
Source Project: materialup   Author: goodev   File: EndlessRecyclerView.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * if layout manager do not have this method , will return 0
 *
 * @return
 */
public int findFirstVisibleItemPosition() {
    LayoutManager manager = getLayoutManager();

    int firstVisibleItems = 0;
    if (manager instanceof LinearLayoutManager) {
        firstVisibleItems = ((LinearLayoutManager) manager).findFirstVisibleItemPosition();
    } else if (manager instanceof GridLayoutManager) {
        firstVisibleItems = ((GridLayoutManager) manager).findFirstVisibleItemPosition();
    } else if (manager instanceof StaggeredGridLayoutManager) {
        StaggeredGridLayoutManager sg = ((StaggeredGridLayoutManager) manager);
        int[] items = new int[sg.getSpanCount()];
        items = ((StaggeredGridLayoutManager) manager).findFirstVisibleItemPositions(items);
        firstVisibleItems = items[0];
    }

    return firstVisibleItems;
}
 
Example #14
Source Project: KSYMediaPlayer_Android   Author: ksvc   File: LiveMainActivity.java    License: Apache License 2.0 6 votes vote down vote up
private void initView() {
    qRcode = (ImageView) findViewById(R.id.QRcode);
    qRcode.setOnClickListener(this);
    config = (ImageView) findViewById(R.id.config);
    config.setOnClickListener(this);
    title = (RelativeLayout) findViewById(R.id.title);
    recyclerView = (RecyclerView) findViewById(R.id.vod_main_recycler);
    layoutManager = new GridLayoutManager(this, 2);
    layoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() {
        @Override
        public int getSpanSize(int position) {
            if (position == 0) {
                return layoutManager.getSpanCount();
            } else {
                return 1;
            }
        }
    });
    recyclerView.setLayoutManager(layoutManager);
}
 
Example #15
Source Project: NanoIconPack   Author: by-syk   File: IconsFragment.java    License: Apache License 2.0 6 votes vote down vote up
private void init() {
    Bundle bundle = getArguments();
    pageId = bundle.getInt("pageId");
    iconsGetter = (IconsGetter) bundle.getSerializable("iconsGetter");
    gridItemMode = bundle.getInt("mode", IconAdapter.MODE_ICON);

    RecyclerView recyclerView = (RecyclerView) contentView.findViewById(R.id.recycler_view);

    int[] gridNumAndWidth = calculateGridNumAndWidth();
    recyclerView.setLayoutManager(new GridLayoutManager(getContext(), gridNumAndWidth[0]));

    iconAdapter = new IconAdapter(getContext(), gridNumAndWidth[1]);
    iconAdapter.setMode(gridItemMode);
    iconAdapter.setOnItemClickListener(new IconAdapter.OnItemClickListener() {
        @Override
        public void onClick(int pos, IconBean bean) {
            IconDialog.newInstance(bean, ExtraUtil.isFromLauncherPick(getActivity().getIntent()))
                    .show(getFragmentManager(), "iconDialog");
        }
    });
    recyclerView.setAdapter(iconAdapter);
}
 
Example #16
Source Project: example   Author: pratamawijaya   File: MainActivity.java    License: Apache License 2.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    ButterKnife.inject(this);

    coverItems = new ArrayList<>();
    coverItems.add(new CoverItem("Raisa", R.drawable.coveralbum_raisa));
    coverItems.add(new CoverItem("Tulus", R.drawable.coveralbum_tulus));
    coverItems.add(new CoverItem("D'Masive", R.drawable.coveralbum_dmasive));
    coverItems.add(new CoverItem("Skrillex", R.drawable.coveralbum_skrillex));
    coverItems.add(new CoverItem("Angger Dimas", R.drawable.coveralbum_angger));

    adapter = new CoverAdapter(this, coverItems);

    GridLayoutManager gridLayoutManager = new GridLayoutManager(this, 2);
    recyclerView.setLayoutManager(gridLayoutManager);
    recyclerView.setAdapter(adapter);
}
 
Example #17
Source Project: outlay   Author: bmelnychuk   File: CategoriesGridAdapter.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
    Context context = parent.getContext();
    final LayoutInflater inflater = LayoutInflater.from(context);
    switch (viewType) {
        case HEADER:
            final View numpadView = inflater.inflate(app.outlay.R.layout.recycler_numpad, parent, false);
            GridLayoutManager.LayoutParams params = (GridLayoutManager.LayoutParams) numpadView.getLayoutParams();
            params.height = parent.getMeasuredHeight() - (context.getResources().getDimensionPixelSize(app.outlay.R.dimen.category_item_height) * 2);

            final NumpadViewHolder viewHolder = new NumpadViewHolder(numpadView);
            return viewHolder;
        default:
            final View catView = inflater.inflate(app.outlay.R.layout.item_category, parent, false);
            final CategoryViewHolder categoryViewHolder = new CategoryViewHolder(catView);
            return categoryViewHolder;
    }
}
 
Example #18
Source Project: youqu_master   Author: wangfeng19930909   File: WrapperAdapter.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void onAttachedToRecyclerView(final RecyclerView recyclerView) {
    RecyclerView.LayoutManager layoutManager = recyclerView.getLayoutManager();
    if (layoutManager instanceof GridLayoutManager) {
        final GridLayoutManager gridLayoutManager = (GridLayoutManager) layoutManager;
        gridLayoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() {
            @Override
            public int getSpanSize(int position) {
                WrapperAdapter wrapperAdapter = (WrapperAdapter) recyclerView.getAdapter();
                if (isFullSpanType(wrapperAdapter.getItemViewType(position))) {
                    return gridLayoutManager.getSpanCount();
                }
                return 1;

            }
        });
    }
}
 
Example #19
Source Project: Protein   Author: gejiaheng   File: UserShotListFragment.java    License: Apache License 2.0 5 votes vote down vote up
@Override
protected RecyclerView.LayoutManager createLayoutManager() {
    GridLayoutManager gridLayoutManager = new GridLayoutManager(getContext(), 2);
    proteinAdapter.setSpanCount(2);
    gridLayoutManager.setSpanSizeLookup(proteinAdapter.getSpanSizeLookup());
    return gridLayoutManager;
}
 
Example #20
Source Project: meizhi   Author: xingrz   File: GalleryActivity.java    License: Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_gallery);

    application = MeizhiApplication.from(this);

    DisplayMetrics metrics = getResources().getDisplayMetrics();
    int actionBarHeight = getSupportActionBar().getHeight();
    int swipeEndTarget = actionBarHeight + (int) (DEFAULT_CIRCLE_TARGET * metrics.density);

    refresh = (SwipeRefreshLayout) findViewById(R.id.refresh);
    refresh.setColorSchemeResources(R.color.accent);
    refresh.setProgressViewOffset(false, actionBarHeight, swipeEndTarget);
    refresh.setOnRefreshListener(this);

    adapter = new GalleryAdapter(this, this);

    layoutManager = new GridLayoutManager(this, getSpanCount());
    layoutManager.setSpanSizeLookup(new HeaderSpanSizeLookup(layoutManager));

    albums = (ObservableRecyclerView) findViewById(R.id.albums);
    albums.setHasFixedSize(true);
    albums.setLayoutManager(layoutManager);
    albums.setAdapter(adapter);
    albums.setScrollViewCallbacks(this);
}
 
Example #21
Source Project: Android-Application-ZJB   Author: pinguo-sunjianfei   File: ItemDivider.java    License: Apache License 2.0 5 votes vote down vote up
private int getSpanCount(RecyclerView parent) {
    // 列数
    int spanCount = -1;
    RecyclerView.LayoutManager layoutManager = parent.getLayoutManager();
    if (layoutManager instanceof GridLayoutManager) {
        spanCount = ((GridLayoutManager) layoutManager).getSpanCount();
    } else if (layoutManager instanceof StaggeredGridLayoutManager) {
        spanCount = ((StaggeredGridLayoutManager) layoutManager)
                .getSpanCount();
    }
    return spanCount;
}
 
Example #22
Source Project: outlay   Author: bmelnychuk   File: CategoriesFragment.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    ButterKnife.bind(this, view);

    setToolbar(toolbar);
    setDisplayHomeAsUpEnabled(true);
    getActivity().setTitle(getString(app.outlay.R.string.caption_categories));

    GridLayoutManager gridLayoutManager = new GridLayoutManager(getActivity(), 4);
    categoriesGrid.setLayoutManager(gridLayoutManager);

    adapter = new CategoriesDraggableGridAdapter(getOutlayTheme());
    adapter.setDragListener(this);
    adapter.setOnCategoryClickListener(c -> Navigator.goToCategoryDetails(getActivity(), c.getId()));
    categoriesGrid.setAdapter(adapter);

    ItemTouchHelper.Callback callback = new SimpleItemTouchHelperCallback(adapter);
    mItemTouchHelper = new ItemTouchHelper(callback);
    mItemTouchHelper.attachToRecyclerView(categoriesGrid);

    fab.setImageDrawable(getResourceHelper().getFabIcon(app.outlay.R.string.ic_material_add));
    fab.setOnClickListener(v -> Navigator.goToCategoryDetails(getActivity(), null));

    Drawable noCategoryIcon = IconUtils.getIconMaterialIcon(
            getContext(),
            MaterialDesignIconic.Icon.gmi_label,
            getOutlayTheme().inactiveIconColor,
            app.outlay.R.dimen.icon_no_results,
            16
    );
    noContentImage.setImageDrawable(noCategoryIcon);
}
 
Example #23
Source Project: FimiX8-RE   Author: wladimir-computin   File: LocalFragmentPresenter.java    License: MIT License 5 votes vote down vote up
public LocalFragmentPresenter(RecyclerView mRecyclerView, PanelRecycleAdapter mPanelRecycleAdapter, ISelectData mISelectData, Context context) {
    super(mRecyclerView, mPanelRecycleAdapter, mISelectData, context);
    doTrans();
    LayoutManager manager = mRecyclerView.getLayoutManager();
    if (manager instanceof GridLayoutManager) {
        this.mGridLayoutManager = (GridLayoutManager) manager;
    }
}
 
Example #24
Source Project: apkextractor   Author: ghmxr   File: RecyclerViewAdapter.java    License: GNU General Public License v3.0 5 votes vote down vote up
public void setLayoutManagerAndView(int mode){
    if(mode==1){
        GridLayoutManager gridLayoutManager=new GridLayoutManager(activity,4);
        recyclerView.setLayoutManager(gridLayoutManager);
        this.mode=1;
    }else{
        LinearLayoutManager linearLayoutManager=new LinearLayoutManager(activity);
        linearLayoutManager.setOrientation(LinearLayoutManager.VERTICAL);
        recyclerView.setLayoutManager(linearLayoutManager);
        this.mode=0;
    }
    notifyDataSetChanged();
}
 
Example #25
Source Project: diycode   Author: GcsSloop   File: SitesListFragment.java    License: Apache License 2.0 5 votes vote down vote up
@NonNull @Override protected RecyclerView.LayoutManager getRecyclerViewLayoutManager() {
    GridLayoutManager layoutManager = new GridLayoutManager(getContext(), 2);
    layoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() {
        @Override
        public int getSpanSize(int position) {
            return (mAdapter.getFullDatas().get(position) instanceof SiteItem) ? 1 : 2;
        }
    });
    return layoutManager;
}
 
Example #26
Source Project: Nimbus   Author: appteam-nith   File: SponsorActivity.java    License: GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_sponsor_try);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    recyclerView= (RecyclerView) findViewById(R.id.list);
    recyclerView.setLayoutManager(new GridLayoutManager(this, 2));
    adapter=new SponsorAdapter(this);
    recyclerView.setAdapter(adapter);
    progressBar= (ProgressBar) findViewById(R.id.progress);
    getData();
}
 
Example #27
Source Project: LivePlayback   Author: smartyuge   File: MainActivity.java    License: Apache License 2.0 5 votes vote down vote up
private void loadRecyclerViewMenuItem() {
    RecyclerView recyclerView = (RecyclerView) findViewById(R.id.ry_menu_item);
    GridLayoutManager layoutManager = new GridLayoutManager(this, 1);
    layoutManager.setOrientation(LinearLayoutManager.VERTICAL);
    recyclerView.setLayoutManager(layoutManager);
    recyclerView.setFocusable(false);
    mMetroViewBorderImpl.attachTo(recyclerView);
    createOptionItemData(recyclerView, R.layout.detail_menu_item);
}
 
Example #28
Source Project: PictureSelector   Author: arvinljw   File: DividerGridItemDecoration.java    License: Apache License 2.0 5 votes vote down vote up
private int getSpanCount(RecyclerView parent) {
    int spanCount = -1;
    RecyclerView.LayoutManager layoutManager = parent.getLayoutManager();
    if (layoutManager instanceof GridLayoutManager) {
        spanCount = ((GridLayoutManager) layoutManager).getSpanCount();
    } else if (layoutManager instanceof StaggeredGridLayoutManager) {
        spanCount = ((StaggeredGridLayoutManager) layoutManager).getSpanCount();
    }
    return spanCount;
}
 
Example #29
Source Project: FimiX8-RE   Author: wladimir-computin   File: X8LocalFragmentPresenter.java    License: MIT License 5 votes vote down vote up
public X8LocalFragmentPresenter(RecyclerView mRecyclerView, X8sPanelRecycleAdapter mPanelRecycleAdapter, ISelectData mISelectData, Context context) {
    super(mRecyclerView, mPanelRecycleAdapter, mISelectData, context, false);
    doTrans();
    LayoutManager manager = mRecyclerView.getLayoutManager();
    if (manager instanceof GridLayoutManager) {
        this.mGridLayoutManager = (GridLayoutManager) manager;
    }
    registerReciver();
}
 
Example #30
Source Project: photo-editor-android   Author: eventtus   File: EmojiFragment.java    License: MIT License 5 votes vote down vote up
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.fragment_main_photo_edit_emoji, container, false);

    emojiRecyclerView = (RecyclerView) rootView.findViewById(R.id.fragment_main_photo_edit_emoji_rv);
    emojiRecyclerView.setHasFixedSize(true);
    emojiRecyclerView.setLayoutManager(new GridLayoutManager(photoEditorActivity, 4));
    EmojiAdapter adapter = new EmojiAdapter(photoEditorActivity, emojiIds);
    adapter.setOnEmojiClickListener(this);
    emojiRecyclerView.setAdapter(adapter);

    return rootView;
}