Giter Club home page Giter Club logo

mvp-android-arch-component's Introduction

MVP with Android architecture components

Build Status codecov
An Android project with MVP pattern which adapts with new Android architecture components introduced in Google IO 2017.
It provides lifecycle-aware Presenter with support of LifeCycle and local data source handled by Room (an abstraction layer over SQLite).

Blog post: Android MVP with new Architecture Components

This demo project uses StackExchange API as a remote data source. It loads and shows all newest Android questions.

Libraries:

License

This project is available under the MIT license. See the LICENSE file for more info.


If you are interested in my useful blog posts and cool projects, you can subscribe to my newsletter by clicking the below link.
SUBSCRIBE TO USEFUL BLOG POSTS AND COOL PROJECTS.

mvp-android-arch-component's People

Contributors

quangctkm9207 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  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  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  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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

mvp-android-arch-component's Issues

LiveData and ViewModel implementation

You can have the presenter be a subclass of the ViewModel class and update data on the ui with the help of LiveData.
If you think it's a good idea I'd like to work on it.

No data loaded

The QuestionsActivity is calling loadQuestions(false) method.

This method is loading data from local storage but there's no data.

public Flowable<List<Question>> loadQuestions(boolean forceRemote) {
Flowable<List<Question>> questions;
    if (forceRemote) {
      questions = remoteDataSource.loadQuestions(true).doOnEach(notification -> {
        // Save new data to local data source
        List<Question> list = notification.getValue();
        if (list != null && !list.isEmpty()) {
          saveDataToLocal(list);
        }
      });
    } else {
      questions = localDataSource.loadQuestions(false);
    }
    return questions;
  }

I think, it would be: if ther's no data on local storage, then load from remote.

I've tryied to change it to something like:

    override fun loadAll(forceRemote: Boolean): Flowable<List<Question>> {
        if (forceRemote){
            return loadFromRemote()
        } else {
            return localDataSource.loadAll(false)
                    .flatMap{ if (it.isEmpty()) Flowable.empty() else Flowable.fromArray(it) }
                    .switchIfEmpty(loadFromRemote())
        }
    }

But no success...

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.