Search in sources :

Example 1 with StatusViewData

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

the class TimelineFragment method onContentHiddenChange.

@Override
public void onContentHiddenChange(boolean isShowing, int position) {
    StatusViewData newViewData = new StatusViewData.Builder(((StatusViewData.Concrete) statuses.getPairedItem(position))).setIsShowingSensitiveContent(isShowing).createStatusViewData();
    statuses.setPairedItem(position, newViewData);
    adapter.changeItem(position, newViewData, false);
}
Also used : StatusViewData(com.keylesspalace.tusky.viewdata.StatusViewData)

Example 2 with StatusViewData

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

the class TimelineFragment method onFetchTimelineFailure.

private void onFetchTimelineFailure(Exception exception, FetchEnd fetchEnd, int position) {
    swipeRefreshLayout.setRefreshing(false);
    if (fetchEnd == FetchEnd.MIDDLE && !statuses.get(position).isRight()) {
        StatusViewData newViewData = new StatusViewData.Placeholder(false);
        statuses.setPairedItem(position, newViewData);
        adapter.changeItem(position, newViewData, true);
    }
    Log.e(TAG, "Fetch Failure: " + exception.getMessage());
    fulfillAnyQueuedFetches(fetchEnd);
}
Also used : StatusViewData(com.keylesspalace.tusky.viewdata.StatusViewData)

Example 3 with StatusViewData

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

the class TimelineFragment method onFavourite.

@Override
public void onFavourite(final boolean favourite, final int position) {
    final Status status = statuses.get(position).getAsRight();
    timelineCases.favouriteWithCallback(status, favourite, new Callback<Status>() {

        @Override
        public void onResponse(@NonNull Call<Status> call, @NonNull Response<Status> response) {
            if (response.isSuccessful()) {
                status.setFavourited(favourite);
                if (status.getReblog() != null) {
                    status.getReblog().setFavourited(favourite);
                }
                Pair<StatusViewData.Concrete, Integer> actual = findStatusAndPosition(position, status);
                if (actual == null)
                    return;
                StatusViewData newViewData = new StatusViewData.Builder(actual.first).setFavourited(favourite).createStatusViewData();
                statuses.setPairedItem(actual.second, newViewData);
                adapter.changeItem(actual.second, newViewData, false);
            }
        }

        @Override
        public void onFailure(@NonNull Call<Status> call, @NonNull Throwable t) {
            Log.d(TAG, "Failed to favourite status " + status.getId(), t);
        }
    });
}
Also used : Status(com.keylesspalace.tusky.entity.Status) StatusViewData(com.keylesspalace.tusky.viewdata.StatusViewData) Pair(android.support.v4.util.Pair)

Example 4 with StatusViewData

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

the class TimelineFragment method onExpandedChange.

@Override
public void onExpandedChange(boolean expanded, int position) {
    StatusViewData newViewData = new StatusViewData.Builder(((StatusViewData.Concrete) statuses.getPairedItem(position))).setIsExpanded(expanded).createStatusViewData();
    statuses.setPairedItem(position, newViewData);
    adapter.changeItem(position, newViewData, false);
}
Also used : StatusViewData(com.keylesspalace.tusky.viewdata.StatusViewData)

Example 5 with StatusViewData

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

the class NotificationsFragment method onContentHiddenChange.

@Override
public void onContentHiddenChange(boolean isShowing, int position) {
    NotificationViewData.Concrete old = (NotificationViewData.Concrete) notifications.getPairedItem(position);
    StatusViewData.Concrete statusViewData = new StatusViewData.Builder(old.getStatusViewData()).setIsShowingSensitiveContent(isShowing).createStatusViewData();
    NotificationViewData notificationViewData = new NotificationViewData.Concrete(old.getType(), old.getId(), old.getAccount(), statusViewData, old.isExpanded());
    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