Skip to content

Commit 7d1a00d

Browse files
committedAug 25, 2019
Update w/ AndroidX & AsyncHttpClient
1 parent ee5ab8c commit 7d1a00d

12 files changed

+29
-31
lines changed
 

‎app/build.gradle

+3-4
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,8 @@ android {
2020

2121
dependencies {
2222
testImplementation 'junit:junit:4.12'
23-
implementation 'com.android.support:appcompat-v7:28.0.0'
24-
implementation 'com.android.support:recyclerview-v7:28.0.0'
25-
implementation 'com.loopj.android:android-async-http:1.4.9'
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'
2626
implementation 'com.github.bumptech.glide:glide:4.8.0'
27-
implementation group: 'com.google.guava', name: 'guava', version: '18.0'
2827
}

‎app/src/main/java/com/codepath/debuggingchallenges/activities/ChangeBackgroundActivity.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import android.graphics.Color;
44
import android.os.Bundle;
5-
import android.support.v7.app.AppCompatActivity;
5+
import androidx.appcompat.app.AppCompatActivity;
66
import android.view.View;
77

88
import com.codepath.debuggingchallenges.R;

‎app/src/main/java/com/codepath/debuggingchallenges/activities/CurrentDayActivity.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package com.codepath.debuggingchallenges.activities;
22

33
import android.os.Bundle;
4-
import android.support.v7.app.AppCompatActivity;
4+
import androidx.appcompat.app.AppCompatActivity;
55
import android.widget.TextView;
66

77
import com.codepath.debuggingchallenges.R;

‎app/src/main/java/com/codepath/debuggingchallenges/activities/MainActivity.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package com.codepath.debuggingchallenges.activities;
22

33
import android.content.Intent;
4-
import android.support.v7.app.AppCompatActivity;
4+
import androidx.appcompat.app.AppCompatActivity;
55
import android.os.Bundle;
66
import android.view.View;
77

‎app/src/main/java/com/codepath/debuggingchallenges/activities/MoviesActivity.java

+14-8
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,23 @@
11
package com.codepath.debuggingchallenges.activities;
22

33
import android.os.Bundle;
4-
import android.support.v7.app.AppCompatActivity;
5-
import android.support.v7.widget.RecyclerView;
4+
import android.util.Log;
65

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;
711
import com.codepath.debuggingchallenges.R;
812
import com.codepath.debuggingchallenges.adapters.MoviesAdapter;
913
import com.codepath.debuggingchallenges.models.Movie;
10-
import com.loopj.android.http.AsyncHttpClient;
11-
import com.loopj.android.http.JsonHttpResponseHandler;
1214

1315
import org.json.JSONArray;
1416
import org.json.JSONException;
15-
import org.json.JSONObject;
1617

1718
import java.util.ArrayList;
1819

19-
import cz.msebera.android.httpclient.Header;
20+
import okhttp3.Headers;
2021

2122
public class MoviesActivity extends AppCompatActivity {
2223

@@ -47,14 +48,19 @@ private void fetchMovies() {
4748
AsyncHttpClient client = new AsyncHttpClient();
4849
client.get(url, null, new JsonHttpResponseHandler() {
4950
@Override
50-
public void onSuccess(int statusCode, Header[] headers, JSONObject response) {
51+
public void onSuccess(int statusCode, Headers headers, JSON response) {
5152
try {
52-
JSONArray moviesJson = response.getJSONArray("results");
53+
JSONArray moviesJson = response.jsonObject.getJSONArray("results");
5354
movies = Movie.fromJSONArray(moviesJson);
5455
} catch (JSONException e) {
5556
e.printStackTrace();
5657
}
5758
}
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+
}
5864
});
5965
}
6066
}

‎app/src/main/java/com/codepath/debuggingchallenges/activities/ToolbarActivity.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package com.codepath.debuggingchallenges.activities;
22

33
import android.os.Bundle;
4-
import android.support.v7.app.AppCompatActivity;
4+
import androidx.appcompat.app.AppCompatActivity;
55
import android.widget.TextView;
66
import android.widget.Toolbar;
77

‎app/src/main/java/com/codepath/debuggingchallenges/adapters/MoviesAdapter.java

+2-3
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,11 @@
33
import android.content.Context;
44
import android.content.res.Resources;
55
import android.graphics.Color;
6-
import android.support.annotation.NonNull;
7-
import android.support.v7.widget.RecyclerView;
6+
import androidx.annotation.NonNull;
7+
import androidx.recyclerview.widget.RecyclerView;
88
import android.view.LayoutInflater;
99
import android.view.View;
1010
import android.view.ViewGroup;
11-
import android.widget.ArrayAdapter;
1211
import android.widget.ImageView;
1312
import android.widget.TextView;
1413

‎app/src/main/res/layout/activity_main.xml

-6
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,4 @@
3131
android:text="@string/view_movies"
3232
android:onClick="launchMoviesActivity"/>
3333

34-
<Button
35-
android:layout_width="match_parent"
36-
android:layout_height="wrap_content"
37-
android:text="@string/search_history"
38-
android:onClick="launchSearchHistoryActivity"/>
39-
4034
</LinearLayout>

‎app/src/main/res/layout/activity_movies.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
android:layout_height="match_parent"
77
tools:context=".activities.MoviesActivity">
88

9-
<android.support.v7.widget.RecyclerView
9+
<androidx.recyclerview.widget.RecyclerView
1010
android:id="@+id/rvMovies"
1111
android:layout_width="match_parent"
1212
android:layout_height="match_parent"

‎app/src/main/res/layout/activity_toolbar.xml

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@
1515
android:id="@+id/tvDescription"
1616
android:layout_centerHorizontal="true" />
1717

18-
<android.support.v7.widget.Toolbar
18+
<androidx.appcompat.widget.Toolbar
1919
android:id="@+id/toolbar"
2020
android:minHeight="?attr/actionBarSize"
2121
android:layout_width="match_parent"
2222
android:layout_height="wrap_content"
2323
app:titleTextColor="@android:color/white"
2424
android:background="?attr/colorPrimary">
25-
</android.support.v7.widget.Toolbar>
25+
</androidx.appcompat.widget.Toolbar>
2626

2727
</RelativeLayout>

‎app/src/main/res/values/strings.xml

-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88
<string name="background_changer">Background Changer</string>
99
<string name="toolbar">Toolbar</string>
1010
<string name="hello">Hello!</string>
11-
<string name="search_history">Search History</string>
12-
<string name="share_search_history">Share Search History</string>
1311
<string name="submit">Submit</string>
1412
<string name="search">Search</string>
1513
<string name="this_is_a_sample_of_really_large_text">This is a Sample of Really Large Text</string>

‎gradle.properties

+3-1
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,6 @@
1515
# When configured, Gradle will run in incubating parallel mode.
1616
# This option should only be used with decoupled projects. More details, visit
1717
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
18-
# org.gradle.parallel=true
18+
# org.gradle.parallel=true
19+
android.enableJetifier=true
20+
android.useAndroidX=true

0 commit comments

Comments
 (0)
Please sign in to comment.