Android MVVM experiment project using the official Data Binding library

Overview

MVVM using Data Binding Build Status

I wanted to experiment creating an MVVM structured project using the official Data Binding library, so I stripped back an old project of mine and replaced relevant codebase with an MVVM approach. This is still experimental, so I'd love to hear any suggestion / improvements to the approach!

Screenshots

Currently writing a Medium article which should explain more... but for now:

Posts

Post cards displayed on the Post Screen (left, above) are built using the following classes:

Post - The post object

PostAdapter - The RecyclerView adapter used to set the view model

PostViewModel - The view model used to manage the display of the posts

item_post - The XML layout file which displays the post card

Comments

Comments displayed on the Comment Screen (right, above) are built using the following classes:

Comment - The comment object

CommentAdapter - The RecyclerView adapter used to set the corresponding view model. Comments work a bit differently from posts as this adapter uses logic to choose to use one of two view models based on the comment type

CommentViewModel - The view model used for standard comments on a post

CommentsHeaderViewModel - The view model used as a header for the post text with an ASK post

item_comment - The XML layout file which displays a standard comment

item_comments_header - The XML layout file used to display the header for an ASK post

Requirements

  • Android SDK.
  • Android 5.1 (API 22) .
  • Android SDK Tools
  • Android SDK Build tools 23.0.0.0
  • Android Support Repository
  • Android Support library

Building

To build, install and run a debug version, run this from the root of the project:

./gradlew installRunDebug

Testing

