• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java GifDrawable类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中pl.droidsonroids.gif.GifDrawable的典型用法代码示例。如果您正苦于以下问题:Java GifDrawable类的具体用法?Java GifDrawable怎么用?Java GifDrawable使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



GifDrawable类属于pl.droidsonroids.gif包,在下文中一共展示了GifDrawable类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: onCreate

import pl.droidsonroids.gif.GifDrawable; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_show_gif);

    if (getSupportActionBar() != null) {
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
        getSupportActionBar().setDisplayShowHomeEnabled(false);
    }

    setTitle(R.string.title_show_gif);

    mGifImageView = (GifImageView) findViewById(R.id.gif_image_view);
    try {
        GifDrawable drawable = new GifDrawable(Config.GIF_SAVE_PATH);
        drawable.start();
        drawable.setLoopCount(10);
        mGifImageView.setBackground(drawable);
    } catch (IOException e) {
        e.printStackTrace();
    }
}
 
开发者ID:pili-engineering,项目名称:PLDroidShortVideo,代码行数:23,代码来源:ShowGIFActivity.java


示例2: onMergedEvent

import pl.droidsonroids.gif.GifDrawable; //导入依赖的package包/类
@Subscribe(threadMode = ThreadMode.MAIN)
public void onMergedEvent(EventMergeFinish mergeService) {
    ProgressBarHelper.getInstance(true).dismiss();
    try {
        mViewDrawableOverlay.setVisibility(View.GONE);
        ViewAnimator.animate(mGifImageView).fadeIn().accelerate().duration(600).start();
        mGifImageView.setVisibility(View.VISIBLE);
        GifDrawable gifFromBytes = new GifDrawable(mergeService.getGifPath());
        gifFromBytes.setLoopCount(0xFFFF);
        mGifImageView.setImageDrawable(gifFromBytes);
        mStickerTextDownLoadDialog.dismiss();
    } catch (IOException e) {
        e.printStackTrace();
    }
    String mergePath = mergeService.getGifPath();
    EventBus.getDefault().post(new EventStartNewThread(true, mergePath));
}
 
开发者ID:junchenChow,项目名称:exciting-app,代码行数:18,代码来源:VoiceMainActivity.java


示例3: decodeGifWrapper

import pl.droidsonroids.gif.GifDrawable; //导入依赖的package包/类
private ImageWrapper decodeGifWrapper(InputStream bis, int width, int height) throws IOException {
    ImageWrapper result = null;
    Resource<GifDrawable> gifResource = gifDecoder.decode(bis, width, height);
    if (gifResource != null) {
        GifDrawable drawable = gifResource.get();
        // We can more efficiently hold Bitmaps in memory, so for static GIFs, try to return Bitmaps
        // instead. Returning a Bitmap incurs the cost of allocating the GifDrawable as well as the normal
        // Bitmap allocation, but since we can encode the Bitmap out as a JPEG, future decodes will be
        // efficient.
        if (drawable.getNumberOfFrames() > 1) {
            result = new ImageWrapper(null /*bitmapResource*/, gifResource);
        } else {
            Resource<Bitmap> bitmapResource = new BitmapResource(drawable.getCurrentFrame(), bitmapPool);
            result = new ImageWrapper(bitmapResource, null /*gifResource*/);
        }
    }
    return result;
}
 
开发者ID:dengyuhan,项目名称:GlidePlus,代码行数:19,代码来源:ImageWrapperResourceDecoder.java


示例4: setImageUrl

import pl.droidsonroids.gif.GifDrawable; //导入依赖的package包/类
public void setImageUrl(String iid, String url, boolean cache) {
    if (!webImageCache.containsKey(iid)) {
        if (!reqIids.contains(iid)) {
            //if (!MiscStatics.canRequest(getContext())) return;    //may we ignore this here? I mean opening a index page on the browser laods about 70 thumbnails at once
            reqIids.add(iid);
            Logger.getLogger("a621").info("Downloading " + iid);
            DownloadTask task = new DownloadTask();
            task.execute(iid, url, (cache ? getContext().getCacheDir().getAbsolutePath() : null)); //have at least 16 MiB RAM for the app to cache
            cleanUp(getContext());
        }
    } else {
        Logger.getLogger("a621").info("Using cache for " + iid);
        uUsage(iid);    //update timestamp for this image
        Drawable resource = webImageCache.get(iid);
        setImageDrawable(webImageCache.get(iid));
        updateDisplay();
        if (resource instanceof GifDrawable) ((GifDrawable)resource).start();
    }
}
 
开发者ID:rebane621,项目名称:e621-android,代码行数:20,代码来源:WebImageView.java


示例5: onPostExecute

