Java 类android.graphics.drawable.PictureDrawable 实例源码

项目:GitHub    文件:SvgSoftwareLayerSetter.java   
@Override
public boolean onLoadFailed(GlideException e, Object model, Target<PictureDrawable> target,
    boolean isFirstResource) {
  ImageView view = ((ImageViewTarget<?>) target).getView();
  view.setLayerType(ImageView.LAYER_TYPE_NONE, null);
  return false;
}
项目:GitHub    文件:SvgSoftwareLayerSetter.java   
@Override
public boolean onResourceReady(PictureDrawable resource, Object model,
    Target<PictureDrawable> target, DataSource dataSource, boolean isFirstResource) {
  ImageView view = ((ImageViewTarget<?>) target).getView();
  view.setLayerType(ImageView.LAYER_TYPE_SOFTWARE, null);
  return false;
}
项目:GitHub    文件:SvgSoftwareLayerSetter.java   
@Override
public boolean onLoadFailed(GlideException e, Object model, Target<PictureDrawable> target,
    boolean isFirstResource) {
  ImageView view = ((ImageViewTarget<?>) target).getView();
  view.setLayerType(ImageView.LAYER_TYPE_NONE, null);
  return false;
}
项目:GitHub    文件:SvgSoftwareLayerSetter.java   
@Override
public boolean onResourceReady(PictureDrawable resource, Object model,
    Target<PictureDrawable> target, DataSource dataSource, boolean isFirstResource) {
  ImageView view = ((ImageViewTarget<?>) target).getView();
  view.setLayerType(ImageView.LAYER_TYPE_SOFTWARE, null);
  return false;
}
项目:Noyze    文件:Utils.java   
/**
 * @returns A {@link Bitmap} for a {@link Drawable}.
 */
public static Bitmap drawableToBitmap(final Drawable drawable) {
    if (null == drawable) return null;
    if (drawable instanceof BitmapDrawable) {
        return ((BitmapDrawable) drawable).getBitmap();
    }

    final Bitmap bitmap = Bitmap.createBitmap(Math.max(0, drawable.getIntrinsicWidth()),
            Math.max(0, drawable.getIntrinsicHeight()), Bitmap.Config.ARGB_8888);
    final Canvas canvas = new Canvas(bitmap);

    // PictureDrawable's get handled separately.
    if (drawable instanceof PictureDrawable) {
        canvas.drawPicture(((PictureDrawable) drawable).getPicture());
        return bitmap;
    }

    drawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight());
    drawable.draw(canvas);

    return bitmap;
}
项目:incubator-taverna-mobile    文件:ImageZoomPresenter.java   
@Override
public void attachView(ImageZoomMvpView mvpView) {

    super.attachView(mvpView);

    requestBuilder = Glide.with(getMvpView().getAppContext())
            .using(Glide.buildStreamModelLoader(Uri.class,
                    getMvpView().getAppContext()), InputStream.class)
            .from(Uri.class)
            .as(SVG.class)
            .transcode(new SvgDrawableTranscoder(), PictureDrawable.class)
            .sourceEncoder(new StreamEncoder())
            .cacheDecoder(new FileToStreamDecoder<SVG>(new SvgDecoder()))
            .decoder(new SvgDecoder())
            .placeholder(R.drawable.placeholder)
            .error(R.drawable.placeholder)
            .override(Target.SIZE_ORIGINAL, Target.SIZE_ORIGINAL)
            .animate(android.R.anim.fade_in);

}
项目:xamoom-android-sdk    文件:ContentBlock3ViewHolder.java   
public ContentBlock3ViewHolder(View itemView, Context context,
                               OnContentBlock3ViewHolderInteractionListener listener) {
  super(itemView);
  mContext = context;
  mTitleTextView = (TextView) itemView.findViewById(R.id.titleTextView);
  mCopyrightTextView = (TextView) itemView.findViewById(R.id.copyrightTextView);
  mImageView = (ImageView) itemView.findViewById(R.id.imageImageView);
  mImageProgressBar = (ProgressBar) itemView.findViewById(R.id.imageProgressBar);
  mListener = listener;

  mFileManager = FileManager.getInstance(context);

  SvgDrawableTranscoder svgDrawableTranscoder =  new SvgDrawableTranscoder();
  svgDrawableTranscoder.setmDeviceWidth(mContext.getResources().getDisplayMetrics().widthPixels);

  requestBuilder = Glide.with(mContext)
      .using(Glide.buildStreamModelLoader(Uri.class, mContext), InputStream.class)
      .from(Uri.class)
      .as(SVG.class)
      .transcode(svgDrawableTranscoder, PictureDrawable.class)
      .sourceEncoder(new StreamEncoder())
      .cacheDecoder(new FileToStreamDecoder<>(new SvgDecoder()))
      .decoder(new SvgDecoder())
      .listener(new SvgSoftwareLayerSetter<Uri>());
}
项目:Noyze    文件:Utils.java   
/**
 * @returns A {@link Bitmap} for a {@link Drawable}.
 */
