Migrate to Xstream to prevent too many changes. Still have memory issue, but some flexibility to still find away around it.
This commit is contained in:
@@ -29,9 +29,7 @@ dependencies {
|
|||||||
compile 'com.squareup.picasso:picasso:2.5.2' //Apache 2.0
|
compile 'com.squareup.picasso:picasso:2.5.2' //Apache 2.0
|
||||||
compile 'com.github.thorbenprimke:realm-recyclerview:0.9.5' //Apache 2.0
|
compile 'com.github.thorbenprimke:realm-recyclerview:0.9.5' //Apache 2.0
|
||||||
compile 'com.squareup.retrofit:retrofit:2.0.0-beta2' //Apache 2.0
|
compile 'com.squareup.retrofit:retrofit:2.0.0-beta2' //Apache 2.0
|
||||||
compile ('com.squareup.retrofit:converter-simplexml:2.0.0-beta2') {
|
compile ('com.thoughtworks.xstream:xstream:1.4.7') { //BSD
|
||||||
exclude group: 'xpp3', module: 'xpp3'
|
exclude group: 'xmlpull'
|
||||||
exclude group: 'stax', module: 'stax-api'
|
|
||||||
exclude group: 'stax', module: 'stax'
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +1,12 @@
|
|||||||
package com.magnatune.eyecreate.companionformagnatune.api;
|
package com.magnatune.eyecreate.companionformagnatune.api;
|
||||||
|
|
||||||
import com.magnatune.eyecreate.companionformagnatune.model.AlbumResponse;
|
import com.magnatune.eyecreate.companionformagnatune.model.AlbumResponse;
|
||||||
|
import com.magnatune.eyecreate.companionformagnatune.model.xml.Album;
|
||||||
|
import com.magnatune.eyecreate.companionformagnatune.model.xml.Track;
|
||||||
import com.squareup.okhttp.ResponseBody;
|
import com.squareup.okhttp.ResponseBody;
|
||||||
|
import com.thoughtworks.xstream.XStream;
|
||||||
import org.simpleframework.xml.Serializer;
|
import com.thoughtworks.xstream.converters.basic.DateConverter;
|
||||||
import org.simpleframework.xml.core.Persister;
|
import com.thoughtworks.xstream.io.xml.Xpp3Driver;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.zip.GZIPInputStream;
|
import java.util.zip.GZIPInputStream;
|
||||||
@@ -15,10 +17,15 @@ public class MagnatuneAlbumsConverter implements Converter<ResponseBody,AlbumRes
|
|||||||
@Override
|
@Override
|
||||||
public AlbumResponse convert(ResponseBody value) throws IOException {
|
public AlbumResponse convert(ResponseBody value) throws IOException {
|
||||||
GZIPInputStream compressedStream = new GZIPInputStream(value.byteStream());
|
GZIPInputStream compressedStream = new GZIPInputStream(value.byteStream());
|
||||||
Serializer serializer = new Persister();
|
XStream parser = new XStream(new Xpp3Driver());
|
||||||
|
parser.processAnnotations(Album.class);
|
||||||
|
parser.processAnnotations(Track.class);
|
||||||
|
parser.processAnnotations(AlbumResponse.class);
|
||||||
|
parser.registerConverter(new DateConverter("yyyy-MM-dd",new String[]{}));
|
||||||
|
parser.ignoreUnknownElements();
|
||||||
AlbumResponse conversion = null;
|
AlbumResponse conversion = null;
|
||||||
try {
|
try {
|
||||||
conversion = serializer.read(AlbumResponse.class,compressedStream);
|
conversion = (AlbumResponse) parser.fromXML(compressedStream);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,16 +1,14 @@
|
|||||||
package com.magnatune.eyecreate.companionformagnatune.model;
|
package com.magnatune.eyecreate.companionformagnatune.model;
|
||||||
|
|
||||||
import com.magnatune.eyecreate.companionformagnatune.model.xml.*;
|
import com.thoughtworks.xstream.annotations.XStreamAlias;
|
||||||
|
import com.thoughtworks.xstream.annotations.XStreamImplicit;
|
||||||
import org.simpleframework.xml.ElementList;
|
|
||||||
import org.simpleframework.xml.Root;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@Root(name="AllAlbums")
|
@XStreamAlias("AllAlbums")
|
||||||
public class AlbumResponse {
|
public class AlbumResponse {
|
||||||
|
|
||||||
@ElementList(inline=true,type= com.magnatune.eyecreate.companionformagnatune.model.xml.Album.class)
|
@XStreamImplicit(itemFieldName = "Album")
|
||||||
public List<com.magnatune.eyecreate.companionformagnatune.model.xml.Album> albums;
|
public List<com.magnatune.eyecreate.companionformagnatune.model.xml.Album> albums;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,51 +1,50 @@
|
|||||||
package com.magnatune.eyecreate.companionformagnatune.model.xml;
|
package com.magnatune.eyecreate.companionformagnatune.model.xml;
|
||||||
|
|
||||||
import org.simpleframework.xml.Element;
|
import com.thoughtworks.xstream.annotations.XStreamAlias;
|
||||||
import org.simpleframework.xml.ElementList;
|
import com.thoughtworks.xstream.annotations.XStreamImplicit;
|
||||||
import org.simpleframework.xml.Root;
|
import com.thoughtworks.xstream.annotations.XStreamOmitField;
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@Root(name="Album",strict = false)
|
@XStreamAlias("Album")
|
||||||
public class Album {
|
public class Album {
|
||||||
|
|
||||||
@Element
|
|
||||||
public String artist;
|
public String artist;
|
||||||
|
|
||||||
@Element
|
|
||||||
public String artistdesc;
|
public String artistdesc;
|
||||||
|
|
||||||
@Element
|
|
||||||
public String cover_small;
|
public String cover_small;
|
||||||
|
|
||||||
@Element
|
|
||||||
public String artistphoto;
|
public String artistphoto;
|
||||||
|
|
||||||
@Element
|
|
||||||
public String albumname;
|
public String albumname;
|
||||||
|
|
||||||
@Element
|
|
||||||
public int year;
|
public int year;
|
||||||
|
|
||||||
@Element(required = false)
|
|
||||||
public String album_notes;
|
public String album_notes;
|
||||||
|
|
||||||
@Element
|
|
||||||
public String mp3genre;
|
public String mp3genre;
|
||||||
|
|
||||||
@Element
|
|
||||||
public String home;
|
public String home;
|
||||||
|
|
||||||
@Element
|
|
||||||
public String magnatunegenres;
|
public String magnatunegenres;
|
||||||
|
|
||||||
@Element
|
|
||||||
public Date launchdate;
|
public Date launchdate;
|
||||||
|
|
||||||
@Element
|
|
||||||
public String albumsku;
|
public String albumsku;
|
||||||
|
|
||||||
@ElementList(inline=true,type=Track.class)
|
@XStreamImplicit(itemFieldName = "Track")
|
||||||
public List<Track> tracks;
|
public List<Track> tracks;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,49 +1,48 @@
|
|||||||
package com.magnatune.eyecreate.companionformagnatune.model.xml;
|
package com.magnatune.eyecreate.companionformagnatune.model.xml;
|
||||||
|
|
||||||
import org.simpleframework.xml.Element;
|
import com.thoughtworks.xstream.annotations.XStreamAlias;
|
||||||
import org.simpleframework.xml.Root;
|
|
||||||
|
|
||||||
@Root(name="Track",strict = false)
|
@XStreamAlias("Track")
|
||||||
public class Track {
|
public class Track {
|
||||||
@Element
|
|
||||||
public String artist;
|
public String artist;
|
||||||
|
|
||||||
@Element
|
|
||||||
public String artistbio;
|
public String artistbio;
|
||||||
|
|
||||||
@Element
|
|
||||||
public String albumname;
|
public String albumname;
|
||||||
|
|
||||||
@Element
|
|
||||||
public String trackname;
|
public String trackname;
|
||||||
|
|
||||||
@Element
|
|
||||||
public int tracknum;
|
public int tracknum;
|
||||||
|
|
||||||
@Element
|
|
||||||
public int year;
|
public int year;
|
||||||
|
|
||||||
@Element
|
|
||||||
public String mp3genre;
|
public String mp3genre;
|
||||||
|
|
||||||
@Element
|
|
||||||
public String magnatunegenres;
|
public String magnatunegenres;
|
||||||
|
|
||||||
@Element
|
|
||||||
public String license;
|
public String license;
|
||||||
|
|
||||||
@Element
|
|
||||||
public long seconds;
|
public long seconds;
|
||||||
|
|
||||||
@Element
|
|
||||||
public String url;
|
public String url;
|
||||||
|
|
||||||
@Element
|
|
||||||
public String mp3lofi;
|
public String mp3lofi;
|
||||||
|
|
||||||
@Element
|
|
||||||
public String oggurl;
|
public String oggurl;
|
||||||
|
|
||||||
@Element
|
|
||||||
public String isrc;
|
public String isrc;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user