some tries
This commit is contained in:
parent
96680343e0
commit
dd924cba20
|
@ -22,8 +22,6 @@ import android.content.SharedPreferences;
|
|||
import android.graphics.drawable.ColorDrawable;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.text.SpannableString;
|
||||
import android.text.Spanned;
|
||||
import android.text.method.LinkMovementMethod;
|
||||
|
@ -46,6 +44,7 @@ import com.bumptech.glide.Glide;
|
|||
import com.bumptech.glide.request.target.CustomTarget;
|
||||
import com.bumptech.glide.request.transition.Transition;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
@ -105,14 +104,7 @@ public class AdminAccountActivity extends BaseActivity {
|
|||
}
|
||||
binding.toolbar.setPopupTheme(Helper.popupStyle());
|
||||
if (account != null) {
|
||||
new Thread(() -> {
|
||||
account = SpannableHelper.convertAccount(AdminAccountActivity.this, account);
|
||||
Handler mainHandler = new Handler(Looper.getMainLooper());
|
||||
Runnable myRunnable = () -> initializeView(account);
|
||||
mainHandler.post(myRunnable);
|
||||
|
||||
}).start();
|
||||
|
||||
initializeView(account);
|
||||
} else {
|
||||
Toasty.error(AdminAccountActivity.this, getString(R.string.toast_error_loading_account), Toast.LENGTH_LONG).show();
|
||||
finish();
|
||||
|
@ -314,7 +306,11 @@ public class AdminAccountActivity extends BaseActivity {
|
|||
}
|
||||
|
||||
|
||||
binding.accountDn.setText(account.span_display_name != null ? account.span_display_name : account.display_name, TextView.BufferType.SPANNABLE);
|
||||
binding.accountDn.setText(
|
||||
account.getSpanDisplayName(AdminAccountActivity.this,
|
||||
new WeakReference<>(binding.accountDn),
|
||||
id -> binding.accountDn.invalidate()),
|
||||
TextView.BufferType.SPANNABLE);
|
||||
binding.accountUn.setText(String.format("@%s", account.acct));
|
||||
binding.accountUn.setOnLongClickListener(v -> {
|
||||
ClipboardManager clipboard = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
|
||||
|
|
|
@ -22,8 +22,6 @@ import android.content.SharedPreferences;
|
|||
import android.graphics.drawable.ColorDrawable;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.text.SpannableString;
|
||||
import android.text.Spanned;
|
||||
import android.text.method.LinkMovementMethod;
|
||||
|
@ -46,6 +44,7 @@ import com.bumptech.glide.Glide;
|
|||
import com.bumptech.glide.request.target.CustomTarget;
|
||||
import com.bumptech.glide.request.transition.Transition;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
@ -105,14 +104,7 @@ public class AdminReportActivity extends BaseActivity {
|
|||
}
|
||||
binding.toolbar.setPopupTheme(Helper.popupStyle());
|
||||
if (account != null) {
|
||||
new Thread(() -> {
|
||||
account = SpannableHelper.convertAccount(AdminReportActivity.this, account);
|
||||
Handler mainHandler = new Handler(Looper.getMainLooper());
|
||||
Runnable myRunnable = () -> initializeView(account);
|
||||
mainHandler.post(myRunnable);
|
||||
|
||||
}).start();
|
||||
|
||||
initializeView(account);
|
||||
} else {
|
||||
Toasty.error(AdminReportActivity.this, getString(R.string.toast_error_loading_account), Toast.LENGTH_LONG).show();
|
||||
finish();
|
||||
|
@ -331,8 +323,11 @@ public class AdminReportActivity extends BaseActivity {
|
|||
binding.accountMoved.setMovementMethod(LinkMovementMethod.getInstance());
|
||||
}
|
||||
|
||||
|
||||
binding.accountDn.setText(account.span_display_name != null ? account.span_display_name : account.display_name, TextView.BufferType.SPANNABLE);
|
||||
binding.accountDn.setText(
|
||||
account.getSpanDisplayName(AdminReportActivity.this,
|
||||
new WeakReference<>(binding.accountDn),
|
||||
id -> binding.accountDn.invalidate()),
|
||||
TextView.BufferType.SPANNABLE);
|
||||
binding.accountUn.setText(String.format("@%s", account.acct));
|
||||
binding.accountUn.setOnLongClickListener(v -> {
|
||||
ClipboardManager clipboard = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
|
||||
|
|
|
@ -84,7 +84,6 @@ import app.fedilab.android.helper.DividerDecorationSimple;
|
|||
import app.fedilab.android.helper.Helper;
|
||||
import app.fedilab.android.helper.MastodonHelper;
|
||||
import app.fedilab.android.helper.MediaHelper;
|
||||
import app.fedilab.android.helper.SpannableHelper;
|
||||
import app.fedilab.android.helper.ThemeHelper;
|
||||
import app.fedilab.android.interfaces.OnDownloadInterface;
|
||||
import app.fedilab.android.jobs.ScheduleThreadWorker;
|
||||
|
@ -268,9 +267,6 @@ public class ComposeActivity extends BaseActivity implements ComposeAdapter.Mana
|
|||
}
|
||||
});
|
||||
} else if (statusDraft != null) {//Restore a draft with all messages
|
||||
if (statusDraft.statusReplyList != null) {
|
||||
statusDraft.statusReplyList = SpannableHelper.convertStatus(getApplication().getApplicationContext(), statusDraft.statusReplyList);
|
||||
}
|
||||
if (statusDraft.statusReplyList != null) {
|
||||
statusList.addAll(statusDraft.statusReplyList);
|
||||
binding.recyclerView.addItemDecoration(new DividerDecorationSimple(ComposeActivity.this, statusList));
|
||||
|
@ -285,7 +281,6 @@ public class ComposeActivity extends BaseActivity implements ComposeAdapter.Mana
|
|||
binding.recyclerView.scrollToPosition(composeAdapter.getItemCount() - 1);
|
||||
|
||||
} else if (statusReply != null) {
|
||||
statusReply = SpannableHelper.convertStatus(getApplication().getApplicationContext(), statusReply);
|
||||
statusList.add(statusReply);
|
||||
int statusCount = statusList.size();
|
||||
statusDraftList.get(0).in_reply_to_id = statusReply.id;
|
||||
|
|
|
@ -43,7 +43,6 @@ import app.fedilab.android.databinding.ActivityConversationBinding;
|
|||
import app.fedilab.android.exception.DBException;
|
||||
import app.fedilab.android.helper.Helper;
|
||||
import app.fedilab.android.helper.MastodonHelper;
|
||||
import app.fedilab.android.helper.SpannableHelper;
|
||||
import app.fedilab.android.helper.ThemeHelper;
|
||||
import app.fedilab.android.ui.fragment.timeline.FragmentMastodonContext;
|
||||
import app.fedilab.android.viewmodel.mastodon.StatusesVM;
|
||||
|
@ -88,7 +87,6 @@ public class ContextActivity extends BaseActivity {
|
|||
}
|
||||
MastodonHelper.loadPPMastodon(binding.profilePicture, currentAccount.mastodon_account);
|
||||
Bundle bundle = new Bundle();
|
||||
focusedStatus = SpannableHelper.convertStatus(getApplication().getApplicationContext(), focusedStatus);
|
||||
bundle.putSerializable(Helper.ARG_STATUS, focusedStatus);
|
||||
currentFragment = Helper.addFragment(getSupportFragmentManager(), R.id.nav_host_fragment_content_main, new FragmentMastodonContext(), bundle, null, null);
|
||||
StatusesVM timelinesVM = new ViewModelProvider(ContextActivity.this).get(StatusesVM.class);
|
||||
|
|
|
@ -27,12 +27,7 @@ import android.content.SharedPreferences;
|
|||
import android.content.res.ColorStateList;
|
||||
import android.graphics.drawable.ColorDrawable;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.text.Html;
|
||||
import android.text.Spannable;
|
||||
import android.text.SpannableString;
|
||||
import android.text.Spanned;
|
||||
import android.text.method.LinkMovementMethod;
|
||||
|
@ -65,6 +60,7 @@ import com.bumptech.glide.request.target.CustomTarget;
|
|||
import com.bumptech.glide.request.transition.Transition;
|
||||
import com.google.android.material.tabs.TabLayout;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
@ -90,7 +86,6 @@ import app.fedilab.android.client.entities.app.WellKnownNodeinfo;
|
|||
import app.fedilab.android.databinding.ActivityProfileBinding;
|
||||
import app.fedilab.android.exception.DBException;
|
||||
import app.fedilab.android.helper.CrossActionHelper;
|
||||
import app.fedilab.android.helper.CustomEmoji;
|
||||
import app.fedilab.android.helper.Helper;
|
||||
import app.fedilab.android.helper.MastodonHelper;
|
||||
import app.fedilab.android.helper.SpannableHelper;
|
||||
|
@ -165,14 +160,7 @@ public class ProfileActivity extends BaseActivity {
|
|||
binding.toolbar.setPopupTheme(Helper.popupStyle());
|
||||
accountsVM = new ViewModelProvider(ProfileActivity.this).get(AccountsVM.class);
|
||||
if (account != null) {
|
||||
new Thread(() -> {
|
||||
account = SpannableHelper.convertAccount(ProfileActivity.this, account);
|
||||
Handler mainHandler = new Handler(Looper.getMainLooper());
|
||||
Runnable myRunnable = () -> initializeView(account);
|
||||
mainHandler.post(myRunnable);
|
||||
|
||||
}).start();
|
||||
|
||||
initializeView(account);
|
||||
} else if (account_id != null) {
|
||||
accountsVM.getAccount(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, account_id).observe(ProfileActivity.this, fetchedAccount -> {
|
||||
account = fetchedAccount;
|
||||
|
@ -359,15 +347,12 @@ public class ProfileActivity extends BaseActivity {
|
|||
binding.fieldsContainer.setAdapter(fieldAdapter);
|
||||
binding.fieldsContainer.setLayoutManager(new LinearLayoutManager(ProfileActivity.this));
|
||||
}
|
||||
if (account.span_display_name == null && account.display_name == null) {
|
||||
binding.accountDn.setText(account.username);
|
||||
} else {
|
||||
Spannable textAccount = account.span_display_name != null ? account.span_display_name : new SpannableString(account.display_name);
|
||||
CustomEmoji.displayEmoji(ProfileActivity.this, account.emojis, textAccount, binding.accountDn, null, id -> {
|
||||
binding.accountDn.setText(textAccount, TextView.BufferType.SPANNABLE);
|
||||
});
|
||||
binding.accountDn.setText(textAccount, TextView.BufferType.SPANNABLE);
|
||||
}
|
||||
|
||||
binding.accountDn.setText(
|
||||
account.getSpanDisplayName(ProfileActivity.this,
|
||||
new WeakReference<>(binding.accountDn),
|
||||
id -> binding.accountDn.invalidate()),
|
||||
TextView.BufferType.SPANNABLE);
|
||||
|
||||
binding.accountUn.setText(String.format("@%s", account.acct));
|
||||
binding.accountUn.setOnLongClickListener(v -> {
|
||||
|
@ -381,13 +366,11 @@ public class ProfileActivity extends BaseActivity {
|
|||
clipboard.setPrimaryClip(clip);
|
||||
return false;
|
||||
});
|
||||
Spannable textNote;
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
|
||||
textNote = account.span_note != null ? account.span_note : new SpannableString(Html.fromHtml(account.note, Html.FROM_HTML_MODE_COMPACT));
|
||||
else
|
||||
textNote = account.span_note != null ? account.span_note : new SpannableString(Html.fromHtml(account.note));
|
||||
CustomEmoji.displayEmoji(ProfileActivity.this, account.emojis, textNote, binding.accountNote, null, id -> binding.accountNote.setText(textNote, TextView.BufferType.SPANNABLE));
|
||||
binding.accountNote.setText(textNote, TextView.BufferType.SPANNABLE);
|
||||
binding.accountNote.setText(
|
||||
account.getSpanNote(ProfileActivity.this,
|
||||
new WeakReference<>(binding.accountNote),
|
||||
id -> binding.accountNote.invalidate()),
|
||||
TextView.BufferType.SPANNABLE);
|
||||
binding.accountNote.setMovementMethod(LinkMovementMethod.getInstance());
|
||||
|
||||
MastodonHelper.loadPPMastodon(binding.accountPp, account);
|
||||
|
|
|
@ -14,15 +14,20 @@ package app.fedilab.android.client.entities.api;
|
|||
* You should have received a copy of the GNU General Public License along with Fedilab; if not,
|
||||
* see <http://www.gnu.org/licenses>. */
|
||||
|
||||
import android.content.Context;
|
||||
import android.text.Spannable;
|
||||
import android.view.View;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.Date;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
|
||||
import app.fedilab.android.helper.SpannableHelper;
|
||||
|
||||
public class Account implements Serializable {
|
||||
|
||||
@SerializedName("id")
|
||||
|
@ -74,11 +79,36 @@ public class Account implements Serializable {
|
|||
@SerializedName("moved")
|
||||
public Account moved;
|
||||
|
||||
public transient boolean emojiDisplayNameFetched = false;
|
||||
public transient boolean emojiNoteFetched = false;
|
||||
//Some extra spannable element - They will be filled automatically when fetching the account
|
||||
public transient Spannable span_display_name;
|
||||
public transient Spannable span_note;
|
||||
private transient Spannable span_display_name;
|
||||
private transient Spannable span_note;
|
||||
|
||||
public synchronized Spannable getSpanDisplayName(Context context, WeakReference<View> viewWeakReference, SpannableHelper.EmojiCallback callback) {
|
||||
if (span_display_name != null) {
|
||||
return span_display_name;
|
||||
}
|
||||
if (display_name == null) {
|
||||
display_name = username;
|
||||
}
|
||||
span_display_name = SpannableHelper.convert(context, display_name, null, this, true, viewWeakReference, !emojiDisplayNameFetched ? callback : null);
|
||||
emojiDisplayNameFetched = true;
|
||||
return span_display_name;
|
||||
}
|
||||
|
||||
|
||||
public synchronized Spannable getSpanNote(Context context, WeakReference<View> viewWeakReference, SpannableHelper.EmojiCallback callback) {
|
||||
if (span_note != null) {
|
||||
return span_note;
|
||||
}
|
||||
span_note = SpannableHelper.convert(context, note, null, this, true, viewWeakReference, !emojiNoteFetched ? callback : null);
|
||||
emojiNoteFetched = true;
|
||||
return span_note;
|
||||
}
|
||||
|
||||
public transient RelationShip relationShip;
|
||||
public transient boolean emojiFetched = false;
|
||||
|
||||
|
||||
public static class AccountParams implements Serializable {
|
||||
@SerializedName("discoverable")
|
||||
|
|
|
@ -14,14 +14,19 @@ package app.fedilab.android.client.entities.api;
|
|||
* You should have received a copy of the GNU General Public License along with Fedilab; if not,
|
||||
* see <http://www.gnu.org/licenses>. */
|
||||
|
||||
import android.content.Context;
|
||||
import android.text.Spannable;
|
||||
import android.view.View;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import app.fedilab.android.helper.SpannableHelper;
|
||||
|
||||
public class Poll implements Serializable {
|
||||
|
||||
@SerializedName("id")
|
||||
|
@ -55,5 +60,15 @@ public class Poll implements Serializable {
|
|||
|
||||
//Some extra spannable element - They will be filled automatically when fetching the poll
|
||||
public transient Spannable span_title;
|
||||
public transient boolean emojiTitleFetched = false;
|
||||
|
||||
public Spannable getSpanTitle(Context context, Status status, WeakReference<View> viewWeakReference, SpannableHelper.EmojiCallback callback) {
|
||||
if (span_title != null) {
|
||||
return span_title;
|
||||
}
|
||||
span_title = SpannableHelper.convert(context, title, status, null, true, viewWeakReference, !emojiTitleFetched ? callback : null);
|
||||
emojiTitleFetched = true;
|
||||
return span_title;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,16 +14,21 @@ package app.fedilab.android.client.entities.api;
|
|||
* You should have received a copy of the GNU General Public License along with Fedilab; if not,
|
||||
* see <http://www.gnu.org/licenses>. */
|
||||
|
||||
import android.content.Context;
|
||||
import android.text.Spannable;
|
||||
import android.view.View;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import app.fedilab.android.helper.SpannableHelper;
|
||||
|
||||
public class Status implements Serializable, Cloneable {
|
||||
|
||||
@SerializedName("id")
|
||||
|
@ -88,10 +93,9 @@ public class Status implements Serializable, Cloneable {
|
|||
|
||||
public Attachment art_attachment;
|
||||
|
||||
//Some extra spannable element - They will be filled automatically when fetching the status
|
||||
public transient Spannable span_content;
|
||||
public transient Spannable span_spoiler_text;
|
||||
public transient Spannable span_translate;
|
||||
public transient boolean emojiContentFetched = false;
|
||||
public transient boolean emojiSpoilerFetched = false;
|
||||
public transient boolean emojiTranslateFetched = false;
|
||||
public boolean isExpended = false;
|
||||
public boolean isTruncated = true;
|
||||
public boolean isFetchMore = false;
|
||||
|
@ -105,7 +109,46 @@ public class Status implements Serializable, Cloneable {
|
|||
public transient boolean setCursorToEnd = false;
|
||||
public transient int cursorPosition = 0;
|
||||
public transient boolean submitted = false;
|
||||
public transient boolean emojiFetched = false;
|
||||
//Some extra spannable element - They will be filled automatically when fetching the status
|
||||
private transient Spannable span_content;
|
||||
private transient Spannable span_spoiler_text;
|
||||
private transient Spannable span_translate;
|
||||
|
||||
public synchronized Spannable getSpanContent(Context context, WeakReference<View> viewWeakReference, SpannableHelper.EmojiCallback callback) {
|
||||
if (span_content != null) {
|
||||
return span_content;
|
||||
}
|
||||
span_content = SpannableHelper.convert(context, content, this, null, true, viewWeakReference, !emojiContentFetched ? callback : null);
|
||||
emojiContentFetched = true;
|
||||
return span_content;
|
||||
}
|
||||
|
||||
|
||||
public Spannable getSpanContentNitter() {
|
||||
if (span_content != null) {
|
||||
return span_content;
|
||||
}
|
||||
span_content = SpannableHelper.convertNitter(content);
|
||||
return span_content;
|
||||
}
|
||||
|
||||
public synchronized Spannable getSpanSpoiler(Context context, WeakReference<View> viewWeakReference, SpannableHelper.EmojiCallback callback) {
|
||||
if (span_spoiler_text != null) {
|
||||
return span_spoiler_text;
|
||||
}
|
||||
span_spoiler_text = SpannableHelper.convert(context, spoiler_text, this, null, true, viewWeakReference, !emojiSpoilerFetched ? callback : null);
|
||||
emojiSpoilerFetched = true;
|
||||
return span_spoiler_text;
|
||||
}
|
||||
|
||||
public synchronized Spannable getSpanTranslate(Context context, WeakReference<View> viewWeakReference, SpannableHelper.EmojiCallback callback) {
|
||||
if (span_translate != null) {
|
||||
return span_translate;
|
||||
}
|
||||
span_translate = SpannableHelper.convert(context, translationContent, this, null, true, viewWeakReference, !emojiTranslateFetched ? callback : null);
|
||||
emojiTranslateFetched = true;
|
||||
return span_translate;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public Object clone() throws CloneNotSupportedException {
|
||||
|
|
|
@ -29,7 +29,6 @@ import app.fedilab.android.client.entities.api.Notification;
|
|||
import app.fedilab.android.client.entities.api.Status;
|
||||
import app.fedilab.android.exception.DBException;
|
||||
import app.fedilab.android.helper.MastodonHelper;
|
||||
import app.fedilab.android.helper.SpannableHelper;
|
||||
import app.fedilab.android.sqlite.Sqlite;
|
||||
import app.fedilab.android.ui.fragment.timeline.FragmentMastodonNotification;
|
||||
|
||||
|
@ -576,7 +575,6 @@ public class QuickLoad {
|
|||
}
|
||||
quickLoad.position = c.getInt(c.getColumnIndexOrThrow(Sqlite.COL_POSITION));
|
||||
//TimelineHelper.filterStatus(_mContext, quickLoad.statuses, TimelineHelper.FilterTimeLineType.PUBLIC);
|
||||
quickLoad.statuses = SpannableHelper.convertStatus(_mContext, quickLoad.statuses);
|
||||
return quickLoad;
|
||||
}
|
||||
|
||||
|
|
|
@ -278,8 +278,6 @@ public class CrossActionHelper {
|
|||
if (results != null) {
|
||||
if (results.statuses == null) {
|
||||
results.statuses = new ArrayList<>();
|
||||
} else {
|
||||
results.statuses = SpannableHelper.convertStatus(context, results.statuses);
|
||||
}
|
||||
if (results.accounts == null) {
|
||||
results.accounts = new ArrayList<>();
|
||||
|
@ -308,15 +306,15 @@ public class CrossActionHelper {
|
|||
/**
|
||||
* Fetch and federate the remote status
|
||||
*/
|
||||
public static void fetchRemoteAccount(@NonNull Context context, @NonNull BaseAccount ownerAccount, app.fedilab.android.client.entities.api.Account targetedAccount, Callback callback) {
|
||||
public static void fetchRemoteAccount(@NonNull Context context, @NonNull BaseAccount ownerAccount, String targetedAcct, Callback callback) {
|
||||
|
||||
|
||||
MastodonSearchService mastodonSearchService = init(context, BaseMainActivity.currentInstance);
|
||||
String search;
|
||||
if (targetedAccount.acct.contains("@")) { //Not from same instance
|
||||
search = targetedAccount.acct;
|
||||
if (targetedAcct.contains("@")) { //Not from same instance
|
||||
search = targetedAcct;
|
||||
} else {
|
||||
search = targetedAccount.acct + "@" + BaseMainActivity.currentInstance;
|
||||
search = targetedAcct + "@" + BaseMainActivity.currentInstance;
|
||||
}
|
||||
new Thread(() -> {
|
||||
Call<Results> resultsCall = mastodonSearchService.search(ownerAccount.token, search, null, "accounts", false, true, false, 0, null, null, 1);
|
||||
|
@ -329,8 +327,6 @@ public class CrossActionHelper {
|
|||
if (results != null) {
|
||||
if (results.statuses == null) {
|
||||
results.statuses = new ArrayList<>();
|
||||
} else {
|
||||
results.statuses = SpannableHelper.convertStatus(context, results.statuses);
|
||||
}
|
||||
if (results.accounts == null) {
|
||||
results.accounts = new ArrayList<>();
|
||||
|
@ -374,8 +370,6 @@ public class CrossActionHelper {
|
|||
if (results != null) {
|
||||
if (results.statuses == null) {
|
||||
results.statuses = new ArrayList<>();
|
||||
} else {
|
||||
results.statuses = SpannableHelper.convertStatus(context, results.statuses);
|
||||
}
|
||||
if (results.accounts == null) {
|
||||
results.accounts = new ArrayList<>();
|
||||
|
|
|
@ -115,11 +115,6 @@ public class NotificationsHelper {
|
|||
if (notifications.notifications.size() > 0) {
|
||||
since_ids.put(slug, notifications.notifications.get(0).id);
|
||||
}
|
||||
for (Notification notification : notifications.notifications) {
|
||||
if (notification != null && notification.status != null) {
|
||||
notification.status = SpannableHelper.convertStatus(context.getApplicationContext(), notification.status);
|
||||
}
|
||||
}
|
||||
}
|
||||
notifications.pagination = MastodonHelper.getPagination(notificationsResponse.headers());
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -37,6 +37,7 @@ import androidx.lifecycle.ViewModelStoreOwner;
|
|||
import androidx.preference.PreferenceManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
|
@ -45,7 +46,6 @@ import app.fedilab.android.R;
|
|||
import app.fedilab.android.activities.ProfileActivity;
|
||||
import app.fedilab.android.client.entities.api.Account;
|
||||
import app.fedilab.android.databinding.DrawerAccountBinding;
|
||||
import app.fedilab.android.helper.CustomEmoji;
|
||||
import app.fedilab.android.helper.Helper;
|
||||
import app.fedilab.android.helper.MastodonHelper;
|
||||
import app.fedilab.android.viewmodel.mastodon.AccountsVM;
|
||||
|
@ -225,21 +225,17 @@ public class AccountAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder
|
|||
}
|
||||
});
|
||||
}
|
||||
CustomEmoji.displayEmoji(context, account.emojis, account.span_display_name, accountViewHolder.binding.displayName, account.id, id -> {
|
||||
if (!account.emojiFetched) {
|
||||
account.emojiFetched = true;
|
||||
accountViewHolder.binding.displayName.post(() -> adapter.notifyItemChanged(position));
|
||||
}
|
||||
});
|
||||
accountViewHolder.binding.displayName.setText(account.span_display_name, TextView.BufferType.SPANNABLE);
|
||||
accountViewHolder.binding.displayName.setText(
|
||||
account.getSpanDisplayName(context,
|
||||
new WeakReference<>(accountViewHolder.binding.displayName),
|
||||
id -> adapter.notifyItemChanged(position)),
|
||||
TextView.BufferType.SPANNABLE);
|
||||
accountViewHolder.binding.username.setText(String.format("@%s", account.acct));
|
||||
CustomEmoji.displayEmoji(context, account.emojis, account.span_note, accountViewHolder.binding.bio, account.id, id -> {
|
||||
if (!account.emojiFetched) {
|
||||
account.emojiFetched = true;
|
||||
accountViewHolder.binding.bio.post(() -> adapter.notifyItemChanged(position));
|
||||
}
|
||||
});
|
||||
accountViewHolder.binding.bio.setText(account.span_note, TextView.BufferType.SPANNABLE);
|
||||
accountViewHolder.binding.bio.setText(
|
||||
account.getSpanNote(context,
|
||||
new WeakReference<>(accountViewHolder.binding.bio),
|
||||
id -> adapter.notifyItemChanged(position)),
|
||||
TextView.BufferType.SPANNABLE);
|
||||
}
|
||||
|
||||
public int getCount() {
|
||||
|
|
|
@ -27,6 +27,7 @@ import androidx.lifecycle.ViewModelProvider;
|
|||
import androidx.lifecycle.ViewModelStoreOwner;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
@ -78,7 +79,11 @@ public class AccountListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHo
|
|||
account = getItem(position);
|
||||
AccountListViewHolder holder = (AccountListViewHolder) viewHolder;
|
||||
MastodonHelper.loadPPMastodon(holder.binding.avatar, account);
|
||||
holder.binding.displayName.setText(account.span_display_name, TextView.BufferType.SPANNABLE);
|
||||
holder.binding.displayName.setText(
|
||||
account.getSpanDisplayName(context,
|
||||
new WeakReference<>(holder.binding.displayName),
|
||||
id -> notifyItemChanged(position)),
|
||||
TextView.BufferType.SPANNABLE);
|
||||
holder.binding.username.setText(String.format("@%s", account.acct));
|
||||
|
||||
if (searchList != null) {
|
||||
|
|
|
@ -73,6 +73,7 @@ import com.bumptech.glide.request.target.CustomTarget;
|
|||
import com.bumptech.glide.request.transition.Transition;
|
||||
|
||||
import java.io.File;
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.text.Normalizer;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
|
@ -103,7 +104,6 @@ import app.fedilab.android.databinding.DrawerStatusComposeBinding;
|
|||
import app.fedilab.android.databinding.DrawerStatusSimpleBinding;
|
||||
import app.fedilab.android.databinding.PopupMediaDescriptionBinding;
|
||||
import app.fedilab.android.exception.DBException;
|
||||
import app.fedilab.android.helper.CustomEmoji;
|
||||
import app.fedilab.android.helper.Helper;
|
||||
import app.fedilab.android.helper.MastodonHelper;
|
||||
import app.fedilab.android.helper.ThemeHelper;
|
||||
|
@ -1041,25 +1041,25 @@ public class ComposeAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder
|
|||
if (getItemViewType(position) == TYPE_NORMAL) {
|
||||
Status status = statusList.get(position);
|
||||
StatusSimpleViewHolder holder = (StatusSimpleViewHolder) viewHolder;
|
||||
CustomEmoji.displayEmoji(context, status.emojis, status.span_content, holder.binding.statusContent, status.id, id -> {
|
||||
if (!status.emojiFetched) {
|
||||
status.emojiFetched = true;
|
||||
holder.binding.statusContent.post(() -> notifyItemChanged(position));
|
||||
}
|
||||
});
|
||||
holder.binding.statusContent.setText(status.span_content, TextView.BufferType.SPANNABLE);
|
||||
holder.binding.statusContent.setText(
|
||||
status.getSpanContent(context,
|
||||
new WeakReference<>(holder.binding.statusContent),
|
||||
id -> notifyItemChanged(position)),
|
||||
TextView.BufferType.SPANNABLE);
|
||||
MastodonHelper.loadPPMastodon(holder.binding.avatar, status.account);
|
||||
CustomEmoji.displayEmoji(context, status.account.emojis, status.account.span_display_name, holder.binding.displayName, status.id, id -> {
|
||||
if (!status.account.emojiFetched) {
|
||||
status.account.emojiFetched = true;
|
||||
holder.binding.statusContent.post(() -> notifyItemChanged(position));
|
||||
}
|
||||
});
|
||||
holder.binding.displayName.setText(status.account.span_display_name, TextView.BufferType.SPANNABLE);
|
||||
holder.binding.displayName.setText(
|
||||
status.account.getSpanDisplayName(context,
|
||||
new WeakReference<>(holder.binding.displayName),
|
||||
id -> notifyItemChanged(position)),
|
||||
TextView.BufferType.SPANNABLE);
|
||||
holder.binding.username.setText(String.format("@%s", status.account.acct));
|
||||
if (status.spoiler_text != null && !status.spoiler_text.trim().isEmpty()) {
|
||||
holder.binding.spoiler.setVisibility(View.VISIBLE);
|
||||
holder.binding.spoiler.setText(status.span_spoiler_text, TextView.BufferType.SPANNABLE);
|
||||
holder.binding.spoiler.setText(
|
||||
status.getSpanSpoiler(context,
|
||||
new WeakReference<>(holder.binding.spoiler),
|
||||
id -> notifyItemChanged(position)),
|
||||
TextView.BufferType.SPANNABLE);
|
||||
} else {
|
||||
holder.binding.spoiler.setVisibility(View.GONE);
|
||||
holder.binding.spoiler.setText(null);
|
||||
|
|
|
@ -36,6 +36,7 @@ import androidx.recyclerview.widget.RecyclerView;
|
|||
import com.bumptech.glide.Glide;
|
||||
import com.bumptech.glide.request.RequestOptions;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Timer;
|
||||
|
@ -49,7 +50,6 @@ import app.fedilab.android.client.entities.api.Conversation;
|
|||
import app.fedilab.android.client.entities.api.Status;
|
||||
import app.fedilab.android.databinding.DrawerConversationBinding;
|
||||
import app.fedilab.android.databinding.ThumbnailBinding;
|
||||
import app.fedilab.android.helper.CustomEmoji;
|
||||
import app.fedilab.android.helper.Helper;
|
||||
import app.fedilab.android.helper.MastodonHelper;
|
||||
|
||||
|
@ -138,26 +138,22 @@ public class ConversationAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
|
|||
notifyItemChanged(position);
|
||||
});
|
||||
holder.binding.spoiler.setVisibility(View.VISIBLE);
|
||||
CustomEmoji.displayEmoji(context, conversation.last_status.emojis, conversation.last_status.span_spoiler_text, holder.binding.spoiler, conversation.last_status.id, id -> {
|
||||
if (!conversation.last_status.emojiFetched) {
|
||||
conversation.last_status.emojiFetched = true;
|
||||
holder.binding.spoiler.post(() -> notifyItemChanged(position));
|
||||
}
|
||||
});
|
||||
holder.binding.spoiler.setText(conversation.last_status.span_spoiler_text, TextView.BufferType.SPANNABLE);
|
||||
holder.binding.spoiler.setText(
|
||||
conversation.last_status.getSpanSpoiler(context,
|
||||
new WeakReference<>(holder.binding.spoiler),
|
||||
id -> notifyItemChanged(position)),
|
||||
TextView.BufferType.SPANNABLE);
|
||||
} else {
|
||||
holder.binding.spoiler.setVisibility(View.GONE);
|
||||
holder.binding.spoilerExpand.setVisibility(View.GONE);
|
||||
holder.binding.spoiler.setText(null);
|
||||
}
|
||||
//--- MAIN CONTENT ---
|
||||
CustomEmoji.displayEmoji(context, conversation.last_status.emojis, conversation.last_status.span_content, holder.binding.statusContent, conversation.last_status.id, id -> {
|
||||
if (!conversation.last_status.emojiFetched) {
|
||||
conversation.last_status.emojiFetched = true;
|
||||
holder.binding.statusContent.post(() -> notifyItemChanged(position));
|
||||
}
|
||||
});
|
||||
holder.binding.statusContent.setText(conversation.last_status.span_content, TextView.BufferType.SPANNABLE);
|
||||
holder.binding.statusContent.setText(
|
||||
conversation.last_status.getSpanContent(context,
|
||||
new WeakReference<>(holder.binding.statusContent),
|
||||
id -> notifyItemChanged(position)),
|
||||
TextView.BufferType.SPANNABLE);
|
||||
//--- DATE ---
|
||||
holder.binding.lastMessageDate.setText(Helper.dateDiff(context, conversation.last_status.created_at));
|
||||
|
||||
|
|
|
@ -21,8 +21,6 @@ import android.app.Activity;
|
|||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.text.Spannable;
|
||||
import android.text.SpannableString;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
@ -34,6 +32,7 @@ import androidx.lifecycle.ViewModelProvider;
|
|||
import androidx.lifecycle.ViewModelStoreOwner;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
|
@ -45,7 +44,6 @@ import app.fedilab.android.databinding.DrawerFetchMoreBinding;
|
|||
import app.fedilab.android.databinding.DrawerFollowBinding;
|
||||
import app.fedilab.android.databinding.DrawerStatusNotificationBinding;
|
||||
import app.fedilab.android.databinding.NotificationsRelatedAccountsBinding;
|
||||
import app.fedilab.android.helper.CustomEmoji;
|
||||
import app.fedilab.android.helper.Helper;
|
||||
import app.fedilab.android.helper.MastodonHelper;
|
||||
import app.fedilab.android.viewmodel.mastodon.SearchVM;
|
||||
|
@ -118,24 +116,37 @@ public class NotificationAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Will manage the current position of the element in the adapter. Action is async, and position might have changed
|
||||
*
|
||||
* @param notificationList List<Notification> - Not null when calling from notification adapter
|
||||
* @param id String - Current status
|
||||
* @return int - position in real time
|
||||
*/
|
||||
public static int getPositionAsync(List<Notification> notificationList, String id) {
|
||||
int position = 0;
|
||||
if (notificationList != null) {
|
||||
for (Notification notification : notificationList) {
|
||||
if (notification.status != null && notification.status.id.compareTo(id) == 0) {
|
||||
break;
|
||||
}
|
||||
position++;
|
||||
}
|
||||
}
|
||||
return position;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder viewHolder, int position) {
|
||||
Notification notification = notificationList.get(position);
|
||||
if (getItemViewType(position) == TYPE_FOLLOW || getItemViewType(position) == TYPE_FOLLOW_REQUEST) {
|
||||
ViewHolderFollow holderFollow = (ViewHolderFollow) viewHolder;
|
||||
MastodonHelper.loadPPMastodon(holderFollow.binding.avatar, notification.account);
|
||||
if (notification.account.span_display_name == null && notification.account.display_name != null) {
|
||||
notification.account.span_display_name = new SpannableString(notification.account.display_name);
|
||||
} else {
|
||||
notification.account.span_display_name = new SpannableString(notification.account.username);
|
||||
}
|
||||
CustomEmoji.displayEmoji(context, notification.account.emojis, notification.account.span_display_name, holderFollow.binding.displayName, notification.id, id -> {
|
||||
if (!notification.account.emojiFetched) {
|
||||
notification.account.emojiFetched = true;
|
||||
holderFollow.binding.displayName.post(() -> notifyItemChanged(position));
|
||||
}
|
||||
});
|
||||
holderFollow.binding.displayName.setText(notification.account.span_display_name, TextView.BufferType.SPANNABLE);
|
||||
holderFollow.binding.displayName.setText(
|
||||
notification.account.getSpanDisplayName(context,
|
||||
new WeakReference<>(holderFollow.binding.displayName),
|
||||
id -> notifyItemChanged(getPositionAsync(notificationList, id))),
|
||||
TextView.BufferType.SPANNABLE);
|
||||
holderFollow.binding.username.setText(String.format("@%s", notification.account.acct));
|
||||
if (getItemViewType(position) == TYPE_FOLLOW_REQUEST) {
|
||||
holderFollow.binding.rejectButton.setVisibility(View.VISIBLE);
|
||||
|
@ -197,19 +208,18 @@ public class NotificationAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
|
|||
holderStatus.bindingNotification.containerTransparent.setAlpha(.3f);
|
||||
if (getItemViewType(position) == TYPE_MENTION || getItemViewType(position) == TYPE_STATUS) {
|
||||
holderStatus.bindingNotification.status.actionButtons.setVisibility(View.VISIBLE);
|
||||
Spannable title = new SpannableString("");
|
||||
String title = "";
|
||||
if (getItemViewType(position) == TYPE_MENTION) {
|
||||
title = new SpannableString(String.format(Locale.getDefault(), "%s %s", notification.account.display_name, context.getString(R.string.notif_mention)));
|
||||
title = String.format(Locale.getDefault(), "%s %s", notification.account.display_name, context.getString(R.string.notif_mention));
|
||||
} else if (getItemViewType(position) == TYPE_STATUS) {
|
||||
title = new SpannableString(String.format(Locale.getDefault(), "%s %s", notification.account.display_name, context.getString(R.string.notif_status)));
|
||||
title = String.format(Locale.getDefault(), "%s %s", notification.account.display_name, context.getString(R.string.notif_status));
|
||||
}
|
||||
CustomEmoji.displayEmoji(context, notification.account.emojis, title, holderStatus.binding.displayName, notification.id, id -> {
|
||||
if (!notification.account.emojiFetched) {
|
||||
notification.account.emojiFetched = true;
|
||||
holderStatus.binding.displayName.post(() -> notifyItemChanged(position));
|
||||
}
|
||||
});
|
||||
holderStatus.bindingNotification.status.displayName.setText(title, TextView.BufferType.SPANNABLE);
|
||||
notification.account.display_name = title;
|
||||
holderStatus.bindingNotification.status.displayName.setText(
|
||||
notification.account.getSpanDisplayName(context,
|
||||
new WeakReference<>(holderStatus.bindingNotification.status.displayName),
|
||||
id -> holderStatus.bindingNotification.status.displayName.post(() -> notifyItemChanged(getPositionAsync(notificationList, id)))),
|
||||
TextView.BufferType.SPANNABLE);
|
||||
holderStatus.bindingNotification.status.username.setText(String.format("@%s", notification.account.acct));
|
||||
holderStatus.bindingNotification.containerTransparent.setAlpha(.1f);
|
||||
if (notification.status != null && notification.status.visibility.equalsIgnoreCase("direct")) {
|
||||
|
@ -220,14 +230,14 @@ public class NotificationAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
|
|||
}
|
||||
} else {
|
||||
holderStatus.bindingNotification.containerTransparent.setVisibility(View.VISIBLE);
|
||||
Spannable title = new SpannableString("");
|
||||
String title = "";
|
||||
MastodonHelper.loadPPMastodon(holderStatus.binding.avatar, notification.account);
|
||||
if (getItemViewType(position) == TYPE_FAVOURITE) {
|
||||
title = new SpannableString(String.format(Locale.getDefault(), "%s %s", notification.account.display_name, context.getString(R.string.notif_favourite)));
|
||||
title = String.format(Locale.getDefault(), "%s %s", notification.account.display_name, context.getString(R.string.notif_favourite));
|
||||
} else if (getItemViewType(position) == TYPE_REBLOG) {
|
||||
title = new SpannableString(String.format(Locale.getDefault(), "%s %s", notification.account.display_name, context.getString(R.string.notif_reblog)));
|
||||
title = String.format(Locale.getDefault(), "%s %s", notification.account.display_name, context.getString(R.string.notif_reblog));
|
||||
} else if (getItemViewType(position) == TYPE_POLL) {
|
||||
title = new SpannableString(context.getString(R.string.notif_poll));
|
||||
title = context.getString(R.string.notif_poll);
|
||||
}
|
||||
if (notification.relatedNotifications != null && notification.relatedNotifications.size() > 0) {
|
||||
if (notification.type.equals("favourite")) {
|
||||
|
@ -276,12 +286,12 @@ public class NotificationAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
|
|||
// start the new activity
|
||||
context.startActivity(intent, options.toBundle());
|
||||
});
|
||||
CustomEmoji.displayEmoji(context, notification.account.emojis, title, holderStatus.binding.displayName, notification.id, id -> {
|
||||
if (!notification.account.emojiFetched) {
|
||||
notification.account.emojiFetched = true;
|
||||
holderStatus.binding.displayName.post(() -> notifyItemChanged(position));
|
||||
}
|
||||
});
|
||||
notification.account.display_name = title;
|
||||
holderStatus.bindingNotification.status.displayName.setText(
|
||||
notification.account.getSpanDisplayName(context,
|
||||
new WeakReference<>(holderStatus.bindingNotification.status.displayName),
|
||||
id -> holderStatus.bindingNotification.status.displayName.post(() -> notifyItemChanged(getPositionAsync(notificationList, id)))),
|
||||
TextView.BufferType.SPANNABLE);
|
||||
holderStatus.bindingNotification.status.displayName.setText(title, TextView.BufferType.SPANNABLE);
|
||||
holderStatus.bindingNotification.status.username.setText(String.format("@%s", notification.account.acct));
|
||||
holderStatus.bindingNotification.status.actionButtons.setVisibility(View.GONE);
|
||||
|
@ -289,6 +299,7 @@ public class NotificationAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
public long getItemId(int position) {
|
||||
return position;
|
||||
}
|
||||
|
|
|
@ -36,11 +36,11 @@ import android.os.Build;
|
|||
import android.os.Bundle;
|
||||
import android.os.CountDownTimer;
|
||||
import android.text.Html;
|
||||
import android.text.Spannable;
|
||||
import android.text.SpannableString;
|
||||
import android.text.Spanned;
|
||||
import android.text.TextUtils;
|
||||
import android.text.style.ForegroundColorSpan;
|
||||
import android.util.Log;
|
||||
import android.util.TypedValue;
|
||||
import android.view.ContextThemeWrapper;
|
||||
import android.view.LayoutInflater;
|
||||
|
@ -80,6 +80,7 @@ import com.github.stom79.mytransl.translate.Params;
|
|||
import com.github.stom79.mytransl.translate.Translate;
|
||||
import com.varunest.sparkbutton.SparkButton;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
@ -113,7 +114,6 @@ import app.fedilab.android.databinding.LayoutMediaBinding;
|
|||
import app.fedilab.android.databinding.LayoutPollItemBinding;
|
||||
import app.fedilab.android.exception.DBException;
|
||||
import app.fedilab.android.helper.CrossActionHelper;
|
||||
import app.fedilab.android.helper.CustomEmoji;
|
||||
import app.fedilab.android.helper.GlideFocus;
|
||||
import app.fedilab.android.helper.Helper;
|
||||
import app.fedilab.android.helper.LongClickLinkMovementMethod;
|
||||
|
@ -744,21 +744,12 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
|
|||
|
||||
//--- ACCOUNT INFO ---
|
||||
MastodonHelper.loadPPMastodon(holder.binding.avatar, statusToDeal.account);
|
||||
Spannable span_display_name = statusToDeal.account.span_display_name;
|
||||
if (span_display_name == null || span_display_name.toString().trim().length() == 0) {
|
||||
span_display_name = new SpannableString(statusToDeal.account.username);
|
||||
}
|
||||
|
||||
CustomEmoji.displayEmoji(context, statusToDeal.account.emojis, span_display_name, holder.binding.displayName, status.id, id -> {
|
||||
if (!statusToDeal.account.emojiFetched) {
|
||||
statusToDeal.account.emojiFetched = true;
|
||||
if (timelineType == Timeline.TimeLineEnum.UNKNOWN) {
|
||||
return;
|
||||
}
|
||||
holder.binding.statusContent.post(() -> adapter.notifyItemChanged(getPositionAsync(notificationList, statusList, id)));
|
||||
}
|
||||
});
|
||||
holder.binding.displayName.setText(span_display_name, TextView.BufferType.SPANNABLE);
|
||||
holder.binding.displayName.setText(
|
||||
statusToDeal.account.getSpanDisplayName(context,
|
||||
new WeakReference<>(holder.binding.displayName),
|
||||
id -> holder.binding.displayName.post(() -> adapter.notifyItemChanged(getPositionAsync(notificationList, statusList, id)))),
|
||||
TextView.BufferType.SPANNABLE);
|
||||
if (theme_text_header_1_line != -1) {
|
||||
holder.binding.displayName.setTextColor(theme_text_header_1_line);
|
||||
}
|
||||
|
@ -823,16 +814,11 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
|
|||
if (expand_cw || expand) {
|
||||
holder.binding.spoilerExpand.setVisibility(View.VISIBLE);
|
||||
holder.binding.spoiler.setVisibility(View.VISIBLE);
|
||||
CustomEmoji.displayEmoji(context, statusToDeal.emojis, statusToDeal.span_spoiler_text, holder.binding.spoiler, status.id, id -> {
|
||||
if (!statusToDeal.emojiFetched) {
|
||||
statusToDeal.emojiFetched = true;
|
||||
if (timelineType == Timeline.TimeLineEnum.UNKNOWN) {
|
||||
return;
|
||||
}
|
||||
holder.binding.statusContent.post(() -> adapter.notifyItemChanged(getPositionAsync(notificationList, statusList, id)));
|
||||
}
|
||||
});
|
||||
holder.binding.spoiler.setText(statusToDeal.span_spoiler_text, TextView.BufferType.SPANNABLE);
|
||||
holder.binding.spoiler.setText(
|
||||
statusToDeal.getSpanSpoiler(context,
|
||||
new WeakReference<>(holder.binding.spoiler),
|
||||
id -> holder.binding.spoiler.post(() -> adapter.notifyItemChanged(getPositionAsync(notificationList, statusList, id)))),
|
||||
TextView.BufferType.SPANNABLE);
|
||||
statusToDeal.isExpended = true;
|
||||
statusToDeal.isMediaDisplayed = true;
|
||||
} else {
|
||||
|
@ -843,16 +829,12 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
|
|||
});
|
||||
holder.binding.spoilerExpand.setVisibility(View.VISIBLE);
|
||||
holder.binding.spoiler.setVisibility(View.VISIBLE);
|
||||
CustomEmoji.displayEmoji(context, statusToDeal.emojis, statusToDeal.span_spoiler_text, holder.binding.spoiler, status.id, id -> {
|
||||
if (!statusToDeal.emojiFetched) {
|
||||
statusToDeal.emojiFetched = true;
|
||||
if (timelineType == Timeline.TimeLineEnum.UNKNOWN) {
|
||||
return;
|
||||
}
|
||||
holder.binding.statusContent.post(() -> adapter.notifyItemChanged(getPositionAsync(notificationList, statusList, id)));
|
||||
}
|
||||
});
|
||||
holder.binding.spoiler.setText(statusToDeal.span_spoiler_text, TextView.BufferType.SPANNABLE);
|
||||
|
||||
holder.binding.spoiler.setText(
|
||||
statusToDeal.getSpanSpoiler(context,
|
||||
new WeakReference<>(holder.binding.spoiler),
|
||||
id -> holder.binding.spoiler.post(() -> adapter.notifyItemChanged(getPositionAsync(notificationList, statusList, id)))),
|
||||
TextView.BufferType.SPANNABLE);
|
||||
}
|
||||
if (statusToDeal.isExpended) {
|
||||
holder.binding.spoilerExpand.setText(context.getString(R.string.hide_content));
|
||||
|
@ -868,20 +850,13 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
|
|||
//--- BOOSTER INFO ---
|
||||
if (status.reblog != null) {
|
||||
MastodonHelper.loadPPMastodon(holder.binding.statusBoosterAvatar, status.account);
|
||||
Spannable span_display_name_boost = status.account.span_display_name;
|
||||
if (span_display_name_boost == null || span_display_name_boost.toString().trim().length() == 0) {
|
||||
span_display_name_boost = new SpannableString(status.account.username);
|
||||
}
|
||||
CustomEmoji.displayEmoji(context, statusToDeal.account.emojis, span_display_name_boost, holder.binding.statusBoosterDisplayName, status.id, id -> {
|
||||
if (!statusToDeal.account.emojiFetched) {
|
||||
statusToDeal.account.emojiFetched = true;
|
||||
if (timelineType == Timeline.TimeLineEnum.UNKNOWN) {
|
||||
return;
|
||||
}
|
||||
holder.binding.statusContent.post(() -> adapter.notifyItemChanged(getPositionAsync(notificationList, statusList, id)));
|
||||
}
|
||||
});
|
||||
holder.binding.statusBoosterDisplayName.setText(span_display_name_boost, TextView.BufferType.SPANNABLE);
|
||||
|
||||
holder.binding.statusBoosterDisplayName.setText(
|
||||
status.account.getSpanDisplayName(context,
|
||||
new WeakReference<>(holder.binding.statusBoosterDisplayName),
|
||||
id -> holder.binding.statusBoosterDisplayName.post(() -> adapter.notifyItemChanged(getPositionAsync(notificationList, statusList, id)))),
|
||||
TextView.BufferType.SPANNABLE);
|
||||
|
||||
holder.binding.statusBoosterInfo.setVisibility(View.VISIBLE);
|
||||
holder.binding.boosterDivider.setVisibility(View.VISIBLE);
|
||||
if (theme_text_header_1_line != -1) {
|
||||
|
@ -913,18 +888,15 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
|
|||
break;
|
||||
}
|
||||
//--- MAIN CONTENT ---
|
||||
|
||||
CustomEmoji.displayEmoji(context, statusToDeal.emojis, statusToDeal.span_content, holder.binding.statusContent, status.id, id -> {
|
||||
if (!status.emojiFetched) {
|
||||
status.emojiFetched = true;
|
||||
if (timelineType == Timeline.TimeLineEnum.UNKNOWN) {
|
||||
return;
|
||||
}
|
||||
holder.binding.statusContent.post(() -> adapter.notifyItemChanged(getPositionAsync(notificationList, statusList, id)));
|
||||
}
|
||||
});
|
||||
|
||||
holder.binding.statusContent.setText(statusToDeal.span_content, TextView.BufferType.SPANNABLE);
|
||||
holder.binding.statusContent.setText(
|
||||
statusToDeal.getSpanContent(context,
|
||||
new WeakReference<>(holder.binding.statusContent),
|
||||
id -> holder.binding.statusContent.post(() -> {
|
||||
Log.v(Helper.TAG, "notifiy: " + id);
|
||||
Log.v(Helper.TAG, "position: " + getPositionAsync(notificationList, statusList, id));
|
||||
adapter.notifyItemChanged(getPositionAsync(notificationList, statusList, id));
|
||||
})),
|
||||
TextView.BufferType.SPANNABLE);
|
||||
if (truncate_toots_size > 0) {
|
||||
holder.binding.statusContent.setMaxLines(truncate_toots_size);
|
||||
holder.binding.statusContent.setEllipsize(TextUtils.TruncateAt.END);
|
||||
|
@ -955,16 +927,11 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
|
|||
}
|
||||
if (statusToDeal.translationContent != null) {
|
||||
holder.binding.containerTrans.setVisibility(View.VISIBLE);
|
||||
CustomEmoji.displayEmoji(context, statusToDeal.emojis, statusToDeal.span_translate, holder.binding.statusContentTranslated, status.id, id -> {
|
||||
if (!statusToDeal.emojiFetched) {
|
||||
statusToDeal.emojiFetched = true;
|
||||
if (timelineType == Timeline.TimeLineEnum.UNKNOWN) {
|
||||
return;
|
||||
}
|
||||
holder.binding.statusContent.post(() -> adapter.notifyItemChanged(getPositionAsync(notificationList, statusList, id)));
|
||||
}
|
||||
});
|
||||
holder.binding.statusContentTranslated.setText(statusToDeal.span_translate, TextView.BufferType.SPANNABLE);
|
||||
holder.binding.statusContentTranslated.setText(
|
||||
statusToDeal.getSpanTranslate(context,
|
||||
new WeakReference<>(holder.binding.statusContentTranslated),
|
||||
id -> holder.binding.statusContentTranslated.post(() -> adapter.notifyItemChanged(getPositionAsync(notificationList, statusList, id)))),
|
||||
TextView.BufferType.SPANNABLE);
|
||||
} else {
|
||||
holder.binding.containerTrans.setVisibility(View.GONE);
|
||||
}
|
||||
|
@ -1226,16 +1193,11 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
|
|||
pollItemBinding.pollItemPercent.setTextColor(theme_text_color);
|
||||
pollItemBinding.pollItemText.setTextColor(theme_text_color);
|
||||
}
|
||||
CustomEmoji.displayEmoji(context, statusToDeal.emojis, pollItem.span_title, pollItemBinding.pollItemText, status.id, id -> {
|
||||
if (!statusToDeal.emojiFetched) {
|
||||
statusToDeal.emojiFetched = true;
|
||||
if (timelineType == Timeline.TimeLineEnum.UNKNOWN) {
|
||||
return;
|
||||
}
|
||||
holder.binding.statusContent.post(() -> adapter.notifyItemChanged(getPositionAsync(notificationList, statusList, id)));
|
||||
}
|
||||
});
|
||||
pollItemBinding.pollItemText.setText(pollItem.span_title, TextView.BufferType.SPANNABLE);
|
||||
pollItemBinding.pollItemText.setText(
|
||||
pollItem.getSpanTitle(context, statusToDeal,
|
||||
new WeakReference<>(pollItemBinding.pollItemText),
|
||||
id -> pollItemBinding.pollItemText.post(() -> adapter.notifyItemChanged(getPositionAsync(notificationList, statusList, id)))),
|
||||
TextView.BufferType.SPANNABLE);
|
||||
pollItemBinding.pollItemValue.setProgress((int) value);
|
||||
if (pollItem.votes_count == greaterValue) {
|
||||
pollItemBinding.pollItemPercent.setTypeface(null, Typeface.BOLD);
|
||||
|
@ -1263,16 +1225,11 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
|
|||
for (Poll.PollItem pollOption : statusToDeal.poll.options) {
|
||||
CheckBox cb = new CheckBox(context);
|
||||
cb.setButtonTintList(ThemeHelper.getButtonColorStateList(context));
|
||||
CustomEmoji.displayEmoji(context, statusToDeal.emojis, pollOption.span_title, cb, status.id, id -> {
|
||||
if (!statusToDeal.emojiFetched) {
|
||||
statusToDeal.emojiFetched = true;
|
||||
if (timelineType == Timeline.TimeLineEnum.UNKNOWN) {
|
||||
return;
|
||||
}
|
||||
holder.binding.statusContent.post(() -> adapter.notifyItemChanged(getPositionAsync(notificationList, statusList, id)));
|
||||
}
|
||||
});
|
||||
cb.setText(pollOption.span_title, TextView.BufferType.SPANNABLE);
|
||||
cb.setText(
|
||||
pollOption.getSpanTitle(context, statusToDeal,
|
||||
new WeakReference<>(cb),
|
||||
id -> cb.post(() -> adapter.notifyItemChanged(getPositionAsync(notificationList, statusList, id)))),
|
||||
TextView.BufferType.SPANNABLE);
|
||||
holder.binding.poll.multipleChoice.addView(cb);
|
||||
}
|
||||
holder.binding.poll.multipleChoice.setVisibility(View.VISIBLE);
|
||||
|
@ -1283,25 +1240,12 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
|
|||
for (Poll.PollItem pollOption : statusToDeal.poll.options) {
|
||||
RadioButton rb = new RadioButton(context);
|
||||
rb.setButtonTintList(ThemeHelper.getButtonColorStateList(context));
|
||||
CustomEmoji.displayEmoji(context, statusToDeal.account.emojis, pollOption.span_title, rb, status.id, id -> {
|
||||
if (!statusToDeal.account.emojiFetched) {
|
||||
statusToDeal.account.emojiFetched = true;
|
||||
if (timelineType == Timeline.TimeLineEnum.UNKNOWN) {
|
||||
return;
|
||||
}
|
||||
holder.binding.statusContent.post(() -> adapter.notifyItemChanged(getPositionAsync(notificationList, statusList, id)));
|
||||
}
|
||||
});
|
||||
CustomEmoji.displayEmoji(context, statusToDeal.emojis, pollOption.span_title, rb, status.id, id -> {
|
||||
if (!statusToDeal.emojiFetched) {
|
||||
statusToDeal.emojiFetched = true;
|
||||
if (timelineType == Timeline.TimeLineEnum.UNKNOWN) {
|
||||
return;
|
||||
}
|
||||
holder.binding.statusContent.post(() -> adapter.notifyItemChanged(getPositionAsync(notificationList, statusList, id)));
|
||||
}
|
||||
});
|
||||
rb.setText(pollOption.span_title, TextView.BufferType.SPANNABLE);
|
||||
rb.setText(
|
||||
pollOption.getSpanTitle(context, statusToDeal,
|
||||
new WeakReference<>(rb),
|
||||
id -> rb.post(() -> adapter.notifyItemChanged(getPositionAsync(notificationList, statusList, id)))),
|
||||
TextView.BufferType.SPANNABLE);
|
||||
|
||||
holder.binding.poll.singleChoiceRadioGroup.addView(rb);
|
||||
}
|
||||
holder.binding.poll.singleChoiceRadioGroup.setVisibility(View.VISIBLE);
|
||||
|
@ -1626,7 +1570,6 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
|
|||
if (translate.getTranslatedContent() != null) {
|
||||
statusToDeal.translationShown = true;
|
||||
statusToDeal.translationContent = translate.getTranslatedContent();
|
||||
SpannableHelper.convertStatus(context.getApplicationContext(), statusToDeal);
|
||||
adapter.notifyItemChanged(getPositionAsync(notificationList, statusList, statusToDeal));
|
||||
} else {
|
||||
Toasty.error(context, context.getString(R.string.toast_error_translate), Toast.LENGTH_LONG).show();
|
||||
|
@ -1901,16 +1844,11 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
|
|||
.load(status.art_attachment.preview_url)
|
||||
.apply(new RequestOptions().transform(new RoundedCorners((int) Helper.convertDpToPixel(3, context))))
|
||||
.into(holder.bindingArt.artMedia);
|
||||
CustomEmoji.displayEmoji(context, status.emojis, status.account.span_display_name, holder.bindingArt.artAcct, status.id, id -> {
|
||||
if (!status.emojiFetched) {
|
||||
status.emojiFetched = true;
|
||||
if (timelineType == Timeline.TimeLineEnum.UNKNOWN) {
|
||||
return;
|
||||
}
|
||||
notifyItemChanged(getPositionAsync(null, statusList, id));
|
||||
}
|
||||
});
|
||||
holder.bindingArt.artAcct.setText(status.account.span_display_name, TextView.BufferType.SPANNABLE);
|
||||
holder.bindingArt.artAcct.setText(
|
||||
status.account.getSpanDisplayName(context,
|
||||
new WeakReference<>(holder.bindingArt.artAcct),
|
||||
id -> holder.bindingArt.artAcct.post(() -> notifyItemChanged(getPositionAsync(null, statusList, id)))),
|
||||
TextView.BufferType.SPANNABLE);
|
||||
holder.bindingArt.artUsername.setText(String.format(Locale.getDefault(), "@%s", status.account.acct));
|
||||
holder.bindingArt.artPp.setOnClickListener(v -> {
|
||||
Intent intent = new Intent(context, ProfileActivity.class);
|
||||
|
|
|
@ -43,7 +43,6 @@ import app.fedilab.android.client.entities.app.Timeline;
|
|||
import app.fedilab.android.databinding.FragmentPaginationBinding;
|
||||
import app.fedilab.android.helper.DividerDecoration;
|
||||
import app.fedilab.android.helper.Helper;
|
||||
import app.fedilab.android.helper.SpannableHelper;
|
||||
import app.fedilab.android.helper.ThemeHelper;
|
||||
import app.fedilab.android.ui.drawer.StatusAdapter;
|
||||
import app.fedilab.android.viewmodel.mastodon.StatusesVM;
|
||||
|
@ -96,11 +95,10 @@ public class FragmentMastodonContext extends Fragment {
|
|||
}
|
||||
} else if (statusPosted != null && statusAdapter != null) {
|
||||
if (requireActivity() instanceof ContextActivity) {
|
||||
Status convertStatus = SpannableHelper.convertStatus(context, statusPosted);
|
||||
int i = 0;
|
||||
for (Status status : statuses) {
|
||||
if (status.id.equals(convertStatus.in_reply_to_id)) {
|
||||
statuses.add((i + 1), convertStatus);
|
||||
if (status.id.equals(statusPosted.in_reply_to_id)) {
|
||||
statuses.add((i + 1), statusPosted);
|
||||
statusAdapter.notifyItemInserted((i + 1));
|
||||
if (requireActivity() instanceof ContextActivity) {
|
||||
//Redraw decorations
|
||||
|
|
|
@ -56,7 +56,6 @@ import app.fedilab.android.client.entities.app.Timeline;
|
|||
import app.fedilab.android.databinding.FragmentPaginationBinding;
|
||||
import app.fedilab.android.helper.Helper;
|
||||
import app.fedilab.android.helper.MastodonHelper;
|
||||
import app.fedilab.android.helper.SpannableHelper;
|
||||
import app.fedilab.android.helper.ThemeHelper;
|
||||
import app.fedilab.android.ui.drawer.StatusAdapter;
|
||||
import app.fedilab.android.viewmodel.mastodon.AccountsVM;
|
||||
|
@ -118,8 +117,7 @@ public class FragmentMastodonTimeline extends Fragment implements StatusAdapter.
|
|||
statusAdapter.notifyItemRemoved(position);
|
||||
}
|
||||
} else if (statusPosted != null && statusAdapter != null && timelineType == Timeline.TimeLineEnum.HOME) {
|
||||
Status convertStatus = SpannableHelper.convertStatus(context, statusPosted);
|
||||
statuses.add(0, convertStatus);
|
||||
statuses.add(0, statusPosted);
|
||||
statusAdapter.notifyItemInserted(0);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -52,7 +52,6 @@ import app.fedilab.android.client.entities.api.Tag;
|
|||
import app.fedilab.android.client.entities.api.Token;
|
||||
import app.fedilab.android.helper.Helper;
|
||||
import app.fedilab.android.helper.MastodonHelper;
|
||||
import app.fedilab.android.helper.SpannableHelper;
|
||||
import okhttp3.MultipartBody;
|
||||
import okhttp3.OkHttpClient;
|
||||
import retrofit2.Call;
|
||||
|
@ -306,9 +305,6 @@ public class AccountsVM extends AndroidViewModel {
|
|||
}
|
||||
}
|
||||
Account finalAccount = account;
|
||||
if (finalAccount != null) {
|
||||
SpannableHelper.convertAccount(getApplication().getApplicationContext(), finalAccount);
|
||||
}
|
||||
Handler mainHandler = new Handler(Looper.getMainLooper());
|
||||
Runnable myRunnable = () -> accountMutableLiveData.setValue(finalAccount);
|
||||
mainHandler.post(myRunnable);
|
||||
|
@ -342,7 +338,7 @@ public class AccountsVM extends AndroidViewModel {
|
|||
try {
|
||||
Response<List<Status>> accountStatusesResponse = accountStatusesCall.execute();
|
||||
if (accountStatusesResponse.isSuccessful()) {
|
||||
statusList = SpannableHelper.convertStatus(getApplication().getApplicationContext(), accountStatusesResponse.body());
|
||||
statusList = accountStatusesResponse.body();
|
||||
pagination = MastodonHelper.getPagination(accountStatusesResponse.headers());
|
||||
|
||||
}
|
||||
|
@ -378,7 +374,7 @@ public class AccountsVM extends AndroidViewModel {
|
|||
try {
|
||||
Response<List<Account>> followersResponse = followersCall.execute();
|
||||
if (followersResponse.isSuccessful()) {
|
||||
accountList = SpannableHelper.convertAccounts(getApplication().getApplicationContext(), followersResponse.body());
|
||||
accountList = followersResponse.body();
|
||||
pagination = MastodonHelper.getPagination(followersResponse.headers());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
|
@ -414,7 +410,7 @@ public class AccountsVM extends AndroidViewModel {
|
|||
try {
|
||||
Response<List<Account>> followingResponse = followingCall.execute();
|
||||
if (followingResponse.isSuccessful()) {
|
||||
accountList = SpannableHelper.convertAccounts(getApplication().getApplicationContext(), followingResponse.body());
|
||||
accountList = followingResponse.body();
|
||||
pagination = MastodonHelper.getPagination(followingResponse.headers());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
|
@ -883,11 +879,6 @@ public class AccountsVM extends AndroidViewModel {
|
|||
}
|
||||
}
|
||||
List<Account> finalAccountList = accountList;
|
||||
if (finalAccountList != null) {
|
||||
for (Account account : finalAccountList) {
|
||||
SpannableHelper.convertAccount(getApplication().getApplicationContext(), account);
|
||||
}
|
||||
}
|
||||
Handler mainHandler = new Handler(Looper.getMainLooper());
|
||||
Runnable myRunnable = () -> accountListMutableLiveData.setValue(finalAccountList);
|
||||
mainHandler.post(myRunnable);
|
||||
|
@ -912,7 +903,7 @@ public class AccountsVM extends AndroidViewModel {
|
|||
Response<List<Status>> bookmarksResponse = bookmarksCall.execute();
|
||||
if (bookmarksResponse.isSuccessful()) {
|
||||
statusList = bookmarksResponse.body();
|
||||
statuses.statuses = SpannableHelper.convertStatus(getApplication().getApplicationContext(), statusList);
|
||||
statuses.statuses = statusList;
|
||||
statuses.pagination = MastodonHelper.getPagination(bookmarksResponse.headers());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
|
@ -943,7 +934,7 @@ public class AccountsVM extends AndroidViewModel {
|
|||
Response<List<Status>> favouritesResponse = favouritesCall.execute();
|
||||
if (favouritesResponse.isSuccessful()) {
|
||||
statusList = favouritesResponse.body();
|
||||
statuses.statuses = SpannableHelper.convertStatus(getApplication().getApplicationContext(), statusList);
|
||||
statuses.statuses = statusList;
|
||||
statuses.pagination = MastodonHelper.getPagination(favouritesResponse.headers());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
|
@ -975,7 +966,7 @@ public class AccountsVM extends AndroidViewModel {
|
|||
Response<List<Account>> mutesResponse = mutesCall.execute();
|
||||
if (mutesResponse.isSuccessful()) {
|
||||
accountList = mutesResponse.body();
|
||||
accounts.accounts = SpannableHelper.convertAccounts(getApplication().getApplicationContext(), accountList);
|
||||
accounts.accounts = accountList;
|
||||
accounts.pagination = MastodonHelper.getPagination(mutesResponse.headers());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
|
@ -1007,7 +998,7 @@ public class AccountsVM extends AndroidViewModel {
|
|||
Response<List<Account>> blocksResponse = blocksCall.execute();
|
||||
if (blocksResponse.isSuccessful()) {
|
||||
accountList = blocksResponse.body();
|
||||
accounts.accounts = SpannableHelper.convertAccounts(getApplication().getApplicationContext(), accountList);
|
||||
accounts.accounts = accountList;
|
||||
accounts.pagination = MastodonHelper.getPagination(blocksResponse.headers());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
|
@ -1303,7 +1294,7 @@ public class AccountsVM extends AndroidViewModel {
|
|||
Response<List<Account>> followRequestsResponse = followRequestsCall.execute();
|
||||
if (followRequestsResponse.isSuccessful()) {
|
||||
accountList = followRequestsResponse.body();
|
||||
accounts.accounts = SpannableHelper.convertAccounts(getApplication().getApplicationContext(), accountList);
|
||||
accounts.accounts = accountList;
|
||||
accounts.pagination = MastodonHelper.getPagination(followRequestsResponse.headers());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
|
|
|
@ -32,7 +32,6 @@ import java.util.concurrent.TimeUnit;
|
|||
import app.fedilab.android.client.endpoints.MastodonAnnouncementsService;
|
||||
import app.fedilab.android.client.entities.api.Announcement;
|
||||
import app.fedilab.android.helper.Helper;
|
||||
import app.fedilab.android.helper.SpannableHelper;
|
||||
import okhttp3.OkHttpClient;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Response;
|
||||
|
@ -83,7 +82,6 @@ public class AnnouncementsVM extends AndroidViewModel {
|
|||
Response<List<Announcement>> getAnnouncementsResponse = getAnnouncementsCall.execute();
|
||||
if (getAnnouncementsResponse.isSuccessful()) {
|
||||
announcementList = getAnnouncementsResponse.body();
|
||||
SpannableHelper.convertAnnouncement(getApplication(), announcementList);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
|
|
|
@ -35,7 +35,6 @@ import app.fedilab.android.client.entities.api.Notifications;
|
|||
import app.fedilab.android.client.entities.api.PushSubscription;
|
||||
import app.fedilab.android.helper.Helper;
|
||||
import app.fedilab.android.helper.MastodonHelper;
|
||||
import app.fedilab.android.helper.SpannableHelper;
|
||||
import app.fedilab.android.helper.TimelineHelper;
|
||||
import okhttp3.OkHttpClient;
|
||||
import retrofit2.Call;
|
||||
|
@ -103,15 +102,6 @@ public class NotificationsVM extends AndroidViewModel {
|
|||
if (notificationsResponse.isSuccessful()) {
|
||||
List<Notification> notFilteredNotifications = notificationsResponse.body();
|
||||
notifications.notifications = TimelineHelper.filterNotification(getApplication().getApplicationContext(), notFilteredNotifications);
|
||||
if (notifications.notifications != null) {
|
||||
for (Notification notification : notifications.notifications) {
|
||||
if (notification != null) {
|
||||
if (notification.status != null) {
|
||||
notification.status = SpannableHelper.convertStatus(getApplication().getApplicationContext(), notification.status);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
notifications.pagination = MastodonHelper.getPagination(notificationsResponse.headers());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
|
@ -147,9 +137,6 @@ public class NotificationsVM extends AndroidViewModel {
|
|||
Response<Notification> notificationResponse = notificationCall.execute();
|
||||
if (notificationResponse.isSuccessful()) {
|
||||
notification = notificationResponse.body();
|
||||
if (notification != null) {
|
||||
notification.status = SpannableHelper.convertStatus(getApplication().getApplicationContext(), notification.status);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
|
|
|
@ -36,7 +36,6 @@ import app.fedilab.android.client.entities.api.Status;
|
|||
import app.fedilab.android.client.entities.app.StatusCache;
|
||||
import app.fedilab.android.exception.DBException;
|
||||
import app.fedilab.android.helper.Helper;
|
||||
import app.fedilab.android.helper.SpannableHelper;
|
||||
import okhttp3.OkHttpClient;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Response;
|
||||
|
@ -112,13 +111,9 @@ public class SearchVM extends AndroidViewModel {
|
|||
if (results != null) {
|
||||
if (results.statuses == null) {
|
||||
results.statuses = new ArrayList<>();
|
||||
} else {
|
||||
results.statuses = SpannableHelper.convertStatus(getApplication(), results.statuses);
|
||||
}
|
||||
if (results.accounts == null) {
|
||||
results.accounts = new ArrayList<>();
|
||||
} else {
|
||||
results.accounts = SpannableHelper.convertAccounts(getApplication().getApplicationContext(), results.accounts);
|
||||
}
|
||||
if (results.hashtags == null) {
|
||||
results.hashtags = new ArrayList<>();
|
||||
|
@ -144,7 +139,6 @@ public class SearchVM extends AndroidViewModel {
|
|||
try {
|
||||
results.statuses = new ArrayList<>();
|
||||
List<Status> statuses = new StatusCache(getApplication()).searchStatus(StatusCache.CacheEnum.HOME, instance, userId, q);
|
||||
statuses = SpannableHelper.convertStatus(getApplication(), statuses);
|
||||
results.statuses.addAll(statuses);
|
||||
} catch (DBException e) {
|
||||
e.printStackTrace();
|
||||
|
|
|
@ -47,7 +47,6 @@ import app.fedilab.android.client.entities.app.StatusCache;
|
|||
import app.fedilab.android.exception.DBException;
|
||||
import app.fedilab.android.helper.Helper;
|
||||
import app.fedilab.android.helper.MastodonHelper;
|
||||
import app.fedilab.android.helper.SpannableHelper;
|
||||
import app.fedilab.android.helper.TimelineHelper;
|
||||
import okhttp3.Headers;
|
||||
import okhttp3.MultipartBody;
|
||||
|
@ -279,7 +278,7 @@ public class StatusesVM extends AndroidViewModel {
|
|||
try {
|
||||
Response<Status> statusResponse = statusCall.execute();
|
||||
if (statusResponse.isSuccessful()) {
|
||||
status = SpannableHelper.convertStatus(getApplication().getApplicationContext(), statusResponse.body());
|
||||
status = statusResponse.body();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
|
@ -356,13 +355,7 @@ public class StatusesVM extends AndroidViewModel {
|
|||
context = contextResponse.body();
|
||||
if (context != null) {
|
||||
TimelineHelper.filterStatus(getApplication().getApplicationContext(), context.descendants, TimelineHelper.FilterTimeLineType.CONTEXT);
|
||||
for (Status status : context.descendants) {
|
||||
SpannableHelper.convertStatus(getApplication().getApplicationContext(), status);
|
||||
}
|
||||
TimelineHelper.filterStatus(getApplication().getApplicationContext(), context.ancestors, TimelineHelper.FilterTimeLineType.CONTEXT);
|
||||
for (Status status : context.ancestors) {
|
||||
SpannableHelper.convertStatus(getApplication().getApplicationContext(), status);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -406,7 +399,7 @@ public class StatusesVM extends AndroidViewModel {
|
|||
try {
|
||||
Response<List<Account>> accountsResponse = accountsCall.execute();
|
||||
if (accountsResponse.isSuccessful()) {
|
||||
accounts = SpannableHelper.convertAccounts(getApplication().getApplicationContext(), accountsResponse.body());
|
||||
accounts = accountsResponse.body();
|
||||
}
|
||||
headers = accountsResponse.headers();
|
||||
} catch (Exception e) {
|
||||
|
@ -451,7 +444,7 @@ public class StatusesVM extends AndroidViewModel {
|
|||
try {
|
||||
Response<List<Account>> accountsResponse = accountsCall.execute();
|
||||
if (accountsResponse.isSuccessful()) {
|
||||
accounts = SpannableHelper.convertAccounts(getApplication().getApplicationContext(), accountsResponse.body());
|
||||
accounts = accountsResponse.body();
|
||||
}
|
||||
headers = accountsResponse.headers();
|
||||
} catch (Exception e) {
|
||||
|
@ -489,7 +482,7 @@ public class StatusesVM extends AndroidViewModel {
|
|||
try {
|
||||
Response<Status> statusResponse = statusCall.execute();
|
||||
if (statusResponse.isSuccessful()) {
|
||||
status = SpannableHelper.convertStatus(getApplication().getApplicationContext(), statusResponse.body());
|
||||
status = statusResponse.body();
|
||||
} else {
|
||||
if (statusResponse.errorBody() != null) {
|
||||
errorMessage = statusResponse.errorBody().string();
|
||||
|
@ -533,7 +526,7 @@ public class StatusesVM extends AndroidViewModel {
|
|||
try {
|
||||
Response<Status> statusResponse = statusCall.execute();
|
||||
if (statusResponse.isSuccessful()) {
|
||||
status = SpannableHelper.convertStatus(getApplication().getApplicationContext(), statusResponse.body());
|
||||
status = statusResponse.body();
|
||||
} else {
|
||||
if (statusResponse.errorBody() != null) {
|
||||
errorMessage = statusResponse.errorBody().string();
|
||||
|
@ -579,7 +572,7 @@ public class StatusesVM extends AndroidViewModel {
|
|||
try {
|
||||
Response<Status> statusResponse = statusCall.execute();
|
||||
if (statusResponse.isSuccessful()) {
|
||||
status = SpannableHelper.convertStatus(getApplication().getApplicationContext(), statusResponse.body());
|
||||
status = statusResponse.body();
|
||||
} else {
|
||||
if (statusResponse.errorBody() != null) {
|
||||
errorMessage = statusResponse.errorBody().string();
|
||||
|
@ -623,7 +616,7 @@ public class StatusesVM extends AndroidViewModel {
|
|||
try {
|
||||
Response<Status> statusResponse = statusCall.execute();
|
||||
if (statusResponse.isSuccessful()) {
|
||||
status = SpannableHelper.convertStatus(getApplication().getApplicationContext(), statusResponse.body());
|
||||
status = statusResponse.body();
|
||||
} else {
|
||||
if (statusResponse.errorBody() != null) {
|
||||
errorMessage = statusResponse.errorBody().string();
|
||||
|
@ -667,7 +660,7 @@ public class StatusesVM extends AndroidViewModel {
|
|||
try {
|
||||
Response<Status> statusResponse = statusCall.execute();
|
||||
if (statusResponse.isSuccessful()) {
|
||||
status = SpannableHelper.convertStatus(getApplication().getApplicationContext(), statusResponse.body());
|
||||
status = statusResponse.body();
|
||||
} else {
|
||||
if (statusResponse.errorBody() != null) {
|
||||
errorMessage = statusResponse.errorBody().string();
|
||||
|
@ -711,7 +704,7 @@ public class StatusesVM extends AndroidViewModel {
|
|||
try {
|
||||
Response<Status> statusResponse = statusCall.execute();
|
||||
if (statusResponse.isSuccessful()) {
|
||||
status = SpannableHelper.convertStatus(getApplication().getApplicationContext(), statusResponse.body());
|
||||
status = statusResponse.body();
|
||||
} else {
|
||||
if (statusResponse.errorBody() != null) {
|
||||
errorMessage = statusResponse.errorBody().string();
|
||||
|
@ -755,7 +748,7 @@ public class StatusesVM extends AndroidViewModel {
|
|||
try {
|
||||
Response<Status> statusResponse = statusCall.execute();
|
||||
if (statusResponse.isSuccessful()) {
|
||||
status = SpannableHelper.convertStatus(getApplication().getApplicationContext(), statusResponse.body());
|
||||
status = statusResponse.body();
|
||||
} else {
|
||||
if (statusResponse.errorBody() != null) {
|
||||
errorMessage = statusResponse.errorBody().string();
|
||||
|
@ -799,7 +792,7 @@ public class StatusesVM extends AndroidViewModel {
|
|||
try {
|
||||
Response<Status> statusResponse = statusCall.execute();
|
||||
if (statusResponse.isSuccessful()) {
|
||||
status = SpannableHelper.convertStatus(getApplication().getApplicationContext(), statusResponse.body());
|
||||
status = statusResponse.body();
|
||||
} else {
|
||||
if (statusResponse.errorBody() != null) {
|
||||
errorMessage = statusResponse.errorBody().string();
|
||||
|
@ -843,7 +836,7 @@ public class StatusesVM extends AndroidViewModel {
|
|||
try {
|
||||
Response<Status> statusResponse = statusCall.execute();
|
||||
if (statusResponse.isSuccessful()) {
|
||||
status = SpannableHelper.convertStatus(getApplication().getApplicationContext(), statusResponse.body());
|
||||
status = statusResponse.body();
|
||||
} else {
|
||||
if (statusResponse.errorBody() != null) {
|
||||
errorMessage = statusResponse.errorBody().string();
|
||||
|
@ -887,7 +880,7 @@ public class StatusesVM extends AndroidViewModel {
|
|||
try {
|
||||
Response<Status> statusResponse = statusCall.execute();
|
||||
if (statusResponse.isSuccessful()) {
|
||||
status = SpannableHelper.convertStatus(getApplication().getApplicationContext(), statusResponse.body());
|
||||
status = statusResponse.body();
|
||||
} else {
|
||||
if (statusResponse.errorBody() != null) {
|
||||
errorMessage = statusResponse.errorBody().string();
|
||||
|
|
|
@ -48,7 +48,6 @@ import app.fedilab.android.client.entities.peertube.PeertubeVideo;
|
|||
import app.fedilab.android.exception.DBException;
|
||||
import app.fedilab.android.helper.Helper;
|
||||
import app.fedilab.android.helper.MastodonHelper;
|
||||
import app.fedilab.android.helper.SpannableHelper;
|
||||
import app.fedilab.android.helper.TimelineHelper;
|
||||
import okhttp3.OkHttpClient;
|
||||
import retrofit2.Call;
|
||||
|
@ -121,7 +120,7 @@ public class TimelinesVM extends AndroidViewModel {
|
|||
Response<List<Status>> publicTlResponse = publicTlCall.execute();
|
||||
if (publicTlResponse.isSuccessful()) {
|
||||
statusList = publicTlResponse.body();
|
||||
statusList = SpannableHelper.convertStatus(getApplication().getApplicationContext(), statusList);
|
||||
statusList = statusList;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
|
@ -190,8 +189,7 @@ public class TimelinesVM extends AndroidViewModel {
|
|||
Response<List<Status>> publicTlResponse = publicTlCall.execute();
|
||||
if (publicTlResponse.isSuccessful()) {
|
||||
List<Status> notFilteredStatuses = publicTlResponse.body();
|
||||
List<Status> filteredStatuses = TimelineHelper.filterStatus(getApplication(), notFilteredStatuses, TimelineHelper.FilterTimeLineType.PUBLIC);
|
||||
statuses.statuses = SpannableHelper.convertStatus(getApplication().getApplicationContext(), filteredStatuses);
|
||||
statuses.statuses = TimelineHelper.filterStatus(getApplication(), notFilteredStatuses, TimelineHelper.FilterTimeLineType.PUBLIC);
|
||||
statuses.pagination = MastodonHelper.getPagination(publicTlResponse.headers());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
|
@ -232,7 +230,7 @@ public class TimelinesVM extends AndroidViewModel {
|
|||
statusList.add(status);
|
||||
}
|
||||
}
|
||||
statuses.statuses = SpannableHelper.convertNitterStatus(statusList);
|
||||
statuses.statuses = statusList;
|
||||
String max_id = publicTlResponse.headers().get("min-id");
|
||||
statuses.pagination = new Pagination();
|
||||
statuses.pagination.max_id = max_id;
|
||||
|
@ -278,8 +276,7 @@ public class TimelinesVM extends AndroidViewModel {
|
|||
statusList.add(status);
|
||||
}
|
||||
}
|
||||
List<Status> filteredStatuses = TimelineHelper.filterStatus(getApplication(), statusList, TimelineHelper.FilterTimeLineType.PUBLIC);
|
||||
statuses.statuses = SpannableHelper.convertStatus(getApplication().getApplicationContext(), filteredStatuses);
|
||||
statuses.statuses = TimelineHelper.filterStatus(getApplication(), statusList, TimelineHelper.FilterTimeLineType.PUBLIC);
|
||||
statuses.pagination = new Pagination();
|
||||
if (statusList.size() > 0) {
|
||||
statuses.pagination.min_id = statusList.get(0).id;
|
||||
|
@ -325,8 +322,7 @@ public class TimelinesVM extends AndroidViewModel {
|
|||
statusList.add(status);
|
||||
}
|
||||
}
|
||||
List<Status> filteredStatuses = TimelineHelper.filterStatus(getApplication(), statusList, TimelineHelper.FilterTimeLineType.PUBLIC);
|
||||
statuses.statuses = SpannableHelper.convertStatus(getApplication().getApplicationContext(), filteredStatuses);
|
||||
statuses.statuses = TimelineHelper.filterStatus(getApplication(), statusList, TimelineHelper.FilterTimeLineType.PUBLIC);
|
||||
statuses.pagination = new Pagination();
|
||||
if (statusList.size() > 0) {
|
||||
//These values are not used.
|
||||
|
@ -407,8 +403,7 @@ public class TimelinesVM extends AndroidViewModel {
|
|||
Response<List<Status>> hashTagTlResponse = hashTagTlCall.execute();
|
||||
if (hashTagTlResponse.isSuccessful()) {
|
||||
List<Status> notFilteredStatuses = hashTagTlResponse.body();
|
||||
List<Status> filteredStatuses = TimelineHelper.filterStatus(getApplication().getApplicationContext(), notFilteredStatuses, TimelineHelper.FilterTimeLineType.PUBLIC);
|
||||
statuses.statuses = SpannableHelper.convertStatus(getApplication().getApplicationContext(), filteredStatuses);
|
||||
statuses.statuses = TimelineHelper.filterStatus(getApplication().getApplicationContext(), notFilteredStatuses, TimelineHelper.FilterTimeLineType.PUBLIC);
|
||||
statuses.pagination = MastodonHelper.getPagination(hashTagTlResponse.headers());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
|
@ -450,8 +445,7 @@ public class TimelinesVM extends AndroidViewModel {
|
|||
Response<List<Status>> homeTlResponse = homeTlCall.execute();
|
||||
if (homeTlResponse.isSuccessful()) {
|
||||
List<Status> notFilteredStatuses = homeTlResponse.body();
|
||||
List<Status> filteredStatuses = TimelineHelper.filterStatus(getApplication().getApplicationContext(), notFilteredStatuses, TimelineHelper.FilterTimeLineType.HOME);
|
||||
statuses.statuses = SpannableHelper.convertStatus(getApplication().getApplicationContext(), filteredStatuses);
|
||||
statuses.statuses = TimelineHelper.filterStatus(getApplication().getApplicationContext(), notFilteredStatuses, TimelineHelper.FilterTimeLineType.HOME);
|
||||
statuses.pagination = MastodonHelper.getPagination(homeTlResponse.headers());
|
||||
if (!fetchingMissing) {
|
||||
for (Status status : statuses.statuses) {
|
||||
|
@ -503,8 +497,7 @@ public class TimelinesVM extends AndroidViewModel {
|
|||
statuses = statusCacheDAO.geStatuses(StatusCache.CacheEnum.HOME, instance, user_id, maxId, minId, sinceId);
|
||||
|
||||
if (statuses != null) {
|
||||
List<Status> filteredStatuses = TimelineHelper.filterStatus(getApplication().getApplicationContext(), statuses.statuses, TimelineHelper.FilterTimeLineType.HOME);
|
||||
statuses.statuses = SpannableHelper.convertStatus(getApplication().getApplicationContext(), filteredStatuses);
|
||||
statuses.statuses = TimelineHelper.filterStatus(getApplication().getApplicationContext(), statuses.statuses, TimelineHelper.FilterTimeLineType.HOME);
|
||||
if (statuses.statuses != null && statuses.statuses.size() > 0) {
|
||||
statuses.pagination = new Pagination();
|
||||
statuses.pagination.min_id = statuses.statuses.get(0).id;
|
||||
|
@ -571,7 +564,7 @@ public class TimelinesVM extends AndroidViewModel {
|
|||
try {
|
||||
Response<List<Status>> listTlResponse = listTlCall.execute();
|
||||
if (listTlResponse.isSuccessful()) {
|
||||
statuses.statuses = SpannableHelper.convertStatus(getApplication().getApplicationContext(), listTlResponse.body());
|
||||
statuses.statuses = listTlResponse.body();
|
||||
statuses.pagination = MastodonHelper.getPagination(listTlResponse.headers());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
|
@ -607,11 +600,6 @@ public class TimelinesVM extends AndroidViewModel {
|
|||
Response<List<Conversation>> conversationsResponse = conversationsCall.execute();
|
||||
if (conversationsResponse.isSuccessful()) {
|
||||
conversations.conversations = conversationsResponse.body();
|
||||
if (conversations.conversations != null) {
|
||||
for (Conversation conversation : conversations.conversations) {
|
||||
conversation.last_status = SpannableHelper.convertStatus(getApplication().getApplicationContext(), conversation.last_status);
|
||||
}
|
||||
}
|
||||
conversations.pagination = MastodonHelper.getPagination(conversationsResponse.headers());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
|
|
Loading…
Reference in New Issue