Gif
This commit is contained in:
parent
a6abb262ef
commit
1d3e53a001
|
@ -121,7 +121,6 @@ dependencies {
|
|||
implementation "ch.acra:acra-notification:$acraVersion"
|
||||
implementation 'com.github.stom79:Android-WYSIWYG-Editor:3.2.1'
|
||||
implementation 'com.github.duanhong169:colorpicker:1.1.6'
|
||||
implementation 'com.linecorp:apng:1.6.0'
|
||||
|
||||
implementation 'com.github.pengfeizhou.android.animation:awebp:0.2.16'
|
||||
implementation 'com.github.pengfeizhou.android.animation:apng:0.2.16'
|
||||
|
|
|
@ -52,11 +52,11 @@ import com.bumptech.glide.request.RequestListener;
|
|||
import com.bumptech.glide.request.target.SimpleTarget;
|
||||
import com.bumptech.glide.request.target.Target;
|
||||
import com.bumptech.glide.request.transition.Transition;
|
||||
import com.linecorp.apng.ApngDrawable;
|
||||
import com.linecorp.apng.decoder.ApngException;
|
||||
import com.github.pengfeizhou.animation.apng.APNGDrawable;
|
||||
import com.github.pengfeizhou.animation.loader.AssetStreamLoader;
|
||||
import com.github.pengfeizhou.animation.loader.StreamLoader;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.util.ArrayList;
|
||||
|
@ -1089,13 +1089,14 @@ public class Status implements Parcelable{
|
|||
final int[] i = {0};
|
||||
for (final Emojis emoji : emojis) {
|
||||
Glide.with(context)
|
||||
.asFile()
|
||||
.asDrawable()
|
||||
.load(emoji.getUrl())
|
||||
.listener(new RequestListener<File>() {
|
||||
.listener(new RequestListener<Drawable>() {
|
||||
@Override
|
||||
public boolean onResourceReady(File resource, Object model, Target<File> target, DataSource dataSource, boolean isFirstResource) {
|
||||
public boolean onResourceReady(Drawable resource, Object model, Target<Drawable> target, DataSource dataSource, boolean isFirstResource) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onLoadFailed(@Nullable GlideException e, Object model, Target target, boolean isFirstResource) {
|
||||
i[0]++;
|
||||
|
@ -1105,45 +1106,20 @@ public class Status implements Parcelable{
|
|||
return false;
|
||||
}
|
||||
})
|
||||
.into(new SimpleTarget<File>() {
|
||||
.into(new SimpleTarget<Drawable>() {
|
||||
@Override
|
||||
public void onResourceReady(@NonNull File resource, @Nullable Transition<? super File> transition) {
|
||||
|
||||
ApngDrawable emojo = null;
|
||||
Drawable emojoD = null;
|
||||
|
||||
if( ApngDrawable.Companion.isApng(resource)){
|
||||
try {
|
||||
emojo = ApngDrawable.Companion.decode(resource,(int) Helper.convertDpToPixel(20, context),(int) Helper.convertDpToPixel(20, context));
|
||||
Log.v(Helper.TAG,"frame count " + emojo.getFrameCount());
|
||||
emojo.setLoopCount(ApngDrawable.LOOP_FOREVER);
|
||||
emojo.start();
|
||||
|
||||
} catch (ApngException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}else{
|
||||
emojoD = Drawable.createFromPath(resource.getAbsolutePath());
|
||||
assert emojoD != null;
|
||||
emojoD.setBounds(0, 0, (int) Helper.convertDpToPixel(20, context), (int) Helper.convertDpToPixel(20, context));
|
||||
}
|
||||
Log.v(Helper.TAG,"-> " + ApngDrawable.Companion.isApng(resource));
|
||||
public void onResourceReady(@NonNull Drawable resource, @Nullable Transition<? super Drawable> transition) {
|
||||
final String targetedEmoji = ":" + emoji.getShortcode() + ":";
|
||||
if (contentSpan != null && contentSpan.toString().contains(targetedEmoji)) {
|
||||
//emojis can be used several times so we have to loop
|
||||
for (int startPosition = -1; (startPosition = contentSpan.toString().indexOf(targetedEmoji, startPosition + 1)) != -1; startPosition++) {
|
||||
final int endPosition = startPosition + targetedEmoji.length();
|
||||
if( endPosition <= contentSpan.toString().length() && endPosition >= startPosition) {
|
||||
|
||||
ImageSpan imageSpan = new ImageSpan(emojo!=null?emojo:emojoD);
|
||||
resource.setBounds(0,0,(int) Helper.convertDpToPixel(20, context),(int) Helper.convertDpToPixel(20, context));
|
||||
ImageSpan imageSpan = new ImageSpan(resource, ImageSpan.ALIGN_BASELINE);
|
||||
contentSpan.setSpan(
|
||||
imageSpan, startPosition,
|
||||
endPosition, Spannable.SPAN_INCLUSIVE_EXCLUSIVE);
|
||||
if (emojo != null) {
|
||||
emojo.start();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1152,7 +1128,8 @@ public class Status implements Parcelable{
|
|||
for (int startPosition = -1; (startPosition = displayNameSpan.toString().indexOf(targetedEmoji, startPosition + 1)) != -1; startPosition++) {
|
||||
final int endPosition = startPosition + targetedEmoji.length();
|
||||
if(endPosition <= displayNameSpan.toString().length() && endPosition >= startPosition) {
|
||||
ImageSpan imageSpan = new ImageSpan(emojo!=null?emojo:emojoD, ImageSpan.ALIGN_BASELINE);
|
||||
resource.setBounds(0,0,(int) Helper.convertDpToPixel(20, context),(int) Helper.convertDpToPixel(20, context));
|
||||
ImageSpan imageSpan = new ImageSpan(resource, ImageSpan.ALIGN_BASELINE);
|
||||
displayNameSpan.setSpan(
|
||||
imageSpan, startPosition,
|
||||
endPosition, Spannable.SPAN_INCLUSIVE_EXCLUSIVE);
|
||||
|
@ -1165,7 +1142,8 @@ public class Status implements Parcelable{
|
|||
for (int startPosition = -1; (startPosition = contentSpanCW.toString().indexOf(targetedEmoji, startPosition + 1)) != -1; startPosition++) {
|
||||
final int endPosition = startPosition + targetedEmoji.length();
|
||||
if( endPosition <= contentSpanCW.toString().length() && endPosition >= startPosition) {
|
||||
ImageSpan imageSpan = new ImageSpan(emojo!=null?emojo:emojoD, ImageSpan.ALIGN_BASELINE);
|
||||
resource.setBounds(0,0,(int) Helper.convertDpToPixel(20, context),(int) Helper.convertDpToPixel(20, context));
|
||||
ImageSpan imageSpan = new ImageSpan(resource, ImageSpan.ALIGN_BASELINE);
|
||||
contentSpanCW.setSpan(
|
||||
imageSpan, startPosition,
|
||||
endPosition, Spannable.SPAN_INCLUSIVE_EXCLUSIVE);
|
||||
|
@ -1181,6 +1159,7 @@ public class Status implements Parcelable{
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue