@@ -0,0 +1,2478 @@
+/*%0A * Copyright (C) 2016 The Android Open Source Project%0A *%0A * Licensed under the Apache License, Version 2.0 (the %22License%22);%0A * you may not use this file except in compliance with the License.%0A * You may obtain a copy of the License at%0A *%0A *      http://www.apache.org/licenses/LICENSE-2.0%0A *%0A * Unless required by applicable law or agreed to in writing, software%0A * distributed under the License is distributed on an %22AS IS%22 BASIS,%0A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A * See the License for the specific language governing permissions and%0A * limitations under the License.%0A */%0A%0Apackage com.google.android.cameraview;%0A%0Aimport android.content.Context;%0Aimport android.support.v4.view.ViewCompat;%0Aimport android.view.Surface;%0Aimport android.view.SurfaceHolder;%0Aimport android.view.SurfaceView;%0Aimport android.view.View;%0Aimport android.view.ViewGroup;%0A%0Aclass SurfaceViewPreview extends PreviewImpl %7B%0A%0A    final SurfaceView mSurfaceView;%0A%0A    SurfaceViewPreview(Context context, ViewGroup parent) %7B%0A        final View view = View.inflate(context, R.layout.surface_view, parent);%0A        mSurfaceView = (SurfaceView) view.findViewById(R.id.surface_view);%0A        final SurfaceHolder holder = mSurfaceView.getHolder();%0A        //noinspection deprecation%0A        holder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);%0A        holder.addCallback(new SurfaceHolder.Callback() %7B%0A            @Override%0A            public void surfaceCreated(SurfaceHolder h) %7B%0A            %7D%0A%0A            @Override%0A            public void surfaceChanged(SurfaceHolder h, int format, int width, int height) %7B%0A                setSize(width, height);%0A                if (!ViewCompat.isInLayout(mSurfaceView)) %7B%0A                    dispatchSurfaceChanged();%0A                %7D%0A            %7D%0A%0A            @Override%0A            public void surfaceDestroyed(SurfaceHolder h) %7B%0A                setSize(0, 0);%0A            %7D%0A        %7D);%0A    %7D%0A%0A    @Override%0A    Surface getSurface() %7B%0A        return getSurfaceHolder().getSurface();%0A    %7D%0A%0A    @Override%0A    SurfaceHolder getSurfaceHolder() %7B%0A        return mSurfaceView.getHolder();%0A    %7D%0A%0A    @Override%0A    View getView() %7B%0A        return mSurfaceView;%0A    %7D%0A%0A    @Override%0A    Class getOutputClass() %7B%0A        return SurfaceHolder.class;%0A    %7D%0A%0A    @Override%0A    void setDisplayOrientation(int displayOrientation) %7B%0A    %7D%0A%0A    @Override%0A    boolean isReady() %7B%0A        return getWidth() != 0 && getHeight() != 0;%0A    %7D%0A%0A%7D%0A

Create SurfaceViewPreview.java