Search in sources :

Example 11 with StatusViewData

use of com.keylesspalace.tusky.viewdata.StatusViewData in project Tusky by tuskyapp.

the class TimelineFragment method addItems.

private void addItems(List<Status> newStatuses, @Nullable String fromId) {
    if (ListUtils.isEmpty(newStatuses)) {
        return;
    }
    int end = statuses.size();
    Status last = statuses.get(end - 1).getAsRightOrNull();
    // types by ID anyway and we should change equals() for Status, I think, so this makes sense
    if (last != null && !findStatus(newStatuses, last.getId())) {
        statuses.addAll(listStatusList(newStatuses));
        List<StatusViewData> newViewDatas = statuses.getPairedCopy().subList(statuses.size() - newStatuses.size(), statuses.size());
        if (BuildConfig.DEBUG && newStatuses.size() != newViewDatas.size()) {
            String error = String.format(Locale.getDefault(), "Incorrectly got statusViewData sublist." + " newStatuses.size == %d newViewDatas.size == %d, statuses.size == %d", newStatuses.size(), newViewDatas.size(), statuses.size());
            throw new AssertionError(error);
        }
        if (fromId != null) {
            bottomId = fromId;
        }
        adapter.addItems(newViewDatas);
    }
}
Also used : Status(com.keylesspalace.tusky.entity.Status) StatusViewData(com.keylesspalace.tusky.viewdata.StatusViewData)

Example 12 with StatusViewData

use of com.keylesspalace.tusky.viewdata.StatusViewData in project Tusky by tuskyapp.

the class NotificationsFragment method onExpandedChange.

@Override
public void onExpandedChange(boolean expanded, int position) {
    NotificationViewData.Concrete old = (NotificationViewData.Concrete) notifications.getPairedItem(position);
    StatusViewData.Concrete statusViewData = new StatusViewData.Builder(old.getStatusViewData()).setIsExpanded(expanded).createStatusViewData();
    NotificationViewData notificationViewData = new NotificationViewData.Concrete(old.getType(), old.getId(), old.getAccount(), statusViewData, expanded);
    notifications.setPairedItem(position, notificationViewData);
    adapter.updateItemWithNotify(position, notificationViewData, false);
}
Also used : StatusViewData(com.keylesspalace.tusky.viewdata.StatusViewData) NotificationViewData(com.keylesspalace.tusky.viewdata.NotificationViewData)

Aggregations

StatusViewData (com.keylesspalace.tusky.viewdata.StatusViewData)12 Status (com.keylesspalace.tusky.entity.Status)5 Pair (android.support.v4.util.Pair)3 NotificationViewData (com.keylesspalace.tusky.viewdata.NotificationViewData)2 Nullable (android.support.annotation.Nullable)1