/** * Crea una nueva identidad para un crypto broker * * @return key con el resultado de la operacion:<br> * <br> * <code>CREATE_IDENTITY_SUCCESS</code>: Se creo exitosamente una identidad <br> * <code>CREATE_IDENTITY_FAIL_MODULE_EXCEPTION</code>: Se genero una excepcion cuando se * ejecuto el metodo para crear la identidad en el Module Manager <br> * <code>CREATE_IDENTITY_FAIL_MODULE_IS_NULL</code>: No se tiene una referencia al Module * Manager <br> * <code>CREATE_IDENTITY_FAIL_NO_VALID_DATA</code>: Los datos ingresados para crear la * identidad no son validos (faltan datos, no tiene el formato correcto, etc) <br> */ private int createNewIdentity() { String brokerNameText = mIdentityName.getText().toString(); boolean dataIsValid = validateIdentityData(brokerNameText, brokerImageByteArray); if (dataIsValid) { if (moduleManager != null) { try { if (!isUpdate) moduleManager.createNewRedeemPoint( brokerNameText, (brokerImageByteArray == null) ? convertImage(R.drawable.ic_profile_male) : brokerImageByteArray); else moduleManager.updateIdentityRedeemPoint( identitySelected.getPublicKey(), brokerNameText, brokerImageByteArray); } catch (CantCreateNewRedeemPointException e) { errorManager.reportUnexpectedUIException( UISource.VIEW, UnexpectedUIExceptionSeverity.UNSTABLE, e); } catch (CantUpdateIdentityRedeemPointException e) { errorManager.reportUnexpectedUIException( UISource.VIEW, UnexpectedUIExceptionSeverity.UNSTABLE, e); } return CREATE_IDENTITY_SUCCESS; } return CREATE_IDENTITY_FAIL_MODULE_IS_NULL; } return CREATE_IDENTITY_FAIL_NO_VALID_DATA; }
private void loadIdentity() { if (identitySelected.getImage() != null) { Bitmap bitmap = null; if (identitySelected.getImage().length > 0) { bitmap = BitmapFactory.decodeByteArray( identitySelected.getImage(), 0, identitySelected.getImage().length); // bitmap = Bitmap.createScaledBitmap(bitmap, mBrokerImage.getWidth(), // mBrokerImage.getHeight(), true); } else { bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.profile_image); // Picasso.with(getActivity()).load(R.drawable.profile_image).into(mBrokerImage); } bitmap = Bitmap.createScaledBitmap(bitmap, 100, 100, true); brokerImageByteArray = toByteArray(bitmap); mIdentityImage.setImageDrawable(ImagesUtils.getRoundedBitmap(getResources(), bitmap)); } mIdentityName.setText(identitySelected.getAlias()); }