Search in sources :

Example 1 with CodeScannerView

use of com.budiyev.android.codescanner.CodeScannerView in project ScanEco by Pepapipi.

the class MainActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    // Création et initialisation du scanner
    CodeScannerView mCodeScannerView = findViewById(R.id.scanner_view);
    mCodeScanner = new CodeScanner(this, mCodeScannerView);
    // Initialisation des variables qui nous permettront d'affocher les
    // caracteristiques du produit
    mEcranBlanc = findViewById(R.id.view_ecranBlanc);
    mNomProduit = findViewById(R.id.textView_nomProduit);
    mImageEmballage = findViewById(R.id.imageView_EmballageScan);
    mMarqueProduit = findViewById(R.id.textView_marqueProduit);
    mImageViewPoubelle1 = findViewById(R.id.imageView_poubelle1);
    mImageViewPoubelle2 = findViewById(R.id.imageView_poubelle2);
    mImageViewPoubelle3 = findViewById(R.id.imageView_poubelle3);
    mTraitView = findViewById(R.id.traitView);
    // Initialisation des listes
    mDonneesDuProduit = new DoneesProduit();
    mDonneesDuProduit.initialisationDesListes();
    // Initialisation du swipe de l'utilisateur
    this.mGestureUtilisateur = new GestureDetector(MainActivity.this, this);
    // Initialisation de la barre de menu
    BottomNavigationView bottomNavigationView = findViewById(R.id.bottom_navigation);
    bottomNavigationView.setOnItemSelectedListener(item -> {
        int itemId = item.getItemId();
        if (itemId == R.id.accueilHorRamPoubelles) {
            ouvrirHorRamPoubelles();
        } else if (itemId == R.id.accueilAnimations) {
            ouvrirAnimations();
        } else if (itemId == R.id.accueilPointDeCollecte) {
            ouvrirRecherchePointDeCollecte();
        }
        return true;
    });
    // Initialisation du bouton qui ouvre la page recherche sans scan
    ImageButton mBoutonRechercheSansScan = findViewById(R.id.bouton1);
    // Quand le bouton est cliqué alors il sera redirigé vers la page recherche sans scan
    mBoutonRechercheSansScan.setOnClickListener(v -> ouvrirRechercheSansScan());
    // S'il a refusé on redemande si on peut l'utilser, mais on ne peut pas se servir du scan
    if (ContextCompat.checkSelfPermission(this, Manifest.permission.CAMERA) == PackageManager.PERMISSION_DENIED) {
        mPermissionResult.launch(Manifest.permission.CAMERA);
    } else // S'il accepte, on lance le scan
    {
        startScanning();
    }
}
Also used : ImageButton(android.widget.ImageButton) CodeScanner(com.budiyev.android.codescanner.CodeScanner) BottomNavigationView(com.google.android.material.bottomnavigation.BottomNavigationView) CodeScannerView(com.budiyev.android.codescanner.CodeScannerView) GestureDetector(android.view.GestureDetector)

Example 2 with CodeScannerView

use of com.budiyev.android.codescanner.CodeScannerView in project EasyPlayer-RTMP-Android by EasyDSS.

the class ScanQRActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_scan_qr);
    CodeScannerView scannerView = findViewById(R.id.scanner_view);
    mCodeScanner = new CodeScanner(this, scannerView);
    mCodeScanner.setScanMode(ScanMode.SINGLE);
    mCodeScanner.setAutoFocusEnabled(true);
    mCodeScanner.setDecodeCallback(new DecodeCallback() {

        @Override
        public void onDecoded(@NonNull final Result result) {
            runOnUiThread(new Runnable() {

                @Override
                public void run() {
                    if (!TextUtils.isEmpty(result.getText())) {
                        final String text = result.getText().trim();
                        if (text.toLowerCase().startsWith("rtmp://")) {
                            Intent intent = new Intent();
                            intent.putExtra("text", text);
                            setResult(RESULT_OK, intent);
                            finish();
                        }
                    }
                }
            });
        }
    });
    scannerView.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            mCodeScanner.startPreview();
        }
    });
}
Also used : CodeScanner(com.budiyev.android.codescanner.CodeScanner) CodeScannerView(com.budiyev.android.codescanner.CodeScannerView) Intent(android.content.Intent) DecodeCallback(com.budiyev.android.codescanner.DecodeCallback) CodeScannerView(com.budiyev.android.codescanner.CodeScannerView) View(android.view.View) Result(com.google.zxing.Result)