import pl.droidsonroids.gif.GifDrawable; //导入依赖的package包/类
@Override
protected void onPostExecute(Drawable result) {
    if (result != null) {
        if (sUseCache) {
            Logger.getLogger("a621").info("Storing " + iid + "...");
            WebImageView.webImageCache.put(iid, result);
            WebImageView.webImageUsage.put(iid, System.currentTimeMillis()/1000);
        }
        WebImageView.this.setImageDrawable(result);
        if (gif && cacheDir != null) {  //if cachedir is null we can't have a gif at hand, see code above
            GifDrawable rr = (GifDrawable) result;
            rr.setLoopCount(0);
            rr.start();
        }
        //WebImageView.this.postInvalidate();
        updateDisplay();

        if (reqIids.contains(iid)) reqIids.remove(iid);

        if (wil != null) wil.onImageLoaded();
    } else {
        Logger.getLogger("a621").info("Could not download " + iid);
    }
}
 
开发者ID:rebane621,项目名称:e621-android,代码行数:25,代码来源:WebImageView.java


示例6: onDestroy

import pl.droidsonroids.gif.GifDrawable; //导入依赖的package包/类
@Override
    protected void onDestroy() {
        super.onDestroy();

//        WebView webView = (WebView) findViewById(R.id.webViewGif);
//        if (webView.getVisibility() == View.VISIBLE) {
//            webView.removeAllViews();
//            webView.clearCache(true);
//            webView.destroy();
//            webView = null;
//        }
        if (gifImageView != null && gifImageView.getDrawable() != null) {
            GifDrawable drawable = (GifDrawable) gifImageView.getDrawable();
            drawable.recycle();
        }
        if (attacher != null) {
            attacher.cleanup();
            attacher = null;
        }
    }
 
开发者ID:EuphoriaDev,项目名称:euphoria-vk-client,代码行数:21,代码来源:PhotoViewerActivity.java


示例7: doInBackground

import pl.droidsonroids.gif.GifDrawable; //导入依赖的package包/类
@Override
protected GifDrawable doInBackground(String... strings) {
    try {
        URLConnection urlConnection = new URL(logoUrl).openConnection();
        urlConnection.connect();
        final int contentLength = urlConnection.getContentLength();
        ByteBuffer buffer = ByteBuffer.allocateDirect(contentLength);
        ReadableByteChannel channel = Channels.newChannel(urlConnection.getInputStream());
        while (buffer.remaining() > 0){
            channel.read(buffer);
        }
        channel.close();
        return new GifDrawable(buffer);

    } catch (IOException e) {
        e.printStackTrace();
        return null;
    }

}
 
开发者ID:Galarzaa90,项目名称:TibiaCompendium,代码行数:21,代码来源:GuildFragment.java


示例8: onCreate

import pl.droidsonroids.gif.GifDrawable; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    test_gif = (GifImageView) findViewById(R.id.test_gif);
    //设置图片数据
    test_gif.setImageResource(R.drawable.ui_bg_03);
    final android.widget.MediaController mediaController = new android.widget.MediaController(this);
    mediaController.setMediaPlayer((GifDrawable) test_gif.getDrawable());
    test_gif.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            mediaController.show();
            //Snackbar.make(test_gif, "可以点击哦", Snackbar.LENGTH_LONG).show();
        }
    });
}
 
开发者ID:xmlxin,项目名称:AndroidLogin,代码行数:18,代码来源:MainActivity.java


示例9: displayGif

import pl.droidsonroids.gif.GifDrawable; //导入依赖的package包/类
/**
 * 加载gif图片
 */
private void displayGif(final GifImageView gifView, byte[] res) {
    gifView.setVisibility(View.VISIBLE);

    try {
        GifDrawable gifFromBytes = new GifDrawable(res);
        gifView.setImageDrawable(gifFromBytes);
    } catch (IOException e) {
        gifView.setImageResource(R.mipmap.default_img_rect);
    }

    gifView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            aty.finish();
        }
    });
}
 
开发者ID:kymjs,项目名称:KJGallery,代码行数:21,代码来源:SamplePagerAdapter.java


示例10: decodeByteArrayOrThrow

import pl.droidsonroids.gif.GifDrawable; //导入依赖的package包/类
/**
 * Decodes image from byte array.
 * Returns {@link GifDrawable} if the image is an animated GIF.
 * Returns {@link BitmapDrawable} if the image is s valid static image {@link BitmapFactory}
 * can decode.
 * Returns null on error.
 *
 * @param res     Resources to use if creating a BitmapDrawable
 * @param data    byte array of compressed image data
 * @param options optional options if an image will be decoded to a Bitmap
 * @return decoded {@link Drawable}
 * @throws IOException          on error
 * @throws NullPointerException if the data byte array is null
 */
