GithubHelp home page GithubHelp logo

tchigher / looping-layout Goto Github PK

View Code? Open in Web Editor NEW

This project forked from beksomega/looping-layout

0.0 0.0 0.0 263 KB

A looping LayoutManager for the Android RecyclerView.

License: Apache License 2.0

Kotlin 100.00%

looping-layout's Introduction

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.

๐ŸŒŸ Setup

Add the dependency to your build.gradle file.

dependencies {
    implementation 'com.github.beksomega:loopinglayout:0.3.1'
}

Apply the layout manager to your RecyclerView.

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:

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.

โœจ Features

  • Vertical and Horizontal Orientations
  • LTR and RTL support
  • ReverseLayout support for both orientations, as well as LTR, and RTL
  • Public functions for finding items and positions
  • Public functions for scrolling programmatically
  • Snap Helper support via the LoopingSnapHelper
  • Accessibility (TalkBack and Voice Access) support

๐Ÿ“ƒ 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.

๐Ÿ’š 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.

โ“ 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!

looping-layout's People

Contributors

beksomega avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.