use of org.fourthline.cling.support.model.container.Container in project BeyondUPnP by kevinshine.
the class ContentContainerActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.listview);
mObjectId = getIntent().getStringExtra(OBJECT_ID_TAG);
mIdentifierString = getIntent().getStringExtra(IDENTIFIER_STRING_TAG);
String title = getIntent().getStringExtra(CONTENT_CONTAINER_TITLE);
//Display container title.
if (title != null) {
setTitle(title);
} else {
setTitle("");
}
mDidlObjectAdapter = new DIDLObjectAdapter(ContentContainerActivity.this);
ListView listView = (ListView) findViewById(android.R.id.list);
listView.setAdapter(mDidlObjectAdapter);
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
DIDLObject didlObject = mDidlObjectAdapter.getItem(position);
if (didlObject instanceof Container) {
Intent intent = new Intent(ContentContainerActivity.this, ContentContainerActivity.class);
intent.putExtra(ContentContainerActivity.OBJECT_ID_TAG, didlObject.getId());
intent.putExtra(ContentContainerActivity.IDENTIFIER_STRING_TAG, mIdentifierString);
intent.putExtra(ContentContainerActivity.CONTENT_CONTAINER_TITLE, didlObject.getTitle());
startActivity(intent);
} else if (didlObject instanceof Item) {
Item item = (Item) didlObject;
playItem(item);
}
}
});
loadContent();
}
use of org.fourthline.cling.support.model.container.Container in project libresonic by Libresonic.
the class FolderBasedContentDirectory method createContainer.
private Container createContainer(MediaFile mediaFile) throws Exception {
Container container = mediaFile.isAlbum() ? createAlbumContainer(mediaFile) : new MusicAlbum();
container.setId(CONTAINER_ID_FOLDER_PREFIX + mediaFile.getId());
container.setTitle(mediaFile.getName());
List<MediaFile> children = mediaFileService.getChildrenOf(mediaFile, true, true, false);
container.setChildCount(children.size());
container.setParentID(CONTAINER_ID_ROOT);
if (!mediaFileService.isRoot(mediaFile)) {
MediaFile parent = mediaFileService.getParentOf(mediaFile);
if (parent != null) {
container.setParentID(String.valueOf(parent.getId()));
}
}
return container;
}
use of org.fourthline.cling.support.model.container.Container in project BeyondUPnP by kevinshine.
the class BeyondContentDirectoryService method browse.
@Override
public BrowseResult browse(String objectID, BrowseFlag browseFlag, String filter, long firstResult, long maxResults, SortCriterion[] orderby) throws ContentDirectoryException {
String address = Utils.getIPAddress(true);
String serverUrl = "http://" + address + ":" + JettyResourceServer.JETTY_SERVER_PORT;
//Create container by id
Container resultBean = ContainerFactory.createContainer(objectID, serverUrl);
DIDLContent content = new DIDLContent();
for (Container c : resultBean.getContainers()) content.addContainer(c);
for (Item item : resultBean.getItems()) content.addItem(item);
int count = resultBean.getChildCount();
String contentModel = "";
try {
contentModel = new DIDLParser().generate(content);
} catch (Exception e) {
throw new ContentDirectoryException(ContentDirectoryErrorCode.CANNOT_PROCESS, e.toString());
}
return new BrowseResult(contentModel, count, count);
}
use of org.fourthline.cling.support.model.container.Container in project libresonic by Libresonic.
the class FolderBasedContentDirectory method createPlaylistRootContainer.
private Container createPlaylistRootContainer() {
Container container = new StorageFolder();
container.setId(CONTAINER_ID_PLAYLIST_ROOT);
container.setTitle("Playlists");
List<Playlist> playlists = playlistService.getAllPlaylists();
container.setChildCount(playlists.size());
container.setParentID(CONTAINER_ID_ROOT);
return container;
}
Aggregations