|
@@ -59,7 +59,7 @@ public class CustomSignDialog extends Dialog {
|
|
|
private String loginDeptCd = "";
|
|
|
private String signImageSeqNo = "";
|
|
|
|
|
|
- private byte[] signImage;
|
|
|
+ private byte[] signImage = {0};
|
|
|
private Bitmap signPadImg;
|
|
|
|
|
|
private LinearLayout startSignLayout;
|
|
@@ -69,6 +69,7 @@ public class CustomSignDialog extends Dialog {
|
|
|
private Button btnCancel;
|
|
|
private Button btnConfirm;
|
|
|
private SignaturePad spSignImage;
|
|
|
+ private String image = "";
|
|
|
// private PhotoView ivSignImage;
|
|
|
|
|
|
public CustomSignDialog(@NonNull Context context, AppCompatActivity activity, UserSignDataInfoVO userSignDataInfoVO) {
|
|
@@ -117,16 +118,16 @@ public class CustomSignDialog extends Dialog {
|
|
|
userId = userSignDataInfoVO.getUserId();
|
|
|
userNm = userSignDataInfoVO.getUserNm();
|
|
|
signImageSeqNo = userSignDataInfoVO.getSignImageSeqNo();
|
|
|
- signImage = userSignDataInfoVO.getSignData().getBytes();
|
|
|
-
|
|
|
- byte[] imgbytes = Base64.decode(signImage, Base64.DEFAULT);
|
|
|
+ image = userSignDataInfoVO.getSignData();
|
|
|
|
|
|
tvUserNm.setText(userNm);
|
|
|
etUserId.setText(userId);
|
|
|
|
|
|
- if (!signImage.equals("")) {
|
|
|
- Bitmap bitmap = BitmapFactory.decodeByteArray(imgbytes, 0, imgbytes.length);
|
|
|
- spSignImage.setSignatureBitmap(bitmap);
|
|
|
+ if (!image.equals("")) {
|
|
|
+ signImage = image.getBytes();
|
|
|
+ byte[] imgbytes = Base64.decode(signImage, Base64.DEFAULT);
|
|
|
+ signPadImg = BitmapFactory.decodeByteArray(imgbytes, 0, imgbytes.length);
|
|
|
+ spSignImage.setSignatureBitmap(signPadImg);
|
|
|
// ivSignImage.setImageBitmap(bitmap);
|
|
|
}
|
|
|
|
|
@@ -147,7 +148,11 @@ public class CustomSignDialog extends Dialog {
|
|
|
@Override
|
|
|
public void onClick(View v) {
|
|
|
if (v == startSignLayout) {
|
|
|
- CustomSignPad customSignPad = new CustomSignPad(mContext, spSignImage.getSignatureBitmap());
|
|
|
+ Bitmap bp = null;
|
|
|
+ if (!image.equals("") || signPadImg != null) {
|
|
|
+ bp = spSignImage.getSignatureBitmap();
|
|
|
+ }
|
|
|
+ CustomSignPad customSignPad = new CustomSignPad(mContext, bp);
|
|
|
customSignPad.setDialogListener(new CustomSignPad.CustomSignPadListener() {
|
|
|
@Override
|
|
|
public void onConfirmClicked(Bitmap signPadImage) {
|
|
@@ -211,48 +216,55 @@ public class CustomSignDialog extends Dialog {
|
|
|
public void error() {
|
|
|
}
|
|
|
};
|
|
|
- instance.csAlert.show();
|
|
|
- instance.csAlert.setContent(mContext.getString(R.string.setSignImage), "");
|
|
|
|
|
|
- instance.csAlert.btnConfirm.setOnClickListener(new View.OnClickListener() {
|
|
|
- @Override
|
|
|
- public void onClick(View v) {
|
|
|
+ if (signPadImg == null) {
|
|
|
+ Toast.makeText(mContext, mContext.getString(R.string.emptySigned) , Toast.LENGTH_SHORT).show();
|
|
|
+ } else {
|
|
|
+ instance.csAlert.show();
|
|
|
+ instance.csAlert.setContent(mContext.getString(R.string.setSignImage), "");
|
|
|
|
|
|
- instance.showProgress();
|
|
|
+ instance.csAlert.btnConfirm.setOnClickListener(new View.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(View v) {
|
|
|
+
|
|
|
+ instance.showProgress();
|
|
|
|
|
|
- Bitmap drawable = spSignImage.getSignatureBitmap();
|
|
|
- ByteArrayOutputStream stream = new ByteArrayOutputStream() ;
|
|
|
+ Bitmap drawable = spSignImage.getSignatureBitmap();
|
|
|
+ ByteArrayOutputStream stream = new ByteArrayOutputStream() ;
|
|
|
|
|
|
- drawable.compress(Bitmap.CompressFormat.JPEG, 80, stream) ;
|
|
|
- byte[] signArr = stream.toByteArray() ;
|
|
|
- String strSignImg = "";
|
|
|
- try {
|
|
|
+ drawable.compress(Bitmap.CompressFormat.JPEG, 80, stream) ;
|
|
|
+ byte[] signArr = stream.toByteArray() ;
|
|
|
+ String strSignImg = "";
|
|
|
+ try {
|
|
|
// strSignImg = Util.base64Encode(signArr);
|
|
|
- strSignImg = Base64.encodeToString(signArr, Base64.DEFAULT);
|
|
|
- stream.close();
|
|
|
- } catch (UnsupportedEncodingException e) {
|
|
|
- e.printStackTrace();
|
|
|
- } catch (IOException e) {
|
|
|
- e.printStackTrace();
|
|
|
+ strSignImg = Base64.encodeToString(signArr, Base64.DEFAULT);
|
|
|
+ stream.close();
|
|
|
+ } catch (UnsupportedEncodingException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ } catch (IOException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+
|
|
|
+ HashMap<String, String> mData = new HashMap<String, String>();
|
|
|
+ mData.put("instCd", BuildConfig.INST_CD);
|
|
|
+ mData.put("userId", userId);
|
|
|
+ mData.put("signSeq", signImageSeqNo);
|
|
|
+ mData.put("inptId", instance.userId);
|
|
|
+ mData.put("signImage", strSignImg);
|
|
|
+
|
|
|
+ Util.callHttp(mContext, ConsentConfig.HOST_HOSPITAL, ConsentConfig.SET_SIGN_IMAGE, mData, callBack);
|
|
|
}
|
|
|
+ });
|
|
|
|
|
|
- HashMap<String, String> mData = new HashMap<String, String>();
|
|
|
- mData.put("instCd", BuildConfig.INST_CD);
|
|
|
- mData.put("userId", userId);
|
|
|
- mData.put("signSeq", signImageSeqNo);
|
|
|
- mData.put("inptId", instance.userId);
|
|
|
- mData.put("signImage", strSignImg);
|
|
|
+ instance.csAlert.btnCancel.setOnClickListener(new View.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(View v) {
|
|
|
+ instance.csAlert.dismiss();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
|
|
|
- Util.callHttp(mContext, ConsentConfig.HOST_HOSPITAL, ConsentConfig.SET_SIGN_IMAGE, mData, callBack);
|
|
|
- }
|
|
|
- });
|
|
|
|
|
|
- instance.csAlert.btnCancel.setOnClickListener(new View.OnClickListener() {
|
|
|
- @Override
|
|
|
- public void onClick(View v) {
|
|
|
- instance.csAlert.dismiss();
|
|
|
- }
|
|
|
- });
|
|
|
}
|
|
|
|
|
|
|
|
@@ -261,6 +273,10 @@ public class CustomSignDialog extends Dialog {
|
|
|
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
|
|
|
if (actionId == EditorInfo.IME_ACTION_DONE || event.getKeyCode() == KeyEvent.KEYCODE_ENTER) {
|
|
|
|
|
|
+ image = "";
|
|
|
+ spSignImage.clear();
|
|
|
+ signPadImg = null;
|
|
|
+
|
|
|
instance.showProgress();
|
|
|
|
|
|
String userId = etUserId.getText().toString().trim();
|
|
@@ -286,16 +302,16 @@ public class CustomSignDialog extends Dialog {
|
|
|
userId = userSignDataInfoVO.getUserId();
|
|
|
userNm = userSignDataInfoVO.getUserNm();
|
|
|
signImageSeqNo = userSignDataInfoVO.getSignImageSeqNo();
|
|
|
- signImage = userSignDataInfoVO.getSignData().getBytes();
|
|
|
-
|
|
|
- byte[] imgbytes = Base64.decode(signImage, Base64.DEFAULT);
|
|
|
+ image = userSignDataInfoVO.getSignData();
|
|
|
|
|
|
tvUserNm.setText(userNm);
|
|
|
etUserId.setText(userId);
|
|
|
|
|
|
- if (!signImage.equals("")) {
|
|
|
- Bitmap bitmap = BitmapFactory.decodeByteArray(imgbytes, 0, signImage.length);
|
|
|
- spSignImage.setSignatureBitmap(bitmap);
|
|
|
+ if (!image.equals("")) {
|
|
|
+ signImage = userSignDataInfoVO.getSignData().getBytes();
|
|
|
+ byte[] imgbytes = Base64.decode(signImage, Base64.DEFAULT);
|
|
|
+ signPadImg = BitmapFactory.decodeByteArray(imgbytes, 0, signImage.length);
|
|
|
+ spSignImage.setSignatureBitmap(signPadImg);
|
|
|
}
|
|
|
}
|
|
|
|