4. public class Server {
private static final String SERVER_URL = "http://localhost:8080/";
public static void fetchContent(OnComplete<ContentCollection> fetch) {
Rest.get(SERVER_URL + "video/list").
jsonContent().fetchAsProperties(callback -> {
fetch.completed((ContentCollection)callback.getResponseData());
}, ContentCollection.class);
}
}
Source Listing - Server
codenameone.com github.com/codenameone/CodenameOne
5. public class Server {
private static final String SERVER_URL = "http://localhost:8080/";
public static void fetchContent(OnComplete<ContentCollection> fetch) {
Rest.get(SERVER_URL + "video/list").
jsonContent().fetchAsProperties(callback -> {
fetch.completed((ContentCollection)callback.getResponseData());
}, ContentCollection.class);
}
}
Source Listing - Server
codenameone.com github.com/codenameone/CodenameOne
6. public class ContentCollection implements PropertyBusinessObject {
public final Property<Content, ContentCollection> lead =
new Property<>("lead", Content.class);
public final ListProperty<Content, ContentCollection> popular =
new ListProperty<>("popular", Content.class);
public final ListProperty<Content, ContentCollection> myList =
new ListProperty<>("myList", Content.class);
public final ListProperty<Content, ContentCollection> recommended =
new ListProperty<>("recommended", Content.class);
private PropertyIndex idx = new PropertyIndex(this,
"ContentCollection", lead, popular, myList, recommended);
@Override
public PropertyIndex getPropertyIndex() {
return idx;
}
}
Source Listing - ContentCollection
codenameone.com github.com/codenameone/CodenameOne
7. public class ContentCollection implements PropertyBusinessObject {
public final Property<Content, ContentCollection> lead =
new Property<>("lead", Content.class);
public final ListProperty<Content, ContentCollection> popular =
new ListProperty<>("popular", Content.class);
public final ListProperty<Content, ContentCollection> myList =
new ListProperty<>("myList", Content.class);
public final ListProperty<Content, ContentCollection> recommended =
new ListProperty<>("recommended", Content.class);
private PropertyIndex idx = new PropertyIndex(this,
"ContentCollection", lead, popular, myList, recommended);
@Override
public PropertyIndex getPropertyIndex() {
return idx;
}
}
Source Listing - ContentCollection
codenameone.com github.com/codenameone/CodenameOne
8. public class Content implements PropertyBusinessObject {
public final Property<String, Content> id = new Property<>("id");
public final Property<EncodedImage, Content> heroImage = new Property<>("heroImage", EncodedImage.class);
public final Property<EncodedImage, Content> icon = new Property<>("icon", EncodedImage.class);
public final Property<EncodedImage, Content> logo = new Property<>("logo", EncodedImage.class);
public final Property<String, Content> name = new Property<>("name");
public final Property<String, Content> description = new Property<>("description");
public final MapProperty<String, String, Content> videoUrls = new MapProperty<>("videoUrls", String.class, String.class);
private final PropertyIndex idx = new PropertyIndex(this, "Content", id, heroImage, icon, logo, name, description, videoUrls);
@Override
public PropertyIndex getPropertyIndex() {
return idx;
}
}
Source Listing - Content
codenameone.com github.com/codenameone/CodenameOne
9. public enum VideoQuality {
NONE,
LOW,
MEDIUM,
HIGH
}
Source Listing - ContentCollection
codenameone.com github.com/codenameone/CodenameOne