// Path: app/src/main/java/eu/se_bastiaan/popcorntimeremote/models/ScanModel.java
// public class ScanModel implements Parcelable {
//     public String ip;
//     public String port;
//     public String user;
//     public String pass;
// 
//     @SuppressWarnings("unused")
//     public static final Parcelable.Creator<ScanModel> CREATOR = new Parcelable.Creator<ScanModel>() {
//         @Override
//         public ScanModel createFromParcel(Parcel in) {
//             return new ScanModel(in);
//         }
// 
//         @Override
//         public ScanModel[] newArray(int size) {
//             return new ScanModel[size];
//         }
//     };
// 
//     protected ScanModel(Parcel in) {
//         ip = in.readString();
//         port = in.readString();
//         user = in.readString();
//         pass = in.readString();
//     }
// 
//     @Override
//     public int describeContents() {
//         return 0;
//     }
// 
//     @Override
//     public void writeToParcel(Parcel dest, int flags) {
//         dest.writeString(ip);
//         dest.writeString(port);
//         dest.writeString(user);
//         dest.writeString(pass);
//     }
// 
// }


import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.support.v7.app.AppCompatActivity;
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 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) {
// Path: app/src/main/java/eu/se_bastiaan/popcorntimeremote/models/ScanModel.java
// public class ScanModel implements Parcelable {
//     public String ip;
//     public String port;
//     public String user;
//     public String pass;
// 
//     @SuppressWarnings("unused")
//     public static final Parcelable.Creator<ScanModel> CREATOR = new Parcelable.Creator<ScanModel>() {
//         @Override
//         public ScanModel createFromParcel(Parcel in) {
//             return new ScanModel(in);
//         }
// 
//         @Override
//         public ScanModel[] newArray(int size) {
//             return new ScanModel[size];
//         }
//     };
// 
//     protected ScanModel(Parcel in) {
//         ip = in.readString();
//         port = in.readString();
//         user = in.readString();
//         pass = in.readString();
//     }
// 
//     @Override
//     public int describeContents() {
//         return 0;
//     }
// 
//     @Override
//     public void writeToParcel(Parcel dest, int flags) {
//         dest.writeString(ip);
//         dest.writeString(port);
//         dest.writeString(user);
//         dest.writeString(pass);
//     }
// 
// }


// Path: app/src/main/java/eu/se_bastiaan/popcorntimeremote/activities/PairingScannerActivity.java
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.support.v7.app.AppCompatActivity;
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 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) {