Search in sources :

Example 1 with UserCollectionInfo

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")));
    }
}
Also used : UserCollectionInfo(org.musicbrainz.android.api.data.UserCollectionInfo)

Example 2 with UserCollectionInfo

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;
}
Also used : LayoutInflater(android.view.LayoutInflater) UserCollectionInfo(org.musicbrainz.android.api.data.UserCollectionInfo) TextView(android.widget.TextView) View(android.view.View)

Example 3 with UserCollectionInfo

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;
}
Also used : HttpEntity(org.apache.http.HttpEntity) UserCollectionInfo(org.musicbrainz.android.api.data.UserCollectionInfo)

Example 4 with UserCollectionInfo

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());
}
Also used : UserCollectionInfo(org.musicbrainz.android.api.data.UserCollectionInfo) Test(org.junit.Test)

Example 5 with UserCollectionInfo

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();
    }
}
Also used : CollectionListAdapter(org.musicbrainz.mobile.adapter.list.CollectionListAdapter) UserCollectionInfo(org.musicbrainz.android.api.data.UserCollectionInfo)

Aggregations

UserCollectionInfo (org.musicbrainz.android.api.data.UserCollectionInfo)6 Test (org.junit.Test)2 LayoutInflater (android.view.LayoutInflater)1 View (android.view.View)1 TextView (android.widget.TextView)1 HttpEntity (org.apache.http.HttpEntity)1 CollectionListAdapter (org.musicbrainz.mobile.adapter.list.CollectionListAdapter)1