@NonNull
public static Drawable decodeByteArrayOrThrow(@Nullable final Resources res,
        final byte[] data,
        @Nullable final BitmapFactory.Options options) throws IOException {
    if (data == null) {
        throw new NullPointerException("data byte array must not be null");
    }
    final boolean animated = isAnimatedGif(
            new BufferedInputStream(new ByteArrayInputStream(data)));
    if (animated) {
        return new GifDrawable(data);
    } else {
        final Bitmap decoded = BitmapFactory.decodeByteArray(data, 0, data.length, options);
        if (decoded == null) {
            throw new IOException("BitmapFactory returned null");
        }
        return new BitmapDrawable(res, decoded);
    }
}
 
开发者ID:Doctoror,项目名称:ImageFactory,代码行数:34,代码来源:ImageFactory.java


示例11: testLoopOnceAnimatedGifAsAssetInputStream

import pl.droidsonroids.gif.GifDrawable; //导入依赖的package包/类
public void testLoopOnceAnimatedGifAsAssetInputStream() throws Throwable {
    final Context context = getInstrumentation().getContext();
    final InputStream is1 = context.getAssets()
            .open("loop_once.gif", AssetManager.ACCESS_RANDOM);
    try {
        assertTrue(ImageFactory.isAnimatedGif(new BufferedInputStream(is1)));
    } finally {
        is1.close();
    }

    final InputStream is = context.getAssets()
            .open("loop_once.gif", AssetManager.ACCESS_RANDOM);
    final Drawable result;
    try {
        result = ImageFactory.decodeStreamOrThrow(context.getResources(), is, null, null);
    } finally {
        is.close();
    }
    assertTrue(result instanceof GifDrawable);
    assertTrue(((GifDrawable) result).getLoopCount() == 1);
}
 
开发者ID:Doctoror,项目名称:ImageFactory,代码行数:22,代码来源:ImageFactoryTest.java


示例12: testLoopOnceAnimatedGifAsByteArray

import pl.droidsonroids.gif.GifDrawable; //导入依赖的package包/类
public void testLoopOnceAnimatedGifAsByteArray() throws Throwable {
    final Context context = getInstrumentation().getContext();
    final InputStream is1 = context.getAssets()
            .open("loop_once.gif", AssetManager.ACCESS_RANDOM);
    final byte[] data;
    try {
        data = toByteArray(is1);
    } finally {
        is1.close();
    }

    assertTrue(ImageFactory
            .isAnimatedGif(new BufferedInputStream(new ByteArrayInputStream(data))));
    final Drawable result = ImageFactory.decodeByteArray(context.getResources(), data);
    assertTrue(result instanceof GifDrawable);
    assertTrue(((GifDrawable) result).getLoopCount() == 1);
}
 
开发者ID:Doctoror,项目名称:ImageFactory,代码行数:18,代码来源:ImageFactoryTest.java


示例13: testLoopedAnimatedGifAsAssetInputStream

import pl.droidsonroids.gif.GifDrawable; //导入依赖的package包/类
public void testLoopedAnimatedGifAsAssetInputStream() throws Throwable {
    final Context context = getInstrumentation().getContext();
    final InputStream is1 = context.getAssets()
            .open("w3c_home_animation.gif", AssetManager.ACCESS_RANDOM);
    try {
        assertTrue(ImageFactory.isAnimatedGif(new BufferedInputStream(is1)));
    } finally {
        is1.close();
    }

    final InputStream is = context.getAssets()
            .open("w3c_home_animation.gif", AssetManager.ACCESS_RANDOM);
    final Drawable result;
    try {
        result = ImageFactory.decodeStream(context.getResources(), is);
    } finally {
        is.close();
    }
    assertTrue(result instanceof GifDrawable);
    assertTrue(((GifDrawable) result).getLoopCount() == 0);
}
 
开发者ID:Doctoror,项目名称:ImageFactory,代码行数:22,代码来源:ImageFactoryTest.java


示例14: testLoopedAnimatedGifAsByteArray

import pl.droidsonroids.gif.GifDrawable; //导入依赖的package包/类
public void testLoopedAnimatedGifAsByteArray() throws Throwable {
    final Context context = getInstrumentation().getContext();
    final InputStream is1 = context.getAssets()
            .open("w3c_home_animation.gif", AssetManager.ACCESS_RANDOM);
    final byte[] data;
    try {
        data = toByteArray(is1);
    } finally {
        is1.close();
    }

    assertTrue(ImageFactory
            .isAnimatedGif(new BufferedInputStream(new ByteArrayInputStream(data))));

    final Drawable result = ImageFactory.decodeByteArray(context.getResources(), data);
    assertTrue(result instanceof GifDrawable);
    assertTrue(((GifDrawable) result).getLoopCount() == 0);
}
 
