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