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