private void loadIdentity() {
    if (identitySelected.getProfileImage() != null) {
      Bitmap bitmap = null;
      if (identitySelected.getProfileImage().length > 0) {
        bitmap =
            BitmapFactory.decodeByteArray(
                identitySelected.getProfileImage(), 0, identitySelected.getProfileImage().length);
        //                bitmap = Bitmap.createScaledBitmap(bitmap, fanImage.getWidth(),
        // fanImage.getHeight(), true);
      } else {
        bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.ic_profile_male);

        // Picasso.with(getActivity()).load(R.drawable.profile_image).into(fanImage);
      }
      bitmap = Bitmap.createScaledBitmap(bitmap, 100, 100, true);
      fanImageByteArray = toByteArray(bitmap);
      fanImage.setImageDrawable(ImagesUtils.getRoundedBitmap(getResources(), bitmap));
    }
    mFanExternalUserName.setText(identitySelected.getUsername());
    //  mFanExternalPassword.setText(identitySelected.getApiToken());
    List<String> arraySpinner = ExternalPlatform.getArrayItems();
    ArrayAdapter<String> adapter =
        new ArrayAdapter<String>(getActivity(), android.R.layout.simple_spinner_item, arraySpinner);
    mFanExternalPlatform.setAdapter(adapter);
    ExternalPlatform[] externalPlatforms = ExternalPlatform.values();
    for (int i = 0; i < externalPlatforms.length; i++) {
      if (externalPlatforms[i] == identitySelected.getExternalPlatform()) {
        mFanExternalPlatform.setSelection(i);
        break;
      }
    }
  }
