anitaa1990 / TrailersApp

A simple demo project for The Movie DB based on MVVM clean architecture.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Data fetched from local DB doesn't show while remote request are running.

isabsent opened this issue · comments

Hi! Thanks for the code sharing!
I have found you are not showing data fetched from local DB while the remote request is running:

    moviesListViewModel.getMoviesLiveData().observe(this, resource -> {
        if(resource.isLoading()) {
            //updateMoviesList(resource.data); - SHOULD BE HERE!
        } else if(!resource.data.isEmpty()) {
            updateMoviesList(resource.data);

        } else handleErrorResponse();
    });

What is the reason for such approach?

P.S.: Another point is you should not check resource.data.isEmpty() before updateMoviesList because of all movies can be removed from a remote server, but you will still have them on a local device screen