当前位置: 首页>>代码示例>>Java>>正文


Java Barcode类代码示例

本文整理汇总了Java中com.google.android.gms.vision.barcode.Barcode的典型用法代码示例。如果您正苦于以下问题:Java Barcode类的具体用法?Java Barcode怎么用?Java Barcode使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Barcode类属于com.google.android.gms.vision.barcode包,在下文中一共展示了Barcode类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onBarcodeCreated

import com.google.android.gms.vision.barcode.Barcode; //导入依赖的package包/类
@Override
public void onBarcodeCreated(Barcode barcode) {

    mBarcode = barcode;
    vibrateDetection();

    if(BuildConfig.FLAVOR.equals(Constants.FLAVOR_FREE)) {
        runOnUiThread(new Runnable() {
            @Override
            public void run() {
                showInterstitialAd();
            }
        });
    }else{
        sendResultMainActivity();
    }
}
 
开发者ID:victoraldir,项目名称:BuddyBook,代码行数:18,代码来源:BarcodeCaptureActivity.java

示例2: draw

import com.google.android.gms.vision.barcode.Barcode; //导入依赖的package包/类
/**
 * Draws the barcode annotations for position, size, and raw value on the supplied canvas.
 */
@Override
public void draw(Canvas canvas) {
    Barcode barcode = mBarcode;
    if (barcode == null) {
        return;
    }

    // Draws the bounding box around the barcode.
    RectF rect = new RectF(barcode.getBoundingBox());
    rect.left = translateX(rect.left);
    rect.top = translateY(rect.top);
    rect.right = translateX(rect.right);
    rect.bottom = translateY(rect.bottom);
    canvas.drawRect(rect, mRectPaint);

    // Draws a label at the bottom of the barcode indicate the barcode value that was detected.
    canvas.drawText(barcode.rawValue, rect.left, rect.bottom, mTextPaint);
}
 
开发者ID:victoraldir,项目名称:BuddyBook,代码行数:22,代码来源:BarcodeGraphic.java

示例3: onScannedMultiple

import com.google.android.gms.vision.barcode.Barcode; //导入依赖的package包/类
@Override
public void onScannedMultiple(List<Barcode> barcodes) {
    Log.e(TAG, "onScannedMultiple: " + barcodes.size());

    String codes = "";
    for (Barcode barcode : barcodes) {
        codes += barcode.displayValue + ", ";
    }

    final String finalCodes = codes;
    runOnUiThread(new Runnable() {
        @Override
        public void run() {
            Toast.makeText(getApplicationContext(), "Barcodes: " + finalCodes, Toast.LENGTH_SHORT).show();
        }
    });
}
 
开发者ID:ravi8x,项目名称:Barcode-Reader,代码行数:18,代码来源:MainActivity.java

示例4: onScannedMultiple

import com.google.android.gms.vision.barcode.Barcode; //导入依赖的package包/类
@Override
public void onScannedMultiple(List<Barcode> barcodes) {
    Log.e(TAG, "onScannedMultiple: " + barcodes.size());

    String codes = "";
    for (Barcode barcode : barcodes) {
        codes += barcode.displayValue + ", ";
    }

    final String finalCodes = codes;
    getActivity().runOnUiThread(new Runnable() {
        @Override
        public void run() {
            Toast.makeText(getActivity(), "Barcodes: " + finalCodes, Toast.LENGTH_SHORT).show();
        }
    });
}
 
开发者ID:ravi8x,项目名称:Barcode-Reader,代码行数:18,代码来源:BarcodeFragment.java

示例5: onUpdate

import com.google.android.gms.vision.barcode.Barcode; //导入依赖的package包/类
/**
 * Update the position/characteristics of the item within the overlay.
 */
@Override
public void onUpdate(Detector.Detections<Barcode> detectionResults, Barcode item) {
    mOverlay.add(mGraphic);
    mGraphic.updateItem(item);

    if (detectionResults != null && detectionResults.getDetectedItems().size() > 1) {
        Log.e("XX", "Multiple items detected");
        Log.e("XX", "onUpdate: " + detectionResults.getDetectedItems().size());

        if (listener != null) {
            List<Barcode> barcodes = asList(detectionResults.getDetectedItems());
            listener.onScannedMultiple(barcodes);
        }
    }
}
 
开发者ID:ravi8x,项目名称:Barcode-Reader,代码行数:19,代码来源:BarcodeGraphicTracker.java

示例6: onActivityResult

