Search in sources :

Example 1 with ReleaseInfo

use of org.musicbrainz.android.api.data.ReleaseInfo in project musicbrainz-android by jdamcd.

the class ReleaseInfoHandler method startElement.

public void startElement(String namespaceURI, String localName, String qName, Attributes atts) throws SAXException {
    if (localName.equals("release")) {
        release = new ReleaseInfo();
        release.setReleaseMbid(atts.getValue("id"));
    } else if (localName.equals("title")) {
        buildString();
    } else if (localName.equals("artist")) {
        inArtist = true;
        releaseArtist = new ReleaseArtist();
        releaseArtist.setMbid(atts.getValue("id"));
    } else if (localName.equals("name")) {
        buildString();
    } else if (localName.equals("date")) {
        buildString();
    } else if (localName.equals("country")) {
        buildString();
    } else if (localName.equals("track-list")) {
        String num = atts.getValue("count");
        int tracks = Integer.parseInt(num);
        release.setTracksNum(release.getTracksNum() + tracks);
    } else if (localName.equals("label")) {
        inLabel = true;
    } else if (localName.equals("format")) {
        buildString();
    } else if (localName.equals("medium")) {
        inMedium = true;
    } else if (localName.equals("sort-name")) {
        buildString();
    }
}
Also used : ReleaseInfo(org.musicbrainz.android.api.data.ReleaseInfo) ReleaseArtist(org.musicbrainz.android.api.data.ReleaseArtist)

Example 2 with ReleaseInfo

use of org.musicbrainz.android.api.data.ReleaseInfo in project musicbrainz-android by jdamcd.

the class CollectionHandler method startElement.

public void startElement(String namespaceURI, String localName, String qName, Attributes atts) throws SAXException {
    if (localName.equals("collection")) {
        collection.setMbid(atts.getValue("id"));
    } else if (localName.equals("name")) {
        buildString();
    } else if (localName.equals("editor")) {
        buildString();
    } else if (localName.equals("release-list")) {
        collection.setCount(Integer.parseInt(atts.getValue("count")));
    } else if (localName.equals("release")) {
        release = new ReleaseInfo();
        release.setReleaseMbid(atts.getValue("id"));
    } else if (localName.equals("title")) {
        buildString();
    } else if (localName.equals("date")) {
        buildString();
    } else if (localName.equals("country")) {
        buildString();
    } else if (localName.equals("artist")) {
        inArtist = true;
        releaseArtist = new ReleaseArtist();
        releaseArtist.setMbid(atts.getValue("id"));
    } else if (localName.equals("sort-name")) {
        buildString();
    }
}
Also used : ReleaseInfo(org.musicbrainz.android.api.data.ReleaseInfo) ReleaseArtist(org.musicbrainz.android.api.data.ReleaseArtist)

Example 3 with ReleaseInfo

use of org.musicbrainz.android.api.data.ReleaseInfo in project musicbrainz-android by jdamcd.

the class ReleaseInfoAdapter method getView.

public View getView(int position, View convertView, ViewGroup parent) {
    View releaseView = convertView;
    ReleaseInfoHolder holder = null;
    if (releaseView == null) {
        LayoutInflater inflater = context.getLayoutInflater();
        releaseView = inflater.inflate(layoutId, parent, false);
        holder = new ReleaseInfoHolder(releaseView);
        releaseView.setTag(holder);
    } else {
        holder = (ReleaseInfoHolder) releaseView.getTag();
    }
    ReleaseInfo release = releasesInfo.get(position);
    holder.getTitle().setText(release.getTitle());
    holder.getArtist().setText(StringFormat.commaSeparateArtists(release.getArtists()));
    holder.getCountry().setText(release.getCountryCode());
    holder.getDate().setText(release.getDate());
    if (layoutId == R.layout.list_release) {
        holder.getTrackNum().setText(release.getTracksNum() + " " + context.getString(R.string.label_tracks));
        holder.getFormat().setText(StringMapper.buildReleaseFormatsString(getContext(), release.getFormats()));
        holder.getLabels().setText(StringFormat.commaSeparate(release.getLabels()));
    }
    return releaseView;
}
Also used : LayoutInflater(android.view.LayoutInflater) ReleaseInfo(org.musicbrainz.android.api.data.ReleaseInfo) TextView(android.widget.TextView) View(android.view.View)

Example 4 with ReleaseInfo

use of org.musicbrainz.android.api.data.ReleaseInfo in project musicbrainz-android by jdamcd.

the class MusicBrainzWebClient method searchRelease.

@Override
public LinkedList<ReleaseInfo> searchRelease(String searchTerm) throws IOException {
    HttpEntity entity = get(QueryBuilder.releaseSearch(searchTerm));
    LinkedList<ReleaseInfo> releases = responseParser.parseReleaseSearch(entity.getContent());
    entity.consumeContent();
    return releases;
}
Also used : HttpEntity(org.apache.http.HttpEntity) ReleaseInfo(org.musicbrainz.android.api.data.ReleaseInfo)

Example 5 with ReleaseInfo

use of org.musicbrainz.android.api.data.ReleaseInfo in project musicbrainz-android by jdamcd.

the class CollectionLookupTest method testLastRelease.

@Test
public void testLastRelease() throws IOException {
    ReleaseInfo last = collection.getReleases().getLast();
    assertEquals("9f00a4d3-82b2-4084-a48b-565703b812ce", last.getReleaseMbid());
    assertEquals("New Leaves", last.getTitle());
    assertEquals("Owen", last.getArtists().get(0).getName());
    assertEquals("2009-09-22", last.getDate());
    assertEquals("US", last.getCountryCode());
}
Also used : ReleaseInfo(org.musicbrainz.android.api.data.ReleaseInfo) Test(org.junit.Test)

Aggregations

ReleaseInfo (org.musicbrainz.android.api.data.ReleaseInfo)11 Test (org.junit.Test)6 ReleaseArtist (org.musicbrainz.android.api.data.ReleaseArtist)5 HttpEntity (org.apache.http.HttpEntity)2 LayoutInflater (android.view.LayoutInflater)1 View (android.view.View)1 TextView (android.widget.TextView)1