public static Bitmap drawableToBitmap(final Drawable drawable) {
    if (null == drawable) return null;
    if (drawable instanceof BitmapDrawable) {
        return ((BitmapDrawable) drawable).getBitmap();
    }

    final Bitmap bitmap = Bitmap.createBitmap(Math.max(0, drawable.getIntrinsicWidth()),
            Math.max(0, drawable.getIntrinsicHeight()), Bitmap.Config.ARGB_8888);
    final Canvas canvas = new Canvas(bitmap);

    // PictureDrawable's get handled separately.
    if (drawable instanceof PictureDrawable) {
        canvas.drawPicture(((PictureDrawable) drawable).getPicture());
        return bitmap;
    }

    drawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight());
    drawable.draw(canvas);

    return bitmap;
}
项目:PebbleNotificationCenter-Android    文件:IconPickerItem.java   
private void loadSvgIcon(String imageName, ImageView imageView)
{
    SVG cachedSvg = svgCache.get(imageName);
    if (cachedSvg != null)
    {
        imageView.setImageDrawable(new PictureDrawable(cachedSvg.renderToPicture()));
    }
    else
    {
        if (currentlyRetrieving.contains(imageView))
            return;
        currentlyRetrieving.add(imageView);

        imageView.setImageDrawable(null);
        Needle.onBackgroundThread().withThreadPoolSize(10).execute(new IconRetrievalTask(imageName, imageView));
    }
}
项目:PebbleNotificationCenter-Android    文件:IconPickerItem.java   
@Override
protected void thenDoUiRelatedWork(SVG svg)
{
    if (svg != null)
    {
        try
        {
            imageView.setImageDrawable(new PictureDrawable(svg.renderToPicture()));
            svgCache.put(imageName, svg);

        }
        catch (NullPointerException e)
        {
            //renderToPicture() sometimes throws NPE.

            Timber.e("SVG Error", e);
            e.printStackTrace();
        }
    }

    currentlyRetrieving.remove(imageView);
}
项目:GitHub    文件:MainActivity.java   
@Override
protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_main);

  imageViewRes = (ImageView) findViewById(R.id.svg_image_view1);
  imageViewNet = (ImageView) findViewById(R.id.svg_image_view2);

  requestBuilder = GlideApp.with(this)
      .as(PictureDrawable.class)
      .placeholder(R.drawable.image_loading)
      .error(R.drawable.image_error)
      .transition(withCrossFade())
      .listener(new SvgSoftwareLayerSetter());
}
项目:GitHub    文件:SvgDrawableTranscoder.java   
@Override
public Resource<PictureDrawable> transcode(Resource<SVG> toTranscode) {
  SVG svg = toTranscode.get();
  Picture picture = svg.renderToPicture();
  PictureDrawable drawable = new PictureDrawable(picture);
  return new SimpleResource<PictureDrawable>(drawable);
}
项目:GitHub    文件:MainActivity.java   
@Override
protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_main);

  imageViewRes = (ImageView) findViewById(R.id.svg_image_view1);
  imageViewNet = (ImageView) findViewById(R.id.svg_image_view2);

  requestBuilder = GlideApp.with(this)
      .as(PictureDrawable.class)
      .placeholder(R.drawable.image_loading)
      .error(R.drawable.image_error)
      .transition(withCrossFade())
      .listener(new SvgSoftwareLayerSetter());
}
项目:GitHub    文件:SvgDrawableTranscoder.java   
@Override
public Resource<PictureDrawable> transcode(Resource<SVG> toTranscode, Options options) {
  SVG svg = toTranscode.get();
  Picture picture = svg.renderToPicture();
  PictureDrawable drawable = new PictureDrawable(picture);
  return new SimpleResource<>(drawable);
}
项目:microMathematics    文件:SVGImageView.java   
/**
 * Directly set the SVG.
 */
