dm77 / barcodescanner

Barcode Scanner Libraries for Android
Other
5.46k stars 1.42k forks source link

activity flicker on loading when add scanner to main activity #498

Closed waleedmakarem closed 4 years ago

waleedmakarem commented 4 years ago

I am trying to add this nice library to main activity, and with 2 buttons, one to display and other to hide the scan window. The scan window will be displayed into the main Activity. Issue : when application loads, it flickers. I know this is related to StartCamera. But how to resolve.

Sample project : https://drive.google.com/open?id=1qJ-58JbgFY4YA93CWepB2ivq9BucPraF

Code concept: @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main);

    lotmp = (LinearLayout) findViewById(R.id.lo);
    lotmp.setVisibility(View.GONE);
    btntmp = (Button) findViewById(R.id.btn);
    btntmp.setOnClickListener(this);
    btntmpa = (Button) findViewById(R.id.btna);
    btntmpa.setOnClickListener(this);
    ActivateBarcode();
}
private void ActivateBarcode() {
    ViewGroup contentFrame = (ViewGroup) findViewById(R.id.content_frame);
    mScannerView = new ZXingScannerView(this);
    contentFrame.addView(mScannerView);
    mBeepManager = new BeepManager(this);
 }

public void onClick(View v) { if (v == btntmp) { lotmp.setVisibility(View.GONE); } else if (v == btntmpa) { StartZXINGCamera = true; lotmp.setVisibility(View.VISIBLE); } }

@Override public void onResume() { super.onResume(); mScannerView.setResultHandler(this); mScannerView.startCamera(); }

stale[bot] commented 4 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.