added camera to preview view

This commit is contained in:
Henry Varona 2018-09-21 17:56:58 -04:00
parent ed21712f68
commit 3e5e0001e1
2 changed files with 10 additions and 4 deletions

View file

@ -37,6 +37,7 @@ import android.widget.ScrollView;
import android.widget.Spinner; import android.widget.Spinner;
import android.widget.TextView; import android.widget.TextView;
import com.google.zxing.BarcodeFormat;
import com.google.zxing.Result; import com.google.zxing.Result;
import com.jaredrummler.materialspinner.MaterialSpinner; import com.jaredrummler.materialspinner.MaterialSpinner;
import com.vincent.filepicker.ToastUtil; import com.vincent.filepicker.ToastUtil;
@ -76,6 +77,8 @@ import cy.agorise.graphenej.Invoice;
import cy.agorise.graphenej.LineItem; import cy.agorise.graphenej.LineItem;
import me.dm7.barcodescanner.zxing.ZXingScannerView; import me.dm7.barcodescanner.zxing.ZXingScannerView;
import static butterknife.internal.Utils.listOf;
public class SendTransactionFragment extends DialogFragment implements UIValidatorListener, ZXingScannerView.ResultHandler { public class SendTransactionFragment extends DialogFragment implements UIValidatorListener, ZXingScannerView.ResultHandler {
SendTransactionValidator sendTransactionValidator; SendTransactionValidator sendTransactionValidator;
@ -112,8 +115,6 @@ public class SendTransactionFragment extends DialogFragment implements UIValidat
ImageView ivPeople; ImageView ivPeople;
@BindView(R.id.ivCamera) @BindView(R.id.ivCamera)
ImageView ivCamera;
ZXingScannerView mScannerView; ZXingScannerView mScannerView;
CryptoCurrencyAdapter assetAdapter; CryptoCurrencyAdapter assetAdapter;
@ -450,7 +451,11 @@ public class SendTransactionFragment extends DialogFragment implements UIValidat
} }
public void beginScanQrCode(){ public void beginScanQrCode(){
mScannerView = new ZXingScannerView(getContext()); //mScannerView = new ZXingScannerView(getContext());
mScannerView.setFormats(listOf(BarcodeFormat.QR_CODE));
mScannerView.setAutoFocus(true);
mScannerView.setLaserColor(R.color.colorAccent);
mScannerView.setMaskColor(R.color.colorAccent);
mScannerView.setResultHandler(this); mScannerView.setResultHandler(this);
mScannerView.startCamera(); mScannerView.startCamera();
} }
@ -529,6 +534,7 @@ public class SendTransactionFragment extends DialogFragment implements UIValidat
@Override @Override
public void handleResult(Result result) { public void handleResult(Result result) {
try { try {
System.out.println("CAMERA result " + result.getText() );
Invoice invoice = Invoice.fromQrCode(result.getText()); Invoice invoice = Invoice.fromQrCode(result.getText());
etTo.setText(invoice.getTo()); etTo.setText(invoice.getTo());

View file

@ -194,7 +194,7 @@
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvMemoError" /> app:layout_constraintTop_toBottomOf="@id/tvMemoError" />
<ImageView <me.dm7.barcodescanner.zxing.ZXingScannerView
android:id="@+id/ivCamera" android:id="@+id/ivCamera"
android:layout_width="180dp" android:layout_width="180dp"
android:layout_height="180dp" android:layout_height="180dp"