package org.spurint.android.viewcontroller;

import android.app.Activity;
import android.view.LayoutInflater;
import android.view.View;

public abstract class ViewController
{
    private final int layoutId;
    private final Activity activity;
    private final View contentView;
    
    private NavigationController navigationController;
    
    public ViewController(Activity activity, int layoutId)
    {
        if (activity == null)
            throw new IllegalArgumentException("Activity cannot be null");
        if (layoutId == 0)
            throw new IllegalArgumentException("Layout ID cannot be 0");
        
        this.activity = activity;
        this.layoutId = layoutId;
        
        this.contentView = LayoutInflater.from(activity).inflate(this.layoutId, null);
    }
    
    public void attachContentView()
    {
        activity.setContentView(contentView);
    }

    protected void _setNavigationController(NavigationController navigationController)
    {
        this.navigationController = navigationController;
    }
    
    protected NavigationController getNavigationController()
    {
        return navigationController;
    }

    protected int getLayoutId()
    {
        return layoutId;
    }

    protected Activity getActivity()
    {
        return activity;
    }

    protected View getContentView()
    {
        return contentView;
    }
}

@@ -130,16 +130,376 @@
 .View;%0A%0A
+/*%0A * TODO:%0A * * Need to use a weak-key/weak-value version of WeakHashMap to keep track%0A *   of Activity-%3EViewController pairs so we know which VC is the active one%0A *   on the Activity.  That way I can fire off the appear/disappear callbacks%0A *   properly.  With a regular WeakHashMap we'll retain the Activity instances%0A *   and they'll never get GC'd.%0A */%0A%0A
 public a
@@ -1187,32 +1187,60 @@
 entView()%0A    %7B%0A
+        onViewWillAppear();%0A
         activity
@@ -1268,24 +1268,225 @@
 ntView);%0A   
+     onViewAppeared();%0A    %7D%0A%0A    protected void onViewWillAppear() %7B %7D%0A    protected void onViewAppeared() %7B %7D%0A    //protected void onViewWillDisappear() %7B %7D%0A    //protected void onViewDisappeared() %7B
  %7D%0A%0A    prot

add onViewWillAppear()/onViewAppeard() notifiers to ViewController