-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit c09417d
Showing
60 changed files
with
2,003 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
# Built application files | ||
*.apk | ||
*.ap_ | ||
|
||
# Files for the ART/Dalvik VM | ||
*.dex | ||
|
||
# Java class files | ||
*.class | ||
|
||
# Generated files | ||
bin/ | ||
gen/ | ||
out/ | ||
|
||
# Gradle files | ||
.gradle/ | ||
build/ | ||
|
||
# Local configuration file (sdk path, etc) | ||
local.properties | ||
|
||
# Proguard folder generated by Eclipse | ||
proguard/ | ||
|
||
# Log Files | ||
*.log | ||
|
||
# Android Studio Navigation editor temp files | ||
.navigation/ | ||
|
||
# Android Studio captures folder | ||
captures/ | ||
|
||
# Intellij | ||
*.iml | ||
.idea/workspace.xml | ||
.idea/tasks.xml | ||
.idea/gradle.xml | ||
.idea/dictionaries | ||
.idea/libraries | ||
|
||
# Keystore files | ||
*.jks | ||
|
||
# External native build folder generated in Android Studio 2.2 and later | ||
.externalNativeBuild | ||
|
||
# Google Services (e.g. APIs or Firebase) | ||
google-services.json | ||
|
||
# Freeline | ||
freeline.py | ||
freeline/ | ||
freeline_project_description.json |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# PopularMovies | ||
Udacity Nanodegree project |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
apply plugin: 'com.android.application' | ||
|
||
android { | ||
compileSdkVersion 27 | ||
buildToolsVersion '27.0.3' | ||
defaultConfig { | ||
applicationId "miki.inc.com.popularmovies" | ||
minSdkVersion 15 | ||
targetSdkVersion 27 | ||
versionCode 1 | ||
versionName "1.0" | ||
buildConfigField "String", "MOVIEDB_API", '"API_KEY"' | ||
vectorDrawables.useSupportLibrary = true | ||
} | ||
buildTypes { | ||
release { | ||
minifyEnabled false | ||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' | ||
} | ||
} | ||
} | ||
|
||
dependencies { | ||
testCompile 'junit:junit:4.12' | ||
compile 'com.android.support:appcompat-v7:27.1.0' | ||
compile 'com.android.support:design:27.1.0' | ||
compile 'com.android.support:recyclerview-v7:27.1.0' | ||
compile 'com.android.support:cardview-v7:27.1.0' | ||
compile "com.android.support:support-vector-drawable:27.1.0" | ||
compile 'com.google.code.gson:gson:2.8.0' | ||
compile 'com.android.volley:volley:1.0.0' | ||
compile 'com.squareup.okhttp:okhttp-urlconnection:2.7.5' | ||
compile 'com.facebook.fresco:fresco:1.8.1' | ||
compile 'com.afollestad.material-dialogs:core:0.8.5.9' | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Add project specific ProGuard rules here. | ||
# You can control the set of applied configuration files using the | ||
# proguardFiles setting in build.gradle. | ||
# | ||
# For more details, see | ||
# http://developer.android.com/guide/developing/tools/proguard.html | ||
|
||
# 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 *; | ||
#} | ||
|
||
# Uncomment this to preserve the line number information for | ||
# debugging stack traces. | ||
#-keepattributes SourceFile,LineNumberTable | ||
|
||
# If you keep the line number information, uncomment this to | ||
# hide the original source file name. | ||
#-renamesourcefileattribute SourceFile |
26 changes: 26 additions & 0 deletions
26
app/src/androidTest/java/miki/inc/com/popularmovies/ExampleInstrumentedTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package miki.inc.com.popularmovies; | ||
|
||
import android.content.Context; | ||
import android.support.test.InstrumentationRegistry; | ||
import android.support.test.runner.AndroidJUnit4; | ||
|
||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
|
||
import static org.junit.Assert.*; | ||
|
||
/** | ||
* Instrumented test, which will execute on an Android device. | ||
* | ||
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a> | ||
*/ | ||
@RunWith(AndroidJUnit4.class) | ||
public class ExampleInstrumentedTest { | ||
@Test | ||
public void useAppContext() throws Exception { | ||
// Context of the app under test. | ||
Context appContext = InstrumentationRegistry.getTargetContext(); | ||
|
||
assertEquals("miki.inc.com.popularmovies", appContext.getPackageName()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
package="miki.inc.com.popularmovies"> | ||
|
||
<uses-permission android:name="android.permission.INTERNET" /> | ||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> | ||
|
||
<application | ||
android:name=".PopularMoviesApplication" | ||
android:allowBackup="true" | ||
android:icon="@mipmap/ic_launcher" | ||
android:label="@string/app_name" | ||
android:supportsRtl="true" | ||
android:theme="@style/AppTheme"> | ||
|
||
<activity | ||
android:name=".ui.activities.HomeActivity" | ||
android:label="@string/app_name" | ||
android:theme="@style/AppTheme.NoActionBar"> | ||
<intent-filter> | ||
<action android:name="android.intent.action.MAIN" /> | ||
|
||
<category android:name="android.intent.category.LAUNCHER" /> | ||
</intent-filter> | ||
</activity> | ||
<activity | ||
android:name=".ui.activities.MoviesDetailsActivity" | ||
android:label="@string/title_activity_movies_details" | ||
android:theme="@style/AppTheme.NoActionBar"/> | ||
</application> | ||
</manifest> |
46 changes: 46 additions & 0 deletions
46
app/src/main/java/miki/inc/com/popularmovies/PopularMoviesApplication.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package miki.inc.com.popularmovies; | ||
|
||
import android.app.Application; | ||
|
||
import com.android.volley.Request; | ||
import com.android.volley.RequestQueue; | ||
import com.android.volley.toolbox.Volley; | ||
import com.facebook.drawee.backends.pipeline.Fresco; | ||
import miki.inc.com.popularmovies.core.OkHttpStack; | ||
|
||
/** | ||
* Created by MIKI on 02-03-2018. | ||
*/ | ||
public class PopularMoviesApplication extends Application { | ||
|
||
public static final String TAG = PopularMoviesApplication.class.getSimpleName(); | ||
|
||
private static PopularMoviesApplication _instance; | ||
private RequestQueue mRequestQueue; | ||
|
||
|
||
@Override | ||
public void onCreate() { | ||
super.onCreate(); | ||
|
||
Fresco.initialize(this); | ||
|
||
_instance = this; | ||
} | ||
|
||
public static PopularMoviesApplication getInstance() { | ||
return _instance; | ||
} | ||
|
||
public RequestQueue getRequestQueue() { | ||
if (mRequestQueue == null) { | ||
mRequestQueue = Volley.newRequestQueue(getApplicationContext(), new OkHttpStack()); | ||
} | ||
return mRequestQueue; | ||
} | ||
|
||
public <T> void addToRequestQueue(Request<T> req) { | ||
req.setTag(TAG); | ||
getRequestQueue().add(req); | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
app/src/main/java/miki/inc/com/popularmovies/api/ApiEndpoints.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package miki.inc.com.popularmovies.api; | ||
|
||
/** | ||
* Created by MIKI on 03-03-2018. | ||
*/ | ||
public class ApiEndpoints { | ||
|
||
private static final String BASE_URL = "http://api.themoviedb.org/3/"; | ||
|
||
public static final String MOVIES_POPULAR = BASE_URL + "movie/popular"; | ||
public static final String MOVIES_TOP_RATED = BASE_URL + "movie/top_rated"; | ||
|
||
} |
70 changes: 70 additions & 0 deletions
70
app/src/main/java/miki/inc/com/popularmovies/core/BaseRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
package miki.inc.com.popularmovies.core; | ||
|
||
import com.android.volley.AuthFailureError; | ||
import com.android.volley.DefaultRetryPolicy; | ||
import com.android.volley.NetworkResponse; | ||
import com.android.volley.Request; | ||
import com.android.volley.Response; | ||
import com.android.volley.toolbox.HttpHeaderParser; | ||
import com.google.gson.Gson; | ||
import com.google.gson.GsonBuilder; | ||
import com.google.gson.reflect.TypeToken; | ||
; | ||
|
||
import java.io.UnsupportedEncodingException; | ||
import java.util.Map; | ||
|
||
/** | ||
* Created by MIKI on 02-03-2018. | ||
*/ | ||
public class BaseRequest<T> extends Request<T> { | ||
|
||
private GsonBuilder gsonBuilder = new GsonBuilder().setDateFormat("yyyy-MM-dd HH:mm:ss"); | ||
|
||
private Map<String, String> params; | ||
private Map<String, String> headers; | ||
private ResponseListener<T> listener; | ||
private TypeToken<T> typeToken; | ||
private Gson gson = gsonBuilder.create(); | ||
|
||
public BaseRequest(int method, String url, Map<String, String> headers, Map<String, String> params, TypeToken<T> typeToken, ResponseListener<T> listener) { | ||
super(method, url, listener); | ||
this.headers = headers; | ||
this.params = params; | ||
this.typeToken = typeToken; | ||
this.listener = listener; | ||
|
||
setRetryPolicy(new DefaultRetryPolicy(5000, 0, DefaultRetryPolicy.DEFAULT_BACKOFF_MULT)); | ||
} | ||
|
||
@Override | ||
protected Response<T> parseNetworkResponse(NetworkResponse networkResponse) { | ||
try { | ||
String jsonResponse = new String(networkResponse.data, | ||
HttpHeaderParser.parseCharset(networkResponse.headers)); | ||
T response = gson.fromJson(jsonResponse, typeToken.getType()); | ||
return Response.success(response, HttpHeaderParser.parseCacheHeaders(networkResponse)); | ||
} catch (UnsupportedEncodingException e) { | ||
e.printStackTrace(); | ||
} | ||
|
||
return null; | ||
} | ||
|
||
@Override | ||
protected void deliverResponse(T t) { | ||
if(listener != null) { | ||
listener.onResponse(t); | ||
} | ||
} | ||
|
||
@Override | ||
protected Map<String, String> getParams() throws AuthFailureError { | ||
return params; | ||
} | ||
|
||
@Override | ||
public Map<String, String> getHeaders() throws AuthFailureError { | ||
return headers != null ? headers : super.getHeaders(); | ||
} | ||
} |
Oops, something went wrong.