开发者ID:Doctoror,项目名称:ImageFactory,代码行数:19,代码来源:ImageFactoryTest.java


示例15: setFace

import pl.droidsonroids.gif.GifDrawable; //导入依赖的package包/类
private void setFace(SpannableStringBuilder spb, String smileName, int length) {
    String path = SmileTable.get(smileName);
    try {
        int height = (int) editTextFastReply.getTextSize() * 2;
        GifDrawable drawable = new GifDrawable(ChhApplication.getInstance().getAssets(), path);
        // Drawable drawable = Drawable.createFromStream(getResources().getAssets().open(path), smileName);
        drawable.setBounds(0, 0, height, height);
        ImageSpan imageSpan = new ImageSpan(drawable, ImageSpan.ALIGN_BASELINE);
        SpannableString spanStr = new SpannableString(smileName);
        spanStr.setSpan(imageSpan, 0, length, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
        spb.append(spanStr);
    } catch (IOException e) {
        e.printStackTrace();
        spb.append(smileName);
    }

}
 
开发者ID:fei-ke,项目名称:ChipHellClient,代码行数:18,代码来源:FastReplyFragment.java


示例16: loadImage

import pl.droidsonroids.gif.GifDrawable; //导入依赖的package包/类
private void loadImage(String path) {
    if(path.endsWith(".gif")){
        try {
            GifDrawable drawable = new GifDrawable(path);
            imageView.setImageDrawable(drawable);
            drawable.start();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
    if(imageView.getDrawable() == null){
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD_MR1){
            usingTileBitmap(path);
        }else{
            imageView.setImageDrawable(Drawable.createFromPath(path));
        }
    }
    imageView.setOnClickListener(clicked);
}
 
开发者ID:yrom,项目名称:AcFun-Area63,代码行数:20,代码来源:ImagePagerActivity.java


示例17: onDestroyView

import pl.droidsonroids.gif.GifDrawable; //导入依赖的package包/类
@Override
public void onDestroyView() {
    Drawable drawable = imageView.getDrawable();
    if(drawable != null){
        if(drawable instanceof GifDrawable){
            ((GifDrawable) drawable).recycle();
        }else {
            drawable.setCallback(null);
        }
        imageView.setImageDrawable(null);
    }
    
    super.onDestroyView();
    if(task != null && task.loading && !task.isCancelled()){
        task.cancel(true);
    }
}
 
开发者ID:yrom,项目名称:AcFun-Area63,代码行数:18,代码来源:ImagePagerActivity.java


示例18: get

import pl.droidsonroids.gif.GifDrawable; //导入依赖的package包/类
@Override
public GifDrawable get() {
    try {
        GifDrawable newDrawable = new GifDrawable(data);
        newDrawable.setLoopCount(drawable.getLoopCount());
        newDrawable.setTransform(gifTransform);
        return newDrawable;
    } catch (Exception e) {
        e.printStackTrace();
        return drawable;
    }
}
 
开发者ID:dengyuhan,项目名称:GlidePlus,代码行数:13,代码来源:GifDrawableResource.java


示例19: decode

import pl.droidsonroids.gif.GifDrawable; //导入依赖的package包/类
@Override
public Resource<GifDrawable> decode(InputStream source, int width, int height) throws IOException {
    byte[] bytes = mByteDecoder.decode(source, width, height).get();
    GifDrawable gifDrawable = new GifDrawable(bytes);
    gifDrawable.setLoopCount(0);
    return new GifDrawableResource(gifDrawable, bytes);
}
 
开发者ID:dengyuhan,项目名称:GlidePlus,代码行数:8,代码来源:GifResourceDecoder.java


示例20: ImageWrapper

import pl.droidsonroids.gif.GifDrawable; //导入依赖的package包/类
public ImageWrapper(Resource<Bitmap> bitmapResource, Resource<GifDrawable> gifResource) {
    if (bitmapResource != null && gifResource != null) {
        throw new IllegalArgumentException("Can only contain either a bitmap resource or a gif resource, not both");
    } else if (bitmapResource == null && gifResource == null) {
        throw new IllegalArgumentException("Must contain either a bitmap resource or a gif resource");
    } else {
        this.bitmapResource = bitmapResource;
        this.gifResource = gifResource;
    }
}
 
开发者ID:dengyuhan,项目名称:GlidePlus,代码行数:11,代码来源:ImageWrapper.java



注:本文中的pl.droidsonroids.gif.GifDrawable类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java Route类代码示例发布时间:2022-05-21
下一篇:
Java NamenodeProtocol类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap