Пример #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;
  }
Пример #2
0
    @Override
    public void onPostExecute(View photo) {
      if (photo != null && !mFinished) {
        final PhotoTable table = PhotoTable.this;

        table.addView(
            photo, new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
        if (table.hasSelection()) {
          for (int slot = 0; slot < mOnDeck.length; slot++) {
            if (mOnDeck[slot] != null) {
              table.moveToTopOfPile(mOnDeck[slot]);
            }
          }
          table.moveToTopOfPile(table.getSelection());
        }

        log("drop it");
        table.throwOnTable(photo);

        if (mOnTable.size() > mTableCapacity) {
          int targetSize = Math.max(0, mOnTable.size() - mRedealCount);
          while (mOnTable.size() > targetSize) {
            fadeAway(mOnTable.poll(), false);
          }
        }

        if (table.mOnTable.size() < table.mTableCapacity) {
          table.scheduleNext(table.mFastDropPeriod);
        }
      }
    }