Giter Site home page Giter Site logo

rethen / lastpageradapter Goto Github PK

View Code? Open in Web Editor NEW

This project forked from rakshakhegde/lastpageradapter

0.0 2.0 0.0 5.01 MB

Don't write a ViewPager Adapter! Hook up your ViewPager to your data model using Android Data Binding Framework. With Kotlin support!

Java 17.80% Kotlin 82.20%

lastpageradapter's Introduction

Release BuddyBuild android min api size

LastPagerAdapter Hero Banner

Don't write a ViewPager Adapter! Hook up your ViewPager to your data model using the new Android Data Binding Framework.

Based on Android Data Binding

πŸ’‹ Sweet and short library

Use the language of your choice.

// Java
new LastPagerAdapter(BR.model)
    .add(R.layout.layout_one, "First Layout Title", modelObject1)
    .add(R.layout.layout_two, "Second Layout Title", modelObject2)
    .into(viewPager);
// Kotlin
viewpager.lastPagerAdapter(BR.model) {
    add(R.layout.layout_one, "First Layout Title", modelObject1)
    add(R.layout.layout_two, "Second Layout Title", modelObject2)
}

Download the demo apk to play around with the LastPagerAdapter demo app.

Demo GIF

Or try the limited 1 min live app demo at Appetize.

πŸ“œ Contents

- [Features](#crown-features) - [Build](#classical_building-build) - [How to use](#thinking-how-to-use) - [Acknowledgements](#sparkles-acknowledgements) - [Author](#man_cartwheeling-author) - [Contribute](#fork_and_knife-contribute) - [License](#memo-license)

πŸ‘‘ Features

     |  LastPagerAdapter

--------------------------|------------------------------------------------------------ :monorail: | Within a few lines easily hook up your data models with your ViewPager :link: | Based on Android Data Binding ✨ | Written in Kotlin. A concise language you should definitely check out, if you haven't already. :pencil2: | No need to write any PagerAdapter (FragmentPagerAdapter, etc.) βΎΉ | Doesn't rely on Fragments. It has complex lifecycle and best be avoided. More reasons why ❌ | No need to modify your existing model classes πŸ“ƒ | Supports different View layouts and hooking it up with ViewPager is a breeze πŸ‘Œ | Super easy API. Concise syntax. Less Bugs for you to worry about. Boosted Productivity. πŸ“ | Helpful error stacktraces πŸš€ | Very fast β€” no reflection πŸ“± | Minimum Android SDK: Gingerbread API 9

πŸ›οΈ Build

Add this in your root build.gradle at the end of repositories:

allprojects {
    repositories {
        ...
        maven { url 'https://jitpack.io' }
    }
}

Step 2. Add the dependency in your module's gradle file

// apply plugin: 'kotlin-kapt'  // this line only for Kotlin projects

android {
    ...
    dataBinding.enabled true
}

dependencies {
    compile 'com.github.rakshakhegde:LastPagerAdapter:1.1.0'
    // kapt 'com.android.databinding:compiler:GRADLE_PLUGIN_VERSION' // this line only for Kotlin projects
}

πŸ€” How to use

<layout> as root for your View layouts is a must:

<layout xmlns:android="http://schemas.android.com/apk/res/android" >

    <data>
        <variable name="model" type="io.github.rakshakhegde.lastpageradaptersample.TextModel" />
    </data>

    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="@{model.text}" />

</layout>

It is important for all the model types to have the same variable name, in this case "model". This name is passed to the adapter constructor as BR.variableName, in this case BR.model:

// Java
new LastPagerAdapter(BR.model)
    .add(R.layout.text_layout, "Optional Layout Title", optionalTextModelObject, optionalWidth)
    .into(viewPager); // don't forget this line
// Kotlin
viewpager.lastPagerAdapter(BR.model) {
    add(R.layout.text_layout, "Optional Layout Title", optionalTextModelObject, optionalWidth)
}

Except the layoutId, everything else is optional

And that is how easy it is. Download the demo apk to play around with the LastPagerAdapter demo app.

✨ Acknowledgements

Library and API Structure inspired from LastAdapter

Library Concept inspired from SmartTabLayout's Utils

Logo and Hero Banner created by Govindaraj Karthikeyan. Check him out on BΔ“hance

Core Logo created using Roman Nurik's awesome Android Asset Studio πŸ”₯πŸ”₯πŸ”₯

πŸ€Έβ€β™‚οΈ Author

**Rakshak Hegde** tweets rampantly (I wish πŸ˜…) at [**@rakshakhegde**](https://twitter.com/rakshakhegde)

Email | Twitter | Facebook | Google+ | Linked.in

🍴 Contribute

Please file bugs, suggest improvements and feel free to contribute

πŸ’‹ Keep It Simple Silly

πŸ“ License

Copyright 2016 Rakshak Hegde

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

At this point I hope you're not emoji nauseated. If you are, just hit that GitHub Stars Star button to stop me from using emojis.
Support this project please
😁

lastpageradapter's People

Contributors

rakshakhegde avatar

Watchers

James Cloos avatar  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.