package com.jenzz.appstate.sample;

import android.app.Application;
import android.widget.Toast;
import com.jenzz.appstate.AppState;
import com.jenzz.appstate.AppStateListener;
import com.jenzz.appstate.RxAppState;
import rx.functions.Action1;

import static android.widget.Toast.LENGTH_LONG;
import static com.jenzz.appstate.AppState.BACKGROUND;
import static com.jenzz.appstate.AppState.FOREGROUND;

public class SampleApplication extends Application {

  private RxAppState appState;

  @Override
  public void onCreate() {
    super.onCreate();

    // RX sample
    RxAppState.monitor(this).subscribe(new Action1<AppState>() {
      @Override
      public void call(AppState appState) {
        // Hocus, Pocus, Abracadabra!
      }
    });

    // Callback sample
    appState = RxAppState.create(this)
        .addListener(new SampleAppStateListener())
        .startMonitoring();
  }

  public RxAppState getAppState() {
    return appState;
  }

  private class SampleAppStateListener implements AppStateListener {

    @Override
    public void onAppDidEnterForeground() {
      Toast.makeText(SampleApplication.this, "RxAppState: " + FOREGROUND, LENGTH_LONG).show();
    }

    @Override
    public void onAppDidEnterBackground() {
      Toast.makeText(SampleApplication.this, "RxAppState: " + BACKGROUND, LENGTH_LONG).show();
    }
  }
}
@@ -61,16 +61,41 @@
 cation;%0A
+import android.util.Log;%0A
 import a
@@ -115,16 +115,17 @@
 .Toast;%0A
+%0A
 import c
@@ -230,24 +230,25 @@
 RxAppState;%0A
+%0A
 import rx.fu
@@ -476,16 +476,67 @@
 tion %7B%0A%0A
+  private static final String TAG = %22RxAppState%22;%0A%0A
   privat
@@ -1164,164 +1164,225 @@
     
-Toast.makeText(SampleApplication.this, %22RxAppState: %22 + FOREGROUND, LENGTH_LONG).show();%0A    %7D%0A%0A    @Override%0A    public void onAppDidEnterBackground() %7B%0A  
+logAndToast(FOREGROUND);%0A    %7D%0A%0A    @Override%0A    public void onAppDidEnterBackground() %7B%0A      logAndToast(BACKGROUND);%0A    %7D%0A  %7D%0A%0A  private void logAndToast(AppState appState) %7B%0A    Log.d(TAG, appState.toString());%0A
     
@@ -1424,35 +1424,29 @@
 is, 
-%22RxAppState: %22 + BACKGROUND
+TAG + %22: %22 + appState
 , LE
@@ -1464,19 +1464,13 @@
 show();%0A
-    %7D%0A
   %7D%0A%7D

Add logging for app state changes