Android Open Source - libraryofalexandria Art Work Model






From Project

Back to project page libraryofalexandria.

License

The source code is released under:

Apache License

If you think the Android project libraryofalexandria listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package alexandria.israelferrer.com.libraryofalexandria;
//  w  w  w .  j ava2  s .  c o m
import android.content.Context;
import android.content.SharedPreferences;

import java.util.List;


public class ArtWorkModel implements Model {
    public static final String PACKAGE = "com.israelferrer.alexandria";
    private final ArtWorkService service;
    private final SharedPreferences persistence;

    public ArtWorkModel(ArtWorkService service,SharedPreferences persistence) {
        this.service = service;
        this.persistence=persistence;
    }


    @Override
    public void getArtWorks(final Callback<List<ArtWork>> callback) {
        service.getArtWorks(new Callback<List<ArtWork>>() {
            @Override
            public void success(List<ArtWork> result) {
                restoreRating(result);
                callback.success(result);
            }

            @Override
            public void failure(Exception exception) {
                callback.failure(exception);
            }
        });
    }

    private void restoreRating(List<ArtWork> result) {
        for (ArtWork artWork : result) {
            artWork.setRating(persistence.getFloat(PACKAGE + artWork.getId(), 0F));
        }
    }
}




Java Source Code List

alexandria.israelferrer.com.libraryofalexandria.ArtWorkListActivityTests.java
alexandria.israelferrer.com.libraryofalexandria.ArtWorkListActivity.java
alexandria.israelferrer.com.libraryofalexandria.ArtWorkListPresenter.java
alexandria.israelferrer.com.libraryofalexandria.ArtWorkModelTests.java
alexandria.israelferrer.com.libraryofalexandria.ArtWorkModel.java
alexandria.israelferrer.com.libraryofalexandria.ArtWorkPersistence.java
alexandria.israelferrer.com.libraryofalexandria.ArtWorkPresenterTests.java
alexandria.israelferrer.com.libraryofalexandria.ArtWorkServiceImpl.java
alexandria.israelferrer.com.libraryofalexandria.ArtWorkService.java
alexandria.israelferrer.com.libraryofalexandria.ArtWork.java
alexandria.israelferrer.com.libraryofalexandria.Callback.java
alexandria.israelferrer.com.libraryofalexandria.Display.java
alexandria.israelferrer.com.libraryofalexandria.ItemView.java
alexandria.israelferrer.com.libraryofalexandria.Model.java
alexandria.israelferrer.com.libraryofalexandria.Presenter.java