import com.google.android.gms.vision.barcode.Barcode; //导入依赖的package包/类
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == BARCODE_READER_REQUEST_CODE) {
        if (resultCode == CommonStatusCodes.SUCCESS) {
            if (data != null) {
                Barcode barcode = data.getParcelableExtra(BarcodeCaptureActivity.BarcodeObject);

                QRURLParser parser = QRURLParser.getInstance();
                String extracted_address = parser.extractAddressFromQrString(barcode.displayValue);
                if (extracted_address == null) {
                    Toast.makeText(this, R.string.toast_qr_code_no_address, Toast.LENGTH_SHORT).show();
                    return;
                }
                Point[] p = barcode.cornerPoints;
                toAddressText.setText(extracted_address);
            }
        } else {
            Log.e("SEND", String.format(getString(R.string.barcode_error_format),
                    CommonStatusCodes.getStatusCodeString(resultCode)));
        }
    } else {
        super.onActivityResult(requestCode, resultCode, data);
    }
}
 
开发者ID:TrustWallet,项目名称:trust-wallet-android,代码行数:25,代码来源:SendActivity.java

示例7: draw

import com.google.android.gms.vision.barcode.Barcode; //导入依赖的package包/类
/**
 * Draws the barcode annotations for position, size, and raw value on the supplied canvas.
 */
@Override
public void draw(Canvas canvas) {
    Barcode barcode = mBarcode;
    if (barcode == null) {
        return;
    }

    // Draws the bounding box around the barcode.
    RectF rect = new RectF(barcode.getBoundingBox());
    rect.left = translateX(rect.left);
    rect.top = translateY(rect.top);
    rect.right = translateX(rect.right);
    rect.bottom = translateY(rect.bottom);
    canvas.drawRect(rect, mRectPaint);

}
 
开发者ID:Emrals,项目名称:Fuse,代码行数:20,代码来源:BarcodeGraphic.java

示例8: create

import com.google.android.gms.vision.barcode.Barcode; //导入依赖的package包/类
@Override
public Tracker<Barcode> create(Barcode barcode) {
    return new Tracker<Barcode>() {
        /**
         * Start tracking the detected item instance within the item overlay.
         */
        @Override
        public void onNewItem(int id, Barcode item) {
            // Act on new barcode found
            WritableMap event = Arguments.createMap();
            event.putString("data", item.displayValue);
            event.putString("type", BarcodeFormat.get(item.format));

            sendNativeEvent(BARCODE_FOUND_KEY, event);
        }
    };
}
 
开发者ID:ekreutz,项目名称:react-native-barcode-scanner-google,代码行数:18,代码来源:BarcodeScannerView.java

示例9: draw

import com.google.android.gms.vision.barcode.Barcode; //导入依赖的package包/类
/**
 * Draws the barcode annotations for position, size, and raw value on the supplied canvas.
 */
@Override
public void draw(Canvas canvas) {
    Barcode barcode = mBarcode;
    if (barcode == null) {
        return;
    }

    // Draws the bounding box around the barcode.
    RectF rect = new RectF(barcode.getBoundingBox());
    rect.left = translateX(rect.left);
    rect.top = translateY(rect.top);
    rect.right = translateX(rect.right);
    rect.bottom = translateY(rect.bottom);
    if (graphicOverlay.isDrawRect())
        canvas.drawRect(rect, mRectPaint);

    // Draws a label at the bottom of the barcode indicate the barcode value that was detected.
    if (graphicOverlay.isShowText())
        canvas.drawText(barcode.rawValue, rect.left, rect.bottom, mTextPaint);
}
 
开发者ID:KingsMentor,项目名称:MobileVisionBarcodeScanner,代码行数:24,代码来源:BarcodeGraphic.java

示例10: onRetrievedMultiple

import com.google.android.gms.vision.barcode.Barcode; //导入依赖的package包/类
@Override
public void onRetrievedMultiple(final Barcode closetToClick, final List<BarcodeGraphic> barcodeGraphics) {
    runOnUiThread(new Runnable() {
        @Override
        public void run() {
            String message = "Code selected : " + closetToClick.displayValue + "\n\nother " +
                    "codes in frame include : \n";
            for (int index = 0; index < barcodeGraphics.size(); index++) {
                Barcode barcode = barcodeGraphics.get(index).getBarcode();
                message += (index + 1) + ". " + barcode.displayValue + "\n";
            }
            AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this)
                    .setTitle("code retrieved")
                    .setMessage(message);
            builder.show();
        }
    });

}
 
开发者ID:KingsMentor,项目名称:MobileVisionBarcodeScanner,代码行数:20,代码来源:MainActivity.java

示例11: onActivityResult

import com.google.android.gms.vision.barcode.Barcode; //导入依赖的package包/类
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    Log.d(TAG, "onActivityResult");
    if (requestCode == RC_BARCODE_CAPTURE) {
        if (resultCode == CommonStatusCodes.SUCCESS) {
            if (data != null) {
                Barcode barcode = data.getParcelableExtra(BarcodeCaptureActivity.BarcodeObject);
                Log.d(TAG, "Barcode read: " + barcode.displayValue);
                mPresenter.newEvent(barcode);
            } else {
                Log.d(TAG, "No barcode captured, intent data is null");
            }
        } else {
            Log.d(TAG, "onActivityResult is not a success");
        }
    }
    else {
        super.onActivityResult(requestCode, resultCode, data);
    }
}
 
