Skip to content

Commit ff610e2

Browse files
committed
Update SDK to 25.
Recode samples.
1 parent 15384ec commit ff610e2

File tree

6 files changed

+15
-94
lines changed

6 files changed

+15
-94
lines changed

app/build.gradle

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
apply plugin: 'com.android.application'
22

33
android {
4-
compileSdkVersion 23
5-
buildToolsVersion "23.0.1"
4+
compileSdkVersion 25
5+
buildToolsVersion "25.0.2"
66
defaultConfig {
77
applicationId "com.example.ponycui_home.svgaplayer"
88
minSdkVersion 16
9-
targetSdkVersion 23
9+
targetSdkVersion 25
1010
versionCode 1
1111
versionName "1.0"
1212
}
@@ -30,7 +30,7 @@ android {
3030

3131
dependencies {
3232
compile fileTree(include: ['*.jar'], dir: 'libs')
33-
compile 'com.android.support:appcompat-v7:23.0.0'
33+
compile 'com.android.support:appcompat-v7:25.3.1'
3434
compile project(':library')
3535
compile 'com.squareup.okhttp3:okhttp:3.4.1'
3636
compile "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"

app/src/main/java/com/example/ponycui_home/svgaplayer/MainActivity.java

+3-82
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
/**
4444
* Created by cuiminghui on 2017/3/30.
4545
* 这是最复杂的一个 Sample, 演示了从网络加载动画,并播放动画。
46+
* 更多的 Sample 可以在这里找到 https://github.com/yyued/SVGA-Samples
4647
*/
4748

4849
public class MainActivity extends AppCompatActivity {
@@ -55,97 +56,17 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
5556
super.onCreate(savedInstanceState);
5657
testView = new SVGAImageView(this);
5758
testView.setBackgroundColor(Color.GRAY);
58-
setupCallback();
5959
loadAnimation();
6060
setContentView(testView);
6161
}
6262

63-
private void setupCallback() {
64-
testView.setCallback(new SVGACallback() {
65-
@Override
66-
public void onPause() {
67-
68-
}
69-
70-
@Override
71-
public void onFinished() {
72-
73-
}
74-
75-
@Override
76-
public void onRepeat() {
77-
78-
}
79-
80-
@Override
81-
public void onStep(int frame, double percentage) {
82-
// System.out.println("当前帧:" + frame);
83-
// System.out.println("当前百分比:" + percentage);
84-
}
85-
});
86-
}
87-
88-
// 加载动态图像
89-
private void loadDynamicBitmap(final Runnable complete) {
90-
OkHttpClient client = new OkHttpClient();
91-
Request request = new Request.Builder().url("http://img.hb.aicdn.com/80cc8e001ccdc54febd448dc45119b4bd7924ea5530b-RllWp3_sq320").build();
92-
client.newCall(request).enqueue(new Callback() {
93-
@Override
94-
public void onFailure(Call call, IOException e) {
95-
96-
}
97-
@Override
98-
public void onResponse(Call call, Response response) throws IOException {
99-
final Bitmap dynamicBitmap = BitmapFactory.decodeStream(response.body().byteStream());
100-
if (dynamicBitmap != null) {
101-
final Bitmap editedBitmap = getRoundedCornerBitmap(dynamicBitmap, 168);
102-
runOnUiThread(new Runnable() {
103-
@Override
104-
public void run() {
105-
dynamicItem.setDynamicImage(editedBitmap, "99"); // 99 这个值是由设计提供的
106-
complete.run();
107-
}
108-
});
109-
}
110-
}
111-
});
112-
}
113-
114-
private void loadDynamicText() {
115-
TextPaint textPaint = new TextPaint();
116-
textPaint.setTextSize(30);
117-
textPaint.setFakeBoldText(true);
118-
textPaint.setARGB(0xff, 0xff, 0xe0, 0xa4);
119-
textPaint.setShadowLayer((float)1.0, (float)0.0, (float)1.0, Color.BLACK);
120-
dynamicItem.setDynamicText("崔小姐不吃鱼 送了魔法奇缘", textPaint, "banner");
121-
}
122-
123-
// 如果有需要,你需要为动态加载的图像自行裁剪圆角、添加滤镜等操作。
124-
private static Bitmap getRoundedCornerBitmap(Bitmap bitmap, int pixels) {
125-
Bitmap output = Bitmap.createBitmap(bitmap.getWidth(), bitmap
126-
.getHeight(), Bitmap.Config.ARGB_8888);
127-
Canvas canvas = new Canvas(output);
128-
final int color = 0xff424242;
129-
final Paint paint = new Paint();
130-
final Rect rect = new Rect(0, 0, bitmap.getWidth(), bitmap.getHeight());
131-
final RectF rectF = new RectF(rect);
132-
final float roundPx = pixels;
133-
paint.setAntiAlias(true);
134-
canvas.drawARGB(0, 0, 0, 0);
135-
paint.setColor(color);
136-
canvas.drawRoundRect(rectF, roundPx, roundPx, paint);
137-
paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN));
138-
canvas.drawBitmap(bitmap, rect, rect, paint);
139-
return output;
140-
}
141-
14263
private void loadAnimation() {
14364
SVGAParser parser = new SVGAParser(this);
14465
try {
145-
parser.parse(new URL("http://legox.yy.com/svga/svga-me/angel.svga"), new SVGAParser.ParseCompletion() {
66+
parser.parse(new URL("https://github.com/yyued/SVGA-Samples/blob/master/angel.svga?raw=true"), new SVGAParser.ParseCompletion() {
14667
@Override
14768
public void onComplete(@NotNull SVGAVideoEntity videoItem) {
148-
SVGADrawable drawable = new SVGADrawable(videoItem, dynamicItem);
69+
SVGADrawable drawable = new SVGADrawable(videoItem);
14970
testView.setImageDrawable(drawable);
15071
testView.startAnimation();
15172
}

app/src/main/res/layout/activity_simple.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
android:layout_height="match_parent"
1111
android:layout_width="match_parent"
1212
android:scaleType="fitCenter"
13-
app:source="750x80.svga"
13+
app:source="posche.svga"
1414
app:antiAlias="true"/>
1515

1616
</RelativeLayout>

build.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ buildscript {
66
jcenter()
77
}
88
dependencies {
9-
classpath 'com.android.tools.build:gradle:2.2.2'
9+
classpath 'com.android.tools.build:gradle:2.3.3'
1010
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
1111

1212
// NOTE: Do not place your application dependencies here; they belong
+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
#Thu Aug 18 11:00:59 CST 2016
1+
#Sun Sep 24 19:22:18 CST 2017
22
distributionBase=GRADLE_USER_HOME
33
distributionPath=wrapper/dists
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists
6-
distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip
6+
distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip

library/build.gradle

+4-4
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ apply plugin: 'com.android.library'
22
apply plugin: 'kotlin-android'
33

44
android {
5-
compileSdkVersion 23
6-
buildToolsVersion "23.0.1"
5+
compileSdkVersion 25
6+
buildToolsVersion "25.0.2"
77
defaultConfig {
88
minSdkVersion 14
9-
targetSdkVersion 23
9+
targetSdkVersion 25
1010
versionCode 1
1111
versionName "1.0"
1212
}
@@ -30,7 +30,7 @@ android {
3030

3131
dependencies {
3232
compile fileTree(include: ['*.jar'], dir: 'libs')
33-
compile 'com.android.support:appcompat-v7:23.0.0'
33+
compile 'com.android.support:appcompat-v7:25.3.1'
3434
compile "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
3535
}
3636
repositories {

0 commit comments

Comments
 (0)