Exemplo n.º 1
0
  /**
   * Converts the cropped bitmap to a BitmapDrawable and returns the same.
   *
   * @param view The view for which a background drawable is required.
   * @return Either the cropped bitmap as a Drawable or null.
   */
  public Drawable getDrawable(View view) {
    Bitmap bitmap = getCroppedBitmap(view);
    if (bitmap == null) {
      return null;
    }

    BitmapDrawable drawable = new BitmapDrawable(view.getContext().getResources(), bitmap);
    drawable.setGravity(Gravity.TOP | Gravity.RIGHT);
    drawable.setTileModeXY(Shader.TileMode.CLAMP, Shader.TileMode.CLAMP);
    return drawable;
  }
Exemplo n.º 2
0
          @Override
          protected void onPostExecute(Bitmap result) {
            super.onPostExecute(result);
            BitmapDrawable next = new BitmapDrawable(result);
            next.setGravity(android.view.Gravity.CENTER);
            Drawable previous = imageView.getDrawable();

            if (previous instanceof TransitionDrawable)
              previous = ((TransitionDrawable) previous).getDrawable(1);

            if (previous == null) imageView.setImageDrawable(next);
            else {
              Drawable[] drawables = {previous, next};
              TransitionDrawable transition = new TransitionDrawable(drawables);
              imageView.setImageDrawable(transition);
              transition.startTransition(1000);
            }

            handler.postDelayed(updateSlideshow, DURATION);
          }