Search in sources :

Example 26 with Status

use of com.keylesspalace.tusky.entity.Status in project Tusky by Vavassor.

the class StatusViewHolder method setupWithStatus.

void setupWithStatus(Status status, StatusActionListener listener) {
    Status realStatus = status.getActionableStatus();
    setDisplayName(realStatus.account.getDisplayName());
    setUsername(realStatus.account.username);
    setCreatedAt(realStatus.createdAt);
    setContent(realStatus.content, realStatus.mentions, listener);
    setAvatar(realStatus.account.avatar);
    setReblogged(realStatus.reblogged);
    setFavourited(realStatus.favourited);
    String rebloggedByDisplayName = status.account.getDisplayName();
    if (status.reblog == null) {
        hideRebloggedByDisplayName();
    } else {
        setRebloggedByDisplayName(rebloggedByDisplayName);
    }
    Status.MediaAttachment[] attachments = realStatus.attachments;
    boolean sensitive = realStatus.sensitive;
    setMediaPreviews(attachments, sensitive, listener);
    /* A status without attachments is sometimes still marked sensitive, so it's necessary to
         * check both whether there are any attachments and if it's marked sensitive. */
    if (!sensitive || attachments.length == 0) {
        hideSensitiveMediaWarning();
    }
    setupButtons(listener, realStatus.account.id);
    setRebloggingEnabled(status.rebloggingAllowed());
    if (realStatus.spoilerText.isEmpty()) {
        hideSpoilerText();
    } else {
        setSpoilerText(realStatus.spoilerText);
    }
}
Also used : Status(com.keylesspalace.tusky.entity.Status)

Example 27 with Status

use of com.keylesspalace.tusky.entity.Status in project Tusky by Vavassor.

the class ThreadAdapter method setContext.

public void setContext(List<Status> ancestors, List<Status> descendants) {
    Status mainStatus = null;
    // In case of refresh, remove old ancestors and descendants first. We'll remove all blindly,
    // as we have no guarantee on their order to be the same as before
    int oldSize = statuses.size();
    if (oldSize > 0) {
        mainStatus = statuses.get(statusIndex);
        statuses.clear();
        notifyItemRangeRemoved(0, oldSize);
    }
    // Insert newly fetched ancestors
    statusIndex = ancestors.size();
    statuses.addAll(0, ancestors);
    notifyItemRangeInserted(0, statusIndex);
    if (mainStatus != null) {
        // In case we needed to delete everything (which is way easier than deleting
        // everything except one), re-insert the remaining status here.
        statuses.add(statusIndex, mainStatus);
        notifyItemInserted(statusIndex);
    }
    // Insert newly fetched descendants
    int end = statuses.size();
    statuses.addAll(descendants);
    notifyItemRangeInserted(end, descendants.size());
}
Also used : Status(com.keylesspalace.tusky.entity.Status)

Example 28 with Status

use of com.keylesspalace.tusky.entity.Status in project Tusky by Vavassor.

the class ThreadAdapter method removeAllByAccountId.

public void removeAllByAccountId(String accountId) {
    for (int i = 0; i < statuses.size(); ) {
        Status status = statuses.get(i);
        if (accountId.equals(status.account.id)) {
            statuses.remove(i);
            notifyItemRemoved(i);
        } else {
            i += 1;
        }
    }
}
Also used : Status(com.keylesspalace.tusky.entity.Status)

Example 29 with Status

use of com.keylesspalace.tusky.entity.Status in project Tusky by Vavassor.

the class ThreadAdapter method onBindViewHolder.

@Override
public void onBindViewHolder(RecyclerView.ViewHolder viewHolder, int position) {
    StatusViewHolder holder = (StatusViewHolder) viewHolder;
    Status status = statuses.get(position);
    holder.setupWithStatus(status, statusActionListener);
}
Also used : Status(com.keylesspalace.tusky.entity.Status)

Example 30 with Status

use of com.keylesspalace.tusky.entity.Status in project Tusky by Vavassor.

the class TimelineAdapter method removeAllByAccountId.

public void removeAllByAccountId(String accountId) {
    for (int i = 0; i < statuses.size(); ) {
        Status status = statuses.get(i);
        if (accountId.equals(status.account.id)) {
            statuses.remove(i);
            notifyItemRemoved(i);
        } else {
            i += 1;
        }
    }
}
Also used : Status(com.keylesspalace.tusky.entity.Status)

Aggregations

Status (com.keylesspalace.tusky.entity.Status)48 StatusViewData (com.keylesspalace.tusky.viewdata.StatusViewData)13 Notification (com.keylesspalace.tusky.entity.Notification)10 Intent (android.content.Intent)4 ArrayList (java.util.ArrayList)4 Either (com.keylesspalace.tusky.util.Either)3 NotificationViewData (com.keylesspalace.tusky.viewdata.NotificationViewData)3 List (java.util.List)3 Context (android.content.Context)2 Pair (android.support.v4.util.Pair)2 TextView (android.widget.TextView)2 AccountEntity (com.keylesspalace.tusky.db.AccountEntity)2 PendingIntent (android.app.PendingIntent)1 ClipData (android.content.ClipData)1 ClipboardManager (android.content.ClipboardManager)1 BitmapDrawable (android.graphics.drawable.BitmapDrawable)1 ColorDrawable (android.graphics.drawable.ColorDrawable)1 Drawable (android.graphics.drawable.Drawable)1 Spanned (android.text.Spanned)1 TextUtils (android.text.TextUtils)1