-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
*.iml | ||
.gradle | ||
/local.properties | ||
/.idea/caches | ||
/.idea/libraries | ||
/.idea/modules.xml | ||
/.idea/workspace.xml | ||
/.idea/navEditor.xml | ||
/.idea/assetWizardSettings.xml | ||
.DS_Store | ||
/build | ||
/captures | ||
.externalNativeBuild | ||
.cxx | ||
local.properties |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# Flix | ||
Flix is an app that allows users to browse movies from the [The Movie Database API](http://docs.themoviedb.apiary.io/#). | ||
|
||
📝 `NOTE - PASTE PART 2 SNIPPET HERE:` Paste the README template for part 2 of this assignment here at the top. This will show a history of your development process, which users stories you completed and how your app looked and functioned at each step. | ||
|
||
--- | ||
|
||
## Flix Part 1 | ||
|
||
### User Stories | ||
`TODO://` In the **User Stories section below**, add an `x` in the `-[ ]` like this `- [x]` for any user story you complete. (🚫 Remove this paragraph after after checking off completed user stories) | ||
|
||
#### REQUIRED (10pts) | ||
- [x] (10pts) User can view a list of movies (title, poster image, and overview) currently playing in theaters from the Movie Database API. | ||
|
||
#### BONUS | ||
- [x] (2pts) Views should be responsive for both landscape/portrait mode. | ||
- [x] (1pt) In portrait mode, the poster image, title, and movie overview is shown. | ||
- [x] (1pt) In landscape mode, the rotated alternate layout should use the backdrop image instead and show the title and movie overview to the right of it. | ||
|
||
- [] (2pts) Display a nice default [placeholder graphic](https://guides.codepath.org/android/Displaying-Images-with-the-Glide-Library#advanced-usage) for each image during loading | ||
- [x] (2pts) Improved the user interface by experimenting with styling and coloring. | ||
- [ ] (2pts) For popular movies (i.e. a movie voted for more than 5 stars), the full backdrop image is displayed. Otherwise, a poster image, the movie title, and overview is listed. Use Heterogenous RecyclerViews and use different ViewHolder layout files for popular movies and less popular ones. | ||
|
||
### App Walkthough GIF | ||
`TODO://` Add the URL to your animated app walkthough `gif` in the image tag below, `YOUR_GIF_URL_HERE`. Make sure the gif actually renders and animates when viewing this README. (🚫 Remove this paragraph after after adding gif) | ||
|
||
<img src="Screenrecorder-2021-09-03-09-05-59-355_SparkVideo.gif" width=250><br> | ||
|
||
### Notes | ||
Describe any challenges encountered while building the app. | ||
|
||
### Open-source libraries used | ||
|
||
- [Android Async HTTP](https://github.com/codepath/CPAsyncHttpClient) - Simple asynchronous HTTP requests with JSON parsing | ||
- [Glide](https://github.com/bumptech/glide) - Image loading and caching library for Androids |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/build |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
plugins { | ||
id 'com.android.application' | ||
} | ||
|
||
android { | ||
compileSdk 30 | ||
|
||
defaultConfig { | ||
applicationId "com.example.flix" | ||
minSdk 21 | ||
targetSdk 30 | ||
versionCode 1 | ||
versionName "1.0" | ||
|
||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" | ||
} | ||
|
||
buildTypes { | ||
release { | ||
minifyEnabled false | ||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' | ||
} | ||
} | ||
compileOptions { | ||
sourceCompatibility JavaVersion.VERSION_1_8 | ||
targetCompatibility JavaVersion.VERSION_1_8 | ||
} | ||
} | ||
|
||
dependencies { | ||
|
||
implementation 'androidx.appcompat:appcompat:1.3.1' | ||
implementation 'com.google.android.material:material:1.4.0' | ||
implementation 'androidx.constraintlayout:constraintlayout:2.1.0' | ||
implementation files('libs\\YouTubeAndroidPlayerApi.jar') | ||
testImplementation 'junit:junit:4.13.2' | ||
androidTestImplementation 'androidx.test.ext:junit:1.1.3' | ||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0' | ||
implementation 'com.codepath.libraries:asynchttpclient:2.1.1' | ||
implementation 'com.github.bumptech.glide:glide:4.12.0' | ||
// Glide v4 uses this new annotation processor -- see https://bumptech.github.io/glide/doc/generatedapi.html | ||
annotationProcessor 'com.github.bumptech.glide:compiler:4.12.0' | ||
|
||
implementation 'org.parceler:parceler-api:1.1.12' | ||
annotationProcessor 'org.parceler:parceler:1.1.12' | ||
|
||
} |
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 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package com.example.flix; | ||
|
||
import android.content.Context; | ||
|
||
import androidx.test.platform.app.InstrumentationRegistry; | ||
import androidx.test.ext.junit.runners.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() { | ||
// Context of the app under test. | ||
Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext(); | ||
assertEquals("com.example.flix", appContext.getPackageName()); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
package="com.example.flix"> | ||
|
||
<uses-permission android:name="android.permission.INTERNET" /> | ||
|
||
<application | ||
android:allowBackup="true" | ||
android:icon="@mipmap/ic_launcher" | ||
android:label="@string/app_name" | ||
android:roundIcon="@mipmap/ic_launcher_round" | ||
android:supportsRtl="true" | ||
android:theme="@style/Theme.Flix"> | ||
<activity | ||
android:name=".DetailActivity" | ||
android:exported="true" /> | ||
<activity | ||
android:name=".MainActivity" | ||
android:exported="true"> | ||
<intent-filter> | ||
<action android:name="android.intent.action.MAIN" /> | ||
|
||
<category android:name="android.intent.category.LAUNCHER" /> | ||
</intent-filter> | ||
</activity> | ||
</application> | ||
|
||
</manifest> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
package com.example.flix; | ||
|
||
import android.os.Bundle; | ||
import android.util.Log; | ||
import android.widget.RatingBar; | ||
import android.widget.TextView; | ||
|
||
import com.codepath.asynchttpclient.AsyncHttpClient; | ||
import com.codepath.asynchttpclient.callback.JsonHttpResponseHandler; | ||
import com.example.flix.models.Movie; | ||
import com.google.android.youtube.player.YouTubeBaseActivity; | ||
import com.google.android.youtube.player.YouTubeInitializationResult; | ||
import com.google.android.youtube.player.YouTubePlayer; | ||
import com.google.android.youtube.player.YouTubePlayerView; | ||
|
||
import org.json.JSONArray; | ||
import org.json.JSONException; | ||
import org.parceler.Parcels; | ||
|
||
import okhttp3.Headers; | ||
|
||
public class DetailActivity extends YouTubeBaseActivity { | ||
|
||
private static final String YOUTUBE_API_KEY = "AIzaSyAXP0mCvCcGPtZNcBjkLvMeH3oP1hYHDDY"; | ||
public static final String VIDEOS_URL ="https://api.themoviedb.org/3/movie/%d/videos?api_key=a07e22bc18f5cb106bfe4cc1f83ad8ed"; | ||
|
||
TextView tvTitle; | ||
TextView tvOverview; | ||
RatingBar ratingBar; | ||
YouTubePlayerView youTubePlayerView; | ||
|
||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.activity_detail); | ||
|
||
tvTitle = findViewById(R.id.tvTitle); | ||
tvOverview = findViewById(R.id.tvOverview); | ||
ratingBar = findViewById(R.id.ratingBar); | ||
youTubePlayerView = findViewById(R.id.player); | ||
|
||
Movie movie = Parcels.unwrap(getIntent().getParcelableExtra("movie")); | ||
tvTitle.setText(movie.getTitle()); | ||
tvOverview.setText(movie.getOverView()); | ||
ratingBar.setRating((float)movie.getVoteAverage()); | ||
|
||
|
||
AsyncHttpClient client = new AsyncHttpClient(); | ||
client.get(String.format(VIDEOS_URL, movie.getMovieId()), new JsonHttpResponseHandler() { | ||
@Override | ||
public void onSuccess(int statusCode, Headers headers, JSON json) { | ||
|
||
try { | ||
JSONArray results = json.jsonObject.getJSONArray("results"); | ||
if(results.length()==0){ | ||
return; | ||
} | ||
String youtubeKey = results.getJSONObject(0).getString("key"); | ||
Log.d("DetailActivity",youtubeKey); | ||
initializeYoutube(youtubeKey); | ||
|
||
} catch (JSONException e) { | ||
Log.e("DetailActivity", "Failed to parse Json"); | ||
} | ||
} | ||
|
||
@Override | ||
public void onFailure(int statusCode, Headers headers, String response, Throwable throwable) { | ||
|
||
} | ||
}); | ||
|
||
|
||
} | ||
|
||
private void initializeYoutube(final String youtubeKey) { | ||
youTubePlayerView.initialize(YOUTUBE_API_KEY, new YouTubePlayer.OnInitializedListener() { | ||
@Override | ||
public void onInitializationSuccess(YouTubePlayer.Provider provider, YouTubePlayer youTubePlayer, boolean b) { | ||
Log.d("DetailActivity","OnInitializationSuccess"); | ||
youTubePlayer.cueVideo(youtubeKey); | ||
|
||
} | ||
|
||
@Override | ||
public void onInitializationFailure(YouTubePlayer.Provider provider, YouTubeInitializationResult youTubeInitializationResult) { | ||
Log.d("DetailActivity","OnInitializationFailure"); | ||
|
||
} | ||
}); | ||
} | ||
} |