GifFrame.java
里面三个成员:当前图片、延时、下张Frame的链接。
package com.ant.liao;
import android.graphics.Bitmap;
public class GifFrame {
/**
-
构造函数
-
@param im 图片
-
@param del 延时
*/
public GifFrame(Bitmap im, int del) {
image = im;
delay = del;
}
public GifFrame(String name,int del){
imageName = name;
delay = del;
}
/*图片/
public Bitmap image;
/*延时/
public int delay;
/*当图片存成文件时的文件名/
public String imageName = null;
/*下一帧/
public GifFrame nextFrame = null;
}
GifDecoder.java
解码线程类
http://code.google.com/p/gifview/source/browse/trunk/src/com/ant/liao/GifDecoder.java
GifView.java
主类,包括常用方法,如GifView构造方法、设置图片源、延迟、绘制等。
http://code.google.com/p/gifview/source/browse/trunk/src/com/ant/liao/GifView.java
android-gif-drawable
android-gif-drawable
Views and Drawable for animated GIFs in Android.
项目地址:https://github.com/koral–/android-gif-drawable
Overview
Bundled GIFLib via JNI is used to render frames. This way should be more efficient thanWebView or Movie classes.
Animation starts automatically and run only if View with attached GifDrawable is visible.
Download
Latest release downloads
Setup
Gradle (Android Studio)
Insert the following dependency to build.gradle file of your project.
1.
dependencies {
2.
compile
'pl.droidsonroids.gif:android-gif-drawable:1.0.+'
3.
}
Note that Maven central repository should be defined eg. in top-level build.gradle like this:
01.
buildscript {
02.
repositories {
03.
mavenCentral()
04.
}
05.
}
06.
allprojects {
07.
repositories {
08.
mavenCentral()
09.
}
10.
}
Maven dependency
SDK with API level 19 is needed. If you don’t have it in your local repository, downloadmaven-android-sdk-deployer and install SDK level 19:mvn install -P 4.4 (from maven-android-sdk-deployer directory). Then add dependency inpom.xml of your project:
1.
<dependency>
2.
<groupId>pl.droidsonroids.gif</groupId>
3.
<artifactId>android-gif-drawable</artifactId>
4.
<version>insert latest version here</version>
5.
<type>aar</type>
6.
</dependency>
Requirements
Android 1.6+ (API level 4+)
Building from source
Android NDK needed to compile native sources
Usage
From XML
The simplest way is to use GifImageView (or GifImageButton) like a normalImageView:
1.
<pl.droidsonroids.gif.GifImageView
2.
android:layout_width=``"match_parent"
3.
android:layout_height=``"match_parent"
4.
android:src=``"@drawable/src_anim"
5.
android:background=``"@drawable/bg_anim"
6.
/>
If drawables declared by android:src and/or android:background are GIF files then they will be automatically recognized asGifDrawables and animated. If given drawable is not a GIF then mentioned Views work like plainImageView and ImageButton.
GifTextView allows you to use GIFs as compound drawables and background.
1.
<pl.droidsonroids.gif.GifTextView
2.
android:layout_width=``"match_parent"
3.
android:layout_height=``"match_parent"
4.
android:drawableTop=``"@drawable/left_anim"
5.
android:drawableStart=``"@drawable/left_anim"
6.
android:background=``"@drawable/bg_anim"
7.
/>
From Java code
GifImageView, GifImageButton and GifTextView have also hooks for setters implemented. So animated GIFs can be set by callingsetImageResource(int resId) and setBackgroundResource(int resId)
GifDrawable can be constructed directly from various sources:
01.
//asset file
02.
GifDrawable gifFromAssets =
new
GifDrawable( getAssets(),
"anim.gif"
);
03.
04.
//resource (drawable or raw)
05.
GifDrawable gifFromResource =
new
GifDrawable( getResources(), R.drawable.anim );
06.
07.
//byte array
08.
byte``[] rawGifBytes = ...
09.
GifDrawable gifFromBytes =
new
GifDrawable( rawGifBytes );
10.
11.
//FileDescriptor
12.
FileDescriptor fd =
new
RandomAccessFile(
"/path/anim.gif"``,
"r"
).getFD();
13.
GifDrawable gifFromFd =
new
GifDrawable( fd );
14.
15.
//file path
16.
GifDrawable gifFromPath =
new
GifDrawable(
"/path/anim.gif"
);
17.
18.
//file
19.
File gifFile =
new
File(getFilesDir(),``"anim.gif"``);
20.
GifDrawable gifFromFile =
new
GifDrawable(gifFile);
21.
22.
//AssetFileDescriptor
23.
AssetFileDescriptor afd = getAssets().openFd(
"anim.gif"
);
24.
GifDrawable gifFromAfd =
new
GifDrawable( afd );
25.
26.
//InputStream (it must support marking)
27.
InputStream sourceIs = ...
28.
BufferedInputStream bis =
new
BufferedInputStream( sourceIs, GIF_LENGTH );
29.
GifDrawable gifFromStream =
new
GifDrawable( bis );
30.
31.
//direct ByteBuffer
32.
ByteBuffer rawGifBytes = ...
33.
GifDrawable gifFromBytes =
new
GifDrawable( rawGifBytes );
InputStreams are closed automatically in finalizer if GifDrawable is no longer needed so you don’t need to explicitly close them. Callingrecycle() will also close underlaying input source.
Note that all input sources need to have ability to rewind to the begining. It is required to correctly play animated GIFs (where animation is repeatable) since subsequent frames are decoded on demand from source.
Animation control
GifDrawable implements an Animatable and MediaPlayerControl so you can use its methods and more:
stop() - stops the animation, can be called from any threadstart() - starts the animation, can be called from any threadisRunning() - returns whether animation is currently running or notreset() - rewinds the animation, does not restart stopped onesetSpeed(float factor) - sets new animation speed factor, eg. passing 2.0f will double the animation speedseekTo(int position) - seeks animation (within current loop) to givenposition (in milliseconds) Only seeking forward is supportedgetDuration() - returns duration of one loop of the animationgetCurrentPosition() - returns elapsed time from the beginning of a current loop of animation
UsingMediaPlayerControl
Standard controls for a MediaPlayer (like in VideoView) can be used to control GIF animation and show its current progress.
Just set GifDrawable as MediaPlayer on your MediaController like this:
01.
@Override
自我介绍一下,小编13年上海交大毕业,曾经在小公司待过,也去过华为、OPPO等大厂,18年进入阿里一直到现在。
深知大多数初中级Android工程师,想要提升技能,往往是自己摸索成长或者是报班学习,但对于培训机构动则近万的学费,着实压力不小。自己不成体系的自学效果低效又漫长,而且极易碰到天花板技术停滞不前!
因此收集整理了一份《2024年Android移动开发全套学习资料》,初衷也很简单,就是希望能够帮助到想自学提升又不知道该从何学起的朋友,同时减轻大家的负担。
既有适合小白学习的零基础资料,也有适合3年以上经验的小伙伴深入学习提升的进阶课程,基本涵盖了95%以上Android开发知识点,真正体系化!
由于文件比较大,这里只是将部分目录截图出来,每个节点里面都包含大厂面经、学习笔记、源码讲义、实战项目、讲解视频,并且会持续更新!
如果你觉得这些内容对你有帮助,可以扫码获取!!(备注:Android)
![](https://img-blog.csdnimg.cn/img_convert/18b9ba0e13c26d31c92a6ca703a5817a.jpeg)
最后
今天关于面试的分享就到这里,还是那句话,有些东西你不仅要懂,而且要能够很好地表达出来,能够让面试官认可你的理解,例如Handler机制,这个是面试必问之题。有些晦涩的点,或许它只活在面试当中,实际工作当中你压根不会用到它,但是你要知道它是什么东西。
最后在这里小编分享一份自己收录整理上述技术体系图相关的几十套腾讯、头条、阿里、美团等公司2021年的面试题,把技术点整理成了视频和PDF(实际上比预期多花了不少精力),包含知识脉络 + 诸多细节,由于篇幅有限,这里以图片的形式给大家展示一部分。
还有 高级架构技术进阶脑图、Android开发面试专题资料,高级进阶架构资料 帮助大家学习提升进阶,也节省大家在网上搜索资料的时间来学习,也可以分享给身边好友一起学习。
【算法合集】
【延伸Android必备知识点】
【Android部分高级架构视频学习资源】
**Android精讲视频领取学习后更加是如虎添翼!**进军BATJ大厂等(备战)!现在都说互联网寒冬,其实无非就是你上错了车,且穿的少(技能),要是你上对车,自身技术能力够强,公司换掉的代价大,怎么可能会被裁掉,都是淘汰末端的业务Curd而已!现如今市场上初级程序员泛滥,这套教程针对Android开发工程师1-6年的人员、正处于瓶颈期,想要年后突破自己涨薪的,进阶Android中高级、架构师对你更是如鱼得水,赶快领取吧!
《互联网大厂面试真题解析、进阶开发核心学习笔记、全套讲解视频、实战项目源码讲义》点击传送门即可获取!
习提升进阶,也节省大家在网上搜索资料的时间来学习,也可以分享给身边好友一起学习。
[外链图片转存中…(img-cTYsLfEF-1713497000355)]
【算法合集】
[外链图片转存中…(img-ebWK3Gh4-1713497000356)]
【延伸Android必备知识点】
[外链图片转存中…(img-5Q7tqd1H-1713497000358)]
【Android部分高级架构视频学习资源】
**Android精讲视频领取学习后更加是如虎添翼!**进军BATJ大厂等(备战)!现在都说互联网寒冬,其实无非就是你上错了车,且穿的少(技能),要是你上对车,自身技术能力够强,公司换掉的代价大,怎么可能会被裁掉,都是淘汰末端的业务Curd而已!现如今市场上初级程序员泛滥,这套教程针对Android开发工程师1-6年的人员、正处于瓶颈期,想要年后突破自己涨薪的,进阶Android中高级、架构师对你更是如鱼得水,赶快领取吧!
《互联网大厂面试真题解析、进阶开发核心学习笔记、全套讲解视频、实战项目源码讲义》点击传送门即可获取!