public void setSVG(SVG mysvg) {
    if (mysvg == null)
        throw new IllegalArgumentException("Null value passed to setSVG()");

    setSoftwareLayerType();
    setImageDrawable(new PictureDrawable(mysvg.renderToPicture()));
}
项目:rview    文件:AsyncImageDiffProcessor.java   
private Pair<Drawable, int[]> loadSvg(InputStream is) throws SVGParseException {
    SVG svg = SVG.getFromInputStream(is);
    int[] size = new int[2];
    size[0] = (int) svg.getDocumentViewBox().width();
    size[1] = (int) svg.getDocumentViewBox().height();
    svg.setDocumentWidth(mSize);
    svg.setDocumentHeight(mSize);
    return new Pair<>(new PictureDrawable(svg.renderToPicture()), size);
}
项目:udacity-p3    文件:SvgSoftwareLayerSetter.java   
@Override
public boolean onException(Exception e, T model, Target<PictureDrawable> target, boolean isFirstResource) {
    ImageView view = ((ImageViewTarget<?>) target).getView();
    if (Build.VERSION_CODES.HONEYCOMB <= Build.VERSION.SDK_INT) {
        view.setLayerType(ImageView.LAYER_TYPE_NONE, null);
    }
    return false;
}
项目:udacity-p3    文件:SvgSoftwareLayerSetter.java   
@Override
public boolean onResourceReady(PictureDrawable resource, T model, Target<PictureDrawable> target,
                               boolean isFromMemoryCache, boolean isFirstResource) {
    ImageView view = ((ImageViewTarget<?>) target).getView();
    if (Build.VERSION_CODES.HONEYCOMB <= Build.VERSION.SDK_INT) {
        view.setLayerType(ImageView.LAYER_TYPE_SOFTWARE, null);
    }
    return false;
}
项目:udacity-p3    文件:SvgImageLoader.java   
public static SvgImageLoader getInstance(Context context) {
    if (mInstance == null) {
        mInstance = new SvgImageLoader();
        genericRequestBuilder = Glide.with(context)
                .using(Glide.buildStreamModelLoader(Uri.class, context), InputStream.class)
                .from(Uri.class)
                .as(SVG.class)
                .transcode(new SvgDrawableTranscoder(), PictureDrawable.class)
                .sourceEncoder(new StreamEncoder())
                .cacheDecoder(new FileToStreamDecoder<>(new SvgDecoder()))
                .decoder(new SvgDecoder())
                .listener(new SvgSoftwareLayerSetter<>());
    }
    return mInstance;
}
项目:udacity-p3    文件:SvgDrawableTranscoder.java   
@Override
public Resource<PictureDrawable> transcode(Resource<SVG> toTranscode) {
    SVG svg = toTranscode.get();
    Picture picture = svg.renderToPicture();
    PictureDrawable drawable = new PictureDrawable(picture);
    return new SimpleResource<PictureDrawable>(drawable);
}
项目:webviewtopdf    文件:MainActivity.java   
private static Bitmap pictureDrawable2Bitmap(PictureDrawable pictureDrawable) {
    Bitmap bitmap = Bitmap.createBitmap(pictureDrawable.getIntrinsicWidth()
            , pictureDrawable.getIntrinsicHeight()
            , Bitmap.Config.ARGB_8888);
    Canvas canvas = new Canvas(bitmap);
    canvas.drawPicture(pictureDrawable.getPicture());
    return bitmap;
}
项目:ZzBeeLayout    文件:SVG.java   
/**
     * Create a picture drawable from the SVG.
     * @return the PictureDrawable.
     */
    public PictureDrawable createPictureDrawable() {
        return new PictureDrawable(picture);
//        return new PictureDrawable(picture) {
//            @Override
//            public int getIntrinsicWidth() {
//                if (bounds != null) {
//                    return (int) bounds.width();
//                } else if (limits != null) {
//                    return (int) limits.width();
//                } else {
//                    return -1;
//                }
//            }
//
//            @Override
//            public int getIntrinsicHeight() {
//                if (bounds != null) {
//                    return (int) bounds.height();
//                } else if (limits != null) {
//                    return (int) limits.height();
//                } else {
//                    return -1;
//                }
//            }
//        };
    }
