This commit is contained in:
Thomas 2022-07-10 18:17:40 +02:00
parent eb1be4f514
commit 993ecc2382
1 changed files with 1 additions and 31 deletions

View File

@ -16,26 +16,16 @@ package app.fedilab.android.ui.drawer;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.graphics.drawable.Drawable;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.BaseAdapter; import android.widget.BaseAdapter;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.preference.PreferenceManager; import androidx.preference.PreferenceManager;
import androidx.recyclerview.widget.RecyclerView; import androidx.recyclerview.widget.RecyclerView;
import com.bumptech.glide.Glide; import com.bumptech.glide.Glide;
import com.bumptech.glide.request.target.CustomTarget;
import com.bumptech.glide.request.transition.Transition;
import com.github.penfeizhou.animation.apng.APNGDrawable;
import com.github.penfeizhou.animation.apng.decode.APNGParser;
import com.github.penfeizhou.animation.gif.GifDrawable;
import com.github.penfeizhou.animation.gif.decode.GifParser;
import java.io.File;
import java.util.List; import java.util.List;
import app.fedilab.android.R; import app.fedilab.android.R;
@ -76,28 +66,8 @@ public class EmojiAdapter extends BaseAdapter {
SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(holder.view.getContext()); SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(holder.view.getContext());
boolean disableAnimatedEmoji = sharedpreferences.getBoolean(parent.getContext().getString(R.string.SET_DISABLE_ANIMATED_EMOJI), false); boolean disableAnimatedEmoji = sharedpreferences.getBoolean(parent.getContext().getString(R.string.SET_DISABLE_ANIMATED_EMOJI), false);
Glide.with(holder.binding.imgCustomEmoji.getContext()) Glide.with(holder.binding.imgCustomEmoji.getContext())
.asFile()
.load(!disableAnimatedEmoji ? emoji.url : emoji.static_url) .load(!disableAnimatedEmoji ? emoji.url : emoji.static_url)
.into(new CustomTarget<File>() { .into(holder.binding.imgCustomEmoji);
@Override
public void onResourceReady(@NonNull File resource, @Nullable Transition<? super File> transition) {
if (APNGParser.isAPNG(resource.getAbsolutePath())) {
APNGDrawable apngDrawable = APNGDrawable.fromFile(resource.getAbsolutePath());
holder.binding.imgCustomEmoji.setImageDrawable(apngDrawable);
} else if (GifParser.isGif(resource.getAbsolutePath())) {
GifDrawable gifDrawable = GifDrawable.fromFile(resource.getAbsolutePath());
holder.binding.imgCustomEmoji.setImageDrawable(gifDrawable);
} else {
Drawable drawable = Drawable.createFromPath(resource.getAbsolutePath());
holder.binding.imgCustomEmoji.setImageDrawable(drawable);
}
}
@Override
public void onLoadCleared(@Nullable Drawable placeholder) {
}
});
return holder.view; return holder.view;
} }