Skip to content

Commit 7d1a00d

Browse files
committed
Update w/ AndroidX & AsyncHttpClient
1 parent ee5ab8c commit 7d1a00d

File tree

12 files changed

+29
-31
lines changed

12 files changed

+29
-31
lines changed

app/build.gradle

Lines changed: 3 additions & 4 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 14 additions & 8 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 2 additions & 3 deletions
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

Lines changed: 0 additions & 6 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 2 additions & 2 deletions
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>

0 commit comments

Comments
 (0)