@Override public void onClick(View v) { int i = v.getId(); if (i == R.id.afc_positive_button) { try { if (artistCommunityInformation != null && identity != null) { getSession() .getModuleManager() .disconnectArtist(artistCommunityInformation.getConnectionId()); Toast.makeText(getContext(), "Disconnected successfully", Toast.LENGTH_SHORT).show(); // set flag so that the preceding fragment reads it on dismiss() getSession().setData("connectionresult", 1); } else { Toast.makeText( getContext(), "Oooops! recovering from system error - ", Toast.LENGTH_SHORT) .show(); } dismiss(); } catch (ArtistDisconnectingFailedException e) { getErrorManager() .reportUnexpectedUIException(UISource.VIEW, UnexpectedUIExceptionSeverity.UNSTABLE, e); Toast.makeText(getContext(), "Could not disconnect, please try again", Toast.LENGTH_SHORT) .show(); } catch (ConnectionRequestNotFoundException e) { getErrorManager() .reportUnexpectedUIException(UISource.VIEW, UnexpectedUIExceptionSeverity.UNSTABLE, e); Toast.makeText( getContext(), "There has been an error. Could not disconnect.", Toast.LENGTH_SHORT) .show(); } dismiss(); } else if (i == R.id.afc_negative_button) { dismiss(); } }
@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)); } } }