public ScanHelper(Activity activity, SurfaceView surfaceView) { this.activity = activity; this.capturePreview = surfaceView; this.hasSurface = false; this.mInactivityTimer = new InactivityTimer(activity); this.mBeepManager = new BeepManager(activity); }
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_section_scan, container, false); FrameLayout frameLayout = (FrameLayout) view.findViewById(R.id.camera_preview); FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams( LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); surfaceView = new SurfaceView(getActivity()); surfaceView.setLayoutParams(layoutParams); viewfinderView = new ViewfinderView(getActivity()); viewfinderView.setLayoutParams(layoutParams); frameLayout.addView(surfaceView); frameLayout.addView(viewfinderView); inactivityTimer = new InactivityTimer(this.getActivity()); ambientLightManager = new AmbientLightManager(this.getActivity()); Button closeButton = (Button) view.findViewById(R.id.button_close); closeButton.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { if (listener != null) { listener.onButtonClick(PayPageState.PAY_FORM, null); } else { Log.e("", "WTF Listener null"); } } } ); return view; }
@Override public void onCreate(Bundle icicle) { super.onCreate(icicle); hasSurface = false; inactivityTimer = new InactivityTimer(getActivity()); beepManager = new BeepManager(getActivity()); ambientLightManager = new AmbientLightManager(getActivity()); PreferenceManager.setDefaultValues(getActivity(), R.xml.preferences, false); }