Example 3 with CodeScannerView

use of com.budiyev.android.codescanner.CodeScannerView in project QRHunt by CMPUT301W22T00.

the class FragmentScanner method onCreateView.

/**
 * Sets up fragment to be loaded in, finds all views, sets onClickListener for buttons
 *
 * @param inflater           Inflater
 * @param container          Where the fragment is contained
 * @param savedInstanceState SavedInstanceState
 * @return root
 */
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    getActivity().getSupportFragmentManager().setFragmentResultListener("getPlayer", this, (requestKey, result) -> {
        Player player = (Player) result.getSerializable("player");
        playerId = player.getPlayerId();
    });
    // Get permissions first
    requestPermissionsIfNecessary(new String[] { Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.WRITE_EXTERNAL_STORAGE, Manifest.permission.CAMERA });
    final Activity activity = getActivity();
    View root = inflater.inflate(R.layout.fragment_scanner, container, false);
    CodeScannerView scannerView = root.findViewById(R.id.scanner_view);
    assert activity != null;
    codeScanner = new CodeScanner(activity, scannerView);
    codeScanner.setCamera(CodeScanner.CAMERA_BACK);
    codeScanner.setScanMode(ScanMode.CONTINUOUS);
    codeScanner.setAutoFocusMode(AutoFocusMode.SAFE);
    codeScanner.setFlashEnabled(false);
    codeScanner.setAutoFocusEnabled(true);
    codeScanner.setFormats(CodeScanner.ALL_FORMATS);
    codeScanner.setDecodeCallback(result -> activity.runOnUiThread(() -> {
        camera = new QrCodeProcessor(FragmentScanner.this, result.getText(), playerId);
        codeScanner.setScanMode(ScanMode.PREVIEW);
        camera.processQRCode();
        final Handler handler = new Handler(Looper.getMainLooper());
        handler.postDelayed(new Runnable() {

            @Override
            public void run() {
                codeScanner.setScanMode(ScanMode.CONTINUOUS);
            }
        }, 2000);
    }));
    codeScanner.setErrorCallback(thrown -> Log.e(TAG, "Camera has failed: ", thrown));
    return root;
}
Also used : Player(com.bigyoshi.qrhunt.player.Player) CodeScanner(com.budiyev.android.codescanner.CodeScanner) CodeScannerView(com.budiyev.android.codescanner.CodeScannerView) Activity(android.app.Activity) Handler(android.os.Handler) CodeScannerView(com.budiyev.android.codescanner.CodeScannerView) View(android.view.View) Nullable(androidx.annotation.Nullable)

Aggregations

CodeScanner (com.budiyev.android.codescanner.CodeScanner)3 CodeScannerView (com.budiyev.android.codescanner.CodeScannerView)3 View (android.view.View)2 Activity (android.app.Activity)1 Intent (android.content.Intent)1 Handler (android.os.Handler)1 GestureDetector (android.view.GestureDetector)1 ImageButton (android.widget.ImageButton)1 Nullable (androidx.annotation.Nullable)1 Player (com.bigyoshi.qrhunt.player.Player)1 DecodeCallback (com.budiyev.android.codescanner.DecodeCallback)1 BottomNavigationView (com.google.android.material.bottomnavigation.BottomNavigationView)1 Result (com.google.zxing.Result)1