QR코드를 생성하는데 시간 2~4초정도 걸립니다.
그 사이에 프로그래스 다이얼로그로 현재 생성 중입니다라는 말을 표시하고 싶은데
Ui block이 걸려서 진행이 안되더라구요
이 부분을 어떻게 처리하는 방법이 있을까요?
//QRCode 생성
public void generateRQCode(String contents) {
new Thread(new Runnable() {
@Override
public void run() {
runOnUiThread(new Runnable() {
@Override
public void run() {
mProgressDialog = new ProgressDialog(ExportImportQRCodeActivity.this);
mProgressDialog.setCancelable(false);
mProgressDialog.setMessage("QR코드를 생성 중입니다.");
mProgressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
mProgressDialog.show();
}
});
}
}).start();
QRCodeWriter qrCodeWriter = new QRCodeWriter();
try {
Hashtable hints = new Hashtable();
hints.put(EncodeHintType.CHARACTER_SET, "utf-8"); //QRCode에 한글 인식도 가능하도록 UTF-8로 인코딩한다.
Bitmap bitmap = toBitmap(qrCodeWriter.encode(contents, BarcodeFormat.QR_CODE, 800, 800, hints));
if (ivQrCode != null) {
ivQrCode.setImageBitmap(bitmap);
}
} catch (WriterException e) {
e.printStackTrace();
} catch (NullPointerException npe) {
npe.printStackTrace();
} finally {
if (mProgressDialog != null) {
mProgressDialog.dismiss();
mProgressDialog = null;
}
}
}