项目:AndroidBaseApplication    文件:CountriesAdapter.java   
@Inject
public CountriesAdapter (@ApplicationContext Context applicationContext)
{
    countryList = new ArrayList<>( );
    context = applicationContext;
    requestBuilder = Glide.with( context )
            .using( Glide.buildStreamModelLoader( Uri.class, context ), InputStream.class )
            .from( Uri.class )
            .as( SVG.class )
            .transcode( new SvgDrawableTranscoder( ), PictureDrawable.class )
            .sourceEncoder( new StreamEncoder( ) )
            .cacheDecoder( new FileToStreamDecoder<SVG>( new SvgDecoder( ) ) )
            .decoder( new SvgDecoder( ) )
            .placeholder( R.mipmap.ic_launcher )
            .error( android.R.drawable.stat_notify_error )
            .animate( android.R.anim.fade_in )
            .listener( new SvgSoftwareLayerSetter<Uri>( ) );
}
项目:AndroidBaseApplication    文件:SvgSoftwareLayerSetter.java   
@Override
public boolean onResourceReady (PictureDrawable resource, T model, Target<PictureDrawable>
        target, boolean isFromMemoryCache, boolean isFirstResource)
{
    ImageView view = (( ImageViewTarget<?> ) target).getView( );
    if ( Build.VERSION_CODES.HONEYCOMB <= Build.VERSION.SDK_INT )
    {
        view.setLayerType( ImageView.LAYER_TYPE_SOFTWARE, null );
    }
    return false;
}
项目:AndroidBaseApplication    文件:SvgDrawableTranscoder.java   
@Override
public Resource<PictureDrawable> transcode (Resource<SVG> toTranscode)
{
    SVG svg = toTranscode.get( );
    Picture picture = svg.renderToPicture( );
    PictureDrawable drawable = new PictureDrawable( picture );
    return new SimpleResource<PictureDrawable>( drawable );
}
项目:tryton_android    文件:SVG.java   
/**
     * Create a picture drawable from the SVG.
     * @return the PictureDrawable.
     */
    public PictureDrawable createPictureDrawable() {
        return new PictureDrawable(picture);
//        return new PictureDrawable(picture) {
//            @Override
//            public int getIntrinsicWidth() {
//                if (bounds != null) {
//                    return (int) bounds.width();
//                } else if (limits != null) {
//                    return (int) limits.width();
//                } else {
//                    return -1;
//                }
//            }
//
//            @Override
//            public int getIntrinsicHeight() {
//                if (bounds != null) {
//                    return (int) bounds.height();
//                } else if (limits != null) {
//                    return (int) limits.height();
//                } else {
//                    return -1;
//                }
//            }
//        };
    }
项目:crate    文件:CrateSvgLoader.java   
@NonNull
@Override
protected Result<PictureDrawable> load(@NonNull SvgHolder holder, @NonNull SvgAsset asset) {
    boolean cached = mCache.containsKey(asset);
    PictureDrawable drawable = mCache.get(asset);
    if (drawable == null) {
        drawable = mCrate.getSvgDrawable(asset);
        if (drawable != null) {
            mCache.put(asset, drawable);
        }
    }
    return new Result<>(drawable, asset, cached);
}
项目:crate    文件:CrateSvgLoader.java   
@Override
protected void apply(@NonNull SvgHolder holder, @NonNull Result<PictureDrawable> result) {
    holder.view.setPictureDrawable(result.payload);
    holder.view.setCached(result.cached);
    holder.loaded = true;
    holder.animateIfReady();
}
项目:stepik-android    文件:GlideSvgRequestFactory.java   
public static GenericRequestBuilder<Uri, InputStream, SVG, PictureDrawable> create(Context context, Drawable placeholder) {
    return Glide.with(context.getApplicationContext())
            .using(Glide.buildStreamModelLoader(Uri.class, context), InputStream.class)
            .from(Uri.class)
            .as(SVG.class)
            .transcode(new SvgDrawableTranscoder(), PictureDrawable.class)
            .sourceEncoder(new StreamEncoder())
            .cacheDecoder(new FileToStreamDecoder<>(new SvgDecoder()))
            .decoder(new SvgDecoder())
            .placeholder(placeholder)
            .listener(new SvgSoftwareLayerSetter());
}
项目:stepik-android    文件:SvgSoftwareLayerSetter.java   
@Override
public boolean onException(Exception e, Uri model, Target<PictureDrawable> target, boolean isFirstResource) {
    ImageView view = ((ImageViewTarget<?>) target).getView();
    if (Build.VERSION_CODES.HONEYCOMB <= Build.VERSION.SDK_INT) {
        view.setLayerType(ImageView.LAYER_TYPE_NONE, null);
    }
    return false;
}
项目:stepik-android    文件:SvgSoftwareLayerSetter.java   
@Override
public boolean onResourceReady(PictureDrawable resource, Uri model, Target<PictureDrawable> target, boolean isFromMemoryCache, boolean isFirstResource) {
    ImageView view = ((ImageViewTarget<?>) target).getView();
    if (Build.VERSION_CODES.HONEYCOMB <= Build.VERSION.SDK_INT) {
        view.setLayerType(ImageView.LAYER_TYPE_SOFTWARE, null);
    }
    return false;
}
项目:stepik-android    文件:SvgDrawableTranscoder.java   
@Override
public Resource<PictureDrawable> transcode(Resource<SVG> toTranscode) {
    SVG svg = toTranscode.get();
    Picture picture = svg.renderToPicture();
    PictureDrawable drawable = new PictureDrawable(picture);
    return new SimpleResource<>(drawable);
}
项目:stepik-android    文件:SVGImageView.java   
/**
 * Directly set the SVG.
 */
