Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
fc695b7
dependencies updates
AndroidDeveloperLB Mar 29, 2025
250768c
set targetSdkVersion to 34
AndroidDeveloperLB Mar 29, 2025
a519003
Added 2 ways to go over the frames&bitmaps of the animation file.
AndroidDeveloperLB Mar 3, 2026
b3d8cb9
Added 2 ways to go over the frames&bitmaps of the animation file.
AndroidDeveloperLB Mar 3, 2026
6ccaa63
Updated dependencies. Migrated to kts.
AndroidDeveloperLB Mar 3, 2026
1495a9f
Updated Activities to match material style, fixing their insets issues
AndroidDeveloperLB Mar 4, 2026
220669a
Updated Activities to match material style, fixing their insets issues.
AndroidDeveloperLB Mar 5, 2026
a897e56
Added some nullability annotations in Java.
AndroidDeveloperLB Mar 5, 2026
6e47bae
Rename .java to .kt
AndroidDeveloperLB Mar 5, 2026
5eaf2b8
Converting sample code to Kotlin, adding more to the FrameSequenceTes…
AndroidDeveloperLB Mar 5, 2026
cbf5cf3
Some cleaning of what was added before.
AndroidDeveloperLB Mar 5, 2026
d0cf975
trying to fix issues related to using this library on Jitpack
AndroidDeveloperLB Mar 6, 2026
560c8e8
Added various nullability annotations
AndroidDeveloperLB Mar 6, 2026
041b14b
trying to fix issues related to using this library on Jitpack
AndroidDeveloperLB Mar 6, 2026
5520f3a
trying to fix issues related to using this library on Jitpack
AndroidDeveloperLB Mar 6, 2026
2a2dc6f
trying to fix issues related to using this library on Jitpack
AndroidDeveloperLB Mar 6, 2026
be7ff49
trying to fix issues related to using this library on Jitpack
AndroidDeveloperLB Mar 6, 2026
1a2ee60
Removed a sample file from the FrameSequenceTestActivity.
AndroidDeveloperLB Mar 6, 2026
9f89115
Some refactoring.
AndroidDeveloperLB Mar 6, 2026
9f589b0
Some refactoring.
AndroidDeveloperLB Mar 7, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 0 additions & 38 deletions apng/build.gradle

This file was deleted.

37 changes: 37 additions & 0 deletions apng/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
plugins {
id("com.android.library")
}

android {
namespace = "com.github.penfeizhou.animation.apng"
compileSdk = 36

defaultConfig {
minSdk = 21

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}

buildTypes {
release {
isMinifyEnabled = false
proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro")
}
}

publishing {
singleVariant("release") {
withSourcesJar()
}
}
}

dependencies {
implementation(fileTree(mapOf("dir" to "libs", "include" to listOf("*.jar"))))
api(project(":frameanimation"))
testImplementation("junit:junit:4.13.2")
androidTestImplementation("androidx.test.ext:junit:1.3.0")
androidTestImplementation("androidx.test.espresso:espresso-core:3.7.0")
}

apply(from = rootProject.file("scripts/upload.gradle.kts"))
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

import android.content.Context;

import androidx.annotation.NonNull;

import com.github.penfeizhou.animation.loader.AssetStreamLoader;

