private void init(Context context) { inflate(context, R.layout.home_list_wrapper, this); ButterKnife.bind(this); LinearLayoutManager linearLayoutManager = new LinearLayoutManager(context) { @Override protected int getExtraLayoutSpace(RecyclerView.State state) { return 200; } }; linearLayoutManager.setOrientation(LinearLayoutManager.HORIZONTAL); recyclerView.setLayoutManager(linearLayoutManager); SnapHelper snapHelper = new GravitySnapHelper(Gravity.START); snapHelper.attachToRecyclerView(recyclerView); recyclerView.setHasFixedSize(true); recyclerView.setMotionEventSplittingEnabled(false); recyclerView.setNestedScrollingEnabled(false); recyclerView.setItemAnimator(new DefaultItemAnimator()); recyclerView.setAdapter(adapter); }
private void initGalleryWhenImagesAreAvailable() { RecyclerView recyclerView = (RecyclerView) findViewById(R.id.gallery); recyclerView.setHasFixedSize(true); CenterLayoutManager layoutManager = new CenterLayoutManager(context, CenterLayoutManager.HORIZONTAL, false); SnapHelper snapHelper = new LinearSnapHelper(); if (recyclerView.getOnFlingListener() == null) { snapHelper.attachToRecyclerView(recyclerView); } recyclerView.setLayoutManager(layoutManager); PlacesGalleryAdapter adapter = new PlacesGalleryAdapter(context, imageUrls, (ImageView) findViewById(R.id.singleImage), (TextView) findViewById(R.id.size), recyclerView, languageHelper); if (this.onClickCallback != null) { adapter.setCallback(this.onClickCallback); } recyclerView.setAdapter(adapter); }
private void init(View view) { unbinder = ButterKnife.bind(this, view); mActivity = (AppCompatActivity) getActivity(); mActivity.setSupportActionBar(toolbar); ActionBar actionBar = mActivity.getSupportActionBar(); if (actionBar != null) { actionBar.setDisplayHomeAsUpEnabled(true); actionBar.setDisplayShowTitleEnabled(false); } toolbar.setBackgroundColor(color); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { mActivity.getWindow().setStatusBarColor(Utils.getDarkColor(color)); } toolbar.setTitle(title); LinearLayoutManager layoutManager = new LinearLayoutManager(getActivity(), LinearLayoutManager.VERTICAL, false); recyclerView.setLayoutManager(layoutManager); SnapHelper snapHelper = new GravitySnapHelper(Gravity.TOP); snapHelper.attachToRecyclerView(recyclerView); recyclerView.setHasFixedSize(true); recyclerView.setMotionEventSplittingEnabled(false); recyclerView.setNestedScrollingEnabled(false); recyclerView.setItemAnimator(new DefaultItemAnimator()); recyclerView.addItemDecoration(new DividerItemDecoration(getActivity(), DividerItemDecoration.VERTICAL)); recyclerView.setAdapter(adapter); }
private void init(View view) { unbinder = ButterKnife.bind(this, view); LinearLayoutManager layoutManager = new LinearLayoutManager(getActivity(), LinearLayoutManager.VERTICAL, false); recyclerView.setLayoutManager(layoutManager); SnapHelper snapHelper = new GravitySnapHelper(Gravity.TOP); snapHelper.attachToRecyclerView(recyclerView); recyclerView.setHasFixedSize(true); recyclerView.setMotionEventSplittingEnabled(false); recyclerView.setNestedScrollingEnabled(false); recyclerView.setItemAnimator(new DefaultItemAnimator()); recyclerView.addItemDecoration(new DividerItemDecoration(getActivity(), DividerItemDecoration.VERTICAL)); recyclerView.setAdapter(adapter); }
private void init(Context context) { inflate(context, R.layout.detail_similar_movies_wrapper, this); ButterKnife.bind(this); LinearLayoutManager linearLayoutManager = new LinearLayoutManager(context); linearLayoutManager.setOrientation(LinearLayoutManager.HORIZONTAL); recyclerView.setLayoutManager(linearLayoutManager); SnapHelper snapHelper = new GravitySnapHelper(Gravity.START); snapHelper.attachToRecyclerView(recyclerView); recyclerView.setHasFixedSize(true); recyclerView.setMotionEventSplittingEnabled(false); recyclerView.setNestedScrollingEnabled(false); recyclerView.setItemAnimator(new DefaultItemAnimator()); recyclerView.setAdapter(adapter); }
private void init(Context context) { inflate(context, R.layout.detail_images_wrapper, this); ButterKnife.bind(this); LinearLayoutManager linearLayoutManager = new LinearLayoutManager(context); linearLayoutManager.setOrientation(LinearLayoutManager.HORIZONTAL); recyclerView.setLayoutManager(linearLayoutManager); SnapHelper snapHelper = new GravitySnapHelper(Gravity.END); snapHelper.attachToRecyclerView(recyclerView); recyclerView.setHasFixedSize(true); recyclerView.setMotionEventSplittingEnabled(false); recyclerView.setNestedScrollingEnabled(false); recyclerView.setItemAnimator(new DefaultItemAnimator()); recyclerView.setAdapter(adapter); }
private void init(Context context, @Nullable AttributeSet attrs) { if (attrs != null) { TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.MetalRecyclerViewPager, 0, 0); itemMargin = (int) typedArray.getDimension(R.styleable.MetalRecyclerViewPager_itemMargin, 0f); typedArray.recycle(); } setLayoutManager(new LinearLayoutManager(context, LinearLayoutManager.HORIZONTAL, false)); SnapHelper snapHelper = new PagerSnapHelper(); snapHelper.attachToRecyclerView(this); }
@Override protected void background() { recentlyPlayed = new SongListAdapter(getContext()); CustomLayoutManager customLayoutManager1 = new CustomLayoutManager(getContext()); customLayoutManager1.setSmoothScrollbarEnabled(true); customLayoutManager1.setOrientation(LinearLayoutManager.HORIZONTAL); SnapHelper startSnapHelper = new StartSnapHelper(); recentlyAdding.setLayoutManager(customLayoutManager1); recentlyAdding.setNestedScrollingEnabled(false); recentlyAdding.setVerticalScrollBarEnabled(false); recentlyAdding.setHorizontalScrollBarEnabled(false); songListAdapter.setLayoutId(R.layout.recent_list); recentlyAdding.setScrollBarSize(0); recentlyAdding.setAdapter(songListAdapter); songListAdapter.setOnItemClickListener(onClicks); recentlyAdding.setItemAnimator(new DefaultItemAnimator()); recentlyAdding.setHasFixedSize(true); startSnapHelper.attachToRecyclerView(recentlyAdding); getLoaderManager().initLoader(trackloader, null, RecentFragment.this); CustomLayoutManager customLayoutManager = new CustomLayoutManager(getContext()); customLayoutManager.setSmoothScrollbarEnabled(true); customLayoutManager.setOrientation(LinearLayoutManager.HORIZONTAL); recentlyPlaying.setLayoutManager(customLayoutManager); recentlyPlaying.setNestedScrollingEnabled(false); recentlyPlaying.setVerticalScrollBarEnabled(false); recentlyPlaying.setHorizontalScrollBarEnabled(false); recentlyPlayed.setLayoutId(R.layout.recent_list); recentlyPlaying.setScrollBarSize(0); recentlyPlaying.setAdapter(recentlyPlayed); recentlyPlayed.setOnItemClickListener(onClick); recentlyPlaying.setItemAnimator(new DefaultItemAnimator()); recentlyPlaying.setHasFixedSize(true); startSnapHelper.attachToRecyclerView(recentlyPlaying); getLoaderManager().initLoader(recentloader, null, recentPlaying); }
private void parseAllSections(int i, ViewHolder viewholder) { if (viewholder.recyclerView != null) { SnapHelper snapHelper = new LinearSnapHelper(); viewholder.recyclerView.setOnFlingListener(null); snapHelper.attachToRecyclerView(viewholder.recyclerView); ArrayList arrayList = (ArrayList) dataSet.get(i); if (arrayList.isEmpty()) { return; } Object something = arrayList.get(0); if (something instanceof Artist) { viewholder.recyclerView.setLayoutManager(new GridLayoutManager(activity, 1, GridLayoutManager.HORIZONTAL, false)); viewholder.recyclerView.setItemAnimator(new DefaultItemAnimator()); viewholder.recyclerView.setAdapter(new ArtistAdapter(activity, (ArrayList<Artist>) arrayList, R.layout.item_artist, false, null)); } else if (something instanceof Album) { viewholder.recyclerView.setLayoutManager(new GridLayoutManager(activity, 1, GridLayoutManager.HORIZONTAL, false)); viewholder.recyclerView.setItemAnimator(new DefaultItemAnimator()); viewholder.recyclerView.setAdapter(new AlbumAdapter(activity, (ArrayList<Album>) arrayList, R.layout.pager_item, false, null)); } else if (something instanceof Playlist) { viewholder.recyclerView.setLayoutManager(new LinearLayoutManager(activity)); viewholder.recyclerView.setItemAnimator(new DefaultItemAnimator()); viewholder.recyclerView.setAdapter(new PlaylistAdapter(activity, (ArrayList<Playlist>) arrayList, R.layout.item_list, null)); } else if (something instanceof Song) { GridLayoutManager layoutManager = new GridLayoutManager(activity, 1, LinearLayoutManager.HORIZONTAL, false); viewholder.recyclerView.setLayoutManager(layoutManager); viewholder.recyclerView.setItemAnimator(new DefaultItemAnimator()); viewholder.recyclerView.setAdapter(new SongAdapter(activity, (ArrayList<Song>) arrayList, R.layout.item_image, false, null)); } } }
@Nullable @Override public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_discover_games, container, false); GridLayoutManager popularGamesLayoutManager = new GridLayoutManager(getContext(), 1, GridLayoutManager.HORIZONTAL, false); GridLayoutManager mostAnticipatedGamesLayoutManager = new GridLayoutManager(getContext(), 1, GridLayoutManager.HORIZONTAL, false); GridLayoutManager upcomingGamesLayoutManager = new GridLayoutManager(getContext(), 1, GridLayoutManager.HORIZONTAL, false); RecyclerView popularGamesRecyclerView = (RecyclerView) view.findViewById(R.id.popular_games_list); RecyclerView mostAnticipatedGamesRecyclerView = (RecyclerView) view.findViewById(R.id.most_anticipated_games_list); RecyclerView upcomingGamesRecyclerView = (RecyclerView) view.findViewById(R.id.upcoming_games_list); mContent = (RelativeLayout) view.findViewById(R.id.content); mContentLoading = (RelativeLayout) view.findViewById(R.id.content_loading_progress); // TODO: check https://github.com/rubensousa/RecyclerViewSnap SnapHelper helper = new LinearSnapHelper(); helper.attachToRecyclerView(popularGamesRecyclerView); helper.attachToRecyclerView(mostAnticipatedGamesRecyclerView); helper.attachToRecyclerView(upcomingGamesRecyclerView); popularGamesRecyclerView.setLayoutManager(popularGamesLayoutManager); popularGamesRecyclerView.setAdapter(mPopularGamesAdapter); mostAnticipatedGamesRecyclerView.setLayoutManager(mostAnticipatedGamesLayoutManager); mostAnticipatedGamesRecyclerView.setAdapter(mMostAnticipatedGamesAdapter); upcomingGamesRecyclerView.setLayoutManager(upcomingGamesLayoutManager); upcomingGamesRecyclerView.setAdapter(mUpcomingGamesAdapter); return view; }
private void setupSectionView(RecyclerView recyclerView, @SectionVO.Type int type) { recyclerView.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.HORIZONTAL, false)); recyclerView.setNestedScrollingEnabled(false); recyclerView.setHasFixedSize(true); SectionAdapter adapter = new SectionAdapter(this, type, this); recyclerView.setAdapter(adapter); SnapHelper snapHelper = new LinearSnapHelper(); snapHelper.attachToRecyclerView(recyclerView); }
void setupRecyclerView() { adapter = new AdapterHorizontal(dataset,getActivity(),this); reviewsList.setAdapter(adapter); linearLayoutManager = new LinearLayoutManager(getActivity(),LinearLayoutManager.HORIZONTAL,false); reviewsList.setLayoutManager(linearLayoutManager); SnapHelper helper = new LinearSnapHelper(); // helper.onFling(10,10); helper.attachToRecyclerView(reviewsList); reviewsList.addOnScrollListener(new RecyclerView.OnScrollListener() { @Override public void onScrolled(RecyclerView recyclerView, int dx, int dy) { super.onScrolled(recyclerView, dx, dy); if(dataset!=null && dataset.size()>0) { int position = linearLayoutManager.findFirstVisibleItemPosition(); if(position!=RecyclerView.NO_POSITION) { notifyListItemClick(position); } } } }); }
private void initRecycler(@NonNull RecyclerView recyclerView) { LinearLayoutManager layoutManager = new LinearLayoutManager(recyclerView.getContext(), VERTICAL, false); recyclerView.setLayoutManager(layoutManager); recyclerView.setAdapter(new MultiColoredAdapter(getChildQuantity(), getChildLayoutId())); SnapHelper helper = new LinearSnapHelper(); helper.attachToRecyclerView(recyclerView); }
private void initRecyclerView() { matrixApiLocationRecyclerViewAdapter = new MatrixApiLocationRecyclerViewAdapter(this, matrixLocationList); recyclerView.setLayoutManager(new LinearLayoutManager(getApplicationContext(), LinearLayoutManager.HORIZONTAL, true)); recyclerView.setItemAnimator(new DefaultItemAnimator()); recyclerView.setAdapter(matrixApiLocationRecyclerViewAdapter); SnapHelper snapHelper = new LinearSnapHelper(); snapHelper.attachToRecyclerView(recyclerView); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Mapbox access token is configured here. This needs to be called either in your application // object or in the same activity which contains the mapview. Mapbox.getInstance(this, getString(R.string.access_token)); // This contains the MapView in XML and needs to be called after the access token is configured. setContentView(R.layout.activity_lab_recycler_view_on_map); recyclerView = (RecyclerView) findViewById(R.id.rv_on_top_of_map); Toast.makeText(this, R.string.toast_instruction, Toast.LENGTH_SHORT).show(); // Initialize the map view mapView = (MapView) findViewById(R.id.mapView); mapView.onCreate(savedInstanceState); mapView.getMapAsync(new OnMapReadyCallback() { @Override public void onMapReady(MapboxMap mapboxMap) { RecyclerViewOnMapActivity.this.mapboxMap = mapboxMap; setUpLists(); // Set up the recyclerView locationAdapter = new LocationRecyclerViewAdapter(locationList, mapboxMap); recyclerView.setLayoutManager(new LinearLayoutManager(getApplicationContext(), LinearLayoutManager.HORIZONTAL, true)); recyclerView.setItemAnimator(new DefaultItemAnimator()); recyclerView.setAdapter(locationAdapter); SnapHelper snapHelper = new LinearSnapHelper(); snapHelper.attachToRecyclerView(recyclerView); } }); }
@Override protected void background() { songListAdapter.setLayoutId(R.layout.song_list); albumListAdapter = new AlbumListAdapter(getContext()); albumListAdapter.setLayoutID(R.layout.recent_list); SnapHelper startSnapHelper = new StartSnapHelper(); CustomLayoutManager customLayoutManager = new CustomLayoutManager(getContext()); customLayoutManager.setSmoothScrollbarEnabled(true); customLayoutManager.setOrientation(CustomLayoutManager.HORIZONTAL); albumrv.setAdapter(albumListAdapter); albumrv.setLayoutManager(customLayoutManager); albumrv.setHasFixedSize(true); albumrv.setNestedScrollingEnabled(false); albumrv.setVerticalScrollBarEnabled(false); albumrv.setHorizontalScrollBarEnabled(false); albumrv.setScrollBarSize(0); startSnapHelper.attachToRecyclerView(albumrv); CustomLayoutManager c = new CustomLayoutManager(getContext()); c.setSmoothScrollbarEnabled(true); rv.setAdapter(songListAdapter); rv.addItemDecoration(new DividerItemDecoration(getContext(), 75, false)); rv.setLayoutManager(c); rv.setHasFixedSize(true); songListAdapter.setOnItemClickListener(mOnClick); songListAdapter.setOnLongClickListener(onLongClick); albumListAdapter.setOnItemClickListener(mOnClickAlbum); loadTrak(); if (((MainActivity) getActivity()) != null) { AppCompatActivity appCompatActivity = ((MainActivity) getActivity()); if (appCompatActivity != null && appCompatActivity.getSupportActionBar() != null) { appCompatActivity.getSupportActionBar().setDisplayHomeAsUpEnabled(true); appCompatActivity.setSupportActionBar(toolbar); } } }
@Override protected void function() { mPlayLayout.fastOpen(); mPlayLayout.getIvSkipNext().setImageResource(R.drawable.aw_ic_next); mPlayLayout.getIvSkipPrevious().setImageResource(R.drawable.aw_ic_prev); ateKey = Helper.getATEKey(getContext()); accentColor = Config.accentColor(getContext(), ateKey); mPlayLayout.setPlayButtonBackgroundTintList(ColorStateList.valueOf(accentColor)); moreMenu.setOnClickListener(mOnClickListener); if (getActivity() == null || getActivity().getWindow() == null) { return; } moreMenu.setImageDrawable(ContextCompat.getDrawable(getContext(), R.drawable.ic_menu)); favhelper = new FavHelper(getContext()); favButton.setOnClickListener(mOnClickListener); CustomLayoutManager customlayoutmanager = new CustomLayoutManager(getContext()); customlayoutmanager.setOrientation(LinearLayoutManager.HORIZONTAL); queuerv.setLayoutManager(customlayoutmanager); SnapHelper startSnapHelper = new StartSnapHelper(); startSnapHelper.attachToRecyclerView(queuerv); queuerv.setHasFixedSize(true); queueAdapter = new QueueAdapter(getContext(), this); queueAdapter.setLayoutId(R.layout.gridqueue); queuerv.setAdapter(queueAdapter); queueAdapter.setOnItemClickListener(onClick); ItemTouchHelper.Callback callback = new SimpleItemTouchHelperCallback(queueAdapter); mItemTouchHelper = new ItemTouchHelper(callback); mItemTouchHelper.attachToRecyclerView(queuerv); if (Extras.getInstance().getDarkTheme() || Extras.getInstance().getBlackTheme()) { mPlayLayout.setProgressLineColor(ContextCompat.getColor(getContext(), R.color.translucent_white_8p)); } else { mPlayLayout.setProgressLineColor(ContextCompat.getColor(getContext(), R.color.translucent_white_8p)); } getActivity().getWindow().setStatusBarColor(accentColor); /** * Show Case */ ShowcaseConfig config = new ShowcaseConfig(); config.setDelay(500); MaterialShowcaseSequence sequence = new MaterialShowcaseSequence(getActivity(), "400"); sequence.setConfig(config); sequence.addSequenceItem(queuerv, "Slide right/left to view Lyrics/PlayingView", "GOT IT"); sequence.setOnItemDismissedListener(new MaterialShowcaseSequence.OnSequenceItemDismissedListener() { @Override public void onDismiss(MaterialShowcaseView materialShowcaseView, int i) { materialShowcaseView.hide(); } }); sequence.start(); helper = new Helper(getContext()); startVisualiser(); }