/*******************************************************************************
 *
 * Copyright (c) 2012 Oliver Bley. All rights reserved.
 *
 * This program and the accompanying materials are made
 * available under the terms of the GNU Public License v3
 * which is available at http://www.gnu.org/licenses/
 *
 *******************************************************************************/
package org.fourbit.stuffeverywhere;

import org.fourbit.stuffeverywhere.callbacks.OnPreviewAvailableFitViewSize;
import org.fourbit.stuffeverywhere.callbacks.OnPreviewAvailableIfStartedHideView;
import org.fourbit.stuffeverywhere.callbacks.OnPreviewAvailableMakeViewCameraTrigger;
import org.fourbit.stuffeverywhere.callbacks.OnSurfaceCreatedMakeCameraPreviewable;

import android.graphics.PixelFormat;
import android.hardware.Camera;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.view.LayoutInflater;
import android.view.SurfaceHolder;
import android.view.SurfaceView;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

public class StuffEverywhereActivity extends FragmentActivity {

    public static class TagsFragment extends Fragment {

        @Override
        public View onCreateView(LayoutInflater inflater, ViewGroup container,
                Bundle savedInstanceState) {
            View view = inflater.inflate(R.layout.tags_fragment, container, false);
            return view;
        }
    }

    SurfaceView mSurfaceView;
    TextView mTextViewHint;

    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        mSurfaceView = (SurfaceView) findViewById(R.id.surfaceView1);
        mTextViewHint = (TextView) findViewById(R.id.textView1);

        final Camera.PictureCallback cameraPictureCallback = new Camera.PictureCallback() {

            @Override
            public void onPictureTaken(byte[] imageData, Camera camera) {
                FragmentManager fragmentManager = getSupportFragmentManager();
                FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction()
                        .replace(R.id.bottom_frame, new TagsFragment())
                        .setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN)
                        .addToBackStack(null);
                fragmentTransaction.commit();
            }
        };

        mSurfaceView.getHolder().setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
        mSurfaceView.getHolder().setFormat(PixelFormat.TRANSPARENT);
        mSurfaceView.getHolder().addCallback(
                new OnSurfaceCreatedMakeCameraPreviewable(Camera.class,
                        new OnPreviewAvailableIfStartedHideView(mTextViewHint),
                        new OnPreviewAvailableFitViewSize(mSurfaceView),
                        new OnPreviewAvailableMakeViewCameraTrigger(mSurfaceView,
                                cameraPictureCallback)));
    }
}
@@ -1678,16 +1678,45 @@
 iewHint;
+%0A    byte%5B%5D currentImageData;
 %0A%0A    /*
@@ -2236,24 +2236,191 @@
 a camera) %7B%0A
+                /** Show tags fragment if nothing is captured */%0A                if (currentImageData == null) %7B%0A                    currentImageData = imageData;%0A    
             
@@ -2494,32 +2494,36 @@
                 
+    
 FragmentTransact
@@ -2607,16 +2607,20 @@
         
+   
+ 
 .replace
@@ -2659,16 +2659,20 @@
 ment())%0A
+    
         
@@ -2769,16 +2769,20 @@
         
+ 
+   
 .addToBa
@@ -2796,16 +2796,20 @@
 (null);%0A
+    
         
@@ -2842,24 +2842,42 @@
 n.commit();%0A
+                %7D%0A
             

Attach taken image to activity, only switch fragments when image was null before.