├── .gitignore ├── .idea ├── .name ├── compiler.xml ├── copyright │ └── profiles_settings.xml ├── encodings.xml ├── gradle.xml ├── libraries │ └── commons_lang3_3_0.xml ├── misc.xml ├── modules.xml ├── scopes │ └── scope_settings.xml └── vcs.xml ├── AndroidMarvelAPI.iml ├── Marvel.iml ├── README.md ├── build.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── marvel-api ├── .gitignore ├── build.gradle ├── marvel-api.iml ├── proguard-rules.txt └── src │ └── main │ ├── AndroidManifest.xml │ ├── java │ └── com │ │ └── trey │ │ └── marvel │ │ └── model │ │ ├── api │ │ ├── MarvelApi.java │ │ ├── manager │ │ │ ├── BaseManager.java │ │ │ ├── CharacterManager.java │ │ │ ├── ComicManager.java │ │ │ ├── CreatorManager.java │ │ │ ├── EventManager.java │ │ │ ├── SeriesManager.java │ │ │ └── StoryManager.java │ │ ├── request │ │ │ ├── BaseRequest.java │ │ │ ├── CharacterRequest.java │ │ │ ├── ComicRequest.java │ │ │ ├── CreatorRequest.java │ │ │ ├── EventRequest.java │ │ │ ├── RequestSignature.java │ │ │ ├── SeriesRequest.java │ │ │ └── StoryRequest.java │ │ ├── response │ │ │ ├── DataContainer.java │ │ │ ├── DateAdapter.java │ │ │ └── ServiceResponse.java │ │ ├── service │ │ │ ├── Characters.java │ │ │ ├── Comics.java │ │ │ ├── Creators.java │ │ │ ├── Events.java │ │ │ ├── Series.java │ │ │ └── Stories.java │ │ ├── utils │ │ │ └── HashUtil.java │ │ └── vo │ │ │ ├── Character.java │ │ │ ├── CharacterList.java │ │ │ ├── CharacterSummary.java │ │ │ ├── Comic.java │ │ │ ├── ComicPrice.java │ │ │ ├── Creator.java │ │ │ ├── CreatorList.java │ │ │ ├── CreatorSummary.java │ │ │ ├── Event.java │ │ │ ├── ImageInfo.java │ │ │ ├── IndustryDate.java │ │ │ ├── Item.java │ │ │ ├── ItemList.java │ │ │ ├── Price.java │ │ │ ├── Series.java │ │ │ ├── SeriesList.java │ │ │ ├── Service.java │ │ │ ├── Story.java │ │ │ ├── TextObject.java │ │ │ └── Url.java │ │ └── test │ │ └── ExampleTest.java │ └── res │ ├── drawable-hdpi │ └── ic_launcher.png │ ├── drawable-mdpi │ └── ic_launcher.png │ ├── drawable-xhdpi │ └── ic_launcher.png │ ├── drawable-xxhdpi │ └── ic_launcher.png │ └── values │ └── strings.xml ├── marvel-demo ├── .gitignore ├── build.gradle ├── marvel-api-demo.iml ├── marvel-demo.iml ├── proguard-rules.txt └── src │ └── main │ ├── AndroidManifest.xml │ ├── ic_launcher-web.png │ ├── java │ └── com │ │ └── trey │ │ └── marvel │ │ ├── CharacterListAdapter.java │ │ ├── MainActivity.java │ │ ├── MainApplication.java │ │ ├── NavigationDrawerFragment.java │ │ ├── dummy │ │ └── DummyContent.java │ │ └── fragment │ │ └── CharacterListFragment.java │ └── res │ ├── drawable-hdpi │ ├── drawer_shadow.9.png │ ├── ic_drawer.png │ └── ic_launcher.png │ ├── drawable-mdpi │ ├── drawer_shadow.9.png │ ├── ic_drawer.png │ └── ic_launcher.png │ ├── drawable-xhdpi │ ├── drawer_shadow.9.png │ ├── ic_drawer.png │ └── ic_launcher.png │ ├── drawable-xxhdpi │ ├── drawer_shadow.9.png │ ├── ic_drawer.png │ └── ic_launcher.png │ ├── layout │ ├── activity_main.xml │ ├── fragment_characterlistfragment_grid.xml │ ├── fragment_characterlistfragment_list.xml │ ├── fragment_main.xml │ ├── fragment_navigation_drawer.xml │ └── generic_list_item.xml │ ├── menu │ ├── global.xml │ └── main.xml │ ├── values-large │ └── refs.xml │ ├── values-sw600dp │ └── refs.xml │ ├── values-w820dp │ └── dimens.xml │ └── values │ ├── dimens.xml │ ├── refs.xml │ ├── strings.xml │ └── styles.xml └── settings.gradle /.gitignore: -------------------------------------------------------------------------------- 1 | # built application files 2 | *.apk 3 | *.ap_ 4 | 5 | # files for the dex VM 6 | *.dex 7 | 8 | # Java class files 9 | *.class 10 | 11 | # generated files 12 | bin/ 13 | gen/ 14 | build/ 15 | 16 | # Local configuration file (sdk path, etc) 17 | local.properties 18 | 19 | # Eclipse project files 20 | .classpath 21 | .project 22 | 23 | # Proguard folder generated by Eclipse 24 | proguard/ 25 | 26 | # Intellij project files 27 | *.iws 28 | .idea/workspace.xml 29 | .idea/tasks.xml 30 | .idea/libraries 31 | # Gradle directory 32 | .gradle 33 | 34 | # OS 35 | .DS_Store 36 | -------------------------------------------------------------------------------- /.idea/.name: -------------------------------------------------------------------------------- 1 | Marvel -------------------------------------------------------------------------------- /.idea/compiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /.idea/copyright/profiles_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /.idea/encodings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /.idea/libraries/commons_lang3_3_0.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/scopes/scope_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /AndroidMarvelAPI.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /Marvel.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | An Android library that provided easy access to the Marvel comics api. For more information on the developer API please see [the marvel developer portal][1] 2 | 3 | MarvelAPI uses the Retrofit (with OKHttp) by Square for easy service handling. More information about that library can be found [at the github repo][2] 4 | 5 | There is a demo application in this project that is currently under development. Currently all service endpoints are included in the api. Feel free to begin using it and reporting any bugs/suggestions. 6 | 7 | Usage 8 | -------- 9 | Create a new instance of the MarvelAPI 10 | 11 | MarvelApi.create("YOUR PRIVATE KEY", "YOUR PUBLIC KEY", getApplicationContext(), 5*1024*1024); 12 | 13 | Initiate a request to one of the manager classes. 14 | 15 | StoryRequest request = new StoryRequest(RequestSignature.create()); 16 | request.setLimit(20); 17 | request.setOffset(0); 18 | 19 | ComicManager client = new ComicManager(); 20 | client.getStoriesForComicId(41530, request, new Callback>() { 21 | @Override 22 | public void success(ServiceResponse characterServiceResponse, Response response) { 23 | //your success handling 24 | } 25 | 26 | @Override 27 | public void failure(RetrofitError retrofitError) { 28 | //error handling 29 | } 30 | }); 31 | 32 | 33 | License 34 | ------- 35 | 36 | Licensed under the Apache License, Version 2.0 (the "License"); 37 | you may not use this file except in compliance with the License. 38 | You may obtain a copy of the License at 39 | 40 | http://www.apache.org/licenses/LICENSE-2.0 41 | 42 | Unless required by applicable law or agreed to in writing, software 43 | distributed under the License is distributed on an "AS IS" BASIS, 44 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 45 | See the License for the specific language governing permissions and 46 | limitations under the License. 47 | 48 | 49 | 50 | [1]: http://developer.marvel.com/ 51 | [2]: https://github.com/square/retrofit 52 | -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 2 | 3 | buildscript { 4 | repositories { 5 | mavenCentral() 6 | } 7 | dependencies { 8 | classpath 'com.android.tools.build:gradle:0.13.2' 9 | } 10 | } 11 | 12 | allprojects { 13 | repositories { 14 | mavenCentral() 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | 3 | # IDE (e.g. Android Studio) users: 4 | # Settings specified in this file will override any Gradle settings 5 | # configured through the IDE. 6 | 7 | # For more details on how to configure your build environment visit 8 | # http://www.gradle.org/docs/current/userguide/build_environment.html 9 | 10 | # Specifies the JVM arguments used for the daemon process. 11 | # The setting is particularly useful for tweaking memory settings. 12 | # Default value: -Xmx10248m -XX:MaxPermSize=256m 13 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 14 | 15 | # When configured, Gradle will run in incubating parallel mode. 16 | # This option should only be used with decoupled projects. More details, visit 17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 18 | # org.gradle.parallel=true -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rdrobinson3/AndroidMarvelAPI/17f068736ee8f04c0673e7f52c32aa3441b2dc8b/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Sat Nov 08 19:05:54 EST 2014 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.1-all.zip 7 | -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 10 | DEFAULT_JVM_OPTS="" 11 | 12 | APP_NAME="Gradle" 13 | APP_BASE_NAME=`basename "$0"` 14 | 15 | # Use the maximum available, or set MAX_FD != -1 to use that value. 16 | MAX_FD="maximum" 17 | 18 | warn ( ) { 19 | echo "$*" 20 | } 21 | 22 | die ( ) { 23 | echo 24 | echo "$*" 25 | echo 26 | exit 1 27 | } 28 | 29 | # OS specific support (must be 'true' or 'false'). 30 | cygwin=false 31 | msys=false 32 | darwin=false 33 | case "`uname`" in 34 | CYGWIN* ) 35 | cygwin=true 36 | ;; 37 | Darwin* ) 38 | darwin=true 39 | ;; 40 | MINGW* ) 41 | msys=true 42 | ;; 43 | esac 44 | 45 | # For Cygwin, ensure paths are in UNIX format before anything is touched. 46 | if $cygwin ; then 47 | [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"` 48 | fi 49 | 50 | # Attempt to set APP_HOME 51 | # Resolve links: $0 may be a link 52 | PRG="$0" 53 | # Need this for relative symlinks. 54 | while [ -h "$PRG" ] ; do 55 | ls=`ls -ld "$PRG"` 56 | link=`expr "$ls" : '.*-> \(.*\)$'` 57 | if expr "$link" : '/.*' > /dev/null; then 58 | PRG="$link" 59 | else 60 | PRG=`dirname "$PRG"`"/$link" 61 | fi 62 | done 63 | SAVED="`pwd`" 64 | cd "`dirname \"$PRG\"`/" >&- 65 | APP_HOME="`pwd -P`" 66 | cd "$SAVED" >&- 67 | 68 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 69 | 70 | # Determine the Java command to use to start the JVM. 71 | if [ -n "$JAVA_HOME" ] ; then 72 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 73 | # IBM's JDK on AIX uses strange locations for the executables 74 | JAVACMD="$JAVA_HOME/jre/sh/java" 75 | else 76 | JAVACMD="$JAVA_HOME/bin/java" 77 | fi 78 | if [ ! -x "$JAVACMD" ] ; then 79 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 80 | 81 | Please set the JAVA_HOME variable in your environment to match the 82 | location of your Java installation." 83 | fi 84 | else 85 | JAVACMD="java" 86 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 87 | 88 | Please set the JAVA_HOME variable in your environment to match the 89 | location of your Java installation." 90 | fi 91 | 92 | # Increase the maximum file descriptors if we can. 93 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then 94 | MAX_FD_LIMIT=`ulimit -H -n` 95 | if [ $? -eq 0 ] ; then 96 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 97 | MAX_FD="$MAX_FD_LIMIT" 98 | fi 99 | ulimit -n $MAX_FD 100 | if [ $? -ne 0 ] ; then 101 | warn "Could not set maximum file descriptor limit: $MAX_FD" 102 | fi 103 | else 104 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 105 | fi 106 | fi 107 | 108 | # For Darwin, add options to specify how the application appears in the dock 109 | if $darwin; then 110 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 111 | fi 112 | 113 | # For Cygwin, switch paths to Windows format before running java 114 | if $cygwin ; then 115 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 116 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 117 | 118 | # We build the pattern for arguments to be converted via cygpath 119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 120 | SEP="" 121 | for dir in $ROOTDIRSRAW ; do 122 | ROOTDIRS="$ROOTDIRS$SEP$dir" 123 | SEP="|" 124 | done 125 | OURCYGPATTERN="(^($ROOTDIRS))" 126 | # Add a user-defined pattern to the cygpath arguments 127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 129 | fi 130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 131 | i=0 132 | for arg in "$@" ; do 133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 135 | 136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 138 | else 139 | eval `echo args$i`="\"$arg\"" 140 | fi 141 | i=$((i+1)) 142 | done 143 | case $i in 144 | (0) set -- ;; 145 | (1) set -- "$args0" ;; 146 | (2) set -- "$args0" "$args1" ;; 147 | (3) set -- "$args0" "$args1" "$args2" ;; 148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 154 | esac 155 | fi 156 | 157 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules 158 | function splitJvmOpts() { 159 | JVM_OPTS=("$@") 160 | } 161 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS 162 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" 163 | 164 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" 165 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 12 | set DEFAULT_JVM_OPTS= 13 | 14 | set DIRNAME=%~dp0 15 | if "%DIRNAME%" == "" set DIRNAME=. 16 | set APP_BASE_NAME=%~n0 17 | set APP_HOME=%DIRNAME% 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windowz variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | if "%@eval[2+2]" == "4" goto 4NT_args 53 | 54 | :win9xME_args 55 | @rem Slurp the command line arguments. 56 | set CMD_LINE_ARGS= 57 | set _SKIP=2 58 | 59 | :win9xME_args_slurp 60 | if "x%~1" == "x" goto execute 61 | 62 | set CMD_LINE_ARGS=%* 63 | goto execute 64 | 65 | :4NT_args 66 | @rem Get arguments from the 4NT Shell from JP Software 67 | set CMD_LINE_ARGS=%$ 68 | 69 | :execute 70 | @rem Setup the command line 71 | 72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if "%ERRORLEVEL%"=="0" goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 85 | exit /b 1 86 | 87 | :mainEnd 88 | if "%OS%"=="Windows_NT" endlocal 89 | 90 | :omega 91 | -------------------------------------------------------------------------------- /marvel-api/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /marvel-api/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.library' 2 | 3 | android { 4 | compileSdkVersion 21 5 | buildToolsVersion "21.1.1" 6 | 7 | defaultConfig { 8 | minSdkVersion 15 9 | targetSdkVersion 21 10 | versionCode 1 11 | versionName "1.0" 12 | } 13 | buildTypes { 14 | release { 15 | runProguard false 16 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt' 17 | } 18 | } 19 | } 20 | 21 | dependencies { 22 | compile fileTree(dir: 'libs', include: ['*.jar', '*.aar']) 23 | compile 'com.squareup.retrofit:retrofit:1.7.1' 24 | compile 'com.squareup.okhttp:okhttp:2.1.0-RC1' 25 | compile 'com.squareup.okhttp:okhttp-urlconnection:2.1.0-RC1' 26 | compile 'org.apache.commons:commons-lang3:3.0' 27 | } 28 | -------------------------------------------------------------------------------- /marvel-api/marvel-api.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 8 | 9 | 10 | 11 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | -------------------------------------------------------------------------------- /marvel-api/proguard-rules.txt: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /opt/android-sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the ProGuard 5 | # include property in project.properties. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} -------------------------------------------------------------------------------- /marvel-api/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /marvel-api/src/main/java/com/trey/marvel/model/api/MarvelApi.java: -------------------------------------------------------------------------------- 1 | package com.trey.marvel.model.api; 2 | 3 | import android.content.Context; 4 | 5 | import com.google.gson.FieldNamingPolicy; 6 | import com.google.gson.Gson; 7 | import com.google.gson.GsonBuilder; 8 | import com.google.gson.internal.bind.DateTypeAdapter; 9 | import com.squareup.okhttp.Cache; 10 | import com.squareup.okhttp.OkHttpClient; 11 | import com.trey.marvel.model.api.request.RequestSignature; 12 | import com.trey.marvel.model.api.response.DateAdapter; 13 | 14 | import java.io.IOException; 15 | import java.util.Date; 16 | 17 | import retrofit.RestAdapter; 18 | import retrofit.client.OkClient; 19 | import retrofit.converter.GsonConverter; 20 | 21 | /** 22 | * Main API class. Initialize by calling create. Afterwards the API can be retrieved by calling getInstance(). 23 | * The application context is used to create a response cache. Cache size is configurable. 24 | * 25 | * Created by Trey Robinson on 2/12/14. 26 | */ 27 | public class MarvelApi { 28 | 29 | public static final String PORT = "80"; 30 | public static final String API_URL = "http://gateway.marvel.com" + ":" + PORT; 31 | 32 | private static MarvelApi API; 33 | 34 | private RestAdapter mRestAdapter; 35 | 36 | /** 37 | * Returns an instance of the MarvelApi. Must initialize static instance with 38 | * a call to {@link #create(String, String, android.content.Context, long)} 39 | * @return 40 | */ 41 | public static MarvelApi getInstance(){ 42 | return API; 43 | } 44 | 45 | /** 46 | * Retrieve all characters matching the provided request parameters. 47 | * @param privateKey The private key provided by Marvel 48 | * @param publicKey THe public key provided by Marvel 49 | * @param applicationContext Application Context for creating cache location 50 | * @param cacheSize Size of the Cache 51 | */ 52 | public static void create(String privateKey, String publicKey, Context applicationContext, long cacheSize){ 53 | API = new MarvelApi(privateKey, publicKey, applicationContext, cacheSize); 54 | } 55 | 56 | /** 57 | * Retrieve all characters matching the provided request parameters. 58 | * @param privateKey The private key provided by Marvel 59 | * @param publicKey THe public key provided by Marvel 60 | * @param applicationContext Application Context for creating cache location 61 | * @param cacheSize Size of the Cache 62 | */ 63 | private MarvelApi(String privateKey, String publicKey, Context applicationContext, long cacheSize){ 64 | 65 | //Set the static keys so they can be used to generate the request signatures. 66 | RequestSignature.apiKey = publicKey; 67 | RequestSignature.privateKey = privateKey; 68 | 69 | OkHttpClient okHttpClient = new OkHttpClient(); 70 | Cache cache = null; 71 | 72 | try { 73 | cache = new Cache(applicationContext.getCacheDir(), cacheSize); 74 | } catch (IOException e) { 75 | e.printStackTrace(); 76 | } 77 | 78 | okHttpClient.setCache(cache); 79 | 80 | Gson gson = new GsonBuilder() 81 | .registerTypeAdapter(Date.class, new DateAdapter()) 82 | .create(); 83 | 84 | mRestAdapter = new RestAdapter.Builder() 85 | .setClient(new OkClient(okHttpClient)) 86 | .setConverter(new GsonConverter(gson)) 87 | .setEndpoint(API_URL) 88 | .build(); 89 | } 90 | 91 | public RestAdapter getRestAdapter(){ 92 | return mRestAdapter; 93 | } 94 | } 95 | -------------------------------------------------------------------------------- /marvel-api/src/main/java/com/trey/marvel/model/api/manager/BaseManager.java: -------------------------------------------------------------------------------- 1 | package com.trey.marvel.model.api.manager; 2 | 3 | import org.apache.commons.lang3.StringUtils; 4 | 5 | import java.util.List; 6 | 7 | /** 8 | * Created by Trey Robinson on 2/16/14. 9 | * 10 | * Common functionality used by all service managers. 11 | */ 12 | public class BaseManager { 13 | 14 | /* 15 | * Creates comma delimited string from list object 16 | * */ 17 | public String parameterizeList(List list){ 18 | return StringUtils.join(list, ","); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /marvel-api/src/main/java/com/trey/marvel/model/api/manager/CharacterManager.java: -------------------------------------------------------------------------------- 1 | package com.trey.marvel.model.api.manager; 2 | 3 | import com.trey.marvel.model.api.MarvelApi; 4 | import com.trey.marvel.model.api.request.CharacterRequest; 5 | import com.trey.marvel.model.api.request.ComicRequest; 6 | import com.trey.marvel.model.api.request.EventRequest; 7 | import com.trey.marvel.model.api.request.RequestSignature; 8 | import com.trey.marvel.model.api.request.SeriesRequest; 9 | import com.trey.marvel.model.api.request.StoryRequest; 10 | import com.trey.marvel.model.api.response.ServiceResponse; 11 | import com.trey.marvel.model.api.service.Characters; 12 | import com.trey.marvel.model.api.vo.Character; 13 | import com.trey.marvel.model.api.vo.Comic; 14 | import com.trey.marvel.model.api.vo.Event; 15 | import com.trey.marvel.model.api.vo.Series; 16 | import com.trey.marvel.model.api.vo.Story; 17 | 18 | import retrofit.Callback; 19 | 20 | /** 21 | * Manager that handles retrieval of character information and requests related to a specific character id. 22 | * 23 | * Created by Trey Robinson on 2/12/14. 24 | */ 25 | public class CharacterManager extends BaseManager { 26 | 27 | private Characters characters; 28 | 29 | public CharacterManager() { 30 | characters = MarvelApi.getInstance().getRestAdapter().create(Characters.class); 31 | } 32 | 33 | /** 34 | * Retrieve all characters matching the provided request parameters. 35 | * @param request Parameters for the request 36 | * @param callback Handler called on request completion 37 | */ 38 | public void listCharacters(CharacterRequest request, Callback> callback) { 39 | characters.listCharacters(request.getLimit() 40 | , request.getOffset() 41 | , String.valueOf(request.getTimestamp()) 42 | , request.getApiKey() 43 | , request.getHashSignature() 44 | , request.getName() 45 | , request.getModifiedSince() 46 | , parameterizeList(request.getStories()) 47 | , parameterizeList(request.getSeries()) 48 | , parameterizeList(request.getEvents()) 49 | , request.getOrderBy().getValue() 50 | , callback); 51 | } 52 | 53 | /** 54 | * Retrieve a character with a specific ID. 55 | * @param characterId Unique ID for the character that will be returned by the service 56 | * @param callback Handler called on request completion 57 | */ 58 | public void getCharacterWithId(int characterId, Callback> callback) { 59 | RequestSignature request = RequestSignature.create(); 60 | characters.getCharacterWithId(characterId 61 | , String.valueOf(request.timeStamp) 62 | , request.publicKey 63 | , request.hashSignature 64 | , callback); 65 | } 66 | 67 | /** 68 | * Retrieve all comics for a specific character that match the provided request parameters. 69 | * @param characterId Unique ID for the character 70 | * @param request Parameters for the request 71 | * @param callback Handler called on request completion 72 | */ 73 | public void getComicsForCharacterId(int characterId, ComicRequest request, Callback> callback) { 74 | characters.getComicsForCharacterId(characterId 75 | , request.getLimit() 76 | , request.getOffset() 77 | , String.valueOf(request.getTimestamp()) 78 | , request.getApiKey() 79 | , request.getHashSignature() 80 | , request.getFormat().getValue() 81 | , request.getFormatType().getValue() 82 | , request.isNoVariants() 83 | , request.getDateDescriptor().getValue() 84 | , request.getDateRange() 85 | , request.isHasDigitalIssue() 86 | , request.getModifiedSince() 87 | , parameterizeList(request.getCreators()) 88 | , parameterizeList(request.getSeries()) 89 | , parameterizeList(request.getEvents()) 90 | , parameterizeList(request.getStories()) 91 | , parameterizeList(request.getSharedAppearances()) 92 | , parameterizeList(request.getCollaborators()) 93 | , request.getOrderBy().getValue(), callback); 94 | } 95 | 96 | 97 | /** 98 | * Retrieve all events for a specific character that match the provided request parameters. 99 | * @param characterId Unique ID for the character 100 | * @param request Parameters for the request 101 | * @param callback Handler called on request completion 102 | */ 103 | public void getEventsForCharacterId(int characterId, EventRequest request, Callback> callback) { 104 | characters.getEventsForCharacterId(characterId 105 | , request.getLimit() 106 | , request.getOffset() 107 | , String.valueOf(request.getTimestamp()) 108 | , request.getApiKey() 109 | , request.getHashSignature() 110 | , request.getName() 111 | , request.getModifiedSince() 112 | , parameterizeList(request.getCreators()) 113 | , parameterizeList(request.getSeries()) 114 | , parameterizeList(request.getComics()) 115 | , parameterizeList(request.getStories()) 116 | , request.getOrderBy().getValue() 117 | , callback); 118 | } 119 | 120 | /** 121 | * Retrieve all series for a specific character that match the provided request parameters. 122 | * @param characterId Unique ID for the character 123 | * @param request Parameters for the request 124 | * @param callback Handler called on request completion 125 | */ 126 | public void getSeriesForCharacterId(int characterId, SeriesRequest request, Callback> callback) { 127 | characters.getSeriesForCharacterId(characterId 128 | , request.getLimit() 129 | , request.getOffset() 130 | , String.valueOf(request.getTimestamp()) 131 | , request.getApiKey() 132 | , request.getHashSignature() 133 | , request.getTitle() 134 | , request.getModifiedSince() 135 | , parameterizeList(request.getComics()) 136 | , parameterizeList(request.getStories()) 137 | , parameterizeList(request.getEvents()) 138 | , parameterizeList(request.getCreators()) 139 | , request.getSeriesType().getValue() 140 | , request.getContains().getValue() 141 | , request.getOrderBy().getValue() 142 | , callback); 143 | } 144 | 145 | /** 146 | * Retrieve all Stories for a specific character that match the provided request parameters. 147 | * @param characterId Unique ID for the character 148 | * @param request Parameters for the request 149 | * @param callback Handler called on request completion 150 | */ 151 | public void getStoriesForCharacterId(int characterId, StoryRequest request, Callback> callback){ 152 | characters.getStoriesForCharacterId(characterId 153 | , request.getLimit() 154 | , request.getOffset() 155 | , String.valueOf(request.getTimestamp()) 156 | ,request.getApiKey() 157 | , request.getHashSignature() 158 | , request.getModifiedSince() 159 | , parameterizeList(request.getComics()) 160 | , parameterizeList(request.getSeries()) 161 | , parameterizeList(request.getEvents()) 162 | , parameterizeList(request.getCreators()) 163 | , request.getOrderBy().getValue() 164 | , callback); 165 | } 166 | } 167 | -------------------------------------------------------------------------------- /marvel-api/src/main/java/com/trey/marvel/model/api/manager/ComicManager.java: -------------------------------------------------------------------------------- 1 | package com.trey.marvel.model.api.manager; 2 | 3 | import com.trey.marvel.model.api.MarvelApi; 4 | import com.trey.marvel.model.api.request.CharacterRequest; 5 | import com.trey.marvel.model.api.request.ComicRequest; 6 | import com.trey.marvel.model.api.request.CreatorRequest; 7 | import com.trey.marvel.model.api.request.EventRequest; 8 | import com.trey.marvel.model.api.request.RequestSignature; 9 | import com.trey.marvel.model.api.request.StoryRequest; 10 | import com.trey.marvel.model.api.response.ServiceResponse; 11 | import com.trey.marvel.model.api.service.Comics; 12 | import com.trey.marvel.model.api.vo.Character; 13 | import com.trey.marvel.model.api.vo.Comic; 14 | import com.trey.marvel.model.api.vo.Creator; 15 | import com.trey.marvel.model.api.vo.Event; 16 | import com.trey.marvel.model.api.vo.Story; 17 | 18 | import retrofit.Callback; 19 | 20 | /** 21 | * Manager that handles retrieval for comic information and requests related to a specific comic id. 22 | * 23 | * Created by Trey Robinson on 2/17/14. 24 | */ 25 | public class ComicManager extends BaseManager{ 26 | 27 | private Comics comics; 28 | 29 | public ComicManager() { 30 | comics = MarvelApi.getInstance().getRestAdapter().create(Comics.class); 31 | } 32 | 33 | /** 34 | * Retrieve all comics matching the provided request parameters. 35 | * @param request Parameters for the request 36 | * @param callback Handler called on request completion 37 | */ 38 | public void listComics(ComicRequest request, Callback> callback) { 39 | comics.listComics(request.getLimit() 40 | , request.getOffset() 41 | , String.valueOf(request.getTimestamp()) 42 | , request.getApiKey() 43 | , request.getHashSignature() 44 | , request.getFormat().getValue() 45 | , request.getFormatType().getValue() 46 | , request.isNoVariants() 47 | , request.getDateDescriptor().getValue() 48 | , request.getDateRange() 49 | , request.isHasDigitalIssue() 50 | , request.getModifiedSince() 51 | , parameterizeList(request.getCreators()) 52 | , parameterizeList(request.getSeries()) 53 | , parameterizeList(request.getEvents()) 54 | , parameterizeList(request.getStories()) 55 | , parameterizeList(request.getSharedAppearances()) 56 | , parameterizeList(request.getCollaborators()) 57 | , request.getOrderBy().getValue(), callback); 58 | } 59 | 60 | /** 61 | * Retrieve a comic with a specific ID. 62 | * @param comicId Unique ID for the comic 63 | * @param callback Handler called on request completion 64 | */ 65 | public void getComicWithId(int comicId, Callback> callback){ 66 | RequestSignature request = RequestSignature.create(); 67 | comics.getComicWithId(comicId 68 | , String.valueOf(request.timeStamp) 69 | , request.publicKey 70 | , request.hashSignature 71 | , callback); 72 | } 73 | 74 | /** 75 | * Retrieve all characters for a comic with a specific ID. 76 | * @param comicId Unique ID for the comic 77 | * @param request Parameters for the request 78 | * @param callback Handler called on request completion 79 | */ 80 | public void getCharactersForComicId(int comicId, CharacterRequest request, Callback> callback){ 81 | comics.getCharactersForComicId(comicId 82 | , request.getLimit() 83 | , request.getOffset() 84 | , String.valueOf(request.getTimestamp()) 85 | , request.getApiKey() 86 | , request.getHashSignature() 87 | , request.getName() 88 | , request.getModifiedSince() 89 | , parameterizeList(request.getStories()) 90 | , parameterizeList(request.getSeries()) 91 | , parameterizeList(request.getEvents()) 92 | , request.getOrderBy().getValue() 93 | , callback); 94 | } 95 | 96 | 97 | /** 98 | * Retrieve all creators for a comic with a specific ID. 99 | * @param comicId Unique ID for the comic 100 | * @param request Parameters for the request 101 | * @param callback Handler called on request completion 102 | */ 103 | public void getCreatorsForComicId(int comicId, CreatorRequest request, Callback> callback){ 104 | comics.getCreatorsForComicId(comicId 105 | , request.getLimit() 106 | , request.getOffset() 107 | , String.valueOf(request.getTimestamp()) 108 | , request.getApiKey() 109 | , request.getHashSignature() 110 | , request.getFirstName() 111 | , request.getMiddleName() 112 | , request.getLastName() 113 | , request.getSuffix() 114 | , request.getModifiedSince() 115 | , parameterizeList(request.getComics()) 116 | , parameterizeList(request.getSeries()) 117 | , parameterizeList(request.getStories()) 118 | , request.getOrderBy().getValue() 119 | , callback); 120 | } 121 | 122 | /** 123 | * Retrieve events for a comic with a specific ID. 124 | * @param comicId Unique ID for the comic 125 | * @param request Parameters for the request 126 | * @param callback Handler called on request completion 127 | */ 128 | public void getEventsForComicId(int comicId, EventRequest request, Callback> callback){ 129 | comics.getEventsForComicId(comicId 130 | , request.getLimit() 131 | , request.getOffset() 132 | , String.valueOf(request.getTimestamp()) 133 | , request.getApiKey() 134 | , request.getHashSignature() 135 | , request.getName() 136 | , request.getModifiedSince() 137 | , parameterizeList(request.getCreators()) 138 | , parameterizeList(request.getCharacters()) 139 | , parameterizeList(request.getSeries()) 140 | , parameterizeList(request.getStories()) 141 | , request.getOrderBy().getValue() 142 | , callback); 143 | } 144 | 145 | /** 146 | * Retrieve all stories for a comic with a specific ID. 147 | * @param comicId Unique ID for the comic 148 | * @param request Parameters for the request 149 | * @param callback Handler called on request completion 150 | */ 151 | public void getStoriesForComicId(int comicId, StoryRequest request, Callback> callback){ 152 | comics.getStoriesForComicId(comicId 153 | , request.getLimit() 154 | , request.getOffset() 155 | , String.valueOf(request.getTimestamp()) 156 | , request.getApiKey() 157 | , request.getHashSignature() 158 | , request.getModifiedSince() 159 | , parameterizeList(request.getSeries()) 160 | , parameterizeList(request.getEvents()) 161 | , parameterizeList(request.getCreators()) 162 | , parameterizeList(request.getCharacters()) 163 | , request.getOrderBy().getValue() 164 | , callback); 165 | } 166 | } 167 | -------------------------------------------------------------------------------- /marvel-api/src/main/java/com/trey/marvel/model/api/manager/CreatorManager.java: -------------------------------------------------------------------------------- 1 | package com.trey.marvel.model.api.manager; 2 | 3 | import com.trey.marvel.model.api.MarvelApi; 4 | import com.trey.marvel.model.api.request.ComicRequest; 5 | import com.trey.marvel.model.api.request.CreatorRequest; 6 | import com.trey.marvel.model.api.request.EventRequest; 7 | import com.trey.marvel.model.api.request.RequestSignature; 8 | import com.trey.marvel.model.api.request.SeriesRequest; 9 | import com.trey.marvel.model.api.request.StoryRequest; 10 | import com.trey.marvel.model.api.response.ServiceResponse; 11 | import com.trey.marvel.model.api.service.Creators; 12 | import com.trey.marvel.model.api.vo.Comic; 13 | import com.trey.marvel.model.api.vo.Creator; 14 | import com.trey.marvel.model.api.vo.Event; 15 | import com.trey.marvel.model.api.vo.Series; 16 | import com.trey.marvel.model.api.vo.Story; 17 | 18 | import retrofit.Callback; 19 | 20 | /** 21 | * Manager that handles retrieval of creator information and requests related to a specific creator id. 22 | * 23 | * Created by Trey Robinson on 2/21/14. 24 | */ 25 | public class CreatorManager extends BaseManager { 26 | 27 | private Creators creators; 28 | 29 | public CreatorManager() { 30 | creators = MarvelApi.getInstance().getRestAdapter().create(Creators.class); 31 | } 32 | 33 | /** 34 | * Retrieve all creators matching the provided request parameters. 35 | * @param request Parameters for the request 36 | * @param callback Handler called on request completion 37 | */ 38 | public void listCreators(CreatorRequest request, Callback> callback) { 39 | creators.listCreators(request.getLimit() 40 | , request.getOffset() 41 | , String.valueOf(request.getTimestamp()) 42 | , request.getApiKey() 43 | , request.getHashSignature() 44 | , request.getFirstName() 45 | , request.getMiddleName() 46 | , request.getLastName() 47 | , request.getSuffix() 48 | , request.getModifiedSince() 49 | , parameterizeList(request.getComics()) 50 | , parameterizeList(request.getSeries()) 51 | , parameterizeList(request.getStories()) 52 | , request.getOrderBy().getValue() 53 | , callback); 54 | } 55 | 56 | /** 57 | * Retrieve a creator with a specific ID. 58 | * @param creatorId Unique ID for the creator 59 | * @param callback Handler called on request completion 60 | */ 61 | public void getCreatorWithId(int creatorId, Callback> callback) { 62 | RequestSignature request = RequestSignature.create(); 63 | creators.getCreatorWithId(creatorId 64 | , String.valueOf(request.timeStamp) 65 | , request.publicKey 66 | , request.hashSignature 67 | , callback); 68 | } 69 | 70 | /** 71 | * Retrieve all comics for a creator with a specific ID. 72 | * @param creatorId Unique ID for the creator 73 | * @param request Parameters for the request 74 | * @param callback Handler called on request completion 75 | */ 76 | public void getComicsForCreatorId(int creatorId, ComicRequest request, Callback> callback) { 77 | creators.getComicsForCreatorId(creatorId 78 | , request.getLimit() 79 | , request.getOffset() 80 | , String.valueOf(request.getTimestamp()) 81 | , request.getApiKey() 82 | , request.getHashSignature() 83 | , request.getFormat().getValue() 84 | , request.getFormatType().getValue() 85 | , request.isNoVariants() 86 | , request.getDateDescriptor().getValue() 87 | , request.getDateRange() 88 | , request.isHasDigitalIssue() 89 | , request.getModifiedSince() 90 | , parameterizeList(request.getCharacters()) 91 | , parameterizeList(request.getSeries()) 92 | , parameterizeList(request.getEvents()) 93 | , parameterizeList(request.getStories()) 94 | , parameterizeList(request.getSharedAppearances()) 95 | , parameterizeList(request.getCollaborators()) 96 | , request.getOrderBy().getValue(), callback); 97 | } 98 | 99 | /** 100 | * Retrieve all events for a creator with a specific ID. 101 | * @param creatorId Unique ID for the creator 102 | * @param request Parameters for the request 103 | * @param callback Handler called on request completion 104 | */ 105 | public void getEventsForCreatorId(int creatorId, EventRequest request, Callback> callback) { 106 | creators.getEventsForCreatorId(creatorId 107 | , request.getLimit() 108 | , request.getOffset() 109 | , String.valueOf(request.getTimestamp()) 110 | , request.getApiKey() 111 | , request.getHashSignature() 112 | , request.getName() 113 | , request.getModifiedSince() 114 | , parameterizeList(request.getComics()) 115 | , parameterizeList(request.getCharacters()) 116 | , parameterizeList(request.getSeries()) 117 | , parameterizeList(request.getStories()) 118 | , request.getOrderBy().getValue() 119 | , callback); 120 | } 121 | 122 | /** 123 | * Retrieve all series for a creator with a specific ID. 124 | * @param creatorId Unique ID for the creator 125 | * @param request Parameters for the request 126 | * @param callback Handler called on request completion 127 | */ 128 | public void getSeriesForCreatorId(int creatorId, SeriesRequest request, Callback> callback) { 129 | creators.getSeriesForCreatorId(creatorId 130 | , request.getLimit() 131 | , request.getOffset() 132 | , String.valueOf(request.getTimestamp()) 133 | , request.getApiKey() 134 | , request.getHashSignature() 135 | , request.getTitle() 136 | , request.getModifiedSince() 137 | , parameterizeList(request.getComics()) 138 | , parameterizeList(request.getStories()) 139 | , parameterizeList(request.getEvents()) 140 | , parameterizeList(request.getCharacters()) 141 | , request.getSeriesType().getValue() 142 | , request.getContains().getValue() 143 | , request.getOrderBy().getValue() 144 | , callback); 145 | } 146 | 147 | /** 148 | * Retrieve all stories for a creator with a specific ID. 149 | * @param creatorId Unique ID for the creator 150 | * @param request Parameters for the request 151 | * @param callback Handler called on request completion 152 | */ 153 | public void getStoriesForComicId(int creatorId, StoryRequest request, Callback> callback) { 154 | creators.getStoriesForCreatorId(creatorId 155 | , request.getLimit() 156 | , request.getOffset() 157 | , String.valueOf(request.getTimestamp()) 158 | , request.getApiKey() 159 | , request.getHashSignature() 160 | , request.getModifiedSince() 161 | , parameterizeList(request.getSeries()) 162 | , parameterizeList(request.getEvents()) 163 | , parameterizeList(request.getComics()) 164 | , parameterizeList(request.getCharacters()) 165 | , request.getOrderBy().getValue() 166 | , callback); 167 | } 168 | } 169 | -------------------------------------------------------------------------------- /marvel-api/src/main/java/com/trey/marvel/model/api/manager/EventManager.java: -------------------------------------------------------------------------------- 1 | package com.trey.marvel.model.api.manager; 2 | 3 | import com.trey.marvel.model.api.MarvelApi; 4 | import com.trey.marvel.model.api.request.CharacterRequest; 5 | import com.trey.marvel.model.api.request.ComicRequest; 6 | import com.trey.marvel.model.api.request.CreatorRequest; 7 | import com.trey.marvel.model.api.request.EventRequest; 8 | import com.trey.marvel.model.api.request.SeriesRequest; 9 | import com.trey.marvel.model.api.request.StoryRequest; 10 | import com.trey.marvel.model.api.response.ServiceResponse; 11 | import com.trey.marvel.model.api.service.Events; 12 | import com.trey.marvel.model.api.vo.Character; 13 | import com.trey.marvel.model.api.vo.Comic; 14 | import com.trey.marvel.model.api.vo.Creator; 15 | import com.trey.marvel.model.api.vo.Event; 16 | import com.trey.marvel.model.api.vo.Series; 17 | import com.trey.marvel.model.api.vo.Story; 18 | 19 | import retrofit.Callback; 20 | 21 | /** 22 | * Manager that handles retrieval event information and requests related to a specific event id. 23 | * 24 | * Created by Trey Robinson on 2/22/14. 25 | */ 26 | public class EventManager extends BaseManager{ 27 | 28 | private Events events; 29 | 30 | public EventManager() { 31 | events = MarvelApi.getInstance().getRestAdapter().create(Events.class); 32 | } 33 | 34 | /** 35 | * Retrieve all events matching the provided request parameters. 36 | * @param request Parameters for the request 37 | * @param callback Handler called on request completion 38 | */ 39 | public void listCreators(EventRequest request, Callback> callback) { 40 | events.listEvents(request.getLimit() 41 | , request.getOffset() 42 | , String.valueOf(request.getTimestamp()) 43 | , request.getApiKey() 44 | , request.getHashSignature() 45 | , request.getName() 46 | , request.getModifiedSince() 47 | , parameterizeList(request.getCreators()) 48 | , parameterizeList(request.getSeries()) 49 | , parameterizeList(request.getComics()) 50 | , parameterizeList(request.getStories()) 51 | , parameterizeList(request.getCharacters()) 52 | , request.getOrderBy().getValue() 53 | , callback); 54 | } 55 | 56 | /** 57 | * Retrieve a event with a specific ID. 58 | * @param eventId Unique ID for the event 59 | * @param callback Handler called on request completion 60 | */ 61 | public void getEventWithId(int eventId, CreatorRequest request, Callback> callback) { 62 | events.getEventWithId(eventId 63 | , String.valueOf(request.getTimestamp()) 64 | , request.getApiKey() 65 | , request.getHashSignature() 66 | , callback); 67 | } 68 | 69 | /** 70 | * Retrieve all characters for an event with a specific ID. 71 | * @param eventId Unique ID for the event 72 | * @param request Parameters for the request 73 | * @param callback Handler called on request completion 74 | */ 75 | public void getCharactersForEventId(int eventId, CharacterRequest request, Callback> callback){ 76 | events.getCharactersForEventId(eventId 77 | , request.getLimit() 78 | , request.getOffset() 79 | , String.valueOf(request.getTimestamp()) 80 | , request.getApiKey() 81 | , request.getHashSignature() 82 | , request.getName() 83 | , request.getModifiedSince() 84 | , parameterizeList(request.getSeries()) 85 | , parameterizeList(request.getComics()) 86 | , parameterizeList(request.getStories()) 87 | , request.getOrderBy().getValue() 88 | , callback); 89 | } 90 | 91 | /** 92 | * Retrieve all comics for an event with a specific ID. 93 | * @param eventId Unique ID for the event 94 | * @param request Parameters for the request 95 | * @param callback Handler called on request completion 96 | */ 97 | public void getComicsForEventId(int eventId, ComicRequest request, Callback> callback) { 98 | events.getComicsForEventId(eventId 99 | , request.getLimit() 100 | , request.getOffset() 101 | , String.valueOf(request.getTimestamp()) 102 | , request.getApiKey() 103 | , request.getHashSignature() 104 | , request.getFormat().getValue() 105 | , request.getFormatType().getValue() 106 | , request.isNoVariants() 107 | , request.getDateDescriptor().getValue() 108 | , request.getDateRange() 109 | , request.isHasDigitalIssue() 110 | , request.getModifiedSince() 111 | , parameterizeList(request.getCreators()) 112 | , parameterizeList(request.getCharacters()) 113 | , parameterizeList(request.getSeries()) 114 | , parameterizeList(request.getStories()) 115 | , parameterizeList(request.getSharedAppearances()) 116 | , parameterizeList(request.getCollaborators()) 117 | , request.getOrderBy().getValue(), callback); 118 | } 119 | 120 | /** 121 | * Retrieve all creators for an event with a specific ID. 122 | * @param eventId Unique ID for the event 123 | * @param request Parameters for the request 124 | * @param callback Handler called on request completion 125 | */ 126 | public void getCreatorsForEventId(int eventId, CreatorRequest request, Callback> callback){ 127 | events.getCreatorsForEventId(eventId 128 | , request.getLimit() 129 | , request.getOffset() 130 | , String.valueOf(request.getTimestamp()) 131 | , request.getApiKey() 132 | , request.getHashSignature() 133 | , request.getFirstName() 134 | , request.getMiddleName() 135 | , request.getLastName() 136 | , request.getSuffix() 137 | , request.getModifiedSince() 138 | , parameterizeList(request.getComics()) 139 | , parameterizeList(request.getSeries()) 140 | , parameterizeList(request.getStories()) 141 | , request.getOrderBy().getValue() 142 | , callback); 143 | } 144 | 145 | /** 146 | * Retrieve all series for an event with a specific ID. 147 | * @param eventId Unique ID for the event 148 | * @param request Parameters for the request 149 | * @param callback Handler called on request completion 150 | */ 151 | public void getSeriesForEventId(int eventId, SeriesRequest request, Callback> callback) { 152 | events.getSeriesForEventId(eventId 153 | , request.getLimit() 154 | , request.getOffset() 155 | , String.valueOf(request.getTimestamp()) 156 | , request.getApiKey() 157 | , request.getHashSignature() 158 | , request.getTitle() 159 | , request.getModifiedSince() 160 | , parameterizeList(request.getComics()) 161 | , parameterizeList(request.getStories()) 162 | , parameterizeList(request.getCharacters()) 163 | , parameterizeList(request.getCreators()) 164 | , request.getSeriesType().getValue() 165 | , request.getContains().getValue() 166 | , request.getOrderBy().getValue() 167 | , callback); 168 | } 169 | 170 | /** 171 | * Retrieve all stories for an event with a specific ID. 172 | * @param eventId Unique ID for the event 173 | * @param request Parameters for the request 174 | * @param callback Handler called on request completion 175 | */ 176 | public void getStoriesForEventId(int eventId, StoryRequest request, Callback> callback) { 177 | events.getStoriesForEventId(eventId 178 | , request.getLimit() 179 | , request.getOffset() 180 | , String.valueOf(request.getTimestamp()) 181 | , request.getApiKey() 182 | , request.getHashSignature() 183 | , request.getModifiedSince() 184 | , parameterizeList(request.getSeries()) 185 | , parameterizeList(request.getComics()) 186 | , parameterizeList(request.getCreators()) 187 | , parameterizeList(request.getCharacters()) 188 | , request.getOrderBy().getValue() 189 | , callback); 190 | } 191 | } 192 | -------------------------------------------------------------------------------- /marvel-api/src/main/java/com/trey/marvel/model/api/manager/SeriesManager.java: -------------------------------------------------------------------------------- 1 | package com.trey.marvel.model.api.manager; 2 | 3 | import com.trey.marvel.model.api.MarvelApi; 4 | import com.trey.marvel.model.api.request.CharacterRequest; 5 | import com.trey.marvel.model.api.request.ComicRequest; 6 | import com.trey.marvel.model.api.request.CreatorRequest; 7 | import com.trey.marvel.model.api.request.EventRequest; 8 | import com.trey.marvel.model.api.request.SeriesRequest; 9 | import com.trey.marvel.model.api.request.StoryRequest; 10 | import com.trey.marvel.model.api.response.ServiceResponse; 11 | import com.trey.marvel.model.api.service.Series; 12 | import com.trey.marvel.model.api.vo.Comic; 13 | import com.trey.marvel.model.api.vo.Creator; 14 | import com.trey.marvel.model.api.vo.Event; 15 | import com.trey.marvel.model.api.vo.Story; 16 | 17 | import retrofit.Callback; 18 | 19 | /** 20 | * Manager that handles retrieval series information and requests related to a specific series id. 21 | * 22 | * Created by Trey Robinson on 2/23/14. 23 | */ 24 | public class SeriesManager extends BaseManager { 25 | 26 | private Series series; 27 | 28 | public SeriesManager(){ 29 | series = MarvelApi.getInstance().getRestAdapter().create(Series.class); 30 | } 31 | 32 | /** 33 | * Retrieve all series matching the provided request parameters. 34 | * @param request Parameters for the request 35 | * @param callback Handler called on request completion 36 | */ 37 | public void listSeries(SeriesRequest request, Callback> callback) { 38 | series.listSeries(request.getLimit() 39 | , request.getOffset() 40 | , String.valueOf(request.getTimestamp()) 41 | , request.getApiKey() 42 | , request.getHashSignature() 43 | , request.getTitle() 44 | , request.getModifiedSince() 45 | , parameterizeList(request.getComics()) 46 | , parameterizeList(request.getStories()) 47 | , parameterizeList(request.getEvents()) 48 | , parameterizeList(request.getCreators()) 49 | , parameterizeList(request.getCharacters()) 50 | , request.getSeriesType().getValue() 51 | , request.getContains().getValue() 52 | , request.getOrderBy().getValue() 53 | , callback); 54 | } 55 | 56 | /** 57 | * Retrieve a series with a specific ID. 58 | * @param seriesId Unique ID for the event 59 | * @param callback Handler called on request completion 60 | */ 61 | public void getSeriesWithId(int seriesId, CreatorRequest request, Callback> callback) { 62 | series.getSeriesWithId(seriesId 63 | , String.valueOf(request.getTimestamp()) 64 | , request.getApiKey() 65 | , request.getHashSignature() 66 | , callback); 67 | } 68 | 69 | /** 70 | * Retrieve characters for a series with a specific ID. 71 | * @param seriesId Unique ID for the event 72 | * @param request Parameters for the request 73 | * @param callback Handler called on request completion 74 | */ 75 | public void getCharactersForSeriesId(int seriesId, CharacterRequest request, Callback> callback){ 76 | series.getCharactersForSeriesId(seriesId 77 | , request.getLimit() 78 | , request.getOffset() 79 | , String.valueOf(request.getTimestamp()) 80 | , request.getApiKey() 81 | , request.getHashSignature() 82 | , request.getName() 83 | , request.getModifiedSince() 84 | , parameterizeList(request.getComics()) 85 | , parameterizeList(request.getEvents()) 86 | , parameterizeList(request.getStories()) 87 | , request.getOrderBy().getValue() 88 | , callback); 89 | } 90 | 91 | /** 92 | * Retrieve comics for a series with a specific ID. 93 | * @param seriesId Unique ID for the event 94 | * @param request Parameters for the request 95 | * @param callback Handler called on request completion 96 | */ 97 | public void getComicsForEventId(int seriesId, ComicRequest request, Callback> callback) { 98 | series.getComicsForSeriesId(seriesId 99 | , request.getLimit() 100 | , request.getOffset() 101 | , String.valueOf(request.getTimestamp()) 102 | , request.getApiKey() 103 | , request.getHashSignature() 104 | , request.getFormat().getValue() 105 | , request.getFormatType().getValue() 106 | , request.isNoVariants() 107 | , request.getDateDescriptor().getValue() 108 | , request.getDateRange() 109 | , request.isHasDigitalIssue() 110 | , request.getModifiedSince() 111 | , parameterizeList(request.getCreators()) 112 | , parameterizeList(request.getCharacters()) 113 | , parameterizeList(request.getEvents()) 114 | , parameterizeList(request.getStories()) 115 | , parameterizeList(request.getSharedAppearances()) 116 | , parameterizeList(request.getCollaborators()) 117 | , request.getOrderBy().getValue(), callback); 118 | } 119 | 120 | /** 121 | * Retrieve creators for a series with a specific ID. 122 | * @param seriesId Unique ID for the event 123 | * @param request Parameters for the request 124 | * @param callback Handler called on request completion 125 | */ 126 | public void getCreatorsForSeriesId(int seriesId, CreatorRequest request, Callback> callback){ 127 | series.getCreatorsForSeriesId(seriesId 128 | , request.getLimit() 129 | , request.getOffset() 130 | , String.valueOf(request.getTimestamp()) 131 | , request.getApiKey() 132 | , request.getHashSignature() 133 | , request.getFirstName() 134 | , request.getMiddleName() 135 | , request.getLastName() 136 | , request.getSuffix() 137 | , request.getModifiedSince() 138 | , parameterizeList(request.getComics()) 139 | , parameterizeList(request.getEvents()) 140 | , parameterizeList(request.getStories()) 141 | , request.getOrderBy().getValue() 142 | , callback); 143 | } 144 | 145 | /** 146 | * Retrieve events for a series with a specific ID. 147 | * @param seriesId Unique ID for the event 148 | * @param request Parameters for the request 149 | * @param callback Handler called on request completion 150 | */ 151 | public void getEventsForSeriesId(int seriesId, EventRequest request, Callback> callback) { 152 | series.getEventsForSeriesId(seriesId 153 | , request.getLimit() 154 | , request.getOffset() 155 | , String.valueOf(request.getTimestamp()) 156 | , request.getApiKey() 157 | , request.getHashSignature() 158 | , request.getName() 159 | , request.getModifiedSince() 160 | , parameterizeList(request.getComics()) 161 | , parameterizeList(request.getCharacters()) 162 | , parameterizeList(request.getCreators()) 163 | , parameterizeList(request.getStories()) 164 | , request.getOrderBy().getValue() 165 | , callback); 166 | } 167 | 168 | /** 169 | * Retrieve stories for a series with a specific ID. 170 | * @param seriesId Unique ID for the event 171 | * @param request Parameters for the request 172 | * @param callback Handler called on request completion 173 | */ 174 | public void getStoriesForComicId(int seriesId, StoryRequest request, Callback> callback) { 175 | series.getStoriesForEventId(seriesId 176 | , request.getLimit() 177 | , request.getOffset() 178 | , String.valueOf(request.getTimestamp()) 179 | , request.getApiKey() 180 | , request.getHashSignature() 181 | , request.getModifiedSince() 182 | , parameterizeList(request.getEvents()) 183 | , parameterizeList(request.getComics()) 184 | , parameterizeList(request.getCreators()) 185 | , parameterizeList(request.getCharacters()) 186 | , request.getOrderBy().getValue() 187 | , callback); 188 | } 189 | } 190 | -------------------------------------------------------------------------------- /marvel-api/src/main/java/com/trey/marvel/model/api/manager/StoryManager.java: -------------------------------------------------------------------------------- 1 | package com.trey.marvel.model.api.manager; 2 | 3 | import com.trey.marvel.model.api.MarvelApi; 4 | import com.trey.marvel.model.api.request.CharacterRequest; 5 | import com.trey.marvel.model.api.request.ComicRequest; 6 | import com.trey.marvel.model.api.request.CreatorRequest; 7 | import com.trey.marvel.model.api.request.EventRequest; 8 | import com.trey.marvel.model.api.request.SeriesRequest; 9 | import com.trey.marvel.model.api.request.StoryRequest; 10 | import com.trey.marvel.model.api.response.ServiceResponse; 11 | import com.trey.marvel.model.api.service.Stories; 12 | import com.trey.marvel.model.api.vo.Comic; 13 | import com.trey.marvel.model.api.vo.Creator; 14 | import com.trey.marvel.model.api.vo.Event; 15 | import com.trey.marvel.model.api.vo.Story; 16 | 17 | import retrofit.Callback; 18 | 19 | /** 20 | * Manager that handles retrieval of story information and requests related to a specific story id. 21 | * 22 | * Created by Trey Robinson on 2/23/14. 23 | */ 24 | public class StoryManager extends BaseManager { 25 | 26 | private Stories stories; 27 | 28 | public StoryManager(){ 29 | stories = MarvelApi.getInstance().getRestAdapter().create(Stories.class); 30 | } 31 | 32 | /** 33 | * Retrieve stories matching the provided request parameters. 34 | * @param request Parameters for the request 35 | * @param callback Handler called on request completion 36 | */ 37 | public void listStories(StoryRequest request, Callback> callback) { 38 | stories.listStories(request.getLimit() 39 | , request.getOffset() 40 | , String.valueOf(request.getTimestamp()) 41 | , request.getApiKey() 42 | , request.getHashSignature() 43 | , request.getModifiedSince() 44 | , parameterizeList(request.getEvents()) 45 | , parameterizeList(request.getComics()) 46 | , parameterizeList(request.getCreators()) 47 | , parameterizeList(request.getCharacters()) 48 | , request.getOrderBy().getValue() 49 | , callback); 50 | } 51 | 52 | /** 53 | * Retrieve a story with a specific ID. 54 | * @param storyId Unique ID for the event 55 | * @param callback Handler called on request completion 56 | */ 57 | public void getStoryWithId(int storyId, StoryRequest request, Callback> callback) { 58 | stories.getStoryWithId(storyId 59 | , String.valueOf(request.getTimestamp()) 60 | , request.getApiKey() 61 | , request.getHashSignature() 62 | , callback); 63 | } 64 | 65 | /** 66 | * Retrieve characters for a story with a specific ID. 67 | * @param storyId Unique ID for the event 68 | * @param request Parameters for the request 69 | * @param callback Handler called on request completion 70 | */ 71 | public void getCharactersForStoryId(int storyId, CharacterRequest request, Callback> callback){ 72 | stories.getCharactersForStoryId(storyId 73 | , request.getLimit() 74 | , request.getOffset() 75 | , String.valueOf(request.getTimestamp()) 76 | , request.getApiKey() 77 | , request.getHashSignature() 78 | , request.getName() 79 | , request.getModifiedSince() 80 | , parameterizeList(request.getComics()) 81 | , parameterizeList(request.getSeries()) 82 | , parameterizeList(request.getEvents()) 83 | , request.getOrderBy().getValue() 84 | , callback); 85 | } 86 | 87 | /** 88 | * Retrieve comics for a story with a specific ID. 89 | * @param storyId Unique ID for the event 90 | * @param request Parameters for the request 91 | * @param callback Handler called on request completion 92 | */ 93 | public void getComicsForStoryId(int storyId, ComicRequest request, Callback> callback) { 94 | stories.getComicsForStoryId(storyId 95 | , request.getLimit() 96 | , request.getOffset() 97 | , String.valueOf(request.getTimestamp()) 98 | , request.getApiKey() 99 | , request.getHashSignature() 100 | , request.getFormat().getValue() 101 | , request.getFormatType().getValue() 102 | , request.isNoVariants() 103 | , request.getDateDescriptor().getValue() 104 | , request.getDateRange() 105 | , request.isHasDigitalIssue() 106 | , request.getModifiedSince() 107 | , parameterizeList(request.getCreators()) 108 | , parameterizeList(request.getCharacters()) 109 | , parameterizeList(request.getSeries()) 110 | , parameterizeList(request.getEvents()) 111 | , parameterizeList(request.getSharedAppearances()) 112 | , parameterizeList(request.getCollaborators()) 113 | , request.getOrderBy().getValue(), callback); 114 | } 115 | 116 | /** 117 | * Retrieve creators for a story with a specific ID. 118 | * @param storyId Unique ID for the event 119 | * @param request Parameters for the request 120 | * @param callback Handler called on request completion 121 | */ 122 | public void getCreatorsForSeriesId(int storyId, CreatorRequest request, Callback> callback){ 123 | stories.getCreatorsForStoryId(storyId 124 | , request.getLimit() 125 | , request.getOffset() 126 | , String.valueOf(request.getTimestamp()) 127 | , request.getApiKey() 128 | , request.getHashSignature() 129 | , request.getFirstName() 130 | , request.getMiddleName() 131 | , request.getLastName() 132 | , request.getSuffix() 133 | , request.getModifiedSince() 134 | , parameterizeList(request.getComics()) 135 | , parameterizeList(request.getSeries()) 136 | , parameterizeList(request.getEvents()) 137 | , request.getOrderBy().getValue() 138 | , callback); 139 | } 140 | 141 | /** 142 | * Retrieve events for a story with a specific ID. 143 | * @param storyId Unique ID for the event 144 | * @param request Parameters for the request 145 | * @param callback Handler called on request completion 146 | */ 147 | public void getEventsForStoryId(int storyId, EventRequest request, Callback> callback) { 148 | stories.getEventsForStoryId(storyId 149 | , request.getLimit() 150 | , request.getOffset() 151 | , String.valueOf(request.getTimestamp()) 152 | , request.getApiKey() 153 | , request.getHashSignature() 154 | , request.getName() 155 | , request.getModifiedSince() 156 | , parameterizeList(request.getComics()) 157 | , parameterizeList(request.getCharacters()) 158 | , parameterizeList(request.getCreators()) 159 | , parameterizeList(request.getSeries()) 160 | , request.getOrderBy().getValue() 161 | , callback); 162 | } 163 | 164 | /** 165 | * Retrieve series for a story with a specific ID. 166 | * @param storyId Unique ID for the event 167 | * @param request Parameters for the request 168 | * @param callback Handler called on request completion 169 | */ 170 | public void getSeriesForStoryId(int storyId, SeriesRequest request, Callback> callback) { 171 | stories.getSeriesForStoryId(storyId 172 | , request.getLimit() 173 | , request.getOffset() 174 | , String.valueOf(request.getTimestamp()) 175 | , request.getApiKey() 176 | , request.getHashSignature() 177 | , request.getTitle() 178 | , request.getModifiedSince() 179 | , parameterizeList(request.getComics()) 180 | , parameterizeList(request.getCreators()) 181 | , parameterizeList(request.getCharacters()) 182 | , request.getSeriesType().getValue() 183 | , request.getContains().getValue() 184 | , request.getOrderBy().getValue() 185 | , callback); 186 | } 187 | } -------------------------------------------------------------------------------- /marvel-api/src/main/java/com/trey/marvel/model/api/request/BaseRequest.java: -------------------------------------------------------------------------------- 1 | package com.trey.marvel.model.api.request; 2 | 3 | /** 4 | * Created by Trey Robinson on 2/14/14. 5 | */ 6 | public class BaseRequest { 7 | 8 | private RequestSignature requestSignature; 9 | private int limit; 10 | private int offset; 11 | 12 | public BaseRequest(RequestSignature requestSignature){ 13 | this.requestSignature = requestSignature; 14 | } 15 | 16 | public long getTimestamp(){ 17 | return requestSignature.timeStamp; 18 | } 19 | 20 | public String getHashSignature(){ 21 | return requestSignature.hashSignature; 22 | } 23 | 24 | public String getApiKey(){ 25 | return requestSignature.apiKey; 26 | } 27 | 28 | public int getLimit() { 29 | return limit; 30 | } 31 | 32 | public void setLimit(int limit) { 33 | this.limit = limit; 34 | } 35 | 36 | public int getOffset() { 37 | return offset; 38 | } 39 | 40 | public void setOffset(int offset) { 41 | this.offset = offset; 42 | } 43 | 44 | } 45 | -------------------------------------------------------------------------------- /marvel-api/src/main/java/com/trey/marvel/model/api/request/CharacterRequest.java: -------------------------------------------------------------------------------- 1 | package com.trey.marvel.model.api.request; 2 | 3 | import java.util.Date; 4 | import java.util.List; 5 | 6 | /** 7 | * Created by Trey Robinson on 2/14/14. 8 | */ 9 | public class CharacterRequest extends BaseRequest { 10 | 11 | private String name; 12 | private Date modifiedSince; 13 | private List comics; 14 | private List series; 15 | private List events; 16 | private List stories; 17 | private OrderBy orderBy; 18 | 19 | 20 | public CharacterRequest(RequestSignature requestSignature){ 21 | super(requestSignature); 22 | orderBy = OrderBy.Default; 23 | } 24 | 25 | public String getName() { 26 | return name; 27 | } 28 | 29 | public void setName(String name) { 30 | this.name = name; 31 | } 32 | 33 | public Date getModifiedSince() { 34 | return modifiedSince; 35 | } 36 | 37 | public void setModifiedSince(Date modifiedSince) { 38 | this.modifiedSince = modifiedSince; 39 | } 40 | 41 | public ListgetComics(){ 42 | return this.comics; 43 | } 44 | 45 | public void setComics(List comics) { 46 | this.comics = comics; 47 | } 48 | 49 | public List getSeries() { 50 | return series; 51 | } 52 | 53 | public void setSeries(List series) { 54 | this.series = series; 55 | } 56 | 57 | public List getEvents() { 58 | return events; 59 | } 60 | 61 | public void setEvents(List events) { 62 | this.events = events; 63 | } 64 | 65 | public List getStories() { 66 | return stories; 67 | } 68 | 69 | public void setStories(List stories) { 70 | this.stories = stories; 71 | } 72 | 73 | public OrderBy getOrderBy() { 74 | return orderBy; 75 | } 76 | 77 | public void setOrderBy(OrderBy orderBy) { 78 | this.orderBy = orderBy; 79 | } 80 | 81 | 82 | public enum OrderBy { 83 | Default("") 84 | ,Name ("name") 85 | ,NameDescending("-name") 86 | ,Date("date") 87 | ,DateDescending("-date"); 88 | 89 | private String value; 90 | 91 | OrderBy(String value){ 92 | this.value = value; 93 | } 94 | 95 | public String getValue(){ 96 | return this.value; 97 | } 98 | } 99 | 100 | 101 | } 102 | -------------------------------------------------------------------------------- /marvel-api/src/main/java/com/trey/marvel/model/api/request/ComicRequest.java: -------------------------------------------------------------------------------- 1 | package com.trey.marvel.model.api.request; 2 | 3 | import java.util.Date; 4 | import java.util.List; 5 | 6 | /** 7 | * Created by Trey Robinson on 2/15/14. 8 | */ 9 | public class ComicRequest extends BaseRequest { 10 | 11 | 12 | private Format format; 13 | private FormatType formatType; 14 | private boolean noVariants; 15 | private DateDescriptor dateDescriptor; 16 | private String dateRange; 17 | private boolean hasDigitalIssue; 18 | private Date modifiedSince; 19 | private List creators; 20 | private List characters; 21 | private List series; 22 | private List events; 23 | private List stories; 24 | private List sharedAppearances; 25 | private List collaborators; 26 | private OrderBy orderBy; 27 | private int limit; 28 | private int offset; 29 | 30 | public ComicRequest(RequestSignature requestSignature) { 31 | super(requestSignature); 32 | format = Format.Default; 33 | formatType = FormatType.Default; 34 | dateDescriptor = DateDescriptor.Default; 35 | orderBy = OrderBy.Default; 36 | } 37 | 38 | public Format getFormat() { 39 | return format; 40 | } 41 | 42 | public void setFormat(Format format) { 43 | this.format = format; 44 | } 45 | 46 | public FormatType getFormatType() { 47 | return formatType; 48 | } 49 | 50 | public void setFormatType(FormatType formatType) { 51 | this.formatType = formatType; 52 | } 53 | 54 | public boolean isNoVariants() { 55 | return noVariants; 56 | } 57 | 58 | public void setNoVariants(boolean noVariants) { 59 | this.noVariants = noVariants; 60 | } 61 | 62 | public DateDescriptor getDateDescriptor() { 63 | return dateDescriptor; 64 | } 65 | 66 | public void setDateDescriptor(DateDescriptor dateDescriptor) { 67 | this.dateDescriptor = dateDescriptor; 68 | } 69 | 70 | public String getDateRange() { 71 | return dateRange; 72 | } 73 | 74 | public void setDateRange(String dateRange) { 75 | this.dateRange = dateRange; 76 | } 77 | 78 | public boolean isHasDigitalIssue() { 79 | return hasDigitalIssue; 80 | } 81 | 82 | public void setHasDigitalIssue(boolean hasDigitalIssue) { 83 | this.hasDigitalIssue = hasDigitalIssue; 84 | } 85 | 86 | public Date getModifiedSince() { 87 | return modifiedSince; 88 | } 89 | 90 | public void setModifiedSince(Date modifiedSince) { 91 | this.modifiedSince = modifiedSince; 92 | } 93 | 94 | public List getCreators() { 95 | return creators; 96 | } 97 | 98 | public void setCreators(List creators) { 99 | this.creators = creators; 100 | } 101 | 102 | public List getCharacters() { 103 | return characters; 104 | } 105 | 106 | public void setCharacters(List characters) { 107 | this.characters = characters; 108 | } 109 | 110 | public List getSeries() { 111 | return series; 112 | } 113 | 114 | public void setSeries(List series) { 115 | this.series = series; 116 | } 117 | 118 | public List getEvents() { 119 | return events; 120 | } 121 | 122 | public void setEvents(List events) { 123 | this.events = events; 124 | } 125 | 126 | public List getStories() { 127 | return stories; 128 | } 129 | 130 | public void setStories(List stories) { 131 | this.stories = stories; 132 | } 133 | 134 | public List getSharedAppearances() { 135 | return sharedAppearances; 136 | } 137 | 138 | public void setSharedAppearances(List sharedAppearances) { 139 | this.sharedAppearances = sharedAppearances; 140 | } 141 | 142 | public List getCollaborators() { 143 | return collaborators; 144 | } 145 | 146 | public void setCollaborators(List collaborators) { 147 | this.collaborators = collaborators; 148 | } 149 | 150 | public OrderBy getOrderBy() { 151 | return orderBy; 152 | } 153 | 154 | public void setOrderBy(OrderBy orderBy) { 155 | this.orderBy = orderBy; 156 | } 157 | 158 | public int getLimit() { 159 | return limit; 160 | } 161 | 162 | public void setLimit(int limit) { 163 | this.limit = limit; 164 | } 165 | 166 | public int getOffset() { 167 | return offset; 168 | } 169 | 170 | public void setOffset(int offset) { 171 | this.offset = offset; 172 | } 173 | 174 | public enum Format { 175 | Default(null) 176 | ,Comic ("comic") 177 | ,Magazine ("magazine") 178 | ,TradePaperback("trade paperback") 179 | ,Hardcover ("hardcover") 180 | ,Digest ("digest") 181 | ,GraphicNovel ("graphic novel") 182 | ,DigitalComic ("digital comic") 183 | ,InfiniteComic ("infinite comic"); 184 | 185 | private String value; 186 | 187 | Format(String value){ 188 | this.value = value; 189 | } 190 | 191 | public String getValue(){ 192 | return this.value; 193 | } 194 | } 195 | 196 | public enum FormatType { 197 | Default(null) 198 | ,Comic("comic") 199 | ,Collection("collection"); 200 | 201 | private String value; 202 | 203 | FormatType(String value){ 204 | this.value = value; 205 | } 206 | 207 | public String getValue(){ 208 | return this.value; 209 | } 210 | 211 | 212 | } 213 | 214 | public enum DateDescriptor{ 215 | Default(null) 216 | ,LastWeek("lastWeek") 217 | ,ThisWeek("thisWeek") 218 | ,NextMonth("nextMonth") 219 | ,ThisMonth("thisMonth"); 220 | 221 | private String value; 222 | 223 | DateDescriptor(String value){ 224 | this.value = value; 225 | } 226 | 227 | public String getValue(){ 228 | return this.value; 229 | } 230 | } 231 | public enum OrderBy { 232 | Default(null) 233 | ,FOCDate("focDate") 234 | ,FOCDateDescending("-focDate") 235 | ,OnSaleDate("onsaleDate") 236 | ,OnSaleDateDescending("-onsaleDate") 237 | ,Title("title") 238 | ,TitleDescending("-title") 239 | ,IssueNumber("issueNumber") 240 | ,IssueNumberDescending("-issueNumber") 241 | ,ModifiedDate("modified") 242 | ,ModifiedDateDescending("-modified"); 243 | 244 | 245 | private String value; 246 | 247 | OrderBy(String value){ 248 | this.value = value; 249 | } 250 | 251 | public String getValue(){ 252 | return this.value; 253 | } 254 | } 255 | } 256 | -------------------------------------------------------------------------------- /marvel-api/src/main/java/com/trey/marvel/model/api/request/CreatorRequest.java: -------------------------------------------------------------------------------- 1 | package com.trey.marvel.model.api.request; 2 | 3 | import java.util.Date; 4 | import java.util.List; 5 | 6 | /** 7 | * Created by Trey Robinson on 2/18/14. 8 | */ 9 | public class CreatorRequest extends BaseRequest { 10 | 11 | private String firstName; 12 | private String middleName; 13 | private String lastName; 14 | private String suffix; 15 | private Date modifiedSince; 16 | private List comics; 17 | private List events; 18 | private List series; 19 | private List stories; 20 | private OrderBy orderBy; 21 | 22 | public CreatorRequest(RequestSignature requestSignature) { 23 | super(requestSignature); 24 | orderBy = OrderBy.Default; 25 | } 26 | 27 | public String getFirstName() { 28 | return firstName; 29 | } 30 | 31 | public void setFirstName(String firstName) { 32 | this.firstName = firstName; 33 | } 34 | 35 | public String getMiddleName() { 36 | return middleName; 37 | } 38 | 39 | public void setMiddleName(String middleName) { 40 | this.middleName = middleName; 41 | } 42 | 43 | public String getLastName() { 44 | return lastName; 45 | } 46 | 47 | public void setLastName(String lastName) { 48 | this.lastName = lastName; 49 | } 50 | 51 | public String getSuffix() { 52 | return suffix; 53 | } 54 | 55 | public void setSuffix(String suffix) { 56 | this.suffix = suffix; 57 | } 58 | 59 | public Date getModifiedSince() { 60 | return modifiedSince; 61 | } 62 | 63 | public void setModifiedSince(Date modifiedSince) { 64 | this.modifiedSince = modifiedSince; 65 | } 66 | 67 | public List getComics() { 68 | return comics; 69 | } 70 | 71 | public void setComics(List comics) { 72 | this.comics = comics; 73 | } 74 | 75 | public List getEvents() { 76 | return events; 77 | } 78 | 79 | public void setEvents(List events) { 80 | this.events = events; 81 | } 82 | 83 | public List getSeries() { 84 | return series; 85 | } 86 | 87 | public void setSeries(List series) { 88 | this.series = series; 89 | } 90 | 91 | public List getStories() { 92 | return stories; 93 | } 94 | 95 | public void setStories(List stories) { 96 | this.stories = stories; 97 | } 98 | 99 | public OrderBy getOrderBy() { 100 | return orderBy; 101 | } 102 | 103 | public void setOrderBy(OrderBy orderBy) { 104 | this.orderBy = orderBy; 105 | } 106 | 107 | public enum OrderBy { 108 | Default(null) 109 | ,FistName("firstName") 110 | ,FirstNameDescending("-firstName") 111 | ,LastName("lastName") 112 | ,LastNameDescending("-lastName") 113 | ,MiddleName("middletName") 114 | ,MiddleNameDescending("-middleName") 115 | ,Suffix("suffix") 116 | ,SuffixDescending("-suffix") 117 | ,ModifiedDate("modified") 118 | ,ModifiedDateDescending("-modified"); 119 | 120 | private String value; 121 | 122 | OrderBy(String value){ 123 | this.value = value; 124 | } 125 | 126 | public String getValue(){ 127 | return this.value; 128 | } 129 | } 130 | } 131 | -------------------------------------------------------------------------------- /marvel-api/src/main/java/com/trey/marvel/model/api/request/EventRequest.java: -------------------------------------------------------------------------------- 1 | package com.trey.marvel.model.api.request; 2 | 3 | import java.util.Date; 4 | import java.util.List; 5 | 6 | /** 7 | * Created by Trey Robinson on 2/16/14. 8 | */ 9 | public class EventRequest extends BaseRequest { 10 | 11 | private String name; 12 | private Date modifiedSince; 13 | private List creators; 14 | private List series; 15 | private List comics; 16 | private List stories; 17 | private List characters; 18 | private OrderBy orderBy; 19 | private int limit; 20 | private int offset; 21 | 22 | public EventRequest(RequestSignature requestSignature) { 23 | super(requestSignature); 24 | this.orderBy = OrderBy.Default; 25 | } 26 | 27 | public String getName() { 28 | return name; 29 | } 30 | 31 | public void setName(String name) { 32 | this.name = name; 33 | } 34 | 35 | public Date getModifiedSince() { 36 | return modifiedSince; 37 | } 38 | 39 | public void setModifiedSince(Date modifiedSince) { 40 | this.modifiedSince = modifiedSince; 41 | } 42 | 43 | public List getCreators() { 44 | return creators; 45 | } 46 | 47 | public void setCreators(List creators) { 48 | this.creators = creators; 49 | } 50 | 51 | public List getSeries() { 52 | return series; 53 | } 54 | 55 | public void setSeries(List series) { 56 | this.series = series; 57 | } 58 | 59 | public List getComics() { 60 | return comics; 61 | } 62 | 63 | public void setComics(List comics) { 64 | this.comics = comics; 65 | } 66 | 67 | public List getStories() { 68 | return stories; 69 | } 70 | 71 | public void setStories(List stories) { 72 | this.stories = stories; 73 | } 74 | 75 | public List getCharacters() { 76 | return characters; 77 | } 78 | 79 | public void setCharacters(List characters) { 80 | this.characters = characters; 81 | } 82 | 83 | public OrderBy getOrderBy() { 84 | return orderBy; 85 | } 86 | 87 | public void setOrderBy(OrderBy orderBy) { 88 | this.orderBy = orderBy; 89 | } 90 | 91 | public int getLimit() { 92 | return limit; 93 | } 94 | 95 | public void setLimit(int limit) { 96 | this.limit = limit; 97 | } 98 | 99 | public int getOffset() { 100 | return offset; 101 | } 102 | 103 | public void setOffset(int offset) { 104 | this.offset = offset; 105 | } 106 | 107 | public enum OrderBy { 108 | Default(null) 109 | ,Name("name") 110 | ,NameDescending("-name") 111 | ,StartDate("startDate") 112 | ,StartDateDescending("-startDate") 113 | ,ModifiedDate("modified") 114 | ,ModifiedDateDescending("-modified"); 115 | 116 | private String value; 117 | 118 | OrderBy(String value){ 119 | this.value = value; 120 | } 121 | 122 | public String getValue(){ 123 | return this.value; 124 | } 125 | } 126 | } 127 | -------------------------------------------------------------------------------- /marvel-api/src/main/java/com/trey/marvel/model/api/request/RequestSignature.java: -------------------------------------------------------------------------------- 1 | package com.trey.marvel.model.api.request; 2 | 3 | import com.trey.marvel.model.api.utils.HashUtil; 4 | 5 | import java.util.Calendar; 6 | import java.util.TimeZone; 7 | 8 | /** 9 | * Signature required for all requests per Marvels API documentation. Signatures 10 | * are a combination of the public and private keys as well as a generated timestamp that 11 | * makes each request unique. 12 | * 13 | * Created by Trey Robinson on 2/12/14. 14 | */ 15 | public class RequestSignature { 16 | 17 | public static String apiKey; 18 | public static String privateKey; 19 | 20 | public long timeStamp; 21 | public String publicKey = apiKey; 22 | public String hashSignature; 23 | private static Calendar calendar = Calendar.getInstance(TimeZone.getTimeZone("UTC")); 24 | 25 | 26 | private RequestSignature(){ 27 | this.timeStamp = calendar.getTimeInMillis() / 1000L; 28 | this.hashSignature = HashUtil.md5(String.valueOf(this.timeStamp) + privateKey + publicKey); 29 | } 30 | 31 | /** 32 | * Returnes a new instance of a request signature. 33 | * @return 34 | */ 35 | public static RequestSignature create(){ 36 | return new RequestSignature(); 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /marvel-api/src/main/java/com/trey/marvel/model/api/request/SeriesRequest.java: -------------------------------------------------------------------------------- 1 | package com.trey.marvel.model.api.request; 2 | 3 | import java.util.Date; 4 | import java.util.List; 5 | 6 | /** 7 | * Created by Trey Robinson on 2/16/14. 8 | */ 9 | public class SeriesRequest extends BaseRequest{ 10 | 11 | private String title; 12 | private Date modifiedSince; 13 | private List comics; 14 | private List stories; 15 | private List events; 16 | private List creators; 17 | private List characters; 18 | private SeriesType seriesType; 19 | private Contains contains; 20 | private OrderBy orderBy; 21 | private int limit; 22 | private int offset; 23 | 24 | public SeriesRequest(RequestSignature requestSignature){ 25 | super(requestSignature); 26 | orderBy = OrderBy.Default; 27 | contains = Contains.Default; 28 | seriesType = SeriesType.Default; 29 | } 30 | 31 | public String getTitle() { 32 | return title; 33 | } 34 | 35 | public void setTitle(String title) { 36 | this.title = title; 37 | } 38 | 39 | public Date getModifiedSince() { 40 | return modifiedSince; 41 | } 42 | 43 | public void setModifiedSince(Date modifiedSince) { 44 | this.modifiedSince = modifiedSince; 45 | } 46 | 47 | public List getComics() { 48 | return comics; 49 | } 50 | 51 | public void setComics(List comics) { 52 | this.comics = comics; 53 | } 54 | 55 | public List getStories() { 56 | return stories; 57 | } 58 | 59 | public void setStories(List stories) { 60 | this.stories = stories; 61 | } 62 | 63 | public List getEvents() { 64 | return events; 65 | } 66 | 67 | public void setEvents(List events) { 68 | this.events = events; 69 | } 70 | 71 | public List getCreators() { 72 | return creators; 73 | } 74 | 75 | public void setCreators(List creators) { 76 | this.creators = creators; 77 | } 78 | 79 | public List getCharacters() { 80 | return characters; 81 | } 82 | 83 | public void setCharacters(List characters) { 84 | this.characters = characters; 85 | } 86 | 87 | public SeriesType getSeriesType() { 88 | return seriesType; 89 | } 90 | 91 | public void setSeriesType(SeriesType seriesType) { 92 | this.seriesType = seriesType; 93 | } 94 | 95 | public Contains getContains() { 96 | return contains; 97 | } 98 | 99 | public void setContains(Contains contains) { 100 | this.contains = contains; 101 | } 102 | 103 | public OrderBy getOrderBy() { 104 | return orderBy; 105 | } 106 | 107 | public void setOrderBy(OrderBy orderBy) { 108 | this.orderBy = orderBy; 109 | } 110 | 111 | public int getLimit() { 112 | return limit; 113 | } 114 | 115 | public void setLimit(int limit) { 116 | this.limit = limit; 117 | } 118 | 119 | public int getOffset() { 120 | return offset; 121 | } 122 | 123 | public void setOffset(int offset) { 124 | this.offset = offset; 125 | } 126 | 127 | public enum OrderBy { 128 | Default(null) 129 | ,Title("title") 130 | ,TitleDescending("-title") 131 | ,ModifiedDate("modified") 132 | ,ModifiedDateDescending("-modified") 133 | ,StartYear("startYear") 134 | ,StartYearDescending("-startYear"); 135 | 136 | private String value; 137 | 138 | OrderBy(String value){ 139 | this.value = value; 140 | } 141 | 142 | public String getValue(){ 143 | return this.value; 144 | } 145 | } 146 | 147 | public enum SeriesType { 148 | Default(null) 149 | ,Collection("collection") 150 | ,Oneshot("oneshot") 151 | ,Limited("limited") 152 | ,Ongoing("ongoing"); 153 | 154 | private String value; 155 | 156 | SeriesType(String value){ 157 | this.value = value; 158 | } 159 | 160 | public String getValue(){ 161 | return this.value; 162 | } 163 | } 164 | 165 | public enum Contains { 166 | Default(null) 167 | ,Comic("comic") 168 | ,Magazine("magazine") 169 | ,TradePaperback("trade paperback") 170 | ,Hardcover("hardcover") 171 | ,Digest("digest") 172 | ,GraphicNovel("graphic novel") 173 | ,DigitalComic("digital comic"); 174 | 175 | private String value; 176 | 177 | Contains(String value){ 178 | this.value = value; 179 | } 180 | 181 | public String getValue(){ 182 | return this.value; 183 | } 184 | } 185 | } 186 | -------------------------------------------------------------------------------- /marvel-api/src/main/java/com/trey/marvel/model/api/request/StoryRequest.java: -------------------------------------------------------------------------------- 1 | package com.trey.marvel.model.api.request; 2 | 3 | import java.util.Date; 4 | import java.util.List; 5 | 6 | /** 7 | * Created by Trey Robinson on 2/17/14. 8 | */ 9 | public class StoryRequest extends BaseRequest{ 10 | 11 | private Date modifiedSince; 12 | private List comics; 13 | private List series; 14 | private List events; 15 | private List creators; 16 | private List characters; 17 | private OrderBy orderBy; 18 | 19 | public StoryRequest(RequestSignature requestSignature){ 20 | super(requestSignature); 21 | orderBy = OrderBy.Default; 22 | } 23 | 24 | public Date getModifiedSince() { 25 | return modifiedSince; 26 | } 27 | 28 | public void setModifiedSince(Date modifiedSince) { 29 | this.modifiedSince = modifiedSince; 30 | } 31 | 32 | public List getComics() { 33 | return comics; 34 | } 35 | 36 | public void setComics(List comics) { 37 | this.comics = comics; 38 | } 39 | 40 | public List getSeries() { 41 | return series; 42 | } 43 | 44 | public void setSeries(List series) { 45 | this.series = series; 46 | } 47 | 48 | public List getEvents() { 49 | return events; 50 | } 51 | 52 | public void setEvents(List events) { 53 | this.events = events; 54 | } 55 | 56 | public List getCreators() { 57 | return creators; 58 | } 59 | 60 | public void setCreators(List creators) { 61 | this.creators = creators; 62 | } 63 | 64 | public List getCharacters() { 65 | return characters; 66 | } 67 | 68 | public void setCharacters(List characters) { 69 | this.characters = characters; 70 | } 71 | 72 | public OrderBy getOrderBy() { 73 | return orderBy; 74 | } 75 | 76 | public void setOrderBy(OrderBy orderBy) { 77 | this.orderBy = orderBy; 78 | } 79 | 80 | public enum OrderBy { 81 | Default(null) 82 | ,Id("id") 83 | ,IdDescending("-id") 84 | ,ModifiedDate("modified") 85 | ,ModifiedDateDescending("-modified"); 86 | 87 | private String value; 88 | 89 | OrderBy(String value){ 90 | this.value = value; 91 | } 92 | 93 | public String getValue(){ 94 | return this.value; 95 | } 96 | } 97 | 98 | } 99 | -------------------------------------------------------------------------------- /marvel-api/src/main/java/com/trey/marvel/model/api/response/DataContainer.java: -------------------------------------------------------------------------------- 1 | package com.trey.marvel.model.api.response; 2 | 3 | import com.trey.marvel.model.api.vo.*; 4 | 5 | import java.lang.reflect.Array; 6 | import java.util.List; 7 | 8 | /** 9 | * Created by Trey Robinson on 2/13/14. 10 | */ 11 | public class DataContainer { 12 | 13 | public int offset; 14 | public int limit; 15 | public int total; 16 | public int count; 17 | public List results; 18 | 19 | } 20 | -------------------------------------------------------------------------------- /marvel-api/src/main/java/com/trey/marvel/model/api/response/DateAdapter.java: -------------------------------------------------------------------------------- 1 | package com.trey.marvel.model.api.response; 2 | 3 | import com.google.gson.JsonDeserializationContext; 4 | import com.google.gson.JsonDeserializer; 5 | import com.google.gson.JsonElement; 6 | import com.google.gson.JsonParseException; 7 | 8 | import java.lang.reflect.Type; 9 | import java.text.ParseException; 10 | import java.text.SimpleDateFormat; 11 | import java.util.Arrays; 12 | import java.util.Date; 13 | import java.util.Locale; 14 | 15 | /** 16 | * Created by Trey Robinson on 2/16/14. 17 | * 18 | * Original Code From http://stackoverflow.com/questions/15563155/gson-to-json-conversion-with-two-dateformat 19 | */ 20 | public class DateAdapter implements JsonDeserializer { 21 | 22 | private static final String[] DATE_FORMATS = new String[] { 23 | "yyyy-MM-dd'T'HH:mm:ssZ", 24 | "yyyy-MM-dd HH:mm:ss" 25 | }; 26 | 27 | @Override 28 | public Date deserialize(JsonElement jsonElement, Type type, JsonDeserializationContext jsonDeserializationContext) throws JsonParseException { 29 | for (String format : DATE_FORMATS) { 30 | try { 31 | return new SimpleDateFormat(format, Locale.US).parse(jsonElement.getAsString()); 32 | } catch (ParseException e) { 33 | } 34 | } 35 | throw new JsonParseException("Unparseable date: \"" + jsonElement.getAsString() 36 | + "\". Supported formats: " + Arrays.toString(DATE_FORMATS)); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /marvel-api/src/main/java/com/trey/marvel/model/api/response/ServiceResponse.java: -------------------------------------------------------------------------------- 1 | package com.trey.marvel.model.api.response; 2 | 3 | /** 4 | * Created by Trey Robinson on 2/13/14. 5 | */ 6 | public class ServiceResponse{ 7 | public int code; 8 | public String status; 9 | public String etag; 10 | public DataContainer data; 11 | 12 | } 13 | -------------------------------------------------------------------------------- /marvel-api/src/main/java/com/trey/marvel/model/api/service/Characters.java: -------------------------------------------------------------------------------- 1 | package com.trey.marvel.model.api.service; 2 | 3 | import com.trey.marvel.model.api.response.ServiceResponse; 4 | import com.trey.marvel.model.api.vo.Character; 5 | import com.trey.marvel.model.api.vo.Comic; 6 | import com.trey.marvel.model.api.vo.Event; 7 | import com.trey.marvel.model.api.vo.Series; 8 | import com.trey.marvel.model.api.vo.Story; 9 | 10 | import java.util.Date; 11 | 12 | import retrofit.Callback; 13 | import retrofit.http.GET; 14 | import retrofit.http.Path; 15 | import retrofit.http.Query; 16 | 17 | /** 18 | * Created by Trey Robinson on 2/12/14. 19 | */ 20 | public interface Characters { 21 | 22 | @GET("/v1/public/characters") 23 | public void listCharacters(@Query("limit") int limit 24 | , @Query("offset") int offset 25 | , @Query("ts") String timestamp 26 | , @Query("apikey") String apikey 27 | , @Query("hash") String hashSignature 28 | , @Query("name") String name 29 | , @Query("modifiedSince") Date modifiedSince 30 | , @Query("comics") String comics 31 | , @Query("series") String series 32 | , @Query("events") String events 33 | , @Query("orderBy") String orderBy 34 | , Callback> callback); 35 | 36 | @GET("/v1/public/characters/{characterid}") 37 | public void getCharacterWithId(@Path("characterid") int characterId 38 | , @Query("ts") String timestamp 39 | , @Query("apikey") String apikey 40 | , @Query("hash") String hashSignature 41 | , Callback> callback); 42 | 43 | @GET("/v1/public/characters/{characterid}/comics") 44 | public void getComicsForCharacterId(@Path("characterid") int characterId 45 | , @Query("limit") int limit 46 | , @Query("offset") int offset 47 | , @Query("ts") String timestamp 48 | , @Query("apikey") String apikey 49 | , @Query("hash") String hashSignature 50 | , @Query("format") String format 51 | , @Query("formatType") String formatType 52 | , @Query("noVariants") boolean noVariants 53 | , @Query("dateDescriptor") String dateDescriptor 54 | , @Query("dateRange") String dateRange 55 | , @Query("hasDigitalIssue") Boolean hasDigitalIssue 56 | , @Query("modifiedSince") Date modifiedSince 57 | , @Query("creators") String creators 58 | , @Query("series") String series 59 | , @Query("events") String events 60 | , @Query("stories") String stories 61 | , @Query("sharedAppearances") String sharedAppearances 62 | , @Query("collaborators") String collaborators 63 | , @Query("orderBy") String orderBy 64 | , Callback> callback); 65 | 66 | 67 | @GET("/v1/public/characters/{characterid}/events") 68 | public void getEventsForCharacterId(@Path("characterid") int characterId 69 | , @Query("limit") int limit 70 | , @Query("offset") int offset 71 | , @Query("ts") String timestamp 72 | , @Query("apikey") String apikey 73 | , @Query("hash") String hashSignature 74 | , @Query("name") String name 75 | , @Query("modifiedSince") Date modifiedSince 76 | , @Query("creators") String creators 77 | , @Query("series") String series 78 | , @Query("comics") String comics 79 | , @Query("stories") String stories 80 | , @Query("orderBy") String orderBy 81 | , Callback> callback); 82 | 83 | @GET("/v1/public/characters/{characterid}/series") 84 | public void getSeriesForCharacterId(@Path("characterid") int characterId 85 | , @Query("limit") int limit 86 | , @Query("offset") int offset 87 | , @Query("ts") String timestamp 88 | , @Query("apikey") String apikey 89 | , @Query("hash") String hashSignature 90 | , @Query("title") String title 91 | , @Query("modifiedSince") Date modified 92 | , @Query("comics") String comics 93 | , @Query("stories") String stories 94 | , @Query("events") String events 95 | , @Query("creators") String creators 96 | , @Query("seriesType") String seriesType 97 | , @Query("contains") String contains 98 | , @Query("orderBy") String orderBy 99 | , Callback> callback); 100 | 101 | 102 | @GET("/v1/public/characters/{characterid}/stories") 103 | public void getStoriesForCharacterId(@Path("characterid") int characterId 104 | , @Query("limit") int limit 105 | , @Query("offset") int offset 106 | , @Query("ts") String timestamp 107 | , @Query("apikey") String apikey 108 | , @Query("hash") String hashSignature 109 | , @Query("modifiedSince") Date modified 110 | , @Query("comics") String comics 111 | , @Query("series") String series 112 | , @Query("events") String events 113 | , @Query("creators") String creators 114 | , @Query("orderBy") String orderBy 115 | , Callback> callback); 116 | 117 | 118 | } 119 | -------------------------------------------------------------------------------- /marvel-api/src/main/java/com/trey/marvel/model/api/service/Comics.java: -------------------------------------------------------------------------------- 1 | package com.trey.marvel.model.api.service; 2 | 3 | import com.trey.marvel.model.api.response.ServiceResponse; 4 | import com.trey.marvel.model.api.vo.*; 5 | import com.trey.marvel.model.api.vo.Character; 6 | 7 | import java.util.Date; 8 | 9 | import retrofit.Callback; 10 | import retrofit.http.GET; 11 | import retrofit.http.Path; 12 | import retrofit.http.Query; 13 | 14 | /** 15 | * Created by Trey Robinson on 2/17/14. 16 | */ 17 | public interface Comics { 18 | 19 | @GET("/v1/public/comics") 20 | public void listComics(@Query("limit") int limit 21 | , @Query("offset") int offset 22 | , @Query("ts") String timestamp 23 | , @Query("apikey") String apikey 24 | , @Query("hash") String hashSignature 25 | , @Query("format") String format 26 | , @Query("formatType") String formatType 27 | , @Query("noVariants") boolean noVariants 28 | , @Query("dateDescriptor") String dateDescriptor 29 | , @Query("dateRange") String dateRange 30 | , @Query("hasDigitalIssue") Boolean hasDigitalIssue 31 | , @Query("modifiedSince") Date modifiedSince 32 | , @Query("creators") String creators 33 | , @Query("series") String series 34 | , @Query("events") String events 35 | , @Query("stories") String stories 36 | , @Query("sharedAppearances") String sharedAppearances 37 | , @Query("collaborators") String collaborators 38 | , @Query("orderBy") String orderBy 39 | , Callback> callback); 40 | 41 | @GET("/v1/public/comics/{comicId}") 42 | public void getComicWithId(@Path("comicId") int comicId 43 | , @Query("ts") String timestamp 44 | , @Query("apikey") String apikey 45 | , @Query("hash") String hashSignature 46 | , Callback> callback); 47 | 48 | @GET("/v1/public/comics/{comicId}/characters") 49 | public void getCharactersForComicId(@Path("comicId") int comicId 50 | , @Query("limit") int limit 51 | , @Query("offset") int offset 52 | , @Query("ts") String timestamp 53 | , @Query("apikey") String apikey 54 | , @Query("hash") String hashSignature 55 | , @Query("name") String name 56 | , @Query("modifiedSince") Date modifiedSince 57 | , @Query("series") String series 58 | , @Query("events") String events 59 | , @Query("stories") String stories 60 | , @Query("orderBy") String orderBy 61 | , Callback> callback); 62 | 63 | @GET("/v1/public/comics/{comicId}/creators") 64 | public void getCreatorsForComicId(@Path("comicId") int comicId 65 | , @Query("limit") int limit 66 | , @Query("offset") int offset 67 | , @Query("ts") String timestamp 68 | , @Query("apikey") String apikey 69 | , @Query("hash") String hashSignature 70 | , @Query("firstName") String firstName 71 | , @Query("middleName") String middleName 72 | , @Query("lastName") String lastName 73 | , @Query("suffix") String suffix 74 | , @Query("modifiedSince") Date modifiedSince 75 | , @Query("comics") String comics 76 | , @Query("series") String series 77 | , @Query("stories") String stories 78 | , @Query("orderBy") String orderBy 79 | , Callback> callback); 80 | 81 | @GET("/v1/public/comics/{comicId}/events") 82 | public void getEventsForComicId(@Path("comicId") int comicId 83 | , @Query("limit") int limit 84 | , @Query("offset") int offset 85 | , @Query("ts") String timestamp 86 | , @Query("apikey") String apikey 87 | , @Query("hash") String hashSignature 88 | , @Query("name") String name 89 | , @Query("modifiedSince") Date modifiedSince 90 | , @Query("creator") String creators 91 | , @Query("characters") String characters 92 | , @Query("series") String series 93 | , @Query("stories") String stories 94 | , @Query("orderBy") String orderBy 95 | , Callback> callback); 96 | 97 | 98 | @GET("/v1/public/comics/{comicId}/stories") 99 | public void getStoriesForComicId(@Path("comicId") int comicId 100 | , @Query("limit") int limit 101 | , @Query("offset") int offset 102 | , @Query("ts") String timestamp 103 | , @Query("apikey") String apikey 104 | , @Query("hash") String hashSignature 105 | , @Query("modifiedSince") Date modifiedSince 106 | , @Query("series") String series 107 | , @Query("events") String events 108 | , @Query("creator") String creators 109 | , @Query("characters") String characters 110 | , @Query("orderBy") String orderBy 111 | , Callback> callback); 112 | 113 | 114 | 115 | } 116 | -------------------------------------------------------------------------------- /marvel-api/src/main/java/com/trey/marvel/model/api/service/Creators.java: -------------------------------------------------------------------------------- 1 | package com.trey.marvel.model.api.service; 2 | 3 | import com.trey.marvel.model.api.response.ServiceResponse; 4 | import com.trey.marvel.model.api.vo.Comic; 5 | import com.trey.marvel.model.api.vo.Creator; 6 | import com.trey.marvel.model.api.vo.Event; 7 | import com.trey.marvel.model.api.vo.Series; 8 | import com.trey.marvel.model.api.vo.Story; 9 | 10 | import java.util.Date; 11 | 12 | import retrofit.Callback; 13 | import retrofit.http.GET; 14 | import retrofit.http.Path; 15 | import retrofit.http.Query; 16 | 17 | /** 18 | * Created by Trey Robinson on 2/21/14. 19 | */ 20 | public interface Creators { 21 | 22 | @GET("/v1/public/creators") 23 | public void listCreators(@Query("limit") int limit 24 | , @Query("offset") int offset 25 | , @Query("ts") String timestamp 26 | , @Query("apikey") String apikey 27 | , @Query("hash") String hashSignature 28 | , @Query("firstName") String firstName 29 | , @Query("middleName") String middleName 30 | , @Query("lastName") String lastName 31 | , @Query("suffix") String suffix 32 | , @Query("modifiedSince") Date modifiedSince 33 | , @Query("comics") String comics 34 | , @Query("series") String series 35 | , @Query("stories") String stories 36 | , @Query("orderBy") String orderBy 37 | , Callback> callback); 38 | 39 | @GET("/v1/public/creators/{creatorId}") 40 | public void getCreatorWithId(@Path("creatorId") int creatorId 41 | , @Query("ts") String timestamp 42 | , @Query("apikey") String apikey 43 | , @Query("hash") String hashSignature 44 | , Callback> callback); 45 | 46 | 47 | @GET("/v1/public/creators/{creatorId}/comics") 48 | public void getComicsForCreatorId(@Path("creatorId") int creatorId 49 | , @Query("limit") int limit 50 | , @Query("offset") int offset 51 | , @Query("ts") String timestamp 52 | , @Query("apikey") String apikey 53 | , @Query("hash") String hashSignature 54 | , @Query("format") String format 55 | , @Query("formatType") String formatType 56 | , @Query("noVariants") boolean noVariants 57 | , @Query("dateDescriptor") String dateDescriptor 58 | , @Query("dateRange") String dateRange 59 | , @Query("hasDigitalIssue") Boolean hasDigitalIssue 60 | , @Query("modifiedSince") Date modifiedSince 61 | , @Query("characters") String characters 62 | , @Query("series") String series 63 | , @Query("events") String events 64 | , @Query("stories") String stories 65 | , @Query("sharedAppearances") String sharedAppearances 66 | , @Query("collaborators") String collaborators 67 | , @Query("orderBy") String orderBy 68 | , Callback> callback); 69 | 70 | @GET("/v1/public/creators/{creatorId}/events") 71 | public void getEventsForCreatorId(@Path("creatorId") int creatorId 72 | , @Query("limit") int limit 73 | , @Query("offset") int offset 74 | , @Query("ts") String timestamp 75 | , @Query("apikey") String apikey 76 | , @Query("hash") String hashSignature 77 | , @Query("name") String name 78 | , @Query("modifiedSince") Date modifiedSince 79 | , @Query("comics") String comics 80 | , @Query("characters") String characters 81 | , @Query("series") String series 82 | , @Query("stories") String stories 83 | , @Query("orderBy") String orderBy 84 | , Callback> callback); 85 | 86 | @GET("/v1/public/creators/{creatorId}/series") 87 | public void getSeriesForCreatorId(@Path("creatorId") int creatorId 88 | , @Query("limit") int limit 89 | , @Query("offset") int offset 90 | , @Query("ts") String timestamp 91 | , @Query("apikey") String apikey 92 | , @Query("hash") String hashSignature 93 | , @Query("title") String title 94 | , @Query("modifiedSince") Date modified 95 | , @Query("comics") String comics 96 | , @Query("stories") String stories 97 | , @Query("events") String events 98 | , @Query("characters") String characters 99 | , @Query("seriesType") String seriesType 100 | , @Query("contains") String contains 101 | , @Query("orderBy") String orderBy 102 | , Callback> callback); 103 | 104 | @GET("/v1/public/creators/{creatorId}/stories") 105 | public void getStoriesForCreatorId(@Path("creatorId") int creatorId 106 | , @Query("limit") int limit 107 | , @Query("offset") int offset 108 | , @Query("ts") String timestamp 109 | , @Query("apikey") String apikey 110 | , @Query("hash") String hashSignature 111 | , @Query("modifiedSince") Date modifiedSince 112 | , @Query("series") String series 113 | , @Query("events") String events 114 | , @Query("comics") String comics 115 | , @Query("characters") String characters 116 | , @Query("orderBy") String orderBy 117 | , Callback> callback); 118 | 119 | } 120 | -------------------------------------------------------------------------------- /marvel-api/src/main/java/com/trey/marvel/model/api/service/Events.java: -------------------------------------------------------------------------------- 1 | package com.trey.marvel.model.api.service; 2 | 3 | import com.trey.marvel.model.api.response.ServiceResponse; 4 | import com.trey.marvel.model.api.vo.*; 5 | import com.trey.marvel.model.api.vo.Character; 6 | import com.trey.marvel.model.api.vo.Series; 7 | 8 | import java.util.Date; 9 | 10 | import retrofit.Callback; 11 | import retrofit.http.GET; 12 | import retrofit.http.Path; 13 | import retrofit.http.Query; 14 | 15 | /** 16 | * Created by Trey Robinson on 2/21/14. 17 | */ 18 | public interface Events { 19 | 20 | @GET("/v1/public/events") 21 | public void listEvents(@Query("limit") int limit 22 | , @Query("offset") int offset 23 | , @Query("ts") String timestamp 24 | , @Query("apikey") String apikey 25 | , @Query("hash") String hashSignature 26 | , @Query("name") String name 27 | , @Query("modifiedSince") Date modifiedSince 28 | , @Query("creator") String creators 29 | , @Query("series") String series 30 | , @Query("comics") String comics 31 | , @Query("stories") String stories 32 | , @Query("characters") String characters 33 | , @Query("orderBy") String orderBy 34 | , Callback> callback); 35 | 36 | @GET("/v1/public/events/{eventId}") 37 | public void getEventWithId(@Path("eventId") int eventId 38 | , @Query("ts") String timestamp 39 | , @Query("apikey") String apikey 40 | , @Query("hash") String hashSignature 41 | , Callback> callback); 42 | 43 | @GET("/v1/public/events/{eventId}/characters") 44 | public void getCharactersForEventId(@Path("eventId") int eventId 45 | , @Query("limit") int limit 46 | , @Query("offset") int offset 47 | , @Query("ts") String timestamp 48 | , @Query("apikey") String apikey 49 | , @Query("hash") String hashSignature 50 | , @Query("name") String name 51 | , @Query("modifiedSince") Date modifiedSince 52 | , @Query("series") String series 53 | , @Query("comics") String comics 54 | , @Query("stories") String stories 55 | , @Query("orderBy") String orderBy 56 | , Callback> callback); 57 | 58 | 59 | @GET("/v1/public/events/{eventId}/comics") 60 | public void getComicsForEventId(@Path("eventId") int eventId 61 | , @Query("limit") int limit 62 | , @Query("offset") int offset 63 | , @Query("ts") String timestamp 64 | , @Query("apikey") String apikey 65 | , @Query("hash") String hashSignature 66 | , @Query("format") String format 67 | , @Query("formatType") String formatType 68 | , @Query("noVariants") boolean noVariants 69 | , @Query("dateDescriptor") String dateDescriptor 70 | , @Query("dateRange") String dateRange 71 | , @Query("hasDigitalIssue") Boolean hasDigitalIssue 72 | , @Query("modifiedSince") Date modifiedSince 73 | , @Query("creators") String creators 74 | , @Query("characters") String characters 75 | , @Query("series") String series 76 | , @Query("stories") String stories 77 | , @Query("sharedAppearances") String sharedAppearances 78 | , @Query("collaborators") String collaborators 79 | , @Query("orderBy") String orderBy 80 | , Callback> callback); 81 | 82 | @GET("/v1/public/events/{eventId}/creators") 83 | public void getCreatorsForEventId(@Path("eventId") int eventId 84 | , @Query("limit") int limit 85 | , @Query("offset") int offset 86 | , @Query("ts") String timestamp 87 | , @Query("apikey") String apikey 88 | , @Query("hash") String hashSignature 89 | , @Query("firstName") String firstName 90 | , @Query("middleName") String middleName 91 | , @Query("lastName") String lastName 92 | , @Query("suffix") String suffix 93 | , @Query("modifiedSince") Date modifiedSince 94 | , @Query("comics") String comics 95 | , @Query("series") String series 96 | , @Query("stories") String stories 97 | , @Query("orderBy") String orderBy 98 | , Callback> callback); 99 | 100 | @GET("/v1/public/events/{eventId}/series") 101 | public void getSeriesForEventId(@Path("eventId") int eventId 102 | , @Query("limit") int limit 103 | , @Query("offset") int offset 104 | , @Query("ts") String timestamp 105 | , @Query("apikey") String apikey 106 | , @Query("hash") String hashSignature 107 | , @Query("title") String title 108 | , @Query("modifiedSince") Date modified 109 | , @Query("comics") String comics 110 | , @Query("stories") String stories 111 | , @Query("characters") String characters 112 | , @Query("creators") String creators 113 | , @Query("seriesType") String seriesType 114 | , @Query("contains") String contains 115 | , @Query("orderBy") String orderBy 116 | , Callback> callback); 117 | 118 | @GET("/v1/public/events/{eventId}/stories") 119 | public void getStoriesForEventId(@Path("eventId") int eventId 120 | , @Query("limit") int limit 121 | , @Query("offset") int offset 122 | , @Query("ts") String timestamp 123 | , @Query("apikey") String apikey 124 | , @Query("hash") String hashSignature 125 | , @Query("modifiedSince") Date modifiedSince 126 | , @Query("series") String series 127 | , @Query("comics") String comics 128 | , @Query("creator") String creators 129 | , @Query("characters") String characters 130 | , @Query("orderBy") String orderBy 131 | , Callback> callback); 132 | } 133 | -------------------------------------------------------------------------------- /marvel-api/src/main/java/com/trey/marvel/model/api/service/Series.java: -------------------------------------------------------------------------------- 1 | package com.trey.marvel.model.api.service; 2 | 3 | import com.trey.marvel.model.api.response.ServiceResponse; 4 | import com.trey.marvel.model.api.vo.*; 5 | import com.trey.marvel.model.api.vo.Character; 6 | 7 | 8 | import java.util.Date; 9 | 10 | import retrofit.Callback; 11 | import retrofit.http.GET; 12 | import retrofit.http.Path; 13 | import retrofit.http.Query; 14 | 15 | /** 16 | * Created by Trey Robinson on 2/23/14. 17 | */ 18 | public interface Series { 19 | 20 | @GET("/v1/public/series") 21 | public void listSeries(@Query("limit") int limit 22 | , @Query("offset") int offset 23 | , @Query("ts") String timestamp 24 | , @Query("apikey") String apikey 25 | , @Query("hash") String hashSignature 26 | , @Query("title") String title 27 | , @Query("modifiedSince") Date modified 28 | , @Query("comics") String comics 29 | , @Query("stories") String stories 30 | , @Query("events") String events 31 | , @Query("creators") String creators 32 | , @Query("characters") String characters 33 | , @Query("seriesType") String seriesType 34 | , @Query("contains") String contains 35 | , @Query("orderBy") String orderBy 36 | , Callback> callback); 37 | 38 | @GET("/v1/public/series/{seriesId}") 39 | public void getSeriesWithId(@Path("seriesId") int seriesId 40 | , @Query("ts") String timestamp 41 | , @Query("apikey") String apikey 42 | , @Query("hash") String hashSignature 43 | , Callback> callback); 44 | 45 | @GET("/v1/public/series/{seriesId}/characters") 46 | public void getCharactersForSeriesId(@Path("seriesId") int seriesId 47 | , @Query("limit") int limit 48 | , @Query("offset") int offset 49 | , @Query("ts") String timestamp 50 | , @Query("apikey") String apikey 51 | , @Query("hash") String hashSignature 52 | , @Query("name") String name 53 | , @Query("modifiedSince") Date modifiedSince 54 | , @Query("comics") String comics 55 | , @Query("events") String events 56 | , @Query("stories") String stories 57 | , @Query("orderBy") String orderBy 58 | , Callback> callback); 59 | 60 | @GET("/v1/public/series/{seriesId}/comics") 61 | public void getComicsForSeriesId(@Path("seriesId") int seriesId 62 | , @Query("limit") int limit 63 | , @Query("offset") int offset 64 | , @Query("ts") String timestamp 65 | , @Query("apikey") String apikey 66 | , @Query("hash") String hashSignature 67 | , @Query("format") String format 68 | , @Query("formatType") String formatType 69 | , @Query("noVariants") boolean noVariants 70 | , @Query("dateDescriptor") String dateDescriptor 71 | , @Query("dateRange") String dateRange 72 | , @Query("hasDigitalIssue") Boolean hasDigitalIssue 73 | , @Query("modifiedSince") Date modifiedSince 74 | , @Query("creators") String creators 75 | , @Query("characters") String characters 76 | , @Query("events") String events 77 | , @Query("stories") String stories 78 | , @Query("sharedAppearances") String sharedAppearances 79 | , @Query("collaborators") String collaborators 80 | , @Query("orderBy") String orderBy 81 | , Callback> callback); 82 | 83 | @GET("/v1/public/series/{seriesId}/creators") 84 | public void getCreatorsForSeriesId(@Path("seriesId") int seriesId 85 | , @Query("limit") int limit 86 | , @Query("offset") int offset 87 | , @Query("ts") String timestamp 88 | , @Query("apikey") String apikey 89 | , @Query("hash") String hashSignature 90 | , @Query("firstName") String firstName 91 | , @Query("middleName") String middleName 92 | , @Query("lastName") String lastName 93 | , @Query("suffix") String suffix 94 | , @Query("modifiedSince") Date modifiedSince 95 | , @Query("comics") String comics 96 | , @Query("events") String events 97 | , @Query("stories") String stories 98 | , @Query("orderBy") String orderBy 99 | , Callback> callback); 100 | 101 | @GET("/v1/public/series/{seriesId}/events") 102 | public void getEventsForSeriesId(@Path("seriesId") int seriesId 103 | , @Query("limit") int limit 104 | , @Query("offset") int offset 105 | , @Query("ts") String timestamp 106 | , @Query("apikey") String apikey 107 | , @Query("hash") String hashSignature 108 | , @Query("name") String name 109 | , @Query("modifiedSince") Date modifiedSince 110 | , @Query("comics") String comics 111 | , @Query("characters") String characters 112 | , @Query("creators") String creators 113 | , @Query("stories") String stories 114 | , @Query("orderBy") String orderBy 115 | , Callback> callback); 116 | 117 | @GET("/v1/public/series/{seriesId}/stories") 118 | public void getStoriesForEventId(@Path("seriesId") int seriesId 119 | , @Query("limit") int limit 120 | , @Query("offset") int offset 121 | , @Query("ts") String timestamp 122 | , @Query("apikey") String apikey 123 | , @Query("hash") String hashSignature 124 | , @Query("modifiedSince") Date modifiedSince 125 | , @Query("events") String events 126 | , @Query("comics") String comics 127 | , @Query("creator") String creators 128 | , @Query("characters") String characters 129 | , @Query("orderBy") String orderBy 130 | , Callback> callback); 131 | 132 | } 133 | -------------------------------------------------------------------------------- /marvel-api/src/main/java/com/trey/marvel/model/api/service/Stories.java: -------------------------------------------------------------------------------- 1 | package com.trey.marvel.model.api.service; 2 | 3 | import com.trey.marvel.model.api.response.ServiceResponse; 4 | import com.trey.marvel.model.api.vo.*; 5 | import com.trey.marvel.model.api.vo.Series; 6 | 7 | import java.util.Date; 8 | 9 | import retrofit.Callback; 10 | import retrofit.http.GET; 11 | import retrofit.http.Path; 12 | import retrofit.http.Query; 13 | 14 | /** 15 | * Created by Trey Robinson on 2/23/14. 16 | */ 17 | public interface Stories { 18 | 19 | @GET("/v1/public/stories") 20 | public void listStories(@Query("limit") int limit 21 | , @Query("offset") int offset 22 | , @Query("ts") String timestamp 23 | , @Query("apikey") String apikey 24 | , @Query("hash") String hashSignature 25 | , @Query("modifiedSince") Date modifiedSince 26 | , @Query("events") String events 27 | , @Query("comics") String comics 28 | , @Query("creator") String creators 29 | , @Query("characters") String characters 30 | , @Query("orderBy") String orderBy 31 | , Callback> callback); 32 | 33 | @GET("/v1/public/stories/{storyId}") 34 | public void getStoryWithId(@Path("storyId") int storyId 35 | , @Query("ts") String timestamp 36 | , @Query("apikey") String apikey 37 | , @Query("hash") String hashSignature 38 | , Callback> callback); 39 | 40 | @GET("/v1/public/stories/{storyId}/characters") 41 | public void getCharactersForStoryId(@Path("storyId") int storyId 42 | , @Query("limit") int limit 43 | , @Query("offset") int offset 44 | , @Query("ts") String timestamp 45 | , @Query("apikey") String apikey 46 | , @Query("hash") String hashSignature 47 | , @Query("name") String name 48 | , @Query("modifiedSince") Date modifiedSince 49 | , @Query("comics") String comics 50 | , @Query("series") String series 51 | , @Query("events") String events 52 | , @Query("orderBy") String orderBy 53 | , Callback> callback); 54 | 55 | @GET("/v1/public/stories/{storyId}/comics") 56 | public void getComicsForStoryId(@Path("storyId") int storyId 57 | , @Query("limit") int limit 58 | , @Query("offset") int offset 59 | , @Query("ts") String timestamp 60 | , @Query("apikey") String apikey 61 | , @Query("hash") String hashSignature 62 | , @Query("format") String format 63 | , @Query("formatType") String formatType 64 | , @Query("noVariants") boolean noVariants 65 | , @Query("dateDescriptor") String dateDescriptor 66 | , @Query("dateRange") String dateRange 67 | , @Query("hasDigitalIssue") Boolean hasDigitalIssue 68 | , @Query("modifiedSince") Date modifiedSince 69 | , @Query("creators") String creators 70 | , @Query("characters") String characters 71 | , @Query("series") String series 72 | , @Query("events") String events 73 | , @Query("sharedAppearances") String sharedAppearances 74 | , @Query("collaborators") String collaborators 75 | , @Query("orderBy") String orderBy 76 | , Callback> callback); 77 | 78 | @GET("/v1/public/stories/{storyId}/creators") 79 | public void getCreatorsForStoryId(@Path("storyId") int storyId 80 | , @Query("limit") int limit 81 | , @Query("offset") int offset 82 | , @Query("ts") String timestamp 83 | , @Query("apikey") String apikey 84 | , @Query("hash") String hashSignature 85 | , @Query("firstName") String firstName 86 | , @Query("middleName") String middleName 87 | , @Query("lastName") String lastName 88 | , @Query("suffix") String suffix 89 | , @Query("modifiedSince") Date modifiedSince 90 | , @Query("comics") String comics 91 | , @Query("series") String series 92 | , @Query("events") String events 93 | , @Query("orderBy") String orderBy 94 | , Callback> callback); 95 | 96 | @GET("/v1/public/stories/{storyId}/events") 97 | public void getEventsForStoryId(@Path("storyId") int storyId 98 | , @Query("limit") int limit 99 | , @Query("offset") int offset 100 | , @Query("ts") String timestamp 101 | , @Query("apikey") String apikey 102 | , @Query("hash") String hashSignature 103 | , @Query("name") String name 104 | , @Query("modifiedSince") Date modifiedSince 105 | , @Query("comics") String comics 106 | , @Query("characters") String characters 107 | , @Query("creators") String creators 108 | , @Query("series") String series 109 | , @Query("orderBy") String orderBy 110 | , Callback> callback); 111 | 112 | @GET("/v1/public/stories/{storyId}/series") 113 | public void getSeriesForStoryId(@Path("storyId") int storyId 114 | , @Query("limit") int limit 115 | , @Query("offset") int offset 116 | , @Query("ts") String timestamp 117 | , @Query("apikey") String apikey 118 | , @Query("hash") String hashSignature 119 | , @Query("title") String title 120 | , @Query("modifiedSince") Date modified 121 | , @Query("comics") String comics 122 | , @Query("creators") String creators 123 | , @Query("characters") String characters 124 | , @Query("seriesType") String seriesType 125 | , @Query("contains") String contains 126 | , @Query("orderBy") String orderBy 127 | , Callback> callback); 128 | } 129 | -------------------------------------------------------------------------------- /marvel-api/src/main/java/com/trey/marvel/model/api/utils/HashUtil.java: -------------------------------------------------------------------------------- 1 | package com.trey.marvel.model.api.utils; 2 | 3 | import java.security.MessageDigest; 4 | import java.security.NoSuchAlgorithmException; 5 | 6 | /** 7 | * Created by Trey Robinson on 2/14/14. 8 | */ 9 | public class HashUtil { 10 | 11 | /** 12 | * Creates an md5 hash string from the string input 13 | * 14 | * @param s String to be hashed 15 | * @return 16 | */ 17 | public static final String md5(final String s) { 18 | final String MD5 = "MD5"; 19 | try { 20 | // Create MD5 Hash 21 | MessageDigest digest = java.security.MessageDigest 22 | .getInstance(MD5); 23 | digest.update(s.getBytes()); 24 | byte messageDigest[] = digest.digest(); 25 | 26 | // Create Hex String 27 | StringBuilder hexString = new StringBuilder(); 28 | for (byte aMessageDigest : messageDigest) { 29 | String h = Integer.toHexString(0xFF & aMessageDigest); 30 | while (h.length() < 2) 31 | h = "0" + h; 32 | hexString.append(h); 33 | } 34 | return hexString.toString(); 35 | 36 | } catch (NoSuchAlgorithmException e) { 37 | e.printStackTrace(); 38 | } 39 | return ""; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /marvel-api/src/main/java/com/trey/marvel/model/api/vo/Character.java: -------------------------------------------------------------------------------- 1 | package com.trey.marvel.model.api.vo; 2 | 3 | import java.util.Date; 4 | import java.util.List; 5 | 6 | /** 7 | * Created by Trey Robinson on 2/12/14. 8 | */ 9 | public class Character { 10 | 11 | public int id; 12 | public String name; 13 | public String description; 14 | public Date modified; 15 | public String resourceURI; 16 | public List urls; 17 | public ImageInfo thumbnail; 18 | public ItemList comics; 19 | public ItemList stories; 20 | public ItemList events; 21 | public ItemList series; 22 | 23 | } 24 | -------------------------------------------------------------------------------- /marvel-api/src/main/java/com/trey/marvel/model/api/vo/CharacterList.java: -------------------------------------------------------------------------------- 1 | package com.trey.marvel.model.api.vo; 2 | 3 | import java.util.List; 4 | 5 | /** 6 | * Created by Trey Robinson on 2/14/14. 7 | */ 8 | public class CharacterList { 9 | 10 | 11 | public int available; 12 | public int returned; 13 | public String collectionURL; 14 | public List items; 15 | } 16 | -------------------------------------------------------------------------------- /marvel-api/src/main/java/com/trey/marvel/model/api/vo/CharacterSummary.java: -------------------------------------------------------------------------------- 1 | package com.trey.marvel.model.api.vo; 2 | 3 | /** 4 | * Created by Trey Robinson on 2/14/14. 5 | */ 6 | public class CharacterSummary { 7 | 8 | public String resourceURL; 9 | public String name; 10 | public String role; 11 | } 12 | -------------------------------------------------------------------------------- /marvel-api/src/main/java/com/trey/marvel/model/api/vo/Comic.java: -------------------------------------------------------------------------------- 1 | package com.trey.marvel.model.api.vo; 2 | 3 | import java.util.Date; 4 | import java.util.List; 5 | 6 | /** 7 | * Created by Trey Robinson on 2/14/14. 8 | */ 9 | public class Comic { 10 | 11 | public int id; 12 | public int digitalId; 13 | public String title; 14 | public double issueNumber; 15 | public String variantDescription; 16 | public String description; 17 | public Date modified; 18 | public String isbn; 19 | public String upc; 20 | public String diamondCode; 21 | public String ean; 22 | public String issn; 23 | public String format; 24 | public int pageCount; 25 | public List textObjects; 26 | public String resourceURI; 27 | public List urls; 28 | public Item series; 29 | public List variants; 30 | public List collection; 31 | public List collectedIssues; 32 | public List dates; 33 | public List prices; 34 | public ImageInfo thumbnail; 35 | public List images; 36 | public CreatorList creators; 37 | public CharacterList characters; 38 | public ItemList stories; 39 | public ItemList events; 40 | 41 | 42 | } 43 | -------------------------------------------------------------------------------- /marvel-api/src/main/java/com/trey/marvel/model/api/vo/ComicPrice.java: -------------------------------------------------------------------------------- 1 | package com.trey.marvel.model.api.vo; 2 | 3 | /** 4 | * Created by Trey Robinson on 2/14/14. 5 | */ 6 | public class ComicPrice { 7 | 8 | public String type; 9 | public float price; 10 | } 11 | -------------------------------------------------------------------------------- /marvel-api/src/main/java/com/trey/marvel/model/api/vo/Creator.java: -------------------------------------------------------------------------------- 1 | package com.trey.marvel.model.api.vo; 2 | 3 | import java.util.Date; 4 | import java.util.List; 5 | 6 | /** 7 | * Created by Trey Robinson on 2/18/14. 8 | */ 9 | public class Creator { 10 | 11 | public int id; 12 | public String firstName; 13 | public String middleName; 14 | public String lastName; 15 | public String suffix; 16 | public String fullName; 17 | public Date modified; 18 | public ImageInfo thumbnail; 19 | public String resourceURI; 20 | public ItemList comics; 21 | public ItemList series; 22 | public ItemList stories; 23 | public ItemList events; 24 | public List urls; 25 | 26 | 27 | } 28 | -------------------------------------------------------------------------------- /marvel-api/src/main/java/com/trey/marvel/model/api/vo/CreatorList.java: -------------------------------------------------------------------------------- 1 | package com.trey.marvel.model.api.vo; 2 | 3 | import java.util.List; 4 | 5 | /** 6 | * Created by Trey Robinson on 2/14/14. 7 | */ 8 | public class CreatorList{ 9 | public int available; 10 | public int returned; 11 | public String collectionURI; 12 | public String name; 13 | public String role; 14 | public List items; 15 | } 16 | -------------------------------------------------------------------------------- /marvel-api/src/main/java/com/trey/marvel/model/api/vo/CreatorSummary.java: -------------------------------------------------------------------------------- 1 | package com.trey.marvel.model.api.vo; 2 | 3 | /** 4 | * Created by Trey Robinson on 2/14/14. 5 | */ 6 | public class CreatorSummary extends Item{ 7 | 8 | public String role; 9 | } 10 | -------------------------------------------------------------------------------- /marvel-api/src/main/java/com/trey/marvel/model/api/vo/Event.java: -------------------------------------------------------------------------------- 1 | package com.trey.marvel.model.api.vo; 2 | 3 | import java.util.Date; 4 | import java.util.List; 5 | 6 | /** 7 | * Created by Trey Robinson on 2/16/14. 8 | */ 9 | public class Event { 10 | public int id; 11 | public String title; 12 | public String description; 13 | public String resourceURL; 14 | public List urls; 15 | public Date modified; 16 | public Date start; 17 | public Date end; 18 | public ImageInfo thumbnail; 19 | public ItemList comics; 20 | public ItemList stories; 21 | public ItemList series; 22 | public CharacterList characters; 23 | public CreatorList creators; 24 | public Item next; 25 | public Item previous; 26 | 27 | } 28 | -------------------------------------------------------------------------------- /marvel-api/src/main/java/com/trey/marvel/model/api/vo/ImageInfo.java: -------------------------------------------------------------------------------- 1 | package com.trey.marvel.model.api.vo; 2 | 3 | /** 4 | * Created by Trey Robinson on 2/12/14. 5 | */ 6 | public class ImageInfo { 7 | public String path; 8 | public String extension; 9 | } 10 | -------------------------------------------------------------------------------- /marvel-api/src/main/java/com/trey/marvel/model/api/vo/IndustryDate.java: -------------------------------------------------------------------------------- 1 | package com.trey.marvel.model.api.vo; 2 | 3 | import java.util.Date; 4 | 5 | /** 6 | * Created by Trey Robinson on 2/16/14. 7 | */ 8 | public class IndustryDate { 9 | 10 | public String type; 11 | public Date date; 12 | } 13 | -------------------------------------------------------------------------------- /marvel-api/src/main/java/com/trey/marvel/model/api/vo/Item.java: -------------------------------------------------------------------------------- 1 | package com.trey.marvel.model.api.vo; 2 | 3 | /** 4 | * Created by Trey Robinson on 2/16/14. 5 | */ 6 | public class Item { 7 | 8 | public String resourceURI; 9 | public String name; 10 | public String type; 11 | } 12 | -------------------------------------------------------------------------------- /marvel-api/src/main/java/com/trey/marvel/model/api/vo/ItemList.java: -------------------------------------------------------------------------------- 1 | package com.trey.marvel.model.api.vo; 2 | 3 | import java.util.List; 4 | 5 | /** 6 | * Created by Trey Robinson on 2/16/14. 7 | */ 8 | public class ItemList { 9 | 10 | public int available; 11 | public int returned; 12 | public String collectionURI; 13 | public List items; 14 | } 15 | -------------------------------------------------------------------------------- /marvel-api/src/main/java/com/trey/marvel/model/api/vo/Price.java: -------------------------------------------------------------------------------- 1 | package com.trey.marvel.model.api.vo; 2 | 3 | /** 4 | * Created by Trey Robinson on 2/16/14. 5 | */ 6 | public class Price { 7 | 8 | public String type; 9 | public double price; 10 | } 11 | -------------------------------------------------------------------------------- /marvel-api/src/main/java/com/trey/marvel/model/api/vo/Series.java: -------------------------------------------------------------------------------- 1 | package com.trey.marvel.model.api.vo; 2 | 3 | import java.net.URL; 4 | import java.util.Date; 5 | import java.util.List; 6 | 7 | /** 8 | * Created by Trey Robinson on 2/16/14. 9 | */ 10 | public class Series { 11 | 12 | public int id; 13 | public String title; 14 | public String description; 15 | public String resourceURI; 16 | public List urls; 17 | public int startYear; 18 | public int endYear; 19 | public String rating; 20 | public Date modified; 21 | public ImageInfo thumbnail; 22 | public ItemList comics; 23 | public ItemList stories; 24 | public ItemList events; 25 | public CharacterList characters; 26 | public CreatorList creators; 27 | public Item next; 28 | public Item previous; 29 | } 30 | -------------------------------------------------------------------------------- /marvel-api/src/main/java/com/trey/marvel/model/api/vo/SeriesList.java: -------------------------------------------------------------------------------- 1 | package com.trey.marvel.model.api.vo; 2 | 3 | import java.net.URI; 4 | import java.util.List; 5 | 6 | /** 7 | * Created by Trey Robinson on 2/17/14. 8 | */ 9 | public class SeriesList { 10 | 11 | public int available; 12 | public String collectionURI; 13 | public List items; 14 | public int returned; 15 | } 16 | -------------------------------------------------------------------------------- /marvel-api/src/main/java/com/trey/marvel/model/api/vo/Service.java: -------------------------------------------------------------------------------- 1 | package com.trey.marvel.model.api.vo; 2 | 3 | /** 4 | * Created by Trey Robinson on 2/17/14. 5 | */ 6 | public class Service { 7 | 8 | public String service; 9 | public int id; 10 | } 11 | -------------------------------------------------------------------------------- /marvel-api/src/main/java/com/trey/marvel/model/api/vo/Story.java: -------------------------------------------------------------------------------- 1 | package com.trey.marvel.model.api.vo; 2 | 3 | import java.util.Date; 4 | 5 | /** 6 | * Created by Trey Robinson on 2/17/14. 7 | */ 8 | public class Story { 9 | 10 | public int id; 11 | public String title; 12 | public String description; 13 | public String resourceURI; 14 | public String type; 15 | public Date modified; 16 | public ImageInfo thumbnail; 17 | public ItemList comics; 18 | public SeriesList series; 19 | public CharacterList characters; 20 | public CreatorList creators; 21 | public Item originalIssue; 22 | 23 | } 24 | -------------------------------------------------------------------------------- /marvel-api/src/main/java/com/trey/marvel/model/api/vo/TextObject.java: -------------------------------------------------------------------------------- 1 | package com.trey.marvel.model.api.vo; 2 | 3 | /** 4 | * Created by Trey Robinson on 2/14/14. 5 | */ 6 | public class TextObject { 7 | 8 | public String type; 9 | public String language; 10 | public String text; 11 | } 12 | -------------------------------------------------------------------------------- /marvel-api/src/main/java/com/trey/marvel/model/api/vo/Url.java: -------------------------------------------------------------------------------- 1 | package com.trey.marvel.model.api.vo; 2 | 3 | /** 4 | * Created by Trey Robinson on 2/13/14. 5 | */ 6 | public class Url { 7 | public String type; 8 | public String url; 9 | } 10 | -------------------------------------------------------------------------------- /marvel-api/src/main/java/com/trey/marvel/model/test/ExampleTest.java: -------------------------------------------------------------------------------- 1 | package com.trey.marvel.model.test; 2 | 3 | import android.test.InstrumentationTestCase; 4 | 5 | /** 6 | * Created by Trey Robinson on 2/13/14. 7 | */ 8 | public class ExampleTest extends InstrumentationTestCase { 9 | 10 | public void test() throws Exception { 11 | final int expected = 1; 12 | final int reality = 1; 13 | assertEquals(expected,reality); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /marvel-api/src/main/res/drawable-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rdrobinson3/AndroidMarvelAPI/17f068736ee8f04c0673e7f52c32aa3441b2dc8b/marvel-api/src/main/res/drawable-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /marvel-api/src/main/res/drawable-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rdrobinson3/AndroidMarvelAPI/17f068736ee8f04c0673e7f52c32aa3441b2dc8b/marvel-api/src/main/res/drawable-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /marvel-api/src/main/res/drawable-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rdrobinson3/AndroidMarvelAPI/17f068736ee8f04c0673e7f52c32aa3441b2dc8b/marvel-api/src/main/res/drawable-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /marvel-api/src/main/res/drawable-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rdrobinson3/AndroidMarvelAPI/17f068736ee8f04c0673e7f52c32aa3441b2dc8b/marvel-api/src/main/res/drawable-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /marvel-api/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | My Module 3 | 4 | -------------------------------------------------------------------------------- /marvel-demo/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /marvel-demo/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 21 5 | buildToolsVersion "21.1.1" 6 | 7 | defaultConfig { 8 | minSdkVersion 15 9 | targetSdkVersion 21 10 | versionCode 1 11 | versionName "1.0" 12 | } 13 | buildTypes { 14 | release { 15 | runProguard false 16 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt' 17 | } 18 | } 19 | } 20 | 21 | dependencies { 22 | compile 'com.android.support:support-v4:+' 23 | compile fileTree(dir: 'libs', include: ['*.jar', '*.aar']) 24 | compile project(':marvel-api') 25 | } 26 | -------------------------------------------------------------------------------- /marvel-demo/marvel-api-demo.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 8 | 9 | 10 | 11 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | -------------------------------------------------------------------------------- /marvel-demo/marvel-demo.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 8 | 9 | 10 | 11 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | -------------------------------------------------------------------------------- /marvel-demo/proguard-rules.txt: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /opt/android-sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the ProGuard 5 | # include property in project.properties. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} -------------------------------------------------------------------------------- /marvel-demo/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 11 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /marvel-demo/src/main/ic_launcher-web.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rdrobinson3/AndroidMarvelAPI/17f068736ee8f04c0673e7f52c32aa3441b2dc8b/marvel-demo/src/main/ic_launcher-web.png -------------------------------------------------------------------------------- /marvel-demo/src/main/java/com/trey/marvel/CharacterListAdapter.java: -------------------------------------------------------------------------------- 1 | package com.trey.marvel; 2 | 3 | import android.content.Context; 4 | import android.widget.ArrayAdapter; 5 | 6 | import com.trey.marvel.model.api.vo.*; 7 | import com.trey.marvel.model.api.vo.Character; 8 | 9 | import java.util.List; 10 | 11 | /** 12 | * Created by Trey Robinson on 2/24/14. 13 | */ 14 | public class CharacterListAdapter extends ArrayAdapter{ 15 | 16 | 17 | private List data; 18 | 19 | public CharacterListAdapter(Context context, List data) { 20 | super(context, R.layout.generic_list_item); 21 | this.data = data; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /marvel-demo/src/main/java/com/trey/marvel/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.trey.marvel; 2 | 3 | import android.app.Activity; 4 | 5 | import android.app.ActionBar; 6 | import android.app.Fragment; 7 | import android.app.FragmentManager; 8 | import android.os.Bundle; 9 | import android.view.LayoutInflater; 10 | import android.view.Menu; 11 | import android.view.MenuItem; 12 | import android.view.View; 13 | import android.view.ViewGroup; 14 | import android.support.v4.widget.DrawerLayout; 15 | import android.widget.TextView; 16 | 17 | 18 | public class MainActivity extends Activity 19 | implements NavigationDrawerFragment.NavigationDrawerCallbacks { 20 | 21 | /** 22 | * Fragment managing the behaviors, interactions and presentation of the navigation drawer. 23 | */ 24 | private NavigationDrawerFragment mNavigationDrawerFragment; 25 | 26 | /** 27 | * Used to store the last screen title. For use in {@link #restoreActionBar()}. 28 | */ 29 | private CharSequence mTitle; 30 | 31 | @Override 32 | protected void onCreate(Bundle savedInstanceState) { 33 | super.onCreate(savedInstanceState); 34 | setContentView(R.layout.activity_main); 35 | 36 | mNavigationDrawerFragment = (NavigationDrawerFragment) 37 | getFragmentManager().findFragmentById(R.id.navigation_drawer); 38 | mTitle = getTitle(); 39 | 40 | // Set up the drawer. 41 | mNavigationDrawerFragment.setUp( 42 | R.id.navigation_drawer, 43 | (DrawerLayout) findViewById(R.id.drawer_layout)); 44 | } 45 | 46 | @Override 47 | public void onNavigationDrawerItemSelected(int position) { 48 | // update the main content by replacing fragments 49 | FragmentManager fragmentManager = getFragmentManager(); 50 | fragmentManager.beginTransaction() 51 | .replace(R.id.container, PlaceholderFragment.newInstance(position + 1)) 52 | .commit(); 53 | } 54 | 55 | public void onSectionAttached(int number) { 56 | switch (number) { 57 | case 1: 58 | mTitle = getString(R.string.title_section1); 59 | break; 60 | case 2: 61 | mTitle = getString(R.string.title_section2); 62 | break; 63 | case 3: 64 | mTitle = getString(R.string.title_section3); 65 | break; 66 | } 67 | } 68 | 69 | public void restoreActionBar() { 70 | ActionBar actionBar = getActionBar(); 71 | actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD); 72 | actionBar.setDisplayShowTitleEnabled(true); 73 | actionBar.setTitle(mTitle); 74 | } 75 | 76 | 77 | @Override 78 | public boolean onCreateOptionsMenu(Menu menu) { 79 | if (!mNavigationDrawerFragment.isDrawerOpen()) { 80 | // Only show items in the action bar relevant to this screen 81 | // if the drawer is not showing. Otherwise, let the drawer 82 | // decide what to show in the action bar. 83 | getMenuInflater().inflate(R.menu.main, menu); 84 | restoreActionBar(); 85 | return true; 86 | } 87 | return super.onCreateOptionsMenu(menu); 88 | } 89 | 90 | @Override 91 | public boolean onOptionsItemSelected(MenuItem item) { 92 | // Handle action bar item clicks here. The action bar will 93 | // automatically handle clicks on the Home/Up button, so long 94 | // as you specify a parent activity in AndroidManifest.xml. 95 | int id = item.getItemId(); 96 | if (id == R.id.action_settings) { 97 | return true; 98 | } 99 | return super.onOptionsItemSelected(item); 100 | } 101 | 102 | /** 103 | * A placeholder fragment containing a simple view. 104 | */ 105 | public static class PlaceholderFragment extends Fragment { 106 | /** 107 | * The fragment argument representing the section number for this 108 | * fragment. 109 | */ 110 | private static final String ARG_SECTION_NUMBER = "section_number"; 111 | 112 | /** 113 | * Returns a new instance of this fragment for the given section 114 | * number. 115 | */ 116 | public static PlaceholderFragment newInstance(int sectionNumber) { 117 | PlaceholderFragment fragment = new PlaceholderFragment(); 118 | Bundle args = new Bundle(); 119 | args.putInt(ARG_SECTION_NUMBER, sectionNumber); 120 | fragment.setArguments(args); 121 | return fragment; 122 | } 123 | 124 | public PlaceholderFragment() { 125 | } 126 | 127 | @Override 128 | public View onCreateView(LayoutInflater inflater, ViewGroup container, 129 | Bundle savedInstanceState) { 130 | View rootView = inflater.inflate(R.layout.fragment_main, container, false); 131 | TextView textView = (TextView) rootView.findViewById(R.id.section_label); 132 | textView.setText(Integer.toString(getArguments().getInt(ARG_SECTION_NUMBER))); 133 | return rootView; 134 | } 135 | 136 | @Override 137 | public void onAttach(Activity activity) { 138 | super.onAttach(activity); 139 | ((MainActivity) activity).onSectionAttached( 140 | getArguments().getInt(ARG_SECTION_NUMBER)); 141 | } 142 | } 143 | 144 | } 145 | -------------------------------------------------------------------------------- /marvel-demo/src/main/java/com/trey/marvel/MainApplication.java: -------------------------------------------------------------------------------- 1 | package com.trey.marvel; 2 | 3 | import android.app.Application; 4 | 5 | import com.trey.marvel.model.api.MarvelApi; 6 | import com.trey.marvel.model.api.manager.ComicManager; 7 | import com.trey.marvel.model.api.request.ComicRequest; 8 | import com.trey.marvel.model.api.request.CreatorRequest; 9 | import com.trey.marvel.model.api.request.EventRequest; 10 | import com.trey.marvel.model.api.request.RequestSignature; 11 | import com.trey.marvel.model.api.manager.CharacterManager; 12 | import com.trey.marvel.model.api.request.CharacterRequest; 13 | import com.trey.marvel.model.api.request.SeriesRequest; 14 | import com.trey.marvel.model.api.request.StoryRequest; 15 | import com.trey.marvel.model.api.response.ServiceResponse; 16 | import com.trey.marvel.model.api.vo.Character; 17 | import com.trey.marvel.model.api.vo.Comic; 18 | import com.trey.marvel.model.api.vo.Creator; 19 | import com.trey.marvel.model.api.vo.Event; 20 | import com.trey.marvel.model.api.vo.Series; 21 | import com.trey.marvel.model.api.vo.Story; 22 | 23 | import retrofit.Callback; 24 | import retrofit.RetrofitError; 25 | import retrofit.client.Response; 26 | 27 | 28 | /** 29 | * Created by Trey Robinson on 2/12/14. 30 | */ 31 | public class MainApplication extends Application { 32 | 33 | @Override 34 | public void onCreate() { 35 | super.onCreate(); 36 | 37 | 38 | 39 | MarvelApi.create("YOUR PRIVATE KEY", "YOUR PUBLIC KEY", getApplicationContext(), 5*1024*1024); 40 | 41 | StoryRequest request = new StoryRequest(RequestSignature.create()); 42 | request.setLimit(20); 43 | request.setOffset(0); 44 | 45 | ComicManager client = new ComicManager(); 46 | client.getStoriesForComicId(41530, request, new Callback>() { 47 | @Override 48 | public void success(ServiceResponse characterServiceResponse, Response response) { 49 | 50 | } 51 | 52 | @Override 53 | public void failure(RetrofitError retrofitError) { 54 | 55 | } 56 | }); 57 | // EventRequest request = new EventRequest(RequestSignature.create()); 58 | // request.setLimit(20); 59 | // request.setOffset(0); 60 | 61 | // CharacterManager client = new CharacterManager(); 62 | // client.getEventsForCharacterId(1009521, request, new Callback>() { 63 | // @Override 64 | // public void success(ServiceResponse characterServiceResponse, Response response) { 65 | // 66 | // } 67 | // 68 | // @Override 69 | // public void failure(RetrofitError retrofitError) { 70 | // 71 | // } 72 | // }); 73 | /** 74 | CharacterRequest request = new CharacterRequest(RequestSignature.create()); 75 | request.setLimit(20); 76 | request.setOffset(0); 77 | 78 | CharacterManager client = new CharacterManager(); 79 | client.fetchCharacters(request, new Callback>() { 80 | @Override 81 | public void success(ServiceResponse characterServiceResponse, Response response) { 82 | 83 | } 84 | 85 | @Override 86 | public void failure(RetrofitError retrofitError) { 87 | 88 | } 89 | }); 90 | **/ 91 | /** 92 | CharacterRequest request = new CharacterRequest(RequestSignature.create()); 93 | request.setLimit(20); 94 | request.setOffset(0); 95 | 96 | CharacterManager client = new CharacterManager(); 97 | client.fetchCharacters(request, new Callback>() { 98 | @Override 99 | public void success(ServiceResponse characterServiceResponse, Response response) { 100 | 101 | } 102 | 103 | @Override 104 | public void failure(RetrofitError retrofitError) { 105 | 106 | } 107 | }); 108 | 109 | **/ 110 | // 111 | // EventRequest request = new CharacterRequest(RequestSignature.create()); 112 | // request.setLimit(20); 113 | // request.setOffset(0); 114 | // 115 | // CharacterManager client = new CharacterManager(); 116 | // client.get(1009521, new Callback>() { 117 | // @Override 118 | // public void success(ServiceResponse listCharacterResponse, Response response) { 119 | // ServiceResponse resp = listCharacterResponse; 120 | // 121 | // } 122 | // 123 | // @Override 124 | // public void failure(RetrofitError retrofitError) { 125 | // 126 | // } 127 | // }); 128 | 129 | 130 | /** 131 | ComicRequest request = new ComicRequest(RequestSignature.create()); 132 | request.setLimit(20); 133 | request.setOffset(0); 134 | 135 | CharacterManager client = new CharacterManager(); 136 | client.getComicsForCharacterId(1009521, request, new Callback() { 137 | @Override 138 | public void success(ListComicsResponse listComicsResponse, Response response) { 139 | 140 | 141 | } 142 | 143 | @Override 144 | public void failure(RetrofitError retrofitError) { 145 | 146 | } 147 | }); 148 | 149 | **/ 150 | } 151 | 152 | } 153 | -------------------------------------------------------------------------------- /marvel-demo/src/main/java/com/trey/marvel/NavigationDrawerFragment.java: -------------------------------------------------------------------------------- 1 | package com.trey.marvel; 2 | 3 | 4 | import android.app.Activity; 5 | import android.app.ActionBar; 6 | import android.app.Fragment; 7 | import android.support.v4.app.ActionBarDrawerToggle; 8 | import android.support.v4.view.GravityCompat; 9 | import android.support.v4.widget.DrawerLayout; 10 | import android.content.SharedPreferences; 11 | import android.content.res.Configuration; 12 | import android.os.Bundle; 13 | import android.preference.PreferenceManager; 14 | import android.view.LayoutInflater; 15 | import android.view.Menu; 16 | import android.view.MenuInflater; 17 | import android.view.MenuItem; 18 | import android.view.View; 19 | import android.view.ViewGroup; 20 | import android.widget.AdapterView; 21 | import android.widget.ArrayAdapter; 22 | import android.widget.ListView; 23 | import android.widget.Toast; 24 | 25 | /** 26 | * Fragment used for managing interactions for and presentation of a navigation drawer. 27 | * See the 28 | * design guidelines for a complete explanation of the behaviors implemented here. 29 | */ 30 | public class NavigationDrawerFragment extends Fragment { 31 | 32 | /** 33 | * Remember the position of the selected item. 34 | */ 35 | private static final String STATE_SELECTED_POSITION = "selected_navigation_drawer_position"; 36 | 37 | /** 38 | * Per the design guidelines, you should show the drawer on launch until the user manually 39 | * expands it. This shared preference tracks this. 40 | */ 41 | private static final String PREF_USER_LEARNED_DRAWER = "navigation_drawer_learned"; 42 | 43 | /** 44 | * A pointer to the current callbacks instance (the Activity). 45 | */ 46 | private NavigationDrawerCallbacks mCallbacks; 47 | 48 | /** 49 | * Helper component that ties the action bar to the navigation drawer. 50 | */ 51 | private ActionBarDrawerToggle mDrawerToggle; 52 | 53 | private DrawerLayout mDrawerLayout; 54 | private ListView mDrawerListView; 55 | private View mFragmentContainerView; 56 | 57 | private int mCurrentSelectedPosition = 0; 58 | private boolean mFromSavedInstanceState; 59 | private boolean mUserLearnedDrawer; 60 | 61 | public NavigationDrawerFragment() { 62 | } 63 | 64 | @Override 65 | public void onCreate(Bundle savedInstanceState) { 66 | super.onCreate(savedInstanceState); 67 | 68 | // Read in the flag indicating whether or not the user has demonstrated awareness of the 69 | // drawer. See PREF_USER_LEARNED_DRAWER for details. 70 | SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(getActivity()); 71 | mUserLearnedDrawer = sp.getBoolean(PREF_USER_LEARNED_DRAWER, false); 72 | 73 | if (savedInstanceState != null) { 74 | mCurrentSelectedPosition = savedInstanceState.getInt(STATE_SELECTED_POSITION); 75 | mFromSavedInstanceState = true; 76 | } 77 | 78 | // Select either the default item (0) or the last selected item. 79 | selectItem(mCurrentSelectedPosition); 80 | } 81 | 82 | @Override 83 | public void onActivityCreated (Bundle savedInstanceState) { 84 | super.onActivityCreated(savedInstanceState); 85 | // Indicate that this fragment would like to influence the set of actions in the action bar. 86 | setHasOptionsMenu(true); 87 | } 88 | 89 | @Override 90 | public View onCreateView(LayoutInflater inflater, ViewGroup container, 91 | Bundle savedInstanceState) { 92 | mDrawerListView = (ListView) inflater.inflate( 93 | R.layout.fragment_navigation_drawer, container, false); 94 | mDrawerListView.setOnItemClickListener(new AdapterView.OnItemClickListener() { 95 | @Override 96 | public void onItemClick(AdapterView parent, View view, int position, long id) { 97 | selectItem(position); 98 | } 99 | }); 100 | mDrawerListView.setAdapter(new ArrayAdapter( 101 | getActionBar().getThemedContext(), 102 | android.R.layout.simple_list_item_activated_1, 103 | android.R.id.text1, 104 | new String[]{ 105 | getString(R.string.title_section1), 106 | getString(R.string.title_section2), 107 | getString(R.string.title_section3), 108 | })); 109 | mDrawerListView.setItemChecked(mCurrentSelectedPosition, true); 110 | return mDrawerListView; 111 | } 112 | 113 | public boolean isDrawerOpen() { 114 | return mDrawerLayout != null && mDrawerLayout.isDrawerOpen(mFragmentContainerView); 115 | } 116 | 117 | /** 118 | * Users of this fragment must call this method to set up the navigation drawer interactions. 119 | * 120 | * @param fragmentId The android:id of this fragment in its activity's layout. 121 | * @param drawerLayout The DrawerLayout containing this fragment's UI. 122 | */ 123 | public void setUp(int fragmentId, DrawerLayout drawerLayout) { 124 | mFragmentContainerView = getActivity().findViewById(fragmentId); 125 | mDrawerLayout = drawerLayout; 126 | 127 | // set a custom shadow that overlays the main content when the drawer opens 128 | mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START); 129 | // set up the drawer's list view with items and click listener 130 | 131 | ActionBar actionBar = getActionBar(); 132 | actionBar.setDisplayHomeAsUpEnabled(true); 133 | actionBar.setHomeButtonEnabled(true); 134 | 135 | // ActionBarDrawerToggle ties together the the proper interactions 136 | // between the navigation drawer and the action bar app icon. 137 | mDrawerToggle = new ActionBarDrawerToggle( 138 | getActivity(), /* host Activity */ 139 | mDrawerLayout, /* DrawerLayout object */ 140 | R.drawable.ic_drawer, /* nav drawer image to replace 'Up' caret */ 141 | R.string.navigation_drawer_open, /* "open drawer" description for accessibility */ 142 | R.string.navigation_drawer_close /* "close drawer" description for accessibility */ 143 | ) { 144 | @Override 145 | public void onDrawerClosed(View drawerView) { 146 | super.onDrawerClosed(drawerView); 147 | if (!isAdded()) { 148 | return; 149 | } 150 | 151 | getActivity().invalidateOptionsMenu(); // calls onPrepareOptionsMenu() 152 | } 153 | 154 | @Override 155 | public void onDrawerOpened(View drawerView) { 156 | super.onDrawerOpened(drawerView); 157 | if (!isAdded()) { 158 | return; 159 | } 160 | 161 | if (!mUserLearnedDrawer) { 162 | // The user manually opened the drawer; store this flag to prevent auto-showing 163 | // the navigation drawer automatically in the future. 164 | mUserLearnedDrawer = true; 165 | SharedPreferences sp = PreferenceManager 166 | .getDefaultSharedPreferences(getActivity()); 167 | sp.edit().putBoolean(PREF_USER_LEARNED_DRAWER, true).apply(); 168 | } 169 | 170 | getActivity().invalidateOptionsMenu(); // calls onPrepareOptionsMenu() 171 | } 172 | }; 173 | 174 | // If the user hasn't 'learned' about the drawer, open it to introduce them to the drawer, 175 | // per the navigation drawer design guidelines. 176 | if (!mUserLearnedDrawer && !mFromSavedInstanceState) { 177 | mDrawerLayout.openDrawer(mFragmentContainerView); 178 | } 179 | 180 | // Defer code dependent on restoration of previous instance state. 181 | mDrawerLayout.post(new Runnable() { 182 | @Override 183 | public void run() { 184 | mDrawerToggle.syncState(); 185 | } 186 | }); 187 | 188 | mDrawerLayout.setDrawerListener(mDrawerToggle); 189 | } 190 | 191 | private void selectItem(int position) { 192 | mCurrentSelectedPosition = position; 193 | if (mDrawerListView != null) { 194 | mDrawerListView.setItemChecked(position, true); 195 | } 196 | if (mDrawerLayout != null) { 197 | mDrawerLayout.closeDrawer(mFragmentContainerView); 198 | } 199 | if (mCallbacks != null) { 200 | mCallbacks.onNavigationDrawerItemSelected(position); 201 | } 202 | } 203 | 204 | @Override 205 | public void onAttach(Activity activity) { 206 | super.onAttach(activity); 207 | try { 208 | mCallbacks = (NavigationDrawerCallbacks) activity; 209 | } catch (ClassCastException e) { 210 | throw new ClassCastException("Activity must implement NavigationDrawerCallbacks."); 211 | } 212 | } 213 | 214 | @Override 215 | public void onDetach() { 216 | super.onDetach(); 217 | mCallbacks = null; 218 | } 219 | 220 | @Override 221 | public void onSaveInstanceState(Bundle outState) { 222 | super.onSaveInstanceState(outState); 223 | outState.putInt(STATE_SELECTED_POSITION, mCurrentSelectedPosition); 224 | } 225 | 226 | @Override 227 | public void onConfigurationChanged(Configuration newConfig) { 228 | super.onConfigurationChanged(newConfig); 229 | // Forward the new configuration the drawer toggle component. 230 | mDrawerToggle.onConfigurationChanged(newConfig); 231 | } 232 | 233 | @Override 234 | public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { 235 | // If the drawer is open, show the global app actions in the action bar. See also 236 | // showGlobalContextActionBar, which controls the top-left area of the action bar. 237 | if (mDrawerLayout != null && isDrawerOpen()) { 238 | inflater.inflate(R.menu.global, menu); 239 | showGlobalContextActionBar(); 240 | } 241 | super.onCreateOptionsMenu(menu, inflater); 242 | } 243 | 244 | @Override 245 | public boolean onOptionsItemSelected(MenuItem item) { 246 | if (mDrawerToggle.onOptionsItemSelected(item)) { 247 | return true; 248 | } 249 | 250 | if (item.getItemId() == R.id.action_example) { 251 | Toast.makeText(getActivity(), "Example action.", Toast.LENGTH_SHORT).show(); 252 | return true; 253 | } 254 | 255 | return super.onOptionsItemSelected(item); 256 | } 257 | 258 | /** 259 | * Per the navigation drawer design guidelines, updates the action bar to show the global app 260 | * 'context', rather than just what's in the current screen. 261 | */ 262 | private void showGlobalContextActionBar() { 263 | ActionBar actionBar = getActionBar(); 264 | actionBar.setDisplayShowTitleEnabled(true); 265 | actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD); 266 | actionBar.setTitle(R.string.app_name); 267 | } 268 | 269 | private ActionBar getActionBar() { 270 | return getActivity().getActionBar(); 271 | } 272 | 273 | /** 274 | * Callbacks interface that all activities using this fragment must implement. 275 | */ 276 | public static interface NavigationDrawerCallbacks { 277 | /** 278 | * Called when an item in the navigation drawer is selected. 279 | */ 280 | void onNavigationDrawerItemSelected(int position); 281 | } 282 | } 283 | -------------------------------------------------------------------------------- /marvel-demo/src/main/java/com/trey/marvel/dummy/DummyContent.java: -------------------------------------------------------------------------------- 1 | package com.trey.marvel.dummy; 2 | 3 | import java.util.ArrayList; 4 | import java.util.HashMap; 5 | import java.util.List; 6 | import java.util.Map; 7 | 8 | /** 9 | * Helper class for providing sample content for user interfaces created by 10 | * Android template wizards. 11 | *

