Search in sources :

Example 46 with GridLayoutManager

use of android.support.v7.widget.GridLayoutManager in project MusicDNA by harjot-oberai.

the class AlbumFragment method onViewCreated.

@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    bottomMarginLayout = view.findViewById(R.id.bottom_margin_layout);
    if (HomeActivity.isReloaded)
        bottomMarginLayout.setVisibility(View.GONE);
    else
        bottomMarginLayout.setVisibility(View.VISIBLE);
    rv = (RecyclerView) view.findViewById(R.id.albums_recycler);
    abAdapter = new AlbumRecyclerAdapter(HomeActivity.finalAlbums, getContext());
    glManager = new GridLayoutManager(getContext(), 2);
    rv.setLayoutManager(glManager);
    rv.setItemAnimator(new DefaultItemAnimator());
    rv.setAdapter(abAdapter);
    rv.addOnItemTouchListener(new ClickItemTouchListener(rv) {

        @Override
        boolean onClick(RecyclerView parent, View view, int position, long id) {
            HomeActivity.tempAlbum = HomeActivity.finalAlbums.get(position);
            mCallback.onAlbumClick();
            return true;
        }

        @Override
        boolean onLongClick(RecyclerView parent, View view, int position, long id) {
            return true;
        }

        @Override
        public void onRequestDisallowInterceptTouchEvent(boolean disallowIntercept) {
        }
    });
}
Also used : GridLayoutManager(android.support.v7.widget.GridLayoutManager) RecyclerView(android.support.v7.widget.RecyclerView) RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View) DefaultItemAnimator(android.support.v7.widget.DefaultItemAnimator)

Example 47 with GridLayoutManager

use of android.support.v7.widget.GridLayoutManager in project android-advancedrecyclerview by h6ah4i.

the class DraggableGridExampleFragment method onViewCreated.

@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    //noinspection ConstantConditions
    mRecyclerView = (RecyclerView) getView().findViewById(R.id.recycler_view);
    mLayoutManager = new GridLayoutManager(getContext(), 3, GridLayoutManager.VERTICAL, false);
    // drag & drop manager
    mRecyclerViewDragDropManager = new RecyclerViewDragDropManager();
    mRecyclerViewDragDropManager.setDraggingItemShadowDrawable((NinePatchDrawable) ContextCompat.getDrawable(getContext(), R.drawable.material_shadow_z3));
    // Start dragging after long press
    mRecyclerViewDragDropManager.setInitiateOnLongPress(true);
    mRecyclerViewDragDropManager.setInitiateOnMove(false);
    mRecyclerViewDragDropManager.setLongPressTimeout(750);
    // setup dragging item effects (NOTE: DraggableItemAnimator is required)
    mRecyclerViewDragDropManager.setDragStartItemAnimationDuration(250);
    mRecyclerViewDragDropManager.setDraggingItemAlpha(0.8f);
    mRecyclerViewDragDropManager.setDraggingItemScale(1.3f);
    mRecyclerViewDragDropManager.setDraggingItemRotation(15.0f);
    //adapter
    final DraggableGridExampleAdapter myItemAdapter = new DraggableGridExampleAdapter(getDataProvider());
    mAdapter = myItemAdapter;
    // wrap for dragging
    mWrappedAdapter = mRecyclerViewDragDropManager.createWrappedAdapter(myItemAdapter);
    // DraggableItemAnimator is required to make item animations properly.
    GeneralItemAnimator animator = new DraggableItemAnimator();
    mRecyclerView.setLayoutManager(mLayoutManager);
    // requires *wrapped* adapter
    mRecyclerView.setAdapter(mWrappedAdapter);
    mRecyclerView.setItemAnimator(animator);
    //noinspection StatementWithEmptyBody
    if (supportsViewElevation()) {
    // Lollipop or later has native drop shadow feature. ItemShadowDecorator is not required.
    } else {
        mRecyclerView.addItemDecoration(new ItemShadowDecorator((NinePatchDrawable) ContextCompat.getDrawable(getContext(), R.drawable.material_shadow_z1)));
    }
    mRecyclerViewDragDropManager.attachRecyclerView(mRecyclerView);
// for debugging
//        animator.setDebug(true);
//        animator.setMoveDuration(2000);
}
Also used : GridLayoutManager(android.support.v7.widget.GridLayoutManager) ItemShadowDecorator(com.h6ah4i.android.widget.advrecyclerview.decoration.ItemShadowDecorator) GeneralItemAnimator(com.h6ah4i.android.widget.advrecyclerview.animator.GeneralItemAnimator) DraggableItemAnimator(com.h6ah4i.android.widget.advrecyclerview.animator.DraggableItemAnimator) RecyclerViewDragDropManager(com.h6ah4i.android.widget.advrecyclerview.draggable.RecyclerViewDragDropManager) NinePatchDrawable(android.graphics.drawable.NinePatchDrawable)

