Exemple #1
1
  /** Put a nice border on the bitmap. */
  private static View applyFrame(
      final PhotoTable table, final BitmapFactory.Options options, Bitmap decodedPhoto) {
    LayoutInflater inflater =
        (LayoutInflater) table.getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    View photo = inflater.inflate(R.layout.photo, null);
    ImageView image = (ImageView) photo;
    Drawable[] layers = new Drawable[2];
    int photoWidth = options.outWidth;
    int photoHeight = options.outHeight;
    if (decodedPhoto == null || options.outWidth <= 0 || options.outHeight <= 0) {
      photo = null;
    } else {
      decodedPhoto.setHasMipMap(true);
      layers[0] = new BitmapDrawable(table.mResources, decodedPhoto);
      layers[1] = table.mResources.getDrawable(R.drawable.frame);
      LayerDrawable layerList = new LayerDrawable(layers);
      layerList.setLayerInset(0, table.mInset, table.mInset, table.mInset, table.mInset);
      image.setImageDrawable(layerList);

      photo.setTag(R.id.photo_width, Integer.valueOf(photoWidth));
      photo.setTag(R.id.photo_height, Integer.valueOf(photoHeight));

      photo.setOnTouchListener(new PhotoTouchListener(table.getContext(), table));
    }
    return photo;
  }