如何加载位图而不从URL加载

时间:2016-04-24 16:55:29

标签: java android picasso

@Override
public void onBindViewHolder(final RecyclerItemViewHolder holder, final int position) {

    holder.mPersonName.setText(mPersons.get(position).getName());
    holder.mPersonDescription.setText(mPersons.get(position).getDescription());
    holder.mPersonLocation.setText(mPersons.get(position).getLocation());

    Long time = (mPersons.get(position).getCreationDateLong());
    Date time1 = new Date(time);
    SimpleDateFormat sdf = new SimpleDateFormat("hh:mm a"); // the format of your date
    sdf.setTimeZone(TimeZone.getTimeZone("GMT-4")); // give a timezone reference for formating (see comment at the bottom
    String formattedDate = sdf.format(time1);
    holder.mPersonTime.setText(formattedDate);

    Target targetBitmap = new Target() {
        @Override
        public void onBitmapLoaded(Bitmap bitmap, Picasso.LoadedFrom from) {
            String image = mPersons.get(position).getImage();
            byte[] imageAsBytes = Base64.decode(image.getBytes(), Base64.DEFAULT);
            bitmap = (BitmapFactory.decodeByteArray(imageAsBytes, 0, imageAsBytes.length));
            holder.mPersonPhoto.setImageBitmap(bitmap);
        }
        @Override
        public void onBitmapFailed(Drawable errorDrawable) {}
        @Override
        public void onPrepareLoad(Drawable placeHolderDrawable) {}
    };
    Picasso.with(context).load(?).into(targetBitmap);
    // holder.mPersonPhoto.setImageBitmap(bitmap);
}

.load()上如何在代码中引用位图?

0 个答案:

没有答案