Fix issue #343
This commit is contained in:
parent
180e6199a1
commit
db132141a9
|
@ -1897,7 +1897,7 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
|
|||
builder.setTitle(R.string.insert_emoji);
|
||||
if (emojis != null && emojis.size() > 0) {
|
||||
GridView gridView = new GridView(TootActivity.this);
|
||||
gridView.setAdapter(new CustomEmojiAdapter(getApplicationContext(), android.R.layout.simple_list_item_1, emojis));
|
||||
gridView.setAdapter(new CustomEmojiAdapter(emojis));
|
||||
gridView.setNumColumns(5);
|
||||
gridView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
||||
@Override
|
||||
|
|
|
@ -25,7 +25,7 @@ import android.graphics.drawable.Drawable;
|
|||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.BaseAdapter;
|
||||
import android.widget.ImageView;
|
||||
|
||||
|
||||
|
@ -49,18 +49,13 @@ import app.fedilab.android.helper.Helper;
|
|||
* Created by Thomas on 03/11/2017.
|
||||
* Adapter to display custom emojis
|
||||
*/
|
||||
public class CustomEmojiAdapter extends ArrayAdapter<Emojis> {
|
||||
public class CustomEmojiAdapter extends BaseAdapter {
|
||||
|
||||
|
||||
private Context context;
|
||||
private List<Emojis> emojis;
|
||||
private CustomEmojiAdapter customEmojiAdapter;
|
||||
|
||||
public CustomEmojiAdapter(@NonNull Context context, int resource, List<Emojis> emojis) {
|
||||
super(context, resource, resource);
|
||||
this.context = context;
|
||||
public CustomEmojiAdapter(List<Emojis> emojis) {
|
||||
this.emojis = emojis;
|
||||
customEmojiAdapter = this;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -83,7 +78,7 @@ public class CustomEmojiAdapter extends ArrayAdapter<Emojis> {
|
|||
final ImageView imageView;
|
||||
Emojis emoji = emojis.get(position);
|
||||
if (convertView == null) {
|
||||
LayoutInflater layoutInflater = LayoutInflater.from(context);
|
||||
LayoutInflater layoutInflater = LayoutInflater.from(parent.getContext());
|
||||
convertView = layoutInflater.inflate(R.layout.drawer_emoji_picker, parent, false);
|
||||
imageView = convertView.findViewById(R.id.img_custom_emoji);
|
||||
} else {
|
||||
|
@ -93,7 +88,7 @@ public class CustomEmojiAdapter extends ArrayAdapter<Emojis> {
|
|||
|
||||
if (!emoji.isDrawableFound()) {
|
||||
emoji.setDrawableFound(true);
|
||||
Glide.with(context)
|
||||
Glide.with(parent.getContext())
|
||||
.asFile()
|
||||
.load(emoji.getUrl())
|
||||
.thumbnail(0.1f)
|
||||
|
@ -102,7 +97,7 @@ public class CustomEmojiAdapter extends ArrayAdapter<Emojis> {
|
|||
public void onResourceReady(@NonNull File resourceFile, @Nullable Transition<? super File> transition) {
|
||||
//new transform(context, emoji,resourceFile, imageView).execute();
|
||||
Drawable resource;
|
||||
SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
||||
SharedPreferences sharedpreferences = parent.getContext().getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
||||
boolean disableAnimatedEmoji = sharedpreferences.getBoolean(Helper.SET_DISABLE_ANIMATED_EMOJI, false);
|
||||
if (!disableAnimatedEmoji) {
|
||||
if (GifParser.isGif(resourceFile.getAbsolutePath())) {
|
||||
|
@ -120,11 +115,9 @@ public class CustomEmojiAdapter extends ArrayAdapter<Emojis> {
|
|||
resource = Drawable.createFromPath(resourceFile.getAbsolutePath());
|
||||
emoji.setDrawable(resource);
|
||||
}
|
||||
customEmojiAdapter.notifyDataSetChanged();
|
||||
imageView.setImageDrawable(emoji.getDrawable());
|
||||
}
|
||||
});
|
||||
} else {
|
||||
imageView.setImageDrawable(emoji.getDrawable());
|
||||
}
|
||||
return convertView;
|
||||
}
|
||||
|
|
|
@ -1271,7 +1271,7 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
|
|||
builder.setTitle(R.string.insert_emoji);
|
||||
if (emojisPicker != null && emojisPicker.size() > 0) {
|
||||
GridView gridView = new GridView(context);
|
||||
gridView.setAdapter(new CustomEmojiAdapter(context, android.R.layout.simple_list_item_1, emojisPicker));
|
||||
gridView.setAdapter(new CustomEmojiAdapter(emojisPicker));
|
||||
gridView.setNumColumns(5);
|
||||
gridView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
||||
@Override
|
||||
|
|
Loading…
Reference in New Issue