To run unit tests on your machine using [Robolectric] (http://robolectric.org/):

./gradlew testDebugUnitTest

To run automated tests on connected devices:

./gradlew connectedAndroidTest
Comments
  • Which version of jdk are you running?

    Which version of jdk are you running?

    cloned the repo and gradle build fails :(

    Error:Unable to load class 'org.apache.commons.lang3.StringUtils'. Possible causes for this unexpected error include:

    • You are using JDK version 'java version "1.7.0_71"'. Some versions of JDK 1.7 (e.g. 1.7.0_10) may cause class loading errors in Gradle. Please update to a newer version (e.g. 1.7.0_67). Open JDK Settings
    • Gradle's dependency cache may be corrupt (this sometimes occurs after a network connection timeout.) Re-download dependencies and sync project (requires network)
    • The state of a Gradle build process (daemon) may be corrupt. Stopping all Gradle daemons may solve this problem. Stop Gradle build processes (requires restart)
    • Your project may be using a third-party plugin which is not compatible with the other plugins in the project or the version of Gradle requested by the project.
    In the case of corrupt Gradle processes, you can also try closing the IDE and then killing all Java processes.

    opened by mvpmvh 2
  • Added support for Chrome Custom Tabs

    Added support for Chrome Custom Tabs

    Not too sure if the View Model was the best place to put this, but I've added the minimum amount of code needed to get it working.

    I originally had the toolbar colour set as the theme's primary colour, however, the colour of the status bar is then set to a darker colour than the rest of the app, which looks very odd.

    opened by matt-oakes 1
  • I get error compile project

    I get error compile project

    I get this error and i can fix that:

    Error:(2, 0) Cause: org/apache/commons/lang3/StringUtils
    <a href="openFile:/home/mahdi/Desktop/Home/Projects/Android/MVVM_Hacker_News-master/app/build.gradle">Open File</a>
    
    opened by pishguy 0
  • Reimplemented post adapter addItem to use notifyItemInserted and notifyItemChanged instead of notifyDataSetChanged

    Reimplemented post adapter addItem to use notifyItemInserted and notifyItemChanged instead of notifyDataSetChanged

    As you can read in the documentation NotifyDataSetChanged

    RecyclerView will attempt to synthesize visible structural change events for adapters that report that they have stable IDs when this method is used. This can help for the purposes of animation and visual object persistence but individual item views will still need to be rebound and relaid out.

    If you are writing an adapter it will always be more efficient to use the more specific change events if you can. Rely on notifyDataSetChanged() as a last resort.

    I implemented NotifyItemInserted for when a new item is added and NotifyItemChanged for when an item is updated (that's not happening right now but could in the future).

    opened by chriscoderdr 0
  • Fixes for using this repo in 2017

    Fixes for using this repo in 2017

    I've update a lot of things

    • Retrofit 2
    • OkHttp 3
    • Fixes on unitTests
    • Updated gradle plugin and ...

    With this changes u can easily clone this repository and just import it to AS without any headache.

    opened by PHELAT 0
  • Error while gradle sync (org/apache/commons/lang3/StringUtils)

    Error while gradle sync (org/apache/commons/lang3/StringUtils)

    Facing issues during initial project setup. I am running Gradle sync from Android Studio and it keeps giving me the error shown in the below image. Anyone else facing similar issue?

    image

    opened by captswag 5
  • Data binding with library

    Data binding with library

    Hey developers, How can I use data binding in my application because I am new to data binding concept ? I have an application module and one android lib. Module which has all the entites those are used in app module l.. So how can I use data binding in my app with lib. Module.. Which also include dynamic inflation of view based on parameter in some of the entities in library module 

    opened by patelakshay13890 0
  • Dynamic Binding

    Dynamic Binding

    Hey , Does any one have idea of using Data Binding in Android Studio with all possible options ?? If do have then send me link for the same I need it badly

    I also need to Use it in List view and want to Add Text view to the Linear layout dynamically Based on data using binding.

    opened by patelakshay13890 0
Owner
Joe Birch
Senior Android Engineer @bufferapp. Brighton, UK.
Joe Birch
A data-binding Presentation Model(MVVM) framework for the Android platform.

PLEASE NOTE, THIS PROJECT IS NO LONGER BEING MAINTAINED. As personal time contraints, I am currently unable to keep up. Please use official android da

RoboBinding open source 1.3k Dec 9, 2022
Retrieve Data from an API using MVVM Clean Architecture and Jetpack Compose

MVVM Clean Architecture Demo Retrieve Data from an API using MVVM Clean Architecture and Jetpack Compose. It simply shows a list of movies fetched fro

Daniel Kago 2 Sep 16, 2022
🍿 A TV Showcase App using Jetpack libs and MVVM arch. Data provided by TV Maze API

TV Showcase A TV Showcase ?? Android App using Jetpack libraries and MVVM architecture. Data provided by TVMaze API. Release ?? Download here See how

Lucas Rafagnin 4 Sep 8, 2022
MVVM Redux is a lightweight lib to help you apply the redux concepts in your project based in MVVM.

MVVM Redux is a lightweight lib to help you apply the redux concepts in your project based in MVVM.

Gabriel Brasileiro 36 Oct 16, 2022
🧬 Android DataBinding kit for notifying data changes from Model layers to UI layers on MVVM architecture.

?? Android DataBinding kit for notifying data changes from Model layers to UI layers on MVVM architecture.

Jaewoong Eum 275 Dec 21, 2022
MVVM RECIPE ANDROID APP Is an app where I show how to use MVVM, retrofit, dagger hilt, coroutine, liveData, Kotlin, navigation component, and so on...

MVVM RECIPE ANDROID APP Is an app where I show how to use MVVM, retrofit, dagger hilt, coroutine, liveData, kotlin, navigation component, and so on...

Isaias Cuvula 23 Dec 5, 2022
Basic-MVVM-Example - Basic Android Application MVVM

Android's MVVM Architecture in Kotlin Why a simple app ? Because it's easier to

null 3 Dec 8, 2022
Chat App MVVM + Clean ArchitectureChat App MVVM + Clean Architecture

Chat App MVVM + Clean Architecture This Android application built using MVVM + Clean Architecture architecture approach and is written 100% in Kotlin.

null 4 Nov 29, 2022
Android Clean Architecture💎 Base Project Android with Kotlin and MVVM applying clean architecture

Android Clean Architecture?? Base Project Android with Kotlin and MVVM applying clean architecture

Mina Mikhail 103 Dec 2, 2022
Playground project built with MVVM with Clean Artchitect to try out new tech in Android 🌍

Clean-MVVM-Playground Playground project built with MVVM with Clean Artchitect to try out new tech in Android ?? Features ?? 100% Kotlin Following MVV

Somesh Kumar 8 Dec 9, 2022
MVVM Android Studio Kotlin Project Dog Images

MVVM Android Studio Kotlin Project Dog Images This project implement: MVVM Retro

Teulys Jiménez 1 Apr 17, 2022
Discover the most popular and top rated movies playing. Movies data fetched using tomdbapi.com API.

Movie-App A simple news app build using MVVM architecture. Discover the most popular and top rated movies playing. Movies data fetched using tomdbapi.

Mahmudul Hasan 5 Jan 3, 2023
Currency converter Android application using MVVM architecture

Currency Converter Currency conversion using live exchange rates. Demo Screenshots API service

Riadh Yousfi 0 Oct 31, 2021
An android app built using Kotlin following Multi-Module Clean Architecture MVVM

RickyandMorty An android app built using Kotlin that consumes RickyadMorty API to display characters.It has been built following Clean Architecture Pr

Kibet 14 Sep 2, 2022
❤️ Android Ghibli using Hilt, Motion, Coroutines, Jetpack (ViewModel) based on MVVM architecture.

Glibhi ❤️ Android Ghibli using Hilt, Motion, Coroutines, Jetpack (ViewModel) based on MVVM architecture. Tech stack & Open-source libraries Minimum SD

Geovani Amaral 4 Aug 26, 2022
Android MVVM Base Architecture for Enterprise Mobile Application using Architectural Components

Android MVVM Base Architecture for Enterprise Mobile Application using Architectural Components Highlights MVVM Architectural pattern Offline Support

Behruz Bahromzoda 2 Apr 23, 2022
Android App using Kotlin, MVVM, ViewModel, LiveData, Coroutines, Room and DataBinding

Words Android App using Kotlin, MVVM, ViewModel, LiveData, Coroutines, Room and

Viacheslav Veselov 0 Jul 16, 2022
Simple news app using MVVM

Simple News App Simple news app android using MVVM Screenshots News API key News App uses the News API to load news. To use the API, you will need to

Ar Razy Fathan Rabbani 4 Nov 26, 2022