public void setSVG(SVG mysvg) {
    if (mysvg == null)
        throw new IllegalArgumentException("Null value passed to setSVG()");

    setSoftwareLayerType();
    setImageDrawable(new PictureDrawable(mysvg.renderToPicture()));
}
项目:PdDroidPublisher    文件:PdDroidPatchView.java   
private static Bitmap picture2Bitmap(Picture picture){
    PictureDrawable pictureDrawable = new PictureDrawable(picture);
    Bitmap bitmap = Bitmap.createBitmap(pictureDrawable.getIntrinsicWidth(), pictureDrawable.getIntrinsicHeight(), Config.ARGB_8888);
    //Log.e(TAG, "picture size: " + pictureDrawable.getIntrinsicWidth() + " " + pictureDrawable.getIntrinsicHeight());
    Canvas canvas = new Canvas(bitmap);
    canvas.drawPicture(pictureDrawable.getPicture());
    return bitmap;
}
项目:PdDroidPublisher    文件:SVG.java   
/**
     * Create a picture drawable from the SVG.
     * @return the PictureDrawable.
     */
    public PictureDrawable createPictureDrawable() {
        return new PictureDrawable(picture);
//        return new PictureDrawable(picture) {
//            @Override
//            public int getIntrinsicWidth() {
//                if (bounds != null) {
//                    return (int) bounds.width();
//                } else if (limits != null) {
//                    return (int) limits.width();
//                } else {
//                    return -1;
//                }
//            }
//
//            @Override
//            public int getIntrinsicHeight() {
//                if (bounds != null) {
//                    return (int) bounds.height();
//                } else if (limits != null) {
//                    return (int) limits.height();
//                } else {
//                    return -1;
//                }
//            }
//        };
    }
项目:incubator-taverna-mobile    文件:SvgSoftwareLayerSetter.java   
@Override
public boolean onException(Exception e, T model, Target<PictureDrawable> target,
                           boolean isFirstResource) {
    ImageView view = ((ImageViewTarget<?>) target).getView();
    if (Build.VERSION_CODES.HONEYCOMB <= Build.VERSION.SDK_INT) {
        view.setLayerType(ImageView.LAYER_TYPE_NONE, null);
    }
    return false;
}
项目:incubator-taverna-mobile    文件:SvgSoftwareLayerSetter.java   
@Override
public boolean onResourceReady(PictureDrawable resource, T model
        , Target<PictureDrawable> target, boolean isFromMemoryCache, boolean isFirstResource) {
    ImageView view = ((ImageViewTarget<?>) target).getView();
    if (Build.VERSION_CODES.HONEYCOMB <= Build.VERSION.SDK_INT) {
        view.setLayerType(ImageView.LAYER_TYPE_SOFTWARE, null);
    }
    return false;
}
项目:incubator-taverna-mobile    文件:SvgDrawableTranscoder.java   
@Override
public Resource<PictureDrawable> transcode(Resource<SVG> toTranscode) {
    SVG svg = toTranscode.get();
    Picture picture = svg.renderToPicture();
    PictureDrawable drawable = new PictureDrawable(picture);
    return new SimpleResource<PictureDrawable>(drawable);
}
项目:xamoom-android-sdk    文件:SvgSoftwareLayerSetter.java   
@Override
public boolean onException(Exception e, T model, Target<PictureDrawable> target, boolean isFirstResource) {
    ImageView view = ((ImageViewTarget<?>) target).getView();
    if (Build.VERSION_CODES.HONEYCOMB <= Build.VERSION.SDK_INT) {
        view.setLayerType(ImageView.LAYER_TYPE_NONE, null);
    }
    e.printStackTrace();
    return false;
}
项目:xamoom-android-sdk    文件:SvgSoftwareLayerSetter.java   
@Override
public boolean onResourceReady(PictureDrawable resource, T model, Target<PictureDrawable> target,
                               boolean isFromMemoryCache, boolean isFirstResource) {
    ImageView view = ((ImageViewTarget<?>) target).getView();
    if (Build.VERSION_CODES.HONEYCOMB <= Build.VERSION.SDK_INT) {
        view.setLayerType(ImageView.LAYER_TYPE_SOFTWARE, null);
    }
    return false;
}