/**
Expand All @@ -13,7 +15,7 @@
@Deprecated
public class APNGAssetLoader extends AssetStreamLoader {

public APNGAssetLoader(Context context, String assetName) {
public APNGAssetLoader(@NonNull Context context, String assetName) {
super(context, assetName);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

import android.content.Context;

import androidx.annotation.NonNull;

import com.github.penfeizhou.animation.FrameAnimationDrawable;
import com.github.penfeizhou.animation.apng.decode.APNGDecoder;
import com.github.penfeizhou.animation.decode.FrameSeqDecoder;
Expand All @@ -17,31 +19,35 @@
* @CreateDate: 2019/3/27
*/
public class APNGDrawable extends FrameAnimationDrawable<APNGDecoder> {
public APNGDrawable(Loader provider) {
public APNGDrawable(@NonNull Loader provider) {
super(provider);
}

public APNGDrawable(APNGDecoder decoder) {
public APNGDrawable(@NonNull APNGDecoder decoder) {
super(decoder);
}

@NonNull
@Override
protected APNGDecoder createFrameSeqDecoder(Loader streamLoader, FrameSeqDecoder.RenderListener listener) {
return new APNGDecoder(streamLoader, listener);
}


public static APNGDrawable fromAsset(Context context, String assetPath) {
@NonNull
public static APNGDrawable fromAsset(@NonNull Context context, String assetPath) {
AssetStreamLoader assetStreamLoader = new AssetStreamLoader(context, assetPath);
return new APNGDrawable(assetStreamLoader);
}

@NonNull
public static APNGDrawable fromFile(String filePath) {
FileLoader fileLoader = new FileLoader(filePath);
return new APNGDrawable(fileLoader);
}

public static APNGDrawable fromResource(Context context, int resId) {
@NonNull
public static APNGDrawable fromResource(@NonNull Context context, int resId) {
ResourceStreamLoader resourceStreamLoader = new ResourceStreamLoader(context, resId);
return new APNGDrawable(resourceStreamLoader);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

import android.content.Context;

import androidx.annotation.NonNull;

import com.github.penfeizhou.animation.loader.ResourceStreamLoader;

/**
Expand All @@ -12,7 +14,7 @@
*/
@Deprecated
public class APNGResourceLoader extends ResourceStreamLoader {
public APNGResourceLoader(Context context, int resId) {
public APNGResourceLoader(@NonNull Context context, int resId) {
super(context, resId);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
import android.graphics.Rect;
import android.util.Log;

import androidx.annotation.NonNull;

import com.github.penfeizhou.animation.apng.io.APNGReader;
import com.github.penfeizhou.animation.apng.io.APNGWriter;
import com.github.penfeizhou.animation.decode.Frame;
Expand Down Expand Up @@ -58,6 +60,7 @@ protected APNGWriter getWriter() {
return apngWriter;
}

@NonNull
@Override
protected APNGReader getReader(Reader reader) {
return new APNGReader(reader);
Expand All @@ -75,8 +78,9 @@ protected void release() {
}


@NonNull
@Override
protected Rect read(APNGReader reader) throws IOException {
protected Rect read(@NonNull APNGReader reader) throws IOException {
List<Chunk> chunks = APNGParser.parse(reader);
List<Chunk> otherChunks = new ArrayList<>();

Expand All @@ -89,7 +93,7 @@ protected Rect read(APNGReader reader) throws IOException {
Log.e(TAG, "chunk read reach to end");
break;
}

if (chunk instanceof ACTLChunk) {
mLoopCount = ((ACTLChunk) chunk).num_plays;
actl = true;
Expand Down Expand Up @@ -121,7 +125,7 @@ protected Rect read(APNGReader reader) throws IOException {
canvasWidth = ((IHDRChunk) chunk).width;
canvasHeight = ((IHDRChunk) chunk).height;
ihdrData = ((IHDRChunk) chunk).data;
} else if (!(chunk instanceof IENDChunk)) {
} else {
otherChunks.add(chunk);
}
}
Expand All @@ -131,8 +135,8 @@ protected Rect read(APNGReader reader) throws IOException {
}

@Override
protected void renderFrame(Frame<APNGReader, APNGWriter> frame) {
if (frame == null || fullRect == null) {
protected void renderFrame(@NonNull Frame<APNGReader, APNGWriter> frame) {
if (fullRect == null) {
return;
}
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Rect;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.github.penfeizhou.animation.apng.io.APNGReader;
import com.github.penfeizhou.animation.apng.io.APNGWriter;
Expand Down Expand Up @@ -40,7 +42,7 @@ private CRC32 getCRC32() {
return crc32;
}

public APNGFrame(APNGReader reader, FCTLChunk fctlChunk) {
public APNGFrame(APNGReader reader, @NonNull FCTLChunk fctlChunk) {
super(reader);
blend_op = fctlChunk.blend_op;
dispose_op = fctlChunk.dispose_op;
Expand All @@ -59,7 +61,7 @@ public APNGFrame(APNGReader reader, FCTLChunk fctlChunk) {
frameY = fctlChunk.y_offset;
}

private int encode(APNGWriter apngWriter) throws IOException {
private int encode(@NonNull APNGWriter apngWriter) throws IOException {
int fileSize = 8 + 13 + 12;

//prefixChunks
Expand Down Expand Up @@ -130,7 +132,7 @@ private int encode(APNGWriter apngWriter) throws IOException {


@Override
public Bitmap draw(Canvas canvas, Paint paint, int sampleSize, Bitmap reusedBitmap, APNGWriter writer) {
public Bitmap draw(Canvas canvas, Paint paint, int sampleSize, Bitmap reusedBitmap, @NonNull APNGWriter writer) {
try {
int length = encode(writer);
BitmapFactory.Options options = new BitmapFactory.Options();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import android.content.Context;

import androidx.annotation.NonNull;

import com.github.penfeizhou.animation.apng.io.APNGReader;
import com.github.penfeizhou.animation.io.Reader;
import com.github.penfeizhou.animation.io.StreamReader;
Expand All @@ -24,7 +26,7 @@ static class FormatException extends IOException {
}
}

public static boolean isAPNG(String filePath) {
public static boolean isAPNG(@NonNull String filePath) {
InputStream inputStream = null;
try {
inputStream = new FileInputStream(filePath);
Expand All @@ -42,7 +44,7 @@ public static boolean isAPNG(String filePath) {
}
}

public static boolean isAPNG(Context context, String assetPath) {
public static boolean isAPNG(@NonNull Context context, @NonNull String assetPath) {
InputStream inputStream = null;
try {
inputStream = context.getAssets().open(assetPath);
Expand All @@ -60,7 +62,7 @@ public static boolean isAPNG(Context context, String assetPath) {
}
}

public static boolean isAPNG(Context context, int resId) {
public static boolean isAPNG(@NonNull Context context, int resId) {
InputStream inputStream = null;
try {
inputStream = context.getResources().openRawResource(resId);
Expand Down Expand Up @@ -98,7 +100,8 @@ public static boolean isAPNG(Reader in) {
return false;
}

public static List<Chunk> parse(APNGReader reader) throws IOException {
@NonNull
public static List<Chunk> parse(@NonNull APNGReader reader) throws IOException {
if (!reader.matchFourCC("\u0089PNG") || !reader.matchFourCC("\r\n\u001a\n")) {
throw new FormatException();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

import android.text.TextUtils;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.github.penfeizhou.animation.io.FilterReader;
import com.github.penfeizhou.animation.io.Reader;

Expand All @@ -16,6 +19,7 @@ public class APNGReader extends FilterReader {
private static ThreadLocal<byte[]> __intBytes = new ThreadLocal<>();


@NonNull
protected static byte[] ensureBytes() {
byte[] bytes = __intBytes.get();
if (bytes == null) {
Expand Down Expand Up @@ -48,7 +52,7 @@ public short readShort() throws IOException {
/**
* @return read FourCC and match chars
*/
public boolean matchFourCC(String chars) throws IOException {
public boolean matchFourCC(@Nullable String chars) throws IOException {
if (TextUtils.isEmpty(chars) || chars.length() != 4) {
return false;
}
Expand Down
Loading