Git Product home page Git Product logo

flickr-android's Introduction

flickr-android

Build Status

A small sample app to showcase architecting app using Clean Architecture and MVVM

Overview

Does it support tablet UI as well as UI for different orientation?

Yes. On phone devices, the gallery will show photos in a grid of 2 columns in portrait. But in landscape, column count will be 4.

Phone UI

For tablet devices, more column will be added.

Tablet UI

Does it handle configuration changes?

Yes. For example, when you rotate the device from portrait to landscape, the app won't fetch photos from Flickr again. I used the approach of using retained fragments which is mentioned in https://developer.android.com/guide/topics/resources/runtime-changes.html#RetainingAnObject.

Does it have a good architecture?

I used Clean Architecture and MVVM to drive a scalable, testable code-base. The project is divided into 3 modules:

  • domain: Contains components to perform business logic like Repository interfaces (e.g. PhotoRepository, QueryRepository), and interactors (e.g. GetPhotos). This module is completely independent from Android SDK. So that makes sure that any changes, for example, related to changing network layer, or data storage will not affect this business layer. Executing unit tests is fast because it's just a Java/Kotlin module.
    • Main technologies: Kotlin, RxJava.
  • data: Contains implementations of the Repository interfaces from the domain module. This module depends on Android SDK. This is where I implemented networking layer to access Flickr's public API as well as SQLite-related storage layer to store fetched photos.
    • Main technologies: Retrofit, Immutables, Gson, OkHttp, Room and RxJava.
  • app: Basically, a presentation layer. This place is where MVVM comes to play. This module contains view controllers (e.g. RecentPhotosFragment) and ViewModels (e.g. RecentPhotosViewModel). ViewModels are absolutely testable.
    • Main technologies: Data Binding Library, RxJava and RxAndroid.

On top of that, package hierarchy is organized by features: core, recent, and photodetails.

To understand more about this Clean Architecture approach, you can read further in following links:

Does it have unit tests?

Yes, however as I don't have much time, I only covered few most important classes which are:

  • PhotoRepositoryImpl
  • RecentPhotosViewModel
  • QueryRepository

Unit tests for the remaining classes can be written in the same way as those 3 classes.

Does it have a good way to send data across Activities?

Yes. To show a higher resolution photo, PhotoDetailsActivity only takes a photo id from RecentPhotosActivity. This is to avoid the TransactionTooLargeException which easily happens since Android 7 if we send a large amount of data between Android components. That photo id is then used to retrieve more infos about photo via PhotoRepository. PhotoRepository is backed behind by a good caching mechanism. After we fetch a list of photos from Flickr, they will be put into a memory cache to quickly access later on PhotosDetailsActivity. However, if somehow the app is killed by the system after being pushed into background, given a photo id, the app can retrieve the photo back via a SQLite-based database (implemented via Room).

flickr-android's People

Contributors

thuytrinh avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 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.