app/src/main/java/cl/ucn/disc/dsm/thenews/activities/adapters/NoticiaViewModel.java
public int refresh() {

    try {

      // 1. Get the list of noticia from NewsApi
      final List<Noticia> noticias = this.noticiaService.getNoticias(PAGE_SIZE);

      // 2. Set the values (NEED to be in background)
      this.theNoticias.postValue(noticias);

      // 3. All ok!
      return noticias.size();

    } catch (final Exception ex) {

      log.error("Error", ex);

      // 2. Set the exception
      this.theException.postValue(ex);

      // 3. All error!
      return -1;

    }

  }
/**
   * Update the internal list of Noticias.
   *
   * <p>NOTE: Need to run in background.</p>
   *
   * @return the number of noticias loaded.
   */
Update the internal list of Noticias.
NOTE: Need to run in background.

@return the number of noticias loaded.
Update the internal list of Noticias . NOTE : Need to run in background . @return the number of noticias loaded .
public int refresh() {
    try {
      final List<Noticia> noticias = this.noticiaService.getNoticias(PAGE_SIZE);
      this.theNoticias.postValue(noticias);
      return noticias.size();
    } catch (final Exception ex) {
      log.error("Error", ex);
      this.theException.postValue(ex);
      return -1;
    }
  }
public int refresh ( ) { try { final List < Noticia > noticias = this . noticiaService . getNoticias ( PAGE_SIZE ) ; this . theNoticias . postValue ( noticias ) ; return noticias . size ( ) ; } catch ( final Exception ex ) { log . error ( "Error" , ex ) ; this . theException . postValue ( ex ) ; return - 1 ; } }
Update the internal list of Noticias.
Update the internal list of Noticias .
// 1. Get the list of noticia from NewsApi // 2. Set the values (NEED to be in background) // 3. All ok! // 2. Set the exception // 3. All error!