当前位置: 首页>>代码示例>>Java>>正文


Java GifDrawable类代码示例

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


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


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