use of org.musicbrainz.android.api.data.UserCollectionInfo in project musicbrainz-android by jdamcd.
the class CollectionListHandler method startElement.
public void startElement(String namespaceURI, String localName, String qName, Attributes atts) throws SAXException {
if (localName.equals("collection")) {
editorCollection = new UserCollectionInfo();
editorCollection.setMbid(atts.getValue("id"));
} else if (localName.equals("name")) {
buildString();
} else if (localName.equals("editor")) {
buildString();
} else if (localName.equals("release-list")) {
editorCollection.setCount(Integer.parseInt(atts.getValue("count")));
}
}
use of org.musicbrainz.android.api.data.UserCollectionInfo in project musicbrainz-android by jdamcd.
the class CollectionListAdapter method getView.
public View getView(int position, View convertView, ViewGroup parent) {
View collectionView = convertView;
CollectionInfoHolder holder = null;
if (collectionView == null) {
LayoutInflater inflater = context.getLayoutInflater();
collectionView = inflater.inflate(R.layout.list_collection, parent, false);
holder = new CollectionInfoHolder(collectionView);
collectionView.setTag(holder);
} else {
holder = (CollectionInfoHolder) collectionView.getTag();
}
UserCollectionInfo collection = userCollections.get(position);
holder.getTitle().setText(collection.getName());
holder.getCount().setText(getReleasesDisplayText(collection));
return collectionView;
}
use of org.musicbrainz.android.api.data.UserCollectionInfo in project musicbrainz-android by jdamcd.
the class MusicBrainzWebClient method lookupUserCollections.
@Override
public LinkedList<UserCollectionInfo> lookupUserCollections() throws IOException {
HttpEntity entity = get(QueryBuilder.collectionList());
LinkedList<UserCollectionInfo> collections = responseParser.parseCollectionListLookup(entity.getContent());
entity.consumeContent();
Collections.sort(collections);
return collections;
}
use of org.musicbrainz.android.api.data.UserCollectionInfo in project musicbrainz-android by jdamcd.
the class CollectionListLookupTest method testLastResult.
@Test
public void testLastResult() {
UserCollectionInfo last = collections.get(1);
assertEquals("c6f9fb72-e233-47f4-a2f6-19f16442d93a", last.getMbid());
assertEquals("My Collection", last.getName());
assertEquals("jdamcd", last.getEditor());
assertEquals(2, last.getCount());
}
use of org.musicbrainz.android.api.data.UserCollectionInfo in project musicbrainz-android by jdamcd.
the class CollectionAddDialog method onLoadFinished.
@Override
public void onLoadFinished(Loader<AsyncResult<List<UserCollectionInfo>>> loader, AsyncResult<List<UserCollectionInfo>> result) {
loading.setVisibility(View.GONE);
switch(result.getStatus()) {
case SUCCESS:
List<UserCollectionInfo> collection = result.getData();
try {
adapter = new CollectionListAdapter(getActivity(), collection);
if (adapter.isEmpty()) {
empty.setVisibility(View.VISIBLE);
}
list.setAdapter(adapter);
} catch (Exception e) {
// Fragment not connected.
}
break;
case EXCEPTION:
showConnectionErrorWarning();
}
}
Aggregations