diff --git a/stetho-sample/build.gradle b/stetho-sample/build.gradle
index 25a3f966..0aac4e75 100644
--- a/stetho-sample/build.gradle
+++ b/stetho-sample/build.gradle
@@ -16,6 +16,11 @@ android {
versionName "1.0"
}
+ compileOptions {
+ sourceCompatibility JavaVersion.VERSION_1_8
+ targetCompatibility JavaVersion.VERSION_1_8
+ }
+
buildTypes {
// release target excludes Stetho for illustration purposes.
// See dependencies for instructions on how Stetho developers
@@ -29,6 +34,8 @@ android {
dependencies {
implementation project(':stetho')
+ implementation project(':stetho-timber')
+ implementation 'com.jakewharton.timber:timber:4.1.2'
implementation project(':stetho-urlconnection')
// Uncomment if you wish to play with the Console evaluation
diff --git a/stetho-sample/src/debug/java/com/facebook/stetho/sample/SampleDebugApplication.java b/stetho-sample/src/debug/java/com/facebook/stetho/sample/SampleDebugApplication.java
index f3e1dec2..13f9fbde 100644
--- a/stetho-sample/src/debug/java/com/facebook/stetho/sample/SampleDebugApplication.java
+++ b/stetho-sample/src/debug/java/com/facebook/stetho/sample/SampleDebugApplication.java
@@ -23,6 +23,9 @@
import com.facebook.stetho.inspector.database.ContentProviderSchema;
import com.facebook.stetho.inspector.database.ContentProviderSchema.Table;
import com.facebook.stetho.inspector.protocol.ChromeDevtoolsDomain;
+import com.facebook.stetho.timber.StethoTree;
+
+import timber.log.Timber;
public class SampleDebugApplication extends SampleApplication {
private static final String TAG = "SampleDebugApplication";
@@ -31,6 +34,7 @@ public class SampleDebugApplication extends SampleApplication {
public void onCreate() {
super.onCreate();
+ Timber.plant(new StethoTree());
long startTime = SystemClock.elapsedRealtime();
initializeStetho(this);
long elapsed = SystemClock.elapsedRealtime() - startTime;
diff --git a/stetho-sample/src/main/java/com/facebook/stetho/sample/MainActivity.java b/stetho-sample/src/main/java/com/facebook/stetho/sample/MainActivity.java
index eb0fef34..0e6b83d8 100644
--- a/stetho-sample/src/main/java/com/facebook/stetho/sample/MainActivity.java
+++ b/stetho-sample/src/main/java/com/facebook/stetho/sample/MainActivity.java
@@ -18,6 +18,8 @@
import android.view.View;
import android.widget.Toast;
+import timber.log.Timber;
+
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
@@ -33,10 +35,25 @@ protected void onCreate(Bundle savedInstanceState) {
.show();
}
- findViewById(R.id.settings_btn).setOnClickListener(mMainButtonClicked);
- findViewById(R.id.apod_btn).setOnClickListener(mMainButtonClicked);
- findViewById(R.id.irc_btn).setOnClickListener(mMainButtonClicked);
- findViewById(R.id.about).setOnClickListener(mMainButtonClicked);
+ findViewById(R.id.log_btn).setOnClickListener(v -> {
+ Timber.i("log button clicked");
+ });
+ findViewById(R.id.settings_btn).setOnClickListener(v -> {
+ SettingsActivity.show(MainActivity.this);
+ });
+ findViewById(R.id.apod_btn).setOnClickListener(v -> {
+ APODActivity.show(MainActivity.this);
+ });
+ findViewById(R.id.irc_btn).setOnClickListener(v -> {
+ IRCConnectActivity.show(MainActivity.this);
+ });
+ findViewById(R.id.about).setOnClickListener(v -> {
+ View view = LayoutInflater.from(MainActivity.this).inflate(R.layout.dialog_layout, null);
+ Dialog dialog = new Dialog(MainActivity.this);
+ dialog.setContentView(view);
+ dialog.setTitle(getString(R.string.app_name));
+ dialog.show();
+ });
}
private static boolean isStethoPresent() {
@@ -64,26 +81,6 @@ private SharedPreferences getPrefs() {
return PreferenceManager.getDefaultSharedPreferences(this /* context */);
}
- private final View.OnClickListener mMainButtonClicked = new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- int id = v.getId();
- if (id == R.id.settings_btn) {
- SettingsActivity.show(MainActivity.this);
- } else if (id == R.id.apod_btn) {
- APODActivity.show(MainActivity.this);
- } else if (id == R.id.irc_btn) {
- IRCConnectActivity.show(MainActivity.this);
- } else if (id == R.id.about) {
- View view = LayoutInflater.from(MainActivity.this).inflate(R.layout.dialog_layout, null);
- Dialog dialog = new Dialog(MainActivity.this);
- dialog.setContentView(view);
- dialog.setTitle(getString(R.string.app_name));
- dialog.show();
- }
- }
- };
-
private final SharedPreferences.OnSharedPreferenceChangeListener mToastingPrefListener =
new SharedPreferences.OnSharedPreferenceChangeListener() {
@Override
diff --git a/stetho-sample/src/main/res/layout/main_activity.xml b/stetho-sample/src/main/res/layout/main_activity.xml
index 113d257f..9a711308 100644
--- a/stetho-sample/src/main/res/layout/main_activity.xml
+++ b/stetho-sample/src/main/res/layout/main_activity.xml
@@ -6,6 +6,14 @@
android:gravity="center_horizontal"
android:padding="15dp">
+
+