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();
}
}
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();
}
});
}
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;
}
Aggregations