Code Monkey home page Code Monkey logo

pagingsamplecodelab's Introduction

Android Paging Sample

This App has been developed, following the instructions given in the Google Codelab Android Paging. The original code by Google for this codelab can be referred here, which contains codes written in Kotlin.

This Sample here has been rewritten in Java for Java Developers!

What you will build

The App displays a list of Github Repositories using the Github API for the search query entered. The query will be searched in the Name and Description fields of the Github repositories. The data is saved in the local database cache that is backed by the network data. As the user scrolls to the end of the displayed list, a new network request is triggered and the results are displayed and saved in the database.

This App sample here uses -

  • Room - for local database cache.
  • LiveData and ViewModel - for maintaining the data of the App.
  • DataBinding - for binding View elements to their data. (Not present in the Google's Kotlin sample which employs Kotlin's features and Android KTX to accomplish the same)
  • Retrofit and Okhttp - for communicating with the Github API.
  • Repository pattern as per the Guide to App Architecture.
  • Java 8 lambdas.

In this Codelab, one will learn how to integrate the Paging Library components to accomplish the pagination task.

Getting Started

  • Android Studio 3.0 or higher
  • Familiarity with Android Architecture Components and DataBinding(only for understanding purpose).

Branches in this Repository

  • todo-starter-code
    • This is the repository to start working with.
    • Contains codes written in Java.
    • Contains TODOs where one needs to write code. This is suitably marked such that a Java developer can follow with the existing Kotlin Codelab.
    • Each Codelab step where one needs to write code, has been marked with the TODO comment following the syntax //TODO(Step-X): where X is the Codelab Step number. This number may change if the original codelab changes.
  • solution-code
    • This is the repository for the Solution code written in Java.

Differences with respect to the Original Kotlin sample

  • Firstly, the entire code has been rewritten in Java. Hence it uses Java 8 lambdas in places suitable for its usage.
  • Binding View elements to their Data is carried out by DataBinding. In the Kotlin version, it uses the Kotlin features and Android KTX.
  • Original version uses EditText for capturing User's Search query. In this sample, it is replaced with the TextInputEditText as per the recommendation for the TextInputLayout used.
  • The String resources contains a Unicode character that is not interpretable in Android versions 5.0 or below. This is replaced with %s and the corresponding value is set in the Activity code that displays it.

Sample Screenshot

References

References used for rewritting code in Java -

pagingsamplecodelab's People

Contributors

kaushiknsanji avatar

Watchers

 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.