开发者ID:compte14031879,项目名称:udacity-capstone,代码行数:21,代码来源:EventsFragment.java

示例12: newEvent

import com.google.android.gms.vision.barcode.Barcode; //导入依赖的package包/类
@Override
public void newEvent(final Barcode barcode) {
    Log.d(TAG, "newEvent " + barcode.toString());
    mFoodInspectorRepository.saveScan(barcode.displayValue, new EventDataSource.SaveScanCallback() {
        @Override
        public void onScanSaved() {
            mEventsView.showEventDetailsUi(barcode.displayValue);
        }

        @Override
        public void onScanSavedWithError() {
            mEventsView.showNewEventError();
        }

        @Override
        public void onError(Throwable throwable) {
            Log.e(TAG, throwable.toString());
            mEventsView.showNewEventError();
        }
    });

}
 
开发者ID:compte14031879,项目名称:udacity-capstone,代码行数:23,代码来源:EventsPresenter.java

示例13: isPointInsideBarcode

import com.google.android.gms.vision.barcode.Barcode; //导入依赖的package包/类
public boolean isPointInsideBarcode(float rawX, float rawY) {

        Barcode barcode = mBarcode;
        if (barcode != null) {
            /*
            RectF rect = getViewBoundingBox(barcode);
            float x = translateX(rawX);
            float y = translateY(rawY);
            Log.d("BARCODE", "rect: t: " + rect.top + ", l: " + rect.left + ", r: " + rect.right + ", b: " + rect.bottom +
                    "/ x: " + x + ", y: " + y);
            return rect.contains(x, y);
            */

            return barcode.getBoundingBox().contains((int)rawX, (int)rawY);
        }

        return false;
    }
 
开发者ID:Credntia,项目名称:MVBarcodeReader,代码行数:19,代码来源:BarcodeGraphic.java

示例14: receiveDetections

import com.google.android.gms.vision.barcode.Barcode; //导入依赖的package包/类
@Override
public void receiveDetections(final Detector.Detections<Barcode> var1) {
    if (isResume && var1.getDetectedItems().size() > 0) {
        pauseDetector();
        final Barcode barcode = var1.getDetectedItems().valueAt(0);
        handler.post(new Runnable() {
            @Override
            public void run() {
                if(!handleBarcode(barcode)){
                    resumeDetector();
                }
            }
        });

    }
}
 
开发者ID:MobileTribe,项目名称:pandroid,代码行数:17,代码来源:PandroidScannerView.java

示例15: onActivityResult

import com.google.android.gms.vision.barcode.Barcode; //导入依赖的package包/类
/**
 * Called when an activity you launched exits, giving you the requestCode
 * you started it with, the resultCode it returned, and any additional
 * data from it.  The <var>resultCode</var> will be
 * {@link #RESULT_CANCELED} if the activity explicitly returned that,
 * didn't return any result, or crashed during its operation.
 * <p/>
 * <p>You will receive this call immediately before onResume() when your
 * activity is re-starting.
 * <p/>
 *
 * @param requestCode The integer request code originally supplied to
 *                    startActivityForResult(), allowing you to identify who this
 *                    result came from.
 * @param resultCode  The integer result code returned by the child activity
 *                    through its setResult().
 * @param data        An Intent, which can return result data to the caller
 *                    (various data can be attached to Intent "extras").
 * @see #startActivityForResult
 * @see #createPendingResult
 * @see #setResult(int)
 */
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == RC_BARCODE_CAPTURE) {
        if (resultCode == CommonStatusCodes.SUCCESS) {
            if (data != null) {
                Barcode barcode = data.getParcelableExtra(BarcodeCaptureActivity.BarcodeObject);
                statusMessage.setText(R.string.barcode_success);
                barcodeValue.setText(barcode.displayValue);
                Log.d(TAG, "Barcode read: " + barcode.displayValue);
            } else {
                statusMessage.setText(R.string.barcode_failure);
                Log.d(TAG, "No barcode captured, intent data is null");
            }
        } else {
            statusMessage.setText(String.format(getString(R.string.barcode_error),
                    CommonStatusCodes.getStatusCodeString(resultCode)));
        }
    }
    else {
        super.onActivityResult(requestCode, resultCode, data);
    }
}
 
开发者ID:wax911,项目名称:Vision-Barcode-Scanner,代码行数:45,代码来源:MainActivity.java


注:本文中的com.google.android.gms.vision.barcode.Barcode类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。