Skip to content

Update w/ AndroidX & AsyncHttpClient #3

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 25, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,8 @@ android {

dependencies {
testImplementation 'junit:junit:4.12'
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:recyclerview-v7:28.0.0'
implementation 'com.loopj.android:android-async-http:1.4.9'
implementation 'androidx.appcompat:appcompat:1.0.0'
implementation 'androidx.recyclerview:recyclerview:1.0.0'
implementation 'com.codepath.libraries:asynchttpclient:0.0.9'
implementation 'com.github.bumptech.glide:glide:4.8.0'
implementation group: 'com.google.guava', name: 'guava', version: '18.0'
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this seems unused and I don't recall Guava being needed during implementation.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I remember being confused by it..

}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import android.graphics.Color;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import androidx.appcompat.app.AppCompatActivity;
import android.view.View;

import com.codepath.debuggingchallenges.R;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.codepath.debuggingchallenges.activities;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import androidx.appcompat.app.AppCompatActivity;
import android.widget.TextView;

import com.codepath.debuggingchallenges.R;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.codepath.debuggingchallenges.activities;

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
package com.codepath.debuggingchallenges.activities;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.RecyclerView;
import android.util.Log;

import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.RecyclerView;

import com.codepath.asynchttpclient.AsyncHttpClient;
import com.codepath.asynchttpclient.callback.JsonHttpResponseHandler;
import com.codepath.debuggingchallenges.R;
import com.codepath.debuggingchallenges.adapters.MoviesAdapter;
import com.codepath.debuggingchallenges.models.Movie;
import com.loopj.android.http.AsyncHttpClient;
import com.loopj.android.http.JsonHttpResponseHandler;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import java.util.ArrayList;

import cz.msebera.android.httpclient.Header;
import okhttp3.Headers;

public class MoviesActivity extends AppCompatActivity {

Expand Down Expand Up @@ -47,14 +48,19 @@ private void fetchMovies() {
AsyncHttpClient client = new AsyncHttpClient();
client.get(url, null, new JsonHttpResponseHandler() {
@Override
public void onSuccess(int statusCode, Header[] headers, JSONObject response) {
public void onSuccess(int statusCode, Headers headers, JSON response) {
try {
JSONArray moviesJson = response.getJSONArray("results");
JSONArray moviesJson = response.jsonObject.getJSONArray("results");
movies = Movie.fromJSONArray(moviesJson);
} catch (JSONException e) {
e.printStackTrace();
}
}

@Override
public void onFailure(int statusCode, Headers headers, String response, Throwable throwable) {
Log.e(MoviesActivity.class.getSimpleName(), "Error retrieving movies: ", throwable);
}
});
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.codepath.debuggingchallenges.activities;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import androidx.appcompat.app.AppCompatActivity;
import android.widget.TextView;
import android.widget.Toolbar;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@
import android.content.Context;
import android.content.res.Resources;
import android.graphics.Color;
import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;

Expand Down
6 changes: 0 additions & 6 deletions app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,4 @@
android:text="@string/view_movies"
android:onClick="launchMoviesActivity"/>

<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/search_history"
android:onClick="launchSearchHistoryActivity"/>
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

some legacy redundancy 😅 There is no search history activity in the app and lab doesn't mention it. I deleted it to avoid further confusion.


</LinearLayout>
2 changes: 1 addition & 1 deletion app/src/main/res/layout/activity_movies.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
android:layout_height="match_parent"
tools:context=".activities.MoviesActivity">

<android.support.v7.widget.RecyclerView
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rvMovies"
android:layout_width="match_parent"
android:layout_height="match_parent"
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/res/layout/activity_toolbar.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@
android:id="@+id/tvDescription"
android:layout_centerHorizontal="true" />

<android.support.v7.widget.Toolbar
<androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar"
android:minHeight="?attr/actionBarSize"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:titleTextColor="@android:color/white"
android:background="?attr/colorPrimary">
</android.support.v7.widget.Toolbar>
</androidx.appcompat.widget.Toolbar>

</RelativeLayout>
2 changes: 0 additions & 2 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
<string name="background_changer">Background Changer</string>
<string name="toolbar">Toolbar</string>
<string name="hello">Hello!</string>
<string name="search_history">Search History</string>
<string name="share_search_history">Share Search History</string>
<string name="submit">Submit</string>
<string name="search">Search</string>
<string name="this_is_a_sample_of_really_large_text">This is a Sample of Really Large Text</string>
Expand Down
4 changes: 3 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,6 @@
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
# org.gradle.parallel=true
android.enableJetifier=true
android.useAndroidX=true