예제 #1
0
 public void fillView(User user) {
   TextView textView1 = (TextView) findViewById(R.id.textview1);
   textView1.setText(user.getName());
   if (mLayoutId == R.layout.list_item_user) {
     TextView textView2 = (TextView) findViewById(R.id.textview2);
     textView2.setText(
         TomahawkApp.getContext()
             .getString(
                 R.string.followers_count, user.getFollowersCount(), user.getFollowCount()));
   }
   TextView userTextView1 = (TextView) findViewById(R.id.usertextview1);
   ImageView userImageView1 = (ImageView) findViewById(R.id.userimageview1);
   TomahawkUtils.loadUserImageIntoImageView(
       TomahawkApp.getContext(), userImageView1, user, Image.getSmallImageSize(), userTextView1);
 }
 /**
  * Load a circle-shaped {@link android.graphics.Bitmap} asynchronously
  *
  * @param context the context needed for fetching resources
  * @param imageView the {@link android.widget.ImageView}, which will be used to show the {@link
  *     android.graphics.Bitmap}
  * @param user the user of which to load the data into the views
  * @param width the width in pixels to scale the image down to
  * @param textView the textview which is being used to display the first letter of the user's name
  *     in the placeholder image
  */
 public static void loadUserImageIntoImageView(
     Context context, ImageView imageView, User user, int width, TextView textView) {
   int placeHolder = R.drawable.circle_black;
   if (user.getImage() != null && !TextUtils.isEmpty(user.getImage().getImagePath())) {
     textView.setVisibility(View.GONE);
     String imagePath = buildImagePath(user.getImage(), width);
     Picasso.with(context)
         .load(TomahawkUtils.preparePathForPicasso(imagePath))
         .transform(new CircularImageTransformation())
         .placeholder(placeHolder)
         .error(placeHolder)
         .fit()
         .into(imageView);
   } else {
     textView.setVisibility(View.VISIBLE);
     textView.setText(user.getName().substring(0, 1).toUpperCase());
     Picasso.with(context)
         .load(placeHolder)
         .placeholder(placeHolder)
         .error(placeHolder)
         .fit()
         .into(imageView);
   }
 }