Last active
August 29, 2015 14:16
-
-
Save billmote/343b68b56020ee51c345 to your computer and use it in GitHub Desktop.
An alternative to the custom TypeAdapter to handle Rotten Tomatoes returning different JSON primitives for Movie runtime
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@DebugLog | |
public class Movie { | |
@Expose | |
public Object runtime; | |
// ... | |
public Integer getMovieRuntime() { | |
if (runtime instanceof String && !TextUtils.isEmpty((String) runtime)) { | |
return Integer.valueOf((String) runtime); | |
} else if (runtime instanceof Integer) { | |
return (Integer) runtime; | |
} else return 0; | |
} | |
public void setMovieRuntime(Object runtime) { | |
this.runtime = runtime; | |
} | |
// ... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment