Some fixes

This commit is contained in:
Thomas 2020-06-16 18:23:13 +02:00
parent e310fb850f
commit 1c31f1b9d1
23 changed files with 31 additions and 62 deletions

View File

@ -17,6 +17,7 @@ package app.fedilab.android.asynctasks;
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.os.AsyncTask;
import android.util.Log;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
@ -35,6 +36,7 @@ import app.fedilab.android.client.Entities.Status;
import app.fedilab.android.client.GNUAPI;
import app.fedilab.android.client.PeertubeAPI;
import app.fedilab.android.helper.FilterToots;
import app.fedilab.android.helper.Helper;
import app.fedilab.android.interfaces.OnRetrieveFeedsInterface;
import app.fedilab.android.sqlite.InstancesDAO;
import app.fedilab.android.sqlite.PeertubeFavoritesDAO;
@ -369,13 +371,11 @@ public class RetrieveFeedsAsyncTask extends AsyncTask<Void, Void, Void> {
db = Sqlite.getInstance(contextReference.get().getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
List<app.fedilab.android.client.Entities.Status> statuses = new StatusCacheDAO(contextReference.get(), db).getAllStatus(StatusCacheDAO.BOOKMARK_CACHE);
if (statuses != null) {
for (app.fedilab.android.client.Entities.Status status : statuses) {
app.fedilab.android.client.Entities.Status.fillSpan(contextReference, status);
app.fedilab.android.client.Entities.Status.makeEmojiPoll(contextReference, status.getReblog() != null ? status.getReblog().getPoll() : status.getPoll());
Account.makeAccountNameEmoji(contextReference, status.getReblog() != null ? status.getReblog().getAccount() : status.getAccount());
if( status.getPoll() != null) {
app.fedilab.android.client.Entities.Status.makeEmojiPoll(contextReference, status.getPoll());
}
}
} else {
statuses = new ArrayList<>();

View File

@ -917,17 +917,6 @@ public class Status implements Parcelable {
Glide.with(context)
.asDrawable()
.load(disableAnimatedEmoji ? emoji.getStatic_url() : emoji.getUrl())
.listener(new RequestListener<Drawable>() {
@Override
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) {
return false;
}
})
.into(new CustomTarget<Drawable>() {
@Override
public void onResourceReady(@NonNull Drawable resource, @Nullable Transition<? super Drawable> transition) {
@ -936,7 +925,7 @@ public class Status implements Parcelable {
//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 (resource != null && endPosition <= contentSpan.toString().length() && endPosition >= startPosition) {
if (endPosition <= contentSpan.toString().length() && endPosition >= startPosition) {
ImageSpan imageSpan;
try {
resource.setBounds(0, 0, (int) Helper.convertDpToPixel(20, context), (int) Helper.convertDpToPixel(20, context));
@ -994,17 +983,6 @@ public class Status implements Parcelable {
Glide.with(context)
.asDrawable()
.load(disableAnimatedEmoji ? emoji.getStatic_url() : emoji.getUrl())
.listener(new RequestListener<Drawable>() {
@Override
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) {
return false;
}
})
.into(new CustomTarget<Drawable>() {
@Override
public void onResourceReady(@NonNull Drawable resource, @Nullable Transition<? super Drawable> transition) {
@ -1056,17 +1034,6 @@ public class Status implements Parcelable {
Glide.with(context)
.asBitmap()
.load(imgURL)
.listener(new RequestListener<Bitmap>() {
@Override
public boolean onResourceReady(Bitmap resource, Object model, Target<Bitmap> target, DataSource dataSource, boolean isFirstResource) {
return false;
}
@Override
public boolean onLoadFailed(@Nullable GlideException e, Object model, Target target, boolean isFirstResource) {
return false;
}
})
.into(new CustomTarget<Bitmap>() {
@Override
public void onResourceReady(@NonNull Bitmap resource, Transition<? super Bitmap> transition) {

View File

@ -40,7 +40,7 @@ import static android.content.Context.MODE_PRIVATE;
* Created by Thomas on 03/10/2019
* Adapter for accounts and live notifications
*/
public class AccountLiveAdapter extends RecyclerView.Adapter {
public class AccountLiveAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
private Context context;
private List<Account> accounts;

View File

@ -41,7 +41,7 @@ import app.fedilab.android.interfaces.OnRetrieveEmojiAccountInterface;
* Created by Thomas on 19/06/2019.
* Adapter for account admins
*/
public class AccountsAdminListAdapter extends RecyclerView.Adapter implements OnRetrieveEmojiAccountInterface {
public class AccountsAdminListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> implements OnRetrieveEmojiAccountInterface {
private List<AccountAdmin> accountAdmins;
private Context context;

View File

@ -55,7 +55,7 @@ import es.dmoral.toasty.Toasty;
* Created by Thomas on 07/05/2017.
* Adapter for accounts asking a follow request
*/
public class AccountsFollowRequestAdapter extends RecyclerView.Adapter implements OnPostActionInterface {
public class AccountsFollowRequestAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> implements OnPostActionInterface {
private List<Account> accounts;
private Context context;

View File

@ -50,7 +50,7 @@ import es.dmoral.toasty.Toasty;
* Created by Thomas on 15/12/2017.
* Adapter for accounts in lists
*/
public class AccountsInAListAdapter extends RecyclerView.Adapter implements OnListActionInterface {
public class AccountsInAListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> implements OnListActionInterface {
private List<Account> accounts;
private Context context;

View File

@ -65,7 +65,7 @@ import es.dmoral.toasty.Toasty;
* Created by Thomas on 27/04/2017.
* Adapter for accounts
*/
public class AccountsListAdapter extends RecyclerView.Adapter implements OnPostActionInterface, OnRetrieveEmojiAccountInterface {
public class AccountsListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> implements OnPostActionInterface, OnRetrieveEmojiAccountInterface {
private List<Account> accounts;
private RetrieveAccountsAsyncTask.Type action;

View File

@ -64,7 +64,7 @@ import static android.content.Context.MODE_PRIVATE;
* Created by Thomas on 14/01/2019.
* Adapter for art drawer
*/
public class ArtListAdapter extends RecyclerView.Adapter implements OnPostActionInterface, OnRetrieveEmojiInterface, OnRetrieveRepliesInterface {
public class ArtListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> implements OnPostActionInterface, OnRetrieveEmojiInterface, OnRetrieveRepliesInterface {
private static final int DISPLAYED_STATUS = 1;
private final int HIDDEN_STATUS = 0;

View File

@ -43,7 +43,7 @@ import es.dmoral.toasty.Toasty;
* Created by Thomas on 26/09/2018.
* Adapter for domains
*/
public class DomainsListAdapter extends RecyclerView.Adapter implements OnRetrieveDomainsInterface {
public class DomainsListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> implements OnRetrieveDomainsInterface {
private List<String> domains;
private Context context;

View File

@ -35,7 +35,7 @@ import app.fedilab.android.helper.Helper;
* Created by Thomas on 19/12/2019.
* Adapter for identity proofs
*/
public class IdentityProofsAdapter extends RecyclerView.Adapter {
public class IdentityProofsAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
private Context context;
private List<IdentityProof> identityProofs;

View File

@ -43,7 +43,7 @@ import app.fedilab.android.client.Entities.Status;
* Adapter to display media related to status
*/
public class ImageAdapter extends RecyclerView.Adapter {
public class ImageAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
private Context context;
private List<Status> statuses;

View File

@ -37,7 +37,7 @@ import app.fedilab.android.helper.Helper;
* Adapter to display instances
*/
public class InstancePeertubeRegAdapter extends RecyclerView.Adapter {
public class InstancePeertubeRegAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
private Context context;
private List<InstanceReg> instanceRegs;
private LayoutInflater layoutInflater;

View File

@ -43,7 +43,7 @@ import app.fedilab.android.helper.Helper;
* Adapter to display instances
*/
public class InstanceRegAdapter extends RecyclerView.Adapter {
public class InstanceRegAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
private Context context;
private List<InstanceReg> instanceRegs;
private LayoutInflater layoutInflater;

View File

@ -118,7 +118,7 @@ import static app.fedilab.android.activities.BaseMainActivity.social;
* Adapter for Status
*/
public class NotificationsListAdapter extends RecyclerView.Adapter implements OnPostActionInterface, OnPostNotificationsActionInterface, OnRetrieveEmojiInterface, OnRetrieveEmojiAccountInterface, OnPollInterface, OnRetrieveImageInterface {
public class NotificationsListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> implements OnPostActionInterface, OnPostNotificationsActionInterface, OnRetrieveEmojiInterface, OnRetrieveEmojiAccountInterface, OnPollInterface, OnRetrieveImageInterface {
private final Object lock = new Object();
private Context context;
@ -539,7 +539,7 @@ public class NotificationsListAdapter extends RecyclerView.Adapter implements On
TextView poll_item_percent = item.findViewById(R.id.poll_item_percent);
TextView poll_item_text = item.findViewById(R.id.poll_item_text);
ProgressBar poll_item_value = item.findViewById(R.id.poll_item_value);
poll_item_percent.setText(String.format("%s %%", String.valueOf((int) value)));
poll_item_percent.setText(String.format("%s %%", (int) value));
poll_item_text.setText(pollOption.getTitle(), TextView.BufferType.SPANNABLE);
poll_item_value.setProgress((int) value);
holder.rated.addView(item);
@ -1046,13 +1046,12 @@ public class NotificationsListAdapter extends RecyclerView.Adapter implements On
* @param notification Notification
*/
private void displayConfirmationNotificationDialog(final Notification notification) {
final ArrayList seletedItems = new ArrayList();
final ArrayList<Integer> seletedItems = new ArrayList<>();
AlertDialog dialog = new AlertDialog.Builder(context, style)
.setTitle(R.string.delete_notification_ask)
.setMultiChoiceItems(new String[]{context.getString(R.string.delete_notification_ask_all)}, null, (dialog1, indexSelected, isChecked) -> {
if (isChecked) {
//noinspection unchecked
seletedItems.add(indexSelected);
} else {
if (seletedItems.contains(indexSelected))

View File

@ -55,7 +55,7 @@ import app.fedilab.android.interfaces.OnListActionInterface;
* Created by Thomas on 06/10/2018.
* Adapter for peertube
*/
public class PeertubeAdapter extends RecyclerView.Adapter implements OnListActionInterface {
public class PeertubeAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> implements OnListActionInterface {
private List<Peertube> peertubes;
private Context context;

View File

@ -48,7 +48,7 @@ import app.fedilab.android.helper.Helper;
* Adapter for Peertube notifications
*/
public class PeertubeNotificationsListAdapter extends RecyclerView.Adapter {
public class PeertubeNotificationsListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
private Context context;
private List<PeertubeNotification> notifications;

View File

@ -120,7 +120,7 @@ import static app.fedilab.android.activities.BaseMainActivity.social;
* Created by Thomas on 14/01/2019.
* Adapter for pixelfed drawer
*/
public class PixelfedListAdapter extends RecyclerView.Adapter implements OnPostActionInterface, OnRetrieveEmojiInterface, OnPostStatusActionInterface, OnRetrieveSearchInterface, OnRetrieveSearcAccountshInterface, OnRetrieveContextInterface, OnRetrieveFeedsInterface {
public class PixelfedListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> implements OnPostActionInterface, OnRetrieveEmojiInterface, OnPostStatusActionInterface, OnRetrieveSearchInterface, OnRetrieveSearcAccountshInterface, OnRetrieveContextInterface, OnRetrieveFeedsInterface {
private static final int DISPLAYED_STATUS = 1;
private final int HIDDEN_STATUS = 0;

View File

@ -56,7 +56,7 @@ import app.fedilab.android.helper.Helper;
* Created by Thomas on 02/11/2019.
* Adapter for pixelfed stories drawer
*/
public class PixelfedStoriesListAdapter extends RecyclerView.Adapter {
public class PixelfedStoriesListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
private static final int DISPLAYED_STATUS = 1;
private Context context;

View File

@ -46,7 +46,7 @@ import app.fedilab.android.interfaces.OnPostActionInterface;
* Created by Thomas on 10/03/2020.
* Adapter for reactions on messages
*/
public class ReactionAdapter extends RecyclerView.Adapter implements OnPostActionInterface {
public class ReactionAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> implements OnPostActionInterface {
private List<Reaction> reactions;
private RetrieveFeedsAsyncTask.Type type;

View File

@ -41,7 +41,7 @@ import app.fedilab.android.interfaces.OnRetrieveEmojiAccountInterface;
* Created by Thomas on 19/06/2019.
* Adapter for reports
*/
public class ReportsListAdapter extends RecyclerView.Adapter implements OnRetrieveEmojiAccountInterface {
public class ReportsListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> implements OnRetrieveEmojiAccountInterface {
private List<Report> reports;
private Context context;

View File

@ -197,7 +197,7 @@ import static app.fedilab.android.activities.BaseMainActivity.social;
* Created by Thomas on 24/04/2017.
* Adapter for Status
*/
public class StatusListAdapter extends RecyclerView.Adapter implements OnPostActionInterface, OnRetrieveFeedsInterface, OnRetrieveImageInterface, OnRetrieveEmojiInterface, OnRetrieveRepliesInterface, OnRetrieveCardInterface, OnPollInterface, OnRefreshCachedStatusInterface, OnRetrieveSearcAccountshInterface, OnRetrieveSearchInterface, OnPostStatusActionInterface, OnRetrieveRelationshipQuickReplyInterface, OnSyncBookmarksInterface {
public class StatusListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> implements OnPostActionInterface, OnRetrieveFeedsInterface, OnRetrieveImageInterface, OnRetrieveEmojiInterface, OnRetrieveRepliesInterface, OnRetrieveCardInterface, OnPollInterface, OnRefreshCachedStatusInterface, OnRetrieveSearcAccountshInterface, OnRetrieveSearchInterface, OnPostStatusActionInterface, OnRetrieveRelationshipQuickReplyInterface, OnSyncBookmarksInterface {
public static final int DISPLAYED_STATUS = 1;
public static final int COMPACT_STATUS = 3;
@ -755,7 +755,7 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
TextView poll_item_percent = item.findViewById(R.id.poll_item_percent);
TextView poll_item_text = item.findViewById(R.id.poll_item_text);
ProgressBar poll_item_value = item.findViewById(R.id.poll_item_value);
poll_item_percent.setText(String.format("%s %%", String.valueOf((int) value)));
poll_item_percent.setText(String.format("%s %%", (int) value));
poll_item_text.setText(pollOption.getTitle(), TextView.BufferType.SPANNABLE);
poll_item_value.setProgress((int) value);
holder.rated.addView(item);
@ -1704,6 +1704,9 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
holder.fetch_more.setVisibility(View.GONE);
}
if( type == RetrieveFeedsAsyncTask.Type.CONTEXT ){
holder.fetch_more.setVisibility(View.GONE);
}
if (status.getMentions() != null)
holder.status_mention_spoiler.setText(Helper.makeMentionsClick(context, status.getMentions()), TextView.BufferType.SPANNABLE);

View File

@ -35,7 +35,7 @@ import app.fedilab.android.helper.Helper;
* Created by Thomas on 19/07/2019.
* Adapter for suggestions results
*/
public class SuggestionsAdapter extends RecyclerView.Adapter {
public class SuggestionsAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
private Context context;
private List<Suggestion> suggestions;

View File

@ -39,7 +39,7 @@ import es.dmoral.toasty.Toasty;
* Created by Thomas on 01/12/2018.
* Adapter for tags when editing
*/
public class TagsEditAdapter extends RecyclerView.Adapter {
public class TagsEditAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
private Context context;
private List<String> tags;