Back to project page RoboBinding-album-sample.
The source code is released under:
Apache License
If you think the Android project RoboBinding-album-sample listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package org.robobinding.albumsample.presentationmodel; //w w w.j a v a 2 s . c om import org.robobinding.albumsample.model.Album; import org.robobinding.albumsample.store.AlbumStore; import org.robobinding.annotation.DependsOnStateOf; import org.robobinding.annotation.PresentationModel; /** * @author Cheng Wei * @author Robert Taylor * @since 1.0 */ @PresentationModel public class CreateEditAlbumPresentationModel { private static final String CLASSICAL = "classical"; private final CreateEditAlbumView view; private final AlbumStore albumStore; private final Album.Builder albumBuilder; public CreateEditAlbumPresentationModel(CreateEditAlbumView view, AlbumStore albumStore, Album.Builder albumBuilder) { this.view = view; this.albumStore = albumStore; this.albumBuilder = albumBuilder; } public void save() { albumStore.save(albumBuilder.create()); view.finishActivity(); } public String getTitle() { return albumBuilder.getTitle(); } public void setTitle(String title) { albumBuilder.setTitle(title); } public String getArtist() { return albumBuilder.getArtist(); } public void setArtist(String artist) { albumBuilder.setArtist(artist); } public boolean isClassical() { return albumBuilder.isClassical(); } public void setClassical(boolean classical) { albumBuilder.setClassical(classical); } @DependsOnStateOf(CLASSICAL) public boolean isComposerEnabled() { return isClassical(); } public String getComposer() { return albumBuilder.getComposer(); } public void setComposer(String composer) { albumBuilder.setComposer(composer); } @DependsOnStateOf(CLASSICAL) public String getWindowTitle() { if (albumBuilder.isNew()) return view.getCreateAlbumTitle(); return isClassical() ? "Edit Classical Album" : "Edit Album"; } }