12 | * TODO: Replace all uses of this class before publishing your app. 13 | */ 14 | public class DummyContent { 15 | 16 | /** 17 | * An array of sample (dummy) items. 18 | */ 19 | public static List ITEMS = new ArrayList(); 20 | 21 | /** 22 | * A map of sample (dummy) items, by ID. 23 | */ 24 | public static Map ITEM_MAP = new HashMap(); 25 | 26 | static { 27 | // Add 3 sample items. 28 | addItem(new DummyItem("1", "Item 1")); 29 | addItem(new DummyItem("2", "Item 2")); 30 | addItem(new DummyItem("3", "Item 3")); 31 | } 32 | 33 | private static void addItem(DummyItem item) { 34 | ITEMS.add(item); 35 | ITEM_MAP.put(item.id, item); 36 | } 37 | 38 | /** 39 | * A dummy item representing a piece of content. 40 | */ 41 | public static class DummyItem { 42 | public String id; 43 | public String content; 44 | 45 | public DummyItem(String id, String content) { 46 | this.id = id; 47 | this.content = content; 48 | } 49 | 50 | @Override 51 | public String toString() { 52 | return content; 53 | } 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /marvel-demo/src/main/java/com/trey/marvel/fragment/CharacterListFragment.java: -------------------------------------------------------------------------------- 1 | package com.trey.marvel.fragment; 2 | 3 | import android.app.Activity; 4 | import android.os.Bundle; 5 | import android.support.v4.app.Fragment; 6 | import android.view.LayoutInflater; 7 | import android.view.View; 8 | import android.view.ViewGroup; 9 | import android.widget.AbsListView; 10 | import android.widget.AdapterView; 11 | import android.widget.ArrayAdapter; 12 | import android.widget.ListAdapter; 13 | import android.widget.TextView; 14 | 15 | import com.trey.marvel.R; 16 | import com.trey.marvel.dummy.DummyContent; 17 | 18 | /** 19 | * A fragment representing a list of Items. 20 | *

21 | * Large screen devices (such as tablets) are supported by replacing the ListView 22 | * with a GridView. 23 | *

24 | * Activities containing this fragment MUST implement the {@link Callbacks} 25 | * interface. 26 | */ 27 | public class CharacterListFragment extends Fragment implements AbsListView.OnItemClickListener { 28 | 29 | // TODO: Rename parameter arguments, choose names that match 30 | // the fragment initialization parameters, e.g. ARG_ITEM_NUMBER 31 | private static final String ARG_PARAM1 = "param1"; 32 | private static final String ARG_PARAM2 = "param2"; 33 | 34 | // TODO: Rename and change types of parameters 35 | private String mParam1; 36 | private String mParam2; 37 | 38 | private OnFragmentInteractionListener mListener; 39 | 40 | /** 41 | * The fragment's ListView/GridView. 42 | */ 43 | private AbsListView mListView; 44 | 45 | /** 46 | * The Adapter which will be used to populate the ListView/GridView with 47 | * Views. 48 | */ 49 | private ListAdapter mAdapter; 50 | 51 | // TODO: Rename and change types of parameters 52 | public static CharacterListFragment newInstance(String param1, String param2) { 53 | CharacterListFragment fragment = new CharacterListFragment(); 54 | Bundle args = new Bundle(); 55 | args.putString(ARG_PARAM1, param1); 56 | args.putString(ARG_PARAM2, param2); 57 | fragment.setArguments(args); 58 | return fragment; 59 | } 60 | 61 | /** 62 | * Mandatory empty constructor for the fragment manager to instantiate the 63 | * fragment (e.g. upon screen orientation changes). 64 | */ 65 | public CharacterListFragment() { 66 | } 67 | 68 | @Override 69 | public void onCreate(Bundle savedInstanceState) { 70 | super.onCreate(savedInstanceState); 71 | 72 | if (getArguments() != null) { 73 | mParam1 = getArguments().getString(ARG_PARAM1); 74 | mParam2 = getArguments().getString(ARG_PARAM2); 75 | } 76 | 77 | // TODO: Change Adapter to display your content 78 | mAdapter = new ArrayAdapter(getActivity(), 79 | android.R.layout.simple_list_item_1, android.R.id.text1, DummyContent.ITEMS); 80 | } 81 | 82 | @Override 83 | public View onCreateView(LayoutInflater inflater, ViewGroup container, 84 | Bundle savedInstanceState) { 85 | View view = inflater.inflate(R.layout.fragment_characterlistfragment, container, false); 86 | 87 | // Set the adapter 88 | mListView = (AbsListView) view.findViewById(android.R.id.list); 89 | ((AdapterView) mListView).setAdapter(mAdapter); 90 | 91 | // Set OnItemClickListener so we can be notified on item clicks 92 | mListView.setOnItemClickListener(this); 93 | 94 | return view; 95 | } 96 | 97 | @Override 98 | public void onAttach(Activity activity) { 99 | super.onAttach(activity); 100 | try { 101 | mListener = (OnFragmentInteractionListener) activity; 102 | } catch (ClassCastException e) { 103 | throw new ClassCastException(activity.toString() 104 | + " must implement OnFragmentInteractionListener"); 105 | } 106 | } 107 | 108 | @Override 109 | public void onDetach() { 110 | super.onDetach(); 111 | mListener = null; 112 | } 113 | 114 | 115 | @Override 116 | public void onItemClick(AdapterView parent, View view, int position, long id) { 117 | if (null != mListener) { 118 | // Notify the active callbacks interface (the activity, if the 119 | // fragment is attached to one) that an item has been selected. 120 | mListener.onFragmentInteraction(DummyContent.ITEMS.get(position).id); 121 | } 122 | } 123 | 124 | /** 125 | * The default content for this Fragment has a TextView that is shown when 126 | * the list is empty. If you would like to change the text, call this method 127 | * to supply the text it should use. 128 | */ 129 | public void setEmptyText(CharSequence emptyText) { 130 | View emptyView = mListView.getEmptyView(); 131 | 132 | if (emptyText instanceof TextView) { 133 | ((TextView) emptyView).setText(emptyText); 134 | } 135 | } 136 | 137 | /** 138 | * This interface must be implemented by activities that contain this 139 | * fragment to allow an interaction in this fragment to be communicated 140 | * to the activity and potentially other fragments contained in that 141 | * activity. 142 | *

143 | * See the Android Training lesson Communicating with Other Fragments for more information. 146 | */ 147 | public interface OnFragmentInteractionListener { 148 | // TODO: Update argument type and name 149 | public void onFragmentInteraction(String id); 150 | } 151 | 152 | } 153 | -------------------------------------------------------------------------------- /marvel-demo/src/main/res/drawable-hdpi/drawer_shadow.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rdrobinson3/AndroidMarvelAPI/17f068736ee8f04c0673e7f52c32aa3441b2dc8b/marvel-demo/src/main/res/drawable-hdpi/drawer_shadow.9.png -------------------------------------------------------------------------------- /marvel-demo/src/main/res/drawable-hdpi/ic_drawer.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rdrobinson3/AndroidMarvelAPI/17f068736ee8f04c0673e7f52c32aa3441b2dc8b/marvel-demo/src/main/res/drawable-hdpi/ic_drawer.png -------------------------------------------------------------------------------- /marvel-demo/src/main/res/drawable-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rdrobinson3/AndroidMarvelAPI/17f068736ee8f04c0673e7f52c32aa3441b2dc8b/marvel-demo/src/main/res/drawable-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /marvel-demo/src/main/res/drawable-mdpi/drawer_shadow.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rdrobinson3/AndroidMarvelAPI/17f068736ee8f04c0673e7f52c32aa3441b2dc8b/marvel-demo/src/main/res/drawable-mdpi/drawer_shadow.9.png -------------------------------------------------------------------------------- /marvel-demo/src/main/res/drawable-mdpi/ic_drawer.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rdrobinson3/AndroidMarvelAPI/17f068736ee8f04c0673e7f52c32aa3441b2dc8b/marvel-demo/src/main/res/drawable-mdpi/ic_drawer.png -------------------------------------------------------------------------------- /marvel-demo/src/main/res/drawable-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rdrobinson3/AndroidMarvelAPI/17f068736ee8f04c0673e7f52c32aa3441b2dc8b/marvel-demo/src/main/res/drawable-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /marvel-demo/src/main/res/drawable-xhdpi/drawer_shadow.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rdrobinson3/AndroidMarvelAPI/17f068736ee8f04c0673e7f52c32aa3441b2dc8b/marvel-demo/src/main/res/drawable-xhdpi/drawer_shadow.9.png -------------------------------------------------------------------------------- /marvel-demo/src/main/res/drawable-xhdpi/ic_drawer.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rdrobinson3/AndroidMarvelAPI/17f068736ee8f04c0673e7f52c32aa3441b2dc8b/marvel-demo/src/main/res/drawable-xhdpi/ic_drawer.png -------------------------------------------------------------------------------- /marvel-demo/src/main/res/drawable-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rdrobinson3/AndroidMarvelAPI/17f068736ee8f04c0673e7f52c32aa3441b2dc8b/marvel-demo/src/main/res/drawable-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /marvel-demo/src/main/res/drawable-xxhdpi/drawer_shadow.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rdrobinson3/AndroidMarvelAPI/17f068736ee8f04c0673e7f52c32aa3441b2dc8b/marvel-demo/src/main/res/drawable-xxhdpi/drawer_shadow.9.png -------------------------------------------------------------------------------- /marvel-demo/src/main/res/drawable-xxhdpi/ic_drawer.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rdrobinson3/AndroidMarvelAPI/17f068736ee8f04c0673e7f52c32aa3441b2dc8b/marvel-demo/src/main/res/drawable-xxhdpi/ic_drawer.png -------------------------------------------------------------------------------- /marvel-demo/src/main/res/drawable-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rdrobinson3/AndroidMarvelAPI/17f068736ee8f04c0673e7f52c32aa3441b2dc8b/marvel-demo/src/main/res/drawable-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /marvel-demo/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 12 | 16 | 17 | 22 | 24 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /marvel-demo/src/main/res/layout/fragment_characterlistfragment_grid.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 13 | 14 | 19 | 20 | -------------------------------------------------------------------------------- /marvel-demo/src/main/res/layout/fragment_characterlistfragment_list.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 12 | 13 | 18 | 19 | -------------------------------------------------------------------------------- /marvel-demo/src/main/res/layout/fragment_main.xml: -------------------------------------------------------------------------------- 1 | 10 | 11 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /marvel-demo/src/main/res/layout/fragment_navigation_drawer.xml: -------------------------------------------------------------------------------- 1 | 10 | -------------------------------------------------------------------------------- /marvel-demo/src/main/res/layout/generic_list_item.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | 7 | -------------------------------------------------------------------------------- /marvel-demo/src/main/res/menu/global.xml: -------------------------------------------------------------------------------- 1 |

2 | 6 | 7 | -------------------------------------------------------------------------------- /marvel-demo/src/main/res/menu/main.xml: -------------------------------------------------------------------------------- 1 | 4 | 7 | 11 | 12 | -------------------------------------------------------------------------------- /marvel-demo/src/main/res/values-large/refs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 10 | @layout/fragment_characterlistfragment_grid 11 | 12 | -------------------------------------------------------------------------------- /marvel-demo/src/main/res/values-sw600dp/refs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 10 | @layout/fragment_characterlistfragment_grid 11 | 12 | -------------------------------------------------------------------------------- /marvel-demo/src/main/res/values-w820dp/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 64dp 6 | 7 | -------------------------------------------------------------------------------- /marvel-demo/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16dp 4 | 16dp 5 | 6 | 8 | 240dp 9 | 10 | -------------------------------------------------------------------------------- /marvel-demo/src/main/res/values/refs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 10 | @layout/fragment_characterlistfragment_list 11 | 12 | -------------------------------------------------------------------------------- /marvel-demo/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Marvel 5 | Section 1 6 | Section 2 7 | Section 3 8 | Open navigation drawer 9 | Close navigation drawer 10 | Example action 11 | Settings 12 | 13 | 14 | -------------------------------------------------------------------------------- /marvel-demo/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':marvel-demo' 2 | include 'marvel-api' 3 | --------------------------------------------------------------------------------