Пример #2
0
 @Override
 protected void bindHolder(
     AppFriendsListHolder holder, ArtistCommunityInformation data, int position) {
   if (data.getPublicKey() != null) {
     holder.friendName.setText(data.getAlias());
     if (data.getImage() != null) {
       Bitmap bitmap;
       if (data.getImage().length > 0) {
         bitmap = BitmapFactory.decodeByteArray(data.getImage(), 0, data.getImage().length);
       } else {
         bitmap = BitmapFactory.decodeResource(context.getResources(), R.drawable.profile_image);
       }
       bitmap = Bitmap.createScaledBitmap(bitmap, 40, 40, true);
       holder.friendAvatar.setImageDrawable(
           ImagesUtils.getRoundedBitmap(context.getResources(), bitmap));
     } else {
       Bitmap bitmap;
       bitmap = BitmapFactory.decodeResource(context.getResources(), R.drawable.profile_image);
       bitmap = Bitmap.createScaledBitmap(bitmap, 40, 40, true);
       holder.friendAvatar.setImageDrawable(
           ImagesUtils.getRoundedBitmap(context.getResources(), bitmap));
     }
   }
 }
  @Override
  public void onActivityResult(int requestCode, int resultCode, Intent data) {
    //    super.onActivityResult(requestCode, resultCode, data);
    if (resultCode == Activity.RESULT_OK) {
      Bitmap imageBitmap = null;
      ImageView pictureView = fanImage;
      contextMenuInUse = true;

      switch (requestCode) {
        case REQUEST_IMAGE_CAPTURE:
          Bundle extras = data.getExtras();
          imageBitmap = (Bitmap) extras.get("data");
          updateProfileImage = true;
          break;
        case REQUEST_LOAD_IMAGE:
          Uri selectedImage = data.getData();
          try {
            if (isAttached) {
              ContentResolver contentResolver = getActivity().getContentResolver();
              imageBitmap = MediaStore.Images.Media.getBitmap(contentResolver, selectedImage);
              imageBitmap =
                  Bitmap.createScaledBitmap(
                      imageBitmap, pictureView.getWidth(), pictureView.getHeight(), true);
              fanImageByteArray = toByteArray(imageBitmap);
              updateProfileImage = true;
              Picasso.with(getActivity())
                  .load(selectedImage)
                  .transform(new CircleTransform())
                  .into(fanImage);
            }
          } catch (Exception e) {
            e.printStackTrace();
            Toast.makeText(
                    getActivity().getApplicationContext(),
                    "Error cargando la imagen",
                    Toast.LENGTH_SHORT)
                .show();
          }
          break;
      }

      if (pictureView != null && imageBitmap != null)
        pictureView.setImageDrawable(ImagesUtils.getRoundedBitmap(getResources(), imageBitmap));
    }
  }
  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());
  }
 /** Crea una nueva identidad para un crypto customer */
 private void createNewIdentityInBackDevice(String donde) {
   String customerNameText = mCustomerName.getText().toString();
   if (customerNameText.trim().equals("")) {
     Toast.makeText(getActivity(), "The alias must not be empty", Toast.LENGTH_LONG).show();
   } else {
     if (cryptoCustomerBitmap == null) {
       Toast.makeText(getActivity(), "You must enter an image", Toast.LENGTH_LONG).show();
     } else {
       byte[] imgInBytes = ImagesUtils.toByteArray(cryptoCustomerBitmap);
       final CreateCustomerIdentityExecutor executor =
           new CreateCustomerIdentityExecutor(appSession, customerNameText, imgInBytes);
       int resultKey = executor.execute();
       switch (resultKey) {
         case SUCCESS:
           if (donde.equalsIgnoreCase("OnClick")) {
             Toast.makeText(getActivity(), "Crypto Customer Identity Created.", Toast.LENGTH_LONG)
                 .show();
             changeActivity(
                 Activities.CBP_SUB_APP_CRYPTO_CUSTOMER_IDENTITY, appSession.getAppPublicKey());
           }
           new Thread() {
             @Override
             public void run() {
               try {
                 appSession
                     .getModuleManager()
                     .publishCryptoCustomerIdentity(executor.getIdentity().getPublicKey());
               } catch (CouldNotPublishCryptoCustomerException e) {
                 Toast.makeText(getActivity(), "Error al publicar la identidad", Toast.LENGTH_LONG)
                     .show();
               }
             }
           }.start();
           break;
       }
     }
   }
 }
  @Override
  protected void bindHolder(
      final IntraUserInfoViewHolder holder,
      final CryptoWalletIntraUserActor data,
      final int position) {
    holder.getName().setText(data.getAlias());
    RoundedBitmapDrawable roundedBitmap = null;
    byte[] profileImage = data.getProfileImage();
    try {
      if (profileImage != null) {
        if (profileImage.length > 0) {
          roundedBitmap = ImagesUtils.getRoundedBitmap(context.getResources(), profileImage);
          holder.getThumbnail().setImageDrawable(roundedBitmap);
        } else {
          Picasso.with(context)
              .load(R.drawable.ic_profile_male)
              .transform(new CircleTransform())
              .into(holder.getThumbnail());
        }
      } else {
        Picasso.with(context)
            .load(R.drawable.ic_profile_male)
            .transform(new CircleTransform())
            .into(holder.getThumbnail());
        // roundedBitmap = ImagesUtils.getRoundedBitmap(context.getResources(),
        // R.drawable.ic_profile_male);
      }
    } catch (Exception e) {
      Picasso.with(context)
          .load(R.drawable.ic_profile_male)
          .transform(new CircleTransform())
          .into(holder.getThumbnail());
    }

    holder
        .getContainer_data()
        .setOnClickListener(
            new View.OnClickListener() {
              @Override
              public void onClick(View v) {
                boolean selected = !data.isSelected();
                data.setSelected(selected);
                if (selected == true) {
                  ObjectAnimator animator =
                      ObjectAnimator.ofInt(
                              v, "backgroundColor", Color.WHITE, Color.parseColor("#dcf6f7"))
                          .setDuration(1500);
                  animator.setEvaluator(new ArgbEvaluator());
                  animator.start();
                  holder.getCheckbox_connection().setChecked(true);
                  addConnectionCallback.addMenuEnabled();

                } else {
                  ObjectAnimator animator =
                      ObjectAnimator.ofInt(
                              v, "backgroundColor", Color.parseColor("#dcf6f7"), Color.WHITE)
                          .setDuration(1500);
                  animator.setEvaluator(new ArgbEvaluator());
                  animator.start();
                  holder.getCheckbox_connection().setChecked(false);
                  addConnectionCallback.addMenuDisabled();
                }
                //                TransitionDrawable transition = (TransitionDrawable)
                // v.getBackground();
                //                if(selected==false){
                //                    transition.startTransition(300);
                //                }else{
                //                    transition.reverseTransition(300);
                //                }
                // v.setBackground(context.getDrawable(R.drawable.add_connection_rounded_rectangle_shape));
              }
            });
    if (data.isSelected()) {
      holder
          .getContainer_data()
          .setBackground(context.getDrawable(R.drawable.add_connection_rounded_rectangle_shape));
    } else {
      holder.getContainer_data().setBackgroundColor(Color.parseColor("#ffffff"));
    }
  }