package eu.se_bastiaan.popcorntimeremote.activities;

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.view.MenuItem;

import com.google.gson.Gson;
import com.google.zxing.BarcodeFormat;
import com.google.zxing.Result;

import java.util.Arrays;

import eu.se_bastiaan.popcorntimeremote.R;
import eu.se_bastiaan.popcorntimeremote.models.ScanModel;
import me.dm7.barcodescanner.zxing.ZXingScannerView;

public class PairingScannerActivity extends ActionBarActivity implements ZXingScannerView.ResultHandler {

    public static Integer SCAN = 1440, SUCCESS = 1441;

    ZXingScannerView scannerView;

    @Override
    public void onCreate(Bundle state) {
        super.onCreate(state);
        scannerView = new ZXingScannerView(this);
        setContentView(scannerView);

        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
        getSupportActionBar().setLogo(R.drawable.ic_logo);
    }

    @Override
    public void onResume() {
        super.onResume();
        scannerView.setResultHandler(this);
        scannerView.startCamera();
    }

    @Override
    public void onPause() {
        super.onPause();
        scannerView.stopCamera();
    }

    @Override
    public void handleResult(Result rawResult) {
        try {
            String json = rawResult.getText();
            Gson gson = new Gson();
            ScanModel model = gson.fromJson(json, ScanModel.class);

            Intent intent = new Intent();
            intent.putExtra("result", model);
            setResult(SUCCESS, intent);
            finish();
        } catch (RuntimeException e) {
            e.printStackTrace();
        }
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        if(item.getItemId() == android.R.id.home) {
            finish();
        }

        return super.onOptionsItemSelected(item);
    }
    
}
@@ -43,24 +43,53 @@
 ctivities;%0A%0A
+import android.app.Activity;%0A
 import andro
@@ -539,25 +539,16 @@
 extends 
-ActionBar
 Activity
@@ -592,16 +592,16 @@
 ndler %7B%0A
+
 %0A    pub
@@ -649,16 +649,17 @@
  1441;%0A%0A
+%0A
     ZXin
@@ -767,24 +767,24 @@
 ate(state);%0A
+
         scan
@@ -825,168 +825,8 @@
 s);%0A
-        setContentView(scannerView);%0A%0A        getSupportActionBar().setDisplayHomeAsUpEnabled(true);%0A        getSupportActionBar().setLogo(R.drawable.ic_logo);%0A
     

Fix scanner