Skip to content

Commit 7101dc3

Browse files
committed
Add Stetho to monitoring
1 parent 283bea8 commit 7101dc3

File tree

5 files changed

+22
-2
lines changed

5 files changed

+22
-2
lines changed

example/src/main/AndroidManifest.xml

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
android:label="@string/app_name"
1111
android:roundIcon="@mipmap/ic_launcher_round"
1212
android:supportsRtl="true"
13+
android:name="TestApplication"
1314
android:theme="@style/AppTheme">
1415
<activity android:name="com.codepath.example.TestActivity">
1516
<intent-filter>

example/src/main/java/com/codepath/example/TestActivity.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public void onFailure(int statusCode, @Nullable Headers headers, String errorRes
4545
client.get("https://api.thecatapi.com/v1/images/search", params, new JsonHttpResponseHandler() {
4646
@Override
4747
public void onSuccess(int statusCode, Headers headers, JSON json) {
48-
Log.d("DEBUG", json.toString());
48+
Log.d("DEBUG", json.jsonArray.toString());
4949

5050
}
5151

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package com.codepath.example;
2+
3+
import android.app.Application;
4+
5+
import com.facebook.stetho.Stetho;
6+
7+
public class TestApplication extends Application {
8+
9+
@Override
10+
public void onCreate() {
11+
super.onCreate();
12+
Stetho.initializeWithDefaults(this);
13+
}
14+
}

library/build.gradle

+1
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ dependencies {
4444

4545
implementation 'androidx.appcompat:appcompat:1.0.2'
4646
api "com.squareup.okhttp3:okhttp:4.0.1"
47+
api 'com.facebook.stetho:stetho-okhttp3:1.5.1'
4748

4849
testImplementation 'junit:junit:4.12'
4950
androidTestImplementation 'androidx.test:runner:1.2.0'

library/src/main/java/com/codepath/asynchttpclient/AsyncHttpClient.java

+5-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
import androidx.annotation.Nullable;
44

5+
import com.facebook.stetho.okhttp3.StethoInterceptor;
6+
57
import java.io.File;
68
import java.util.Map;
79

@@ -19,7 +21,9 @@ public class AsyncHttpClient {
1921
public static MediaType MEDIA_TYPE_JSON = MediaType.parse("application/json");
2022

2123
public AsyncHttpClient() {
22-
okHttpClient = new OkHttpClient.Builder().build();
24+
okHttpClient = new OkHttpClient.Builder()
25+
.addNetworkInterceptor(new StethoInterceptor())
26+
.build();
2327
}
2428

2529
public AsyncHttpClient(OkHttpClient client) {

0 commit comments

Comments
 (0)