Coder Social home page Coder Social logo

imagesearch's Introduction

ImageSearch application

This is a demo application showcasing an image search functionality. The data is retrieved from backend web service and is presented in a 3 column grid. The images count may be really big, so they are retrieved on chunks, simulating an infinite scroll. The data is retrieved from flickr API

Application dependencies

This application is integrating the latest android best practices. It's written in kotlin and is based on Android Jetpack components including:

  • ViewModel
  • LiveData
  • Paging
  • Lifecycle
  • ConstraintLayout

Asyncronous tasks are made via kotlin coroutines. No 3rd party dependencies are used.

Application components and implementation details

UI

SearchFragment is the screen responsible for visualising the search bar and search results

Presentation

SearchViewModel is the viewModel feeding the fragment with search results and interacting with data layer to retrieve search results

Data

  • NetworkPhotosDataSource: class implementing PhotosDataSource used to make network API calls.
  • DefaultPhotosRepository: class implementing PhotosRepository used as a facade to hide data retrieving implementation. Currently it transparently calls NetworkPhotosDataSource, but can easily be extended to add some sort of caching with minimal changes adding another PhotosDataSource implementation
  • PhotosPageDataSource : data source based on the Paging component used to retrieve data from the repository for the current or next "page" of photos

Others

  • ImageLoader: class used for loading and caching images from the network
  • JsonMapper: class used for json to object conversion
  • Injector: class used to enhance dependency injection, giving the possibility to replace some implementations during tests

Unit tests

Unit tests are based on Junit 4, Mockito and Kotlinx Coroutines Test

Possible improvements

  • Implement retry mechanism when a web service call fails
  • Implement image cache on file system
  • Add voice search and search suggestions
  • Write some integration tests

imagesearch's People

Contributors

aimilushev avatar

Watchers

James Cloos avatar

Forkers

publicbull

imagesearch's Issues

Sometimes wrong image is loaded

Wrong image is loaded when we have a correct item at cache. The correct one is loaded and afterwards replaced with wrong one.
This is caused by :

  1. When setting image from cache the image tag is not updated
  2. When setting image from cache a pending download for this imageView is not cancelled

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.