package me.mattlogan.pancakes;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.ViewGroup;

import me.mattlogan.library.StackChangedListener;
import me.mattlogan.library.ViewStack;
import me.mattlogan.library.ViewStackDelegate;

public class MainActivity extends AppCompatActivity
        implements ViewStackActivity, ViewStackDelegate {

    private static final String STACK_TAG = "stack";

    private ViewStack viewStack;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        viewStack = ViewStack.create((ViewGroup) findViewById(R.id.container), this);

        viewStack.addStackChangedListener(new StackChangedListener() {
            @Override public void onViewAdded() {
                Log.d("testing", "MainActivity onViewAdded");
            }
        });

        if (savedInstanceState != null) {
            viewStack.rebuildFromBundle(savedInstanceState, STACK_TAG);
        } else {
            viewStack.push(R.layout.view_red);
        }
    }

    @Override
    public void onSaveInstanceState(Bundle outState) {
        viewStack.saveToBundle(outState, STACK_TAG);
        super.onSaveInstanceState(outState);
        Log.d("testing", "MainActivity onSaveInstanceState bundle:" + outState);
    }

    @Override
    public void onBackPressed() {
        viewStack.pop();
    }

    @Override
    public ViewStack viewStack() {
        return viewStack;
    }

    @Override
    public void finishStack() {
        Log.d("testing", "finishStack");
        finish();
    }
}

@@ -125,16 +125,42 @@
 il.Log;%0A
+import android.view.View;%0A
 import a
@@ -862,16 +862,28 @@
 Override
+%0A           
  public 
@@ -899,16 +899,25 @@
 ewAdded(
+View view
 ) %7B%0A    
@@ -983,24 +983,167 @@
            %7D
+%0A%0A            @Override%0A            public void onViewRemoved() %7B%0A                Log.d(%22testing%22, %22MainActivity onViewRemoved%22);%0A            %7D
 %0A        %7D);

Update sample app