Skip to content
This repository has been archived by the owner on Nov 5, 2019. It is now read-only.

Marvel Comics App #2

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions app/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
53 changes: 53 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
apply plugin: 'com.android.application'

android {
compileSdkVersion 23
buildToolsVersion "23.0.2"

defaultConfig {
applicationId "com.unaimasa.marvelcomics"
minSdkVersion 14
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:23.1.1'

// Recycler view
compile 'com.android.support:recyclerview-v7:23.1.1'
// Card View
compile 'com.android.support:cardview-v7:23.1.1'

// Logger libs
compile 'com.github.tony19:logback-android-core:1.1.1-3'
compile 'com.github.tony19:logback-android-classic:1.1.1-3'
compile 'org.slf4j:slf4j-api:1.7.7'

// Commons Lang
compile 'org.apache.commons:commons-lang3:3.4'

// Retrofit 2.0.1
compile 'com.squareup.retrofit2:retrofit:2.0.1'
compile 'com.squareup.retrofit2:converter-gson:2.0.1'

// OkHttp 3.2.0
compile 'com.squareup.okhttp3:okhttp:3.2.0'

// GSON Converter
compile 'com.google.code.gson:gson:2.6.2'

// Universal Image Loader
compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.5'

testCompile 'junit:junit:4.12'
}
17 changes: 17 additions & 0 deletions app/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in /Users/UnaiMasa/Library/Android/sdk/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the proguardFiles
# directive in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

# Add any project specific keep options here:

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.unaimasa.marvelcomics;

import android.app.Application;
import android.test.ApplicationTestCase;

/**
* <a href="http://d.android.com/tools/testing/testing_android.html">Testing Fundamentals</a>
*/
public class ApplicationTest extends ApplicationTestCase<Application> {
public ApplicationTest() {
super(Application.class);
}
}
34 changes: 34 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.unaimasa.marvelcomics">

<uses-permission android:name="android.permission.INTERNET" />

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

<uses-permission android:name="android.permission.CAMERA" />

<uses-feature android:name="android.hardware.camera" />

<uses-feature android:name="android.hardware.camera.autofocus" />

<uses-feature android:name="android.hardware.camera.front" android:required="false" />


<application
android:name=".MarvelComicsApp"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".section.activity.MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>

</manifest>
49 changes: 49 additions & 0 deletions app/src/main/java/com/unaimasa/marvelcomics/Constants.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package com.unaimasa.marvelcomics;

/**
* Created by unai.masa on 13/04/2016.
*/
public class Constants {

public static final String EMPTY_STRING = "";
public static final String HTTP_PATH_SEPARATOR = "/";
public static final String ENDPOINT_PARAM_TEMPLATE = "(.*)";

public interface Config {
boolean DEVELOPER_MODE = true;
}

public interface Errors {
// Incorrect Sintax
int SERVER_400_EXCEPTION = 400;
// Not Authorized
int SERVER_401_EXCEPTION = 401;
// Payment Required
int SERVER_402_EXCEPTION = 402;
// Not Allowed
int SERVER_403_EXCEPTION = 403;
// Not Found
int SERVER_404_EXCEPTION = 404;
// Method Not Allowed
int SERVER_405_EXCEPTION = 405;
// Conflict
int SERVER_409_EXCEPTION = 409;
// Internal Error
int SERVER_500_EXCEPTION = 500;
}

public interface SharedKeys {
// User Information
String COMIC_ID = "marvel_comic_id";
}

public interface Keys {
// URL
String MARVEL_API_URL = "http://gateway.marvel.com/";
// public key
String MARVEL_API_PUBLIC_KEY = "0990cd31700f807b8b54609750af08ad";
// private key
String MARVEL_API_PRIVATE_KEY = "b640c9b82256fbacf06d5e177c21887206d6727c";
}

}
40 changes: 40 additions & 0 deletions app/src/main/java/com/unaimasa/marvelcomics/MarvelComicsApp.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package com.unaimasa.marvelcomics;

import android.app.Application;
import android.content.Context;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.Date;

/**
* Created by UnaiMasa on 13/04/2016.
*/
public class MarvelComicsApp extends Application {

private static final Logger sLogger = LoggerFactory.getLogger(MarvelComicsApp.class);

private static MarvelComicsApp instance;

@Override
public void onCreate() {
super.onCreate();
sLogger.info("Application created - {}", new Date().getTime());
instance = this;
}

public static Context getInstance() {
return instance.getApplicationContext();
}

public static MarvelComicsApp get() {
return instance;
}

@Override
public void onLowMemory() {
super.onLowMemory();
}

}
37 changes: 37 additions & 0 deletions app/src/main/java/com/unaimasa/marvelcomics/base/SingleToast.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package com.unaimasa.marvelcomics.base;

import android.text.TextUtils;
import android.widget.Toast;

import com.unaimasa.marvelcomics.MarvelComicsApp;

import java.util.HashSet;
import java.util.Set;

/**
* Created by unai.masa on 14/10/2015.
*/
public class SingleToast {

private static final Set<CharSequence> sCurrentToasts = new HashSet<>();

private static Toast sInstance = Toast.makeText(MarvelComicsApp.getInstance(), "", Toast.LENGTH_SHORT);

public static void show(CharSequence text, int duration) {
if (sInstance.getView() == null) {
// not initialized somehow - use not single instance approach (e.g. in tests get view is null)
Toast.makeText(MarvelComicsApp.getInstance(), text, duration).show();
return;
}
if (!sInstance.getView().isShown()) {
sCurrentToasts.clear();
}
if (!TextUtils.isEmpty(text) && !sCurrentToasts.contains(text)) {
sCurrentToasts.add(text);
sInstance.setText(text);
sInstance.setDuration(duration);
sInstance.show();
}
}

}
Loading