Need help with looping-layout?
Click the “chat” button below for chat support from the developer who created it, or find similar developers for support.

About the developer

BeksOmega
138 Stars 4 Forks Apache License 2.0 40 Commits 7 Opened issues

Description

A looping LayoutManager for the Android RecyclerView.

Services available

!
?

Need anything else?

Contributors list

# 33,600
Dart
toggl
Firefox
Chrome
35 commits

Looping Layout

The Looping Layout Project is a LayoutManager for the Android RecyclerView. With this project you can add looping/circular/endless functionality to a RecyclerView.

Unlike other solutions for creating a looping recycler, which involve modifying the Adapter, this project isolates all logic inside the LayoutManager. This allows your Adapter to be reused in other non-looping layouts, and it better conforms to the MVC-like architecture provided by the RecyclerView.

This project was original created and is maintained by Beka Westberg (BeksOmega).

It lives at https://github.com/BeksOmega/looping-layout.

:star2: Setup

Add the dependency to your build.gradle file.

groovy
dependencies {
    implementation 'com.github.beksomega:loopinglayout:0.4.0'
}

Apply the layout manager to your RecyclerView.

Kotlin: ```kotlin class MyActivity : Activity() { private lateinit var recyclerView: RecyclerView private lateinit var viewAdapter: RecyclerView.Adapter<*> private lateinit var viewManager: RecyclerView.LayoutManager

override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)
    setContentView(R.layout.my_activity)

viewManager = LoopingLayoutManager(
        this,                           // Pass the context.
        LoopingLayoutManager.VERTICAL,  // Pass the orientation. Vertical by default.
        false                           // Pass whether the views are laid out in reverse.
                                        // False by default.
)
viewAdapter = MyAdapter(myDataset)

recyclerView = findViewById<recyclerview>(R.id.my_recycler_view).apply {
    setHasFixedSize(true)
    layoutManager = viewManager
    adapter = viewAdapter
}

} // ...

} ```

Java: ```java public class MyActivity extends Activity { private RecyclerView recyclerView; private RecyclerView.Adapter mAdapter; private RecyclerView.LayoutManager layoutManager;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.my_activity);
    recyclerView = (RecyclerView) findViewById(R.id.my_recycler_view);

recyclerView.setHasFixedSize(true);

layoutManager = new LoopingLayoutManager(
        this,                           // Pass the context.
        LoopingLayoutManager.VERTICAL,  // Pass the orientation. Vertical by default.
        false                           // Pass whether the views are laid out in reverse.
                                        // False by default.
);
recyclerView.setLayoutManager(layoutManager);

mAdapter = new MyAdapter(myDataset);
recyclerView.setAdapter(mAdapter);

} // ...

} ```

Example code was modified from https://developer.android.com/guide/topics/ui/layout/recyclerview. See that for more information about RecyclerViews.

:sparkles: Features

  • Vertical and Horizontal Orientations
  • LTR and RTL support
  • Reverse layout support for both orientations, as well as LTR, and RTL
  • Public functions for finding items and positions
  • Public functions for finding adapter indices of important positions (eg at the start/end)
  • Public functions for scrolling programmatically
  • Snap Helper support via the LoopingSnapHelper
  • Accessibility (TalkBack and Voice Access) support

:pagewithcurl: License

Looping Layout is licenced under the Apache 2.0 License.

This means it can be used for commercial, public, or private use. You are also free to modify and/or distribute the software. You simply need to maintain the copyright included in each file, and include the license when distributing the library.

:green_heart: Contributing

Contributions are always welcome! Contributing code, writing bug reports, and commenting on feature requests are all super important to this project.

For more info about types of contributions and ways to contribute, please see the contribution guide.

:question: Support

If you think you have found a bug definitely report it using the issue template! Just be sure to search for for duplicate issues before reporting, as someone else may have already come across your problem.

If you have any questions about the project please feel free to message [email protected] with the subject line "Looping Layout". All questions are welcome, don't be shy! Just try to include as much helpful information as possible =)

Currently there is no mailing list, but if you would like one please message [email protected] about that as well!

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.