Example 48 with GridLayoutManager

use of android.support.v7.widget.GridLayoutManager in project MaterialViewPager by florent37.

the class RecyclerViewFragment method onViewCreated.

@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    ButterKnife.bind(this, view);
    final List<Object> items = new ArrayList<>();
    for (int i = 0; i < ITEM_COUNT; ++i) {
        items.add(new Object());
    }
    if (GRID_LAYOUT) {
        mRecyclerView.setLayoutManager(new GridLayoutManager(getActivity(), 2));
    } else {
        mRecyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
    }
    mRecyclerView.setHasFixedSize(true);
    //Use this now
    mRecyclerView.addItemDecoration(new MaterialViewPagerHeaderDecorator());
    mRecyclerView.setAdapter(new TestRecyclerViewAdapter(items));
}
Also used : GridLayoutManager(android.support.v7.widget.GridLayoutManager) ArrayList(java.util.ArrayList) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) TestRecyclerViewAdapter(com.github.florent37.materialviewpager.sample.TestRecyclerViewAdapter) MaterialViewPagerHeaderDecorator(com.github.florent37.materialviewpager.header.MaterialViewPagerHeaderDecorator)

Example 49 with GridLayoutManager

use of android.support.v7.widget.GridLayoutManager in project RecyclerViewItemAnimators by gabrielemariotti.

the class AnimationGridActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_recycler);
    //Setup Spinner
    setupSpinner();
    //Setup RecyclerView
    mRecyclerView = (RecyclerView) findViewById(R.id.list);
    //mRecyclerView.setHasFixedSize(true);
    mRecyclerView.setLayoutManager(new GridLayoutManager(this, 5));
    mAdapter = new AnimationGridAdapter(this);
    AlphaAnimatorAdapter animatorAdapter = new AlphaAnimatorAdapter(mAdapter, mRecyclerView);
    animatorAdapter.getViewAnimator().setInitialDelayMillis(500);
    mRecyclerView.setAdapter(animatorAdapter);
}
Also used : GridLayoutManager(android.support.v7.widget.GridLayoutManager) AlphaAnimatorAdapter(it.gmariotti.recyclerview.adapter.AlphaAnimatorAdapter) AnimationGridAdapter(it.gmariotti.recyclerview.itemanimator.demo.adapter.AnimationGridAdapter)

Example 50 with GridLayoutManager

use of android.support.v7.widget.GridLayoutManager in project RecyclerViewItemAnimators by gabrielemariotti.

the class GridActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_recycler);
    //Setup Spinner
    setupSpinner();
    //Setup RecyclerView
    mRecyclerView = (RecyclerView) findViewById(R.id.list);
    //mRecyclerView.setHasFixedSize(true);
    mRecyclerView.setLayoutManager(new GridLayoutManager(this, 5));
    mAdapter = new GridAdapter(this);
    mRecyclerView.setAdapter(mAdapter);
}
Also used : GridLayoutManager(android.support.v7.widget.GridLayoutManager) GridAdapter(it.gmariotti.recyclerview.itemanimator.demo.adapter.GridAdapter)

Aggregations

GridLayoutManager (android.support.v7.widget.GridLayoutManager)264 RecyclerView (android.support.v7.widget.RecyclerView)118 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)68 View (android.view.View)60 StaggeredGridLayoutManager (android.support.v7.widget.StaggeredGridLayoutManager)38 TextView (android.widget.TextView)32 DefaultItemAnimator (android.support.v7.widget.DefaultItemAnimator)15 MaterialViewPagerHeaderDecorator (com.github.florent37.materialviewpager.header.MaterialViewPagerHeaderDecorator)14 BindView (butterknife.BindView)13 ArrayList (java.util.ArrayList)13 Handler (android.os.Handler)12 Toolbar (android.support.v7.widget.Toolbar)12 ImageView (android.widget.ImageView)12 Context (android.content.Context)11 Intent (android.content.Intent)11 Point (android.graphics.Point)9 Nullable (android.support.annotation.Nullable)9 SwipeRefreshLayout (android.support.v4.widget.SwipeRefreshLayout)9 SuppressLint (android.annotation.SuppressLint)8 AdapterView (android.widget.AdapterView)8