├── app
├── .gitignore
├── src
│ ├── main
│ │ ├── res
│ │ │ ├── mipmap-hdpi
│ │ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-mdpi
│ │ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-xhdpi
│ │ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-xxhdpi
│ │ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-xxxhdpi
│ │ │ │ └── ic_launcher.png
│ │ │ ├── values
│ │ │ │ ├── colors.xml
│ │ │ │ ├── dimens.xml
│ │ │ │ ├── strings.xml
│ │ │ │ └── styles.xml
│ │ │ ├── values-w820dp
│ │ │ │ └── dimens.xml
│ │ │ └── layout
│ │ │ │ ├── activity_movies.xml
│ │ │ │ ├── activity_toolbar.xml
│ │ │ │ ├── activity_change_background.xml
│ │ │ │ ├── activity_main.xml
│ │ │ │ ├── item_movie.xml
│ │ │ │ └── activity_current_day.xml
│ │ ├── java
│ │ │ └── com
│ │ │ │ └── codepath
│ │ │ │ └── debuggingchallenges
│ │ │ │ ├── activities
│ │ │ │ ├── CurrentDayActivity.java
│ │ │ │ ├── ChangeBackgroundActivity.java
│ │ │ │ ├── ToolbarActivity.java
│ │ │ │ ├── MainActivity.java
│ │ │ │ └── MoviesActivity.java
│ │ │ │ ├── models
│ │ │ │ └── Movie.java
│ │ │ │ └── adapters
│ │ │ │ └── MoviesAdapter.java
│ │ └── AndroidManifest.xml
│ ├── test
│ │ └── java
│ │ │ └── com
│ │ │ └── codepath
│ │ │ └── debuggingchallenges
│ │ │ └── ExampleUnitTest.java
│ └── androidTest
│ │ └── java
│ │ └── com
│ │ └── codepath
│ │ └── debuggingchallenges
│ │ └── ApplicationTest.java
├── proguard-rules.pro
└── build.gradle
├── settings.gradle
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── .travis.yml
├── gradle.properties
├── .gitignore
├── gradlew.bat
└── gradlew
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app'
2 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codepath/android-debugging-challenges/HEAD/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codepath/android-debugging-challenges/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codepath/android-debugging-challenges/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codepath/android-debugging-challenges/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codepath/android-debugging-challenges/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codepath/android-debugging-challenges/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #FF4081
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 16dp
4 | 16dp
5 |
6 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Thu Apr 25 22:56:58 PDT 2019
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-5.1.1-all.zip
7 |
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | language: android
2 | jdk:
3 | - oraclejdk8
4 | sudo: false
5 | android:
6 | components:
7 | - tools
8 | - platform-tools
9 | - build-tools-27.0.3
10 | - android-27
11 | licenses:
12 | - android-sdk-license-.+
13 | script:
14 | - "./gradlew build check --daemon"
15 | after_failure: "cat $TRAVIS_BUILD_DIR/app/build/outputs/lint-results-debug.xml"
16 |
--------------------------------------------------------------------------------
/app/src/main/res/values-w820dp/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 64dp
6 |
7 |
--------------------------------------------------------------------------------
/app/src/test/java/com/codepath/debuggingchallenges/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.codepath.debuggingchallenges;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * To work on unit tests, switch the Test Artifact in the Build Variants view.
9 | */
10 | public class ExampleUnitTest {
11 | @Test
12 | public void addition_isCorrect() throws Exception {
13 | assertEquals(4, 2 + 2);
14 | }
15 | }
--------------------------------------------------------------------------------
/app/src/androidTest/java/com/codepath/debuggingchallenges/ApplicationTest.java:
--------------------------------------------------------------------------------
1 | package com.codepath.debuggingchallenges;
2 |
3 | import android.app.Application;
4 | import android.test.ApplicationTestCase;
5 |
6 | /**
7 | * Testing Fundamentals
8 | */
9 | public class ApplicationTest extends ApplicationTestCase {
10 | public ApplicationTest() {
11 | super(Application.class);
12 | }
13 | }
--------------------------------------------------------------------------------
/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in /Users/nickai/Library/Android/sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
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 | #}
18 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | DebuggingChallenges
3 | What day is it?
4 | Poster Image
5 | View Movies
6 | Rating: %1$.2f
7 | Go
8 | Background Changer
9 | Toolbar
10 | Hello!
11 | Submit
12 | Search
13 | This is a Sample of Really Large Text
14 |
15 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
12 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 28
5 |
6 | defaultConfig {
7 | applicationId "com.codepath.debuggingchallenges"
8 | minSdkVersion 21
9 | targetSdkVersion 28
10 | versionCode 1
11 | versionName "1.0"
12 | }
13 | buildTypes {
14 | release {
15 | minifyEnabled false
16 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
17 | }
18 | }
19 | }
20 |
21 | dependencies {
22 | testImplementation 'junit:junit:4.12'
23 | implementation 'androidx.appcompat:appcompat:1.0.0'
24 | implementation 'androidx.recyclerview:recyclerview:1.0.0'
25 | implementation 'com.codepath.libraries:asynchttpclient:0.0.9'
26 | implementation 'com.github.bumptech.glide:glide:4.8.0'
27 | }
28 |
--------------------------------------------------------------------------------
/app/src/main/java/com/codepath/debuggingchallenges/activities/CurrentDayActivity.java:
--------------------------------------------------------------------------------
1 | package com.codepath.debuggingchallenges.activities;
2 |
3 | import android.os.Bundle;
4 | import androidx.appcompat.app.AppCompatActivity;
5 | import android.widget.TextView;
6 |
7 | import com.codepath.debuggingchallenges.R;
8 |
9 | import java.util.Calendar;
10 |
11 | public class CurrentDayActivity extends AppCompatActivity {
12 |
13 | TextView tvDay;
14 |
15 | @Override
16 | protected void onCreate(Bundle savedInstanceState) {
17 | super.onCreate(savedInstanceState);
18 | setContentView(R.layout.activity_current_day);
19 | tvDay = (TextView) findViewById(R.id.tvDay);
20 | tvDay.setText(getDayOfMonth());
21 | }
22 |
23 | private int getDayOfMonth() {
24 | Calendar cal = Calendar.getInstance();
25 | return cal.get(Calendar.DAY_OF_MONTH);
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_movies.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
19 |
20 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 |
3 | # IDE (e.g. Android Studio) users:
4 | # Gradle settings configured through the IDE *will override*
5 | # any settings specified in this file.
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
19 | android.enableJetifier=true
20 | android.useAndroidX=true
--------------------------------------------------------------------------------
/app/src/main/java/com/codepath/debuggingchallenges/activities/ChangeBackgroundActivity.java:
--------------------------------------------------------------------------------
1 | package com.codepath.debuggingchallenges.activities;
2 |
3 | import android.graphics.Color;
4 | import android.os.Bundle;
5 | import androidx.appcompat.app.AppCompatActivity;
6 | import android.view.View;
7 |
8 | import com.codepath.debuggingchallenges.R;
9 |
10 | public class ChangeBackgroundActivity extends AppCompatActivity {
11 |
12 | private int oldColor = Color.BLUE;
13 |
14 | @Override
15 | protected void onCreate(Bundle savedInstanceState) {
16 | super.onCreate(savedInstanceState);
17 | setContentView(R.layout.activity_change_background);
18 | }
19 |
20 | public void onGoClick(View view) {
21 | View mainView = findViewById(android.R.id.content);
22 | mainView.setBackgroundColor(getNextColor());
23 | }
24 |
25 | private int getNextColor() {
26 | int newColor = (oldColor == Color.BLUE) ? Color.RED : Color.BLUE;
27 | oldColor = newColor;
28 | return newColor;
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/app/src/main/java/com/codepath/debuggingchallenges/activities/ToolbarActivity.java:
--------------------------------------------------------------------------------
1 | package com.codepath.debuggingchallenges.activities;
2 |
3 | import android.os.Bundle;
4 | import androidx.appcompat.app.AppCompatActivity;
5 | import android.widget.TextView;
6 | import android.widget.Toolbar;
7 |
8 | import com.codepath.debuggingchallenges.R;
9 |
10 | public class ToolbarActivity extends AppCompatActivity {
11 |
12 | @Override
13 | protected void onCreate(Bundle savedInstanceState) {
14 | super.onCreate(savedInstanceState);
15 | setContentView(R.layout.activity_toolbar);
16 |
17 | // Find the toolbar view inside the activity layout
18 | Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
19 |
20 | // Sets the Toolbar to act as the ActionBar for this Activity window.
21 | // Make sure the toolbar exists in the activity and is not null
22 | setActionBar(toolbar);
23 |
24 | TextView tvDescription = (TextView) findViewById(R.id.tvDescription);
25 | tvDescription.setText(R.string.hello);
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Source: https://gist.github.com/nesquena/5617544/raw/53710b374e7df3302df43b552488d876040ada3d/.gitignore
2 |
3 | # built application files
4 | *.apk
5 | *.ap_
6 |
7 | # files for the dex VM
8 | *.dex
9 |
10 | # Java class files
11 | *.class
12 |
13 | # generated files
14 | bin/
15 | gen/
16 |
17 | # Local configuration file (sdk path, etc)
18 | local.properties
19 |
20 | # Eclipse project files
21 | .classpath
22 | .project
23 |
24 | # Proguard folder generated by Eclipse
25 | proguard/
26 |
27 | # Intellij project files
28 | *.iml
29 | *.ipr
30 | *.iws
31 | .idea/
32 |
33 | *.pydevproject
34 | .project
35 | .metadata
36 | bin/**
37 | tmp/**
38 | tmp/**/*
39 | *.tmp
40 | *.bak
41 | *.swp
42 | *~.nib
43 | local.properties
44 | .classpath
45 | .settings/
46 | .loadpath
47 |
48 | # External tool builders
49 | .externalToolBuilders/
50 |
51 | # Locally stored "Eclipse launch configurations"
52 | *.launch
53 |
54 | # CDT-specific
55 | .cproject
56 |
57 | # PDT-specific
58 | .buildpath
59 |
60 | # Android Studio project files
61 | *.iml
62 | .gradle
63 | .idea
64 | build
65 | import-summary.txt
66 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_toolbar.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
17 |
18 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/app/src/main/java/com/codepath/debuggingchallenges/activities/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.codepath.debuggingchallenges.activities;
2 |
3 | import android.content.Intent;
4 | import androidx.appcompat.app.AppCompatActivity;
5 | import android.os.Bundle;
6 | import android.view.View;
7 |
8 | import com.codepath.debuggingchallenges.R;
9 |
10 | public class MainActivity extends AppCompatActivity {
11 |
12 | @Override
13 | protected void onCreate(Bundle savedInstanceState) {
14 | super.onCreate(savedInstanceState);
15 | setContentView(R.layout.activity_main);
16 | }
17 |
18 | private void launchActivity(Class klass) {
19 | Intent intent = new Intent(this, klass);
20 | startActivity(intent);
21 | }
22 |
23 | public void launchCurrentDayActivity(View view) {
24 | launchActivity(CurrentDayActivity.class);
25 | }
26 |
27 | public void launchMoviesActivity(View view) {
28 | launchActivity(MoviesActivity.class);
29 | }
30 |
31 | public void launchChangeBackgroundActivity(View view) {
32 | launchActivity(ChangeBackgroundActivity.class);
33 | }
34 |
35 | public void launchToolbarActivity(View view) {
36 | launchActivity(ToolbarActivity.class);
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_change_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
11 |
12 |
20 |
21 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
15 |
16 |
21 |
22 |
27 |
28 |
33 |
34 |
35 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/item_movie.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
12 |
13 |
17 |
18 |
24 |
25 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/app/src/main/java/com/codepath/debuggingchallenges/models/Movie.java:
--------------------------------------------------------------------------------
1 | package com.codepath.debuggingchallenges.models;
2 |
3 | import org.json.JSONArray;
4 | import org.json.JSONException;
5 | import org.json.JSONObject;
6 |
7 | import java.util.ArrayList;
8 |
9 | public class Movie {
10 | private String title;
11 | private String posterUrl;
12 | private double rating;
13 |
14 | public Movie(JSONObject jsonObject) throws JSONException {
15 | this.posterUrl = jsonObject.getString("poster_path");
16 | this.title = jsonObject.getString("original-title");
17 | this.rating = jsonObject.getDouble("vote_average");
18 | }
19 |
20 | public String getTitle() {
21 | return title;
22 | }
23 |
24 | public double getRating() {
25 | return rating;
26 | }
27 |
28 | public String getPosterUrl() {
29 | return String.format("https://image.tmdb.org/t/p/w342/%s", posterUrl);
30 | }
31 |
32 | public static ArrayList fromJSONArray(JSONArray jsonArray) {
33 | ArrayList results = new ArrayList<>();
34 | for (int i = 0; i < jsonArray.length(); i++) {
35 | try {
36 | results.add(new Movie(jsonArray.getJSONObject(i)));
37 | } catch (JSONException e) {
38 | e.printStackTrace();
39 | }
40 | }
41 | return results;
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_current_day.xml:
--------------------------------------------------------------------------------
1 |
2 |
11 |
12 |
21 |
22 |
32 |
33 |
--------------------------------------------------------------------------------
/app/src/main/java/com/codepath/debuggingchallenges/activities/MoviesActivity.java:
--------------------------------------------------------------------------------
1 | package com.codepath.debuggingchallenges.activities;
2 |
3 | import android.os.Bundle;
4 | import android.util.Log;
5 |
6 | import androidx.appcompat.app.AppCompatActivity;
7 | import androidx.recyclerview.widget.RecyclerView;
8 |
9 | import com.codepath.asynchttpclient.AsyncHttpClient;
10 | import com.codepath.asynchttpclient.callback.JsonHttpResponseHandler;
11 | import com.codepath.debuggingchallenges.R;
12 | import com.codepath.debuggingchallenges.adapters.MoviesAdapter;
13 | import com.codepath.debuggingchallenges.models.Movie;
14 |
15 | import org.json.JSONArray;
16 | import org.json.JSONException;
17 |
18 | import java.util.ArrayList;
19 |
20 | import okhttp3.Headers;
21 |
22 | public class MoviesActivity extends AppCompatActivity {
23 |
24 | private static final String API_KEY = "a07e22bc18f5cb106bfe4cc1f83ad8ed";
25 |
26 | RecyclerView rvMovies;
27 | MoviesAdapter adapter;
28 | ArrayList movies;
29 |
30 | @Override
31 | protected void onCreate(Bundle savedInstanceState) {
32 | super.onCreate(savedInstanceState);
33 | setContentView(R.layout.activity_movies);
34 | rvMovies = findViewById(R.id.rvMovies);
35 |
36 | // Create the adapter to convert the array to views
37 | MoviesAdapter adapter = new MoviesAdapter(movies);
38 |
39 | // Attach the adapter to a ListView
40 | rvMovies.setAdapter(adapter);
41 |
42 | fetchMovies();
43 | }
44 |
45 |
46 | private void fetchMovies() {
47 | String url = " https://api.themoviedb.org/3/movie/now_playing?api_key=";
48 | AsyncHttpClient client = new AsyncHttpClient();
49 | client.get(url, null, new JsonHttpResponseHandler() {
50 | @Override
51 | public void onSuccess(int statusCode, Headers headers, JSON response) {
52 | try {
53 | JSONArray moviesJson = response.jsonObject.getJSONArray("results");
54 | movies = Movie.fromJSONArray(moviesJson);
55 | } catch (JSONException e) {
56 | e.printStackTrace();
57 | }
58 | }
59 |
60 | @Override
61 | public void onFailure(int statusCode, Headers headers, String response, Throwable throwable) {
62 | Log.e(MoviesActivity.class.getSimpleName(), "Error retrieving movies: ", throwable);
63 | }
64 | });
65 | }
66 | }
67 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/app/src/main/java/com/codepath/debuggingchallenges/adapters/MoviesAdapter.java:
--------------------------------------------------------------------------------
1 | package com.codepath.debuggingchallenges.adapters;
2 |
3 | import android.content.Context;
4 | import android.content.res.Resources;
5 | import android.graphics.Color;
6 | import androidx.annotation.NonNull;
7 | import androidx.recyclerview.widget.RecyclerView;
8 | import android.view.LayoutInflater;
9 | import android.view.View;
10 | import android.view.ViewGroup;
11 | import android.widget.ImageView;
12 | import android.widget.TextView;
13 |
14 | import com.bumptech.glide.Glide;
15 | import com.codepath.debuggingchallenges.R;
16 | import com.codepath.debuggingchallenges.models.Movie;
17 |
18 | import java.util.List;
19 |
20 | public class MoviesAdapter extends RecyclerView.Adapter {
21 |
22 | private List movies;
23 |
24 | public class ViewHolder extends RecyclerView.ViewHolder {
25 | // only needed because we need to set the background color
26 | View view;
27 |
28 | // Lookup view for data population
29 | TextView tvName;
30 | TextView tvRating;
31 | ImageView ivPoster;
32 |
33 | public ViewHolder(View itemView) {
34 | super(itemView);
35 |
36 | view = itemView;
37 | tvName = itemView.findViewById(R.id.tvTitle);
38 | tvRating = itemView.findViewById(R.id.tvRating);
39 | ivPoster = itemView.findViewById(R.id.ivPoster);
40 | }
41 | }
42 |
43 | public MoviesAdapter(List movies) {
44 | this.movies = movies;
45 | }
46 |
47 | @Override
48 | public int getItemCount() {
49 | return 0;
50 | }
51 |
52 | @NonNull
53 | @Override
54 | public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
55 | Context context = parent.getContext();
56 | LayoutInflater inflater = LayoutInflater.from(context);
57 |
58 | // Inflate the custom layout
59 | View movieView = inflater.inflate(R.layout.item_movie, parent, false);
60 |
61 | // Return a new holder instance
62 | ViewHolder viewHolder = new ViewHolder(movieView);
63 | return viewHolder;
64 | }
65 |
66 | @Override
67 | public void onBindViewHolder(MoviesAdapter.ViewHolder viewHolder, int position) {
68 |
69 | Movie movie = movies.get(position);
70 |
71 | // Populate the data into the template view using the data object
72 | viewHolder.tvName.setText(movie.getTitle());
73 |
74 | Resources resources = viewHolder.tvName.getResources();
75 | double movieRating = movie.getRating();
76 |
77 | if (movieRating > 6) {
78 | viewHolder.view.setBackgroundColor(Color.GREEN);
79 | }
80 |
81 | String ratingText = String.format(resources.getString(R.string.rating), movieRating);
82 | viewHolder.tvRating.setText(ratingText);
83 |
84 | Glide.with(viewHolder.ivPoster.getContext()).load(movie.getPosterUrl()).into(
85 | viewHolder.ivPoster);
86 |
87 | }
88 | }
89 |
--------------------------------------------------------------------------------
/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 | # Attempt to set APP_HOME
46 | # Resolve links: $0 may be a link
47 | PRG="$0"
48 | # Need this for relative symlinks.
49 | while [ -h "$PRG" ] ; do
50 | ls=`ls -ld "$PRG"`
51 | link=`expr "$ls" : '.*-> \(.*\)$'`
52 | if expr "$link" : '/.*' > /dev/null; then
53 | PRG="$link"
54 | else
55 | PRG=`dirname "$PRG"`"/$link"
56 | fi
57 | done
58 | SAVED="`pwd`"
59 | cd "`dirname \"$PRG\"`/" >/dev/null
60 | APP_HOME="`pwd -P`"
61 | cd "$SAVED" >/dev/null
62 |
63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
64 |
65 | # Determine the Java command to use to start the JVM.
66 | if [ -n "$JAVA_HOME" ] ; then
67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
68 | # IBM's JDK on AIX uses strange locations for the executables
69 | JAVACMD="$JAVA_HOME/jre/sh/java"
70 | else
71 | JAVACMD="$JAVA_HOME/bin/java"
72 | fi
73 | if [ ! -x "$JAVACMD" ] ; then
74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
75 |
76 | Please set the JAVA_HOME variable in your environment to match the
77 | location of your Java installation."
78 | fi
79 | else
80 | JAVACMD="java"
81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
82 |
83 | Please set the JAVA_HOME variable in your environment to match the
84 | location of your Java installation."
85 | fi
86 |
87 | # Increase the maximum file descriptors if we can.
88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
89 | MAX_FD_LIMIT=`ulimit -H -n`
90 | if [ $? -eq 0 ] ; then
91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
92 | MAX_FD="$MAX_FD_LIMIT"
93 | fi
94 | ulimit -n $MAX_FD
95 | if [ $? -ne 0 ] ; then
96 | warn "Could not set maximum file descriptor limit: $MAX_FD"
97 | fi
98 | else
99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
100 | fi
101 | fi
102 |
103 | # For Darwin, add options to specify how the application appears in the dock
104 | if $darwin; then
105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
106 | fi
107 |
108 | # For Cygwin, switch paths to Windows format before running java
109 | if $cygwin ; then
110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
112 | JAVACMD=`cygpath --unix "$JAVACMD"`
113 |
114 | # We build the pattern for arguments to be converted via cygpath
115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
116 | SEP=""
117 | for dir in $ROOTDIRSRAW ; do
118 | ROOTDIRS="$ROOTDIRS$SEP$dir"
119 | SEP="|"
120 | done
121 | OURCYGPATTERN="(^($ROOTDIRS))"
122 | # Add a user-defined pattern to the cygpath arguments
123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
125 | fi
126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
127 | i=0
128 | for arg in "$@" ; do
129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
131 |
132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
134 | else
135 | eval `echo args$i`="\"$arg\""
136 | fi
137 | i=$((i+1))
138 | done
139 | case $i in
140 | (0) set -- ;;
141 | (1) set -- "$args0" ;;
142 | (2) set -- "$args0" "$args1" ;;
143 | (3) set -- "$args0" "$args1" "$args2" ;;
144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
150 | esac
151 | fi
152 |
153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
154 | function splitJvmOpts() {
155 | JVM_OPTS=("$@")
156 | }
157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
159 |
160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
161 |
--------------------------------------------------------------------------------