implement "load more" placeholder

This commit is contained in:
Conny Duck 2017-11-03 22:17:31 +01:00
commit 80a10c1ac1
16 changed files with 398 additions and 95 deletions

View file

@ -54,7 +54,6 @@ import com.keylesspalace.tusky.viewdata.NotificationViewData;
import com.keylesspalace.tusky.viewdata.StatusViewData;
import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.List;
import retrofit2.Call;
@ -65,11 +64,14 @@ public class NotificationsFragment extends SFragment implements
SwipeRefreshLayout.OnRefreshListener, StatusActionListener,
NotificationsAdapter.NotificationActionListener,
SharedPreferences.OnSharedPreferenceChangeListener {
private static final String TAG = "Notifications"; // logging tag
private static final String TAG = "NotificationF"; // logging tag
private static final int LOAD_AT_ONCE = 30;
private enum FetchEnd {
TOP,
BOTTOM
BOTTOM,
MIDDLE
}
private SwipeRefreshLayout swipeRefreshLayout;
@ -156,12 +158,10 @@ public class NotificationsFragment extends SFragment implements
TabLayout layout = activity.findViewById(R.id.tab_layout);
onTabSelectedListener = new TabLayout.OnTabSelectedListener() {
@Override
public void onTabSelected(TabLayout.Tab tab) {
}
public void onTabSelected(TabLayout.Tab tab) {}
@Override
public void onTabUnselected(TabLayout.Tab tab) {
}
public void onTabUnselected(TabLayout.Tab tab) {}
@Override
public void onTabReselected(TabLayout.Tab tab) {
@ -220,7 +220,7 @@ public class NotificationsFragment extends SFragment implements
@Override
public void onRefresh() {
sendFetchNotificationsRequest(null, topId, FetchEnd.TOP);
sendFetchNotificationsRequest(null, topId, FetchEnd.TOP, -1);
}
@Override
@ -252,8 +252,7 @@ public class NotificationsFragment extends SFragment implements
@Override
public void onFailure(@NonNull Call<Status> call, @NonNull Throwable t) {
Log.d(getClass().getSimpleName(), "Failed to reblog status: " + status.id);
t.printStackTrace();
Log.d(getClass().getSimpleName(), "Failed to reblog status: " + status.id, t);
}
});
}
@ -283,8 +282,7 @@ public class NotificationsFragment extends SFragment implements
@Override
public void onFailure(@NonNull Call<Status> call, @NonNull Throwable t) {
Log.d(getClass().getSimpleName(), "Failed to favourite status: " + status.id);
t.printStackTrace();
Log.d(getClass().getSimpleName(), "Failed to favourite status: " + status.id, t);
}
});
}
@ -321,7 +319,7 @@ public class NotificationsFragment extends SFragment implements
.setIsExpanded(expanded)
.createStatusViewData();
NotificationViewData notificationViewData = new NotificationViewData(old.getType(),
old.getId(), old.getAccount(), statusViewData);
old.getId(), old.getAccount(), statusViewData, false);
notifications.setPairedItem(position, notificationViewData);
adapter.updateItemWithNotify(position, notificationViewData, false);
}
@ -334,11 +332,29 @@ public class NotificationsFragment extends SFragment implements
.setIsShowingSensitiveContent(isShowing)
.createStatusViewData();
NotificationViewData notificationViewData = new NotificationViewData(old.getType(),
old.getId(), old.getAccount(), statusViewData);
old.getId(), old.getAccount(), statusViewData, false);
notifications.setPairedItem(position, notificationViewData);
adapter.updateItemWithNotify(position, notificationViewData, false);
}
@Override
public void onLoadMore(int position) {
//check bounds before accessing list,
if (notifications.size() >= position && position > 0) {
String fromId = notifications.get(position - 1).id;
String toId = notifications.get(position + 1).id;
sendFetchNotificationsRequest(fromId, toId, FetchEnd.MIDDLE, position);
NotificationViewData old = notifications.getPairedItem(position);
NotificationViewData notificationViewData = new NotificationViewData(old.getType(),
old.getId(), old.getAccount(), old.getStatusViewData(), true);
notifications.setPairedItem(position, notificationViewData);
adapter.updateItemWithNotify(position, notificationViewData, false);
} else {
Log.d(TAG, "error loading more");
}
}
@Override
public void onViewTag(String tag) {
super.viewTag(tag);
@ -385,7 +401,7 @@ public class NotificationsFragment extends SFragment implements
}
private void onLoadMore() {
sendFetchNotificationsRequest(bottomId, null, FetchEnd.BOTTOM);
sendFetchNotificationsRequest(bottomId, null, FetchEnd.BOTTOM, -1);
}
private void jumpToTop() {
@ -394,7 +410,7 @@ public class NotificationsFragment extends SFragment implements
}
private void sendFetchNotificationsRequest(String fromId, String uptoId,
final FetchEnd fetchEnd) {
final FetchEnd fetchEnd, final int pos) {
/* If there is a fetch already ongoing, record however many fetches are requested and
* fulfill them after it's complete. */
if (fetchEnd == FetchEnd.TOP && topLoading) {
@ -418,7 +434,7 @@ public class NotificationsFragment extends SFragment implements
});
}
Call<List<Notification>> call = mastodonApi.notifications(fromId, uptoId, null);
Call<List<Notification>> call = mastodonApi.notifications(fromId, uptoId, LOAD_AT_ONCE);
call.enqueue(new Callback<List<Notification>>() {
@Override
@ -426,22 +442,22 @@ public class NotificationsFragment extends SFragment implements
@NonNull Response<List<Notification>> response) {
if (response.isSuccessful()) {
String linkHeader = response.headers().get("Link");
onFetchNotificationsSuccess(response.body(), linkHeader, fetchEnd);
onFetchNotificationsSuccess(response.body(), linkHeader, fetchEnd, pos);
} else {
onFetchNotificationsFailure(new Exception(response.message()), fetchEnd);
onFetchNotificationsFailure(new Exception(response.message()), fetchEnd, pos);
}
}
@Override
public void onFailure(@NonNull Call<List<Notification>> call, @NonNull Throwable t) {
onFetchNotificationsFailure((Exception) t, fetchEnd);
onFetchNotificationsFailure((Exception) t, fetchEnd, pos);
}
});
callList.add(call);
}
private void onFetchNotificationsSuccess(List<Notification> notifications, String linkHeader,
FetchEnd fetchEnd) {
FetchEnd fetchEnd, int pos) {
List<HttpHeaderLink> links = HttpHeaderLink.parse(linkHeader);
switch (fetchEnd) {
case TOP: {
@ -453,6 +469,10 @@ public class NotificationsFragment extends SFragment implements
update(notifications, null, uptoId);
break;
}
case MIDDLE: {
insert(notifications, pos);
break;
}
case BOTTOM: {
HttpHeaderLink next = HttpHeaderLink.findByRelationType(links, "next");
String fromId = null;
@ -489,8 +509,8 @@ public class NotificationsFragment extends SFragment implements
swipeRefreshLayout.setRefreshing(false);
}
public void update(@Nullable List<Notification> newNotifications, @Nullable String fromId,
@Nullable String uptoId) {
private void update(@Nullable List<Notification> newNotifications, @Nullable String fromId,
@Nullable String uptoId) {
if (ListUtils.isEmpty(newNotifications)) {
return;
}
@ -501,8 +521,7 @@ public class NotificationsFragment extends SFragment implements
topId = uptoId;
}
if (notifications.isEmpty()) {
// This construction removes duplicates while preserving order.
notifications.addAll(new LinkedHashSet<>(newNotifications));
notifications.addAll(newNotifications);
} else {
int index = notifications.indexOf(newNotifications.get(newNotifications.size() - 1));
for (int i = 0; i < index; i++) {
@ -510,6 +529,11 @@ public class NotificationsFragment extends SFragment implements
}
int newIndex = newNotifications.indexOf(notifications.get(0));
if (newIndex == -1) {
if(index == -1 && newNotifications.size() >= LOAD_AT_ONCE) {
Notification placeholder = new Notification();
placeholder.type = Notification.Type.PLACEHOLDER;
newNotifications.add(placeholder);
}
notifications.addAll(0, newNotifications);
} else {
List<Notification> sublist = newNotifications.subList(0, newIndex);
@ -519,7 +543,7 @@ public class NotificationsFragment extends SFragment implements
adapter.update(notifications.getPairedCopy());
}
public void addItems(List<Notification> newNotifications, @Nullable String fromId) {
private void addItems(List<Notification> newNotifications, @Nullable String fromId) {
if (ListUtils.isEmpty(newNotifications)) {
return;
}
@ -532,7 +556,7 @@ public class NotificationsFragment extends SFragment implements
notifications.addAll(newNotifications);
List<NotificationViewData> newViewDatas = notifications.getPairedCopy()
.subList(notifications.size() - newNotifications.size(),
notifications.size() - 1);
notifications.size());
adapter.addItems(newViewDatas);
}
}
@ -546,8 +570,15 @@ public class NotificationsFragment extends SFragment implements
return false;
}
private void onFetchNotificationsFailure(Exception exception, FetchEnd fetchEnd) {
private void onFetchNotificationsFailure(Exception exception, FetchEnd fetchEnd, int position) {
swipeRefreshLayout.setRefreshing(false);
if(fetchEnd == FetchEnd.MIDDLE && notifications.getPairedItem(position).getType() == Notification.Type.PLACEHOLDER) {
NotificationViewData old = notifications.getPairedItem(position);
NotificationViewData notificationViewData = new NotificationViewData(old.getType(),
old.getId(), old.getAccount(), old.getStatusViewData(), false);
notifications.setPairedItem(position, notificationViewData);
adapter.updateItemWithNotify(position, notificationViewData, true);
}
Log.e(TAG, "Fetch failure: " + exception.getMessage());
fulfillAnyQueuedFetches(fetchEnd);
}
@ -573,9 +604,29 @@ public class NotificationsFragment extends SFragment implements
}
}
private void insert(List<Notification> newNotifications, int pos) {
notifications.remove(pos);
if (ListUtils.isEmpty(newNotifications)) {
adapter.update(notifications.getPairedCopy());
return;
}
if(newNotifications.size() >= LOAD_AT_ONCE) {
Notification placeholder = new Notification();
placeholder.type = Notification.Type.PLACEHOLDER;
newNotifications.add(placeholder);
}
notifications.addAll(pos, newNotifications);
adapter.update(notifications.getPairedCopy());
}
private void fullyRefresh() {
adapter.clear();
notifications.clear();
sendFetchNotificationsRequest(null, null, FetchEnd.TOP);
sendFetchNotificationsRequest(null, null, FetchEnd.TOP, -1);
}
}

View file

@ -21,6 +21,7 @@ import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.app.ActivityOptionsCompat;
import android.support.v4.content.LocalBroadcastManager;
@ -148,10 +149,10 @@ public abstract class SFragment extends BaseFragment implements AdapterItemRemov
Call<Relationship> call = mastodonApi.muteAccount(id);
call.enqueue(new Callback<Relationship>() {
@Override
public void onResponse(Call<Relationship> call, Response<Relationship> response) {}
public void onResponse(@NonNull Call<Relationship> call, @NonNull Response<Relationship> response) {}
@Override
public void onFailure(Call<Relationship> call, Throwable t) {}
public void onFailure(@NonNull Call<Relationship> call, @NonNull Throwable t) {}
});
callList.add(call);
Intent intent = new Intent(TimelineReceiver.Types.MUTE_ACCOUNT);
@ -164,10 +165,10 @@ public abstract class SFragment extends BaseFragment implements AdapterItemRemov
Call<Relationship> call = mastodonApi.blockAccount(id);
call.enqueue(new Callback<Relationship>() {
@Override
public void onResponse(Call<Relationship> call, retrofit2.Response<Relationship> response) {}
public void onResponse(@NonNull Call<Relationship> call, @NonNull retrofit2.Response<Relationship> response) {}
@Override
public void onFailure(Call<Relationship> call, Throwable t) {}
public void onFailure(@NonNull Call<Relationship> call, @NonNull Throwable t) {}
});
callList.add(call);
Intent intent = new Intent(TimelineReceiver.Types.BLOCK_ACCOUNT);
@ -180,10 +181,10 @@ public abstract class SFragment extends BaseFragment implements AdapterItemRemov
Call<ResponseBody> call = mastodonApi.deleteStatus(id);
call.enqueue(new Callback<ResponseBody>() {
@Override
public void onResponse(Call<ResponseBody> call, retrofit2.Response<ResponseBody> response) {}
public void onResponse(@NonNull Call<ResponseBody> call, @NonNull retrofit2.Response<ResponseBody> response) {}
@Override
public void onFailure(Call<ResponseBody> call, Throwable t) {}
public void onFailure(@NonNull Call<ResponseBody> call, @NonNull Throwable t) {}
});
callList.add(call);
}

View file

@ -20,6 +20,7 @@ import android.content.SharedPreferences;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.TabLayout;
@ -51,7 +52,6 @@ import com.keylesspalace.tusky.view.EndlessOnScrollListener;
import com.keylesspalace.tusky.viewdata.StatusViewData;
import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Locale;
@ -63,10 +63,12 @@ public class TimelineFragment extends SFragment implements
SwipeRefreshLayout.OnRefreshListener,
StatusActionListener,
SharedPreferences.OnSharedPreferenceChangeListener {
private static final String TAG = "Timeline"; // logging tag
private static final String TAG = "TimelineF"; // logging tag
private static final String KIND_ARG = "kind";
private static final String HASHTAG_OR_ID_ARG = "hashtag_or_id";
private static final int LOAD_AT_ONCE = 30;
public enum Kind {
HOME,
PUBLIC_LOCAL,
@ -79,6 +81,7 @@ public class TimelineFragment extends SFragment implements
private enum FetchEnd {
TOP,
BOTTOM,
MIDDLE
}
private SwipeRefreshLayout swipeRefreshLayout;
@ -178,12 +181,10 @@ public class TimelineFragment extends SFragment implements
TabLayout layout = getActivity().findViewById(R.id.tab_layout);
onTabSelectedListener = new TabLayout.OnTabSelectedListener() {
@Override
public void onTabSelected(TabLayout.Tab tab) {
}
public void onTabSelected(TabLayout.Tab tab) {}
@Override
public void onTabUnselected(TabLayout.Tab tab) {
}
public void onTabUnselected(TabLayout.Tab tab) {}
@Override
public void onTabReselected(TabLayout.Tab tab) {
@ -218,7 +219,7 @@ public class TimelineFragment extends SFragment implements
} else if (!composeButton.isShown()) {
composeButton.show();
}
}
}
}
@Override
@ -250,7 +251,7 @@ public class TimelineFragment extends SFragment implements
@Override
public void onRefresh() {
sendFetchTimelineRequest(null, topId, FetchEnd.TOP);
sendFetchTimelineRequest(null, topId, FetchEnd.TOP, -1);
}
@Override
@ -263,7 +264,7 @@ public class TimelineFragment extends SFragment implements
final Status status = statuses.get(position);
super.reblogWithCallback(status, reblog, new Callback<Status>() {
@Override
public void onResponse(Call<Status> call, retrofit2.Response<Status> response) {
public void onResponse(@NonNull Call<Status> call, @NonNull Response<Status> response) {
if (response.isSuccessful()) {
status.reblogged = reblog;
@ -280,9 +281,8 @@ public class TimelineFragment extends SFragment implements
}
@Override
public void onFailure(Call<Status> call, Throwable t) {
Log.d(TAG, "Failed to reblog status " + status.id);
t.printStackTrace();
public void onFailure(@NonNull Call<Status> call, @NonNull Throwable t) {
Log.d(TAG, "Failed to reblog status " + status.id, t);
}
});
}
@ -293,7 +293,7 @@ public class TimelineFragment extends SFragment implements
super.favouriteWithCallback(status, favourite, new Callback<Status>() {
@Override
public void onResponse(Call<Status> call, retrofit2.Response<Status> response) {
public void onResponse(@NonNull Call<Status> call, @NonNull Response<Status> response) {
if (response.isSuccessful()) {
status.favourited = favourite;
@ -310,9 +310,8 @@ public class TimelineFragment extends SFragment implements
}
@Override
public void onFailure(Call<Status> call, Throwable t) {
Log.d(TAG, "Failed to favourite status " + status.id);
t.printStackTrace();
public void onFailure(@NonNull Call<Status> call, @NonNull Throwable t) {
Log.d(TAG, "Failed to favourite status " + status.id, t);
}
});
}
@ -343,6 +342,24 @@ public class TimelineFragment extends SFragment implements
adapter.changeItem(position, newViewData, false);
}
@Override
public void onLoadMore(int position) {
//check bounds before accessing list,
if (statuses.size() >= position && position > 0) {
String fromId = statuses.get(position - 1).id;
String toId = statuses.get(position + 1).id;
sendFetchTimelineRequest(fromId, toId, FetchEnd.MIDDLE, position);
StatusViewData newViewData = new StatusViewData.Builder(statuses.getPairedItem(position))
.setPlaceholderLoading(true).createStatusViewData();
statuses.setPairedItem(position, newViewData);
adapter.changeItem(position, newViewData, false);
} else {
Log.d(TAG, "error loading more");
}
}
@Override
public void onViewMedia(String[] urls, int urlIndex, Status.MediaAttachment.Type type,
View view) {
@ -427,12 +444,12 @@ public class TimelineFragment extends SFragment implements
}
private void onLoadMore() {
sendFetchTimelineRequest(bottomId, null, FetchEnd.BOTTOM);
sendFetchTimelineRequest(bottomId, null, FetchEnd.BOTTOM, -1);
}
private void fullyRefresh() {
adapter.clear();
sendFetchTimelineRequest(null, null, FetchEnd.TOP);
sendFetchTimelineRequest(null, null, FetchEnd.TOP, -1);
}
private boolean jumpToTopAllowed() {
@ -456,20 +473,20 @@ public class TimelineFragment extends SFragment implements
case HOME:
return api.homeTimeline(fromId, uptoId, null);
case PUBLIC_FEDERATED:
return api.publicTimeline(null, fromId, uptoId, null);
return api.publicTimeline(null, fromId, uptoId, LOAD_AT_ONCE);
case PUBLIC_LOCAL:
return api.publicTimeline(true, fromId, uptoId, null);
return api.publicTimeline(true, fromId, uptoId, LOAD_AT_ONCE);
case TAG:
return api.hashtagTimeline(tagOrId, null, fromId, uptoId, null);
return api.hashtagTimeline(tagOrId, null, fromId, uptoId, LOAD_AT_ONCE);
case USER:
return api.accountStatuses(tagOrId, fromId, uptoId, null);
return api.accountStatuses(tagOrId, fromId, uptoId, LOAD_AT_ONCE);
case FAVOURITES:
return api.favourites(fromId, uptoId, null);
return api.favourites(fromId, uptoId, LOAD_AT_ONCE);
}
}
private void sendFetchTimelineRequest(@Nullable String fromId, @Nullable String uptoId,
final FetchEnd fetchEnd) {
final FetchEnd fetchEnd, final int pos) {
/* If there is a fetch already ongoing, record however many fetches are requested and
* fulfill them after it's complete. */
if (fetchEnd == FetchEnd.TOP && topLoading) {
@ -495,18 +512,18 @@ public class TimelineFragment extends SFragment implements
Callback<List<Status>> callback = new Callback<List<Status>>() {
@Override
public void onResponse(Call<List<Status>> call, Response<List<Status>> response) {
public void onResponse(@NonNull Call<List<Status>> call, @NonNull Response<List<Status>> response) {
if (response.isSuccessful()) {
String linkHeader = response.headers().get("Link");
onFetchTimelineSuccess(response.body(), linkHeader, fetchEnd);
onFetchTimelineSuccess(response.body(), linkHeader, fetchEnd, pos);
} else {
onFetchTimelineFailure(new Exception(response.message()), fetchEnd);
onFetchTimelineFailure(new Exception(response.message()), fetchEnd, pos);
}
}
@Override
public void onFailure(Call<List<Status>> call, Throwable t) {
onFetchTimelineFailure((Exception) t, fetchEnd);
public void onFailure(@NonNull Call<List<Status>> call, @NonNull Throwable t) {
onFetchTimelineFailure((Exception) t, fetchEnd, pos);
}
};
@ -515,8 +532,9 @@ public class TimelineFragment extends SFragment implements
listCall.enqueue(callback);
}
public void onFetchTimelineSuccess(List<Status> statuses, String linkHeader,
FetchEnd fetchEnd) {
private void onFetchTimelineSuccess(List<Status> statuses, String linkHeader,
FetchEnd fetchEnd, int pos) {
boolean fullFetch = statuses.size() >= LOAD_AT_ONCE;
filterStatuses(statuses);
List<HttpHeaderLink> links = HttpHeaderLink.parse(linkHeader);
switch (fetchEnd) {
@ -526,7 +544,11 @@ public class TimelineFragment extends SFragment implements
if (previous != null) {
uptoId = previous.uri.getQueryParameter("since_id");
}
updateStatuses(statuses, null, uptoId);
updateStatuses(statuses, null, uptoId, fullFetch);
break;
}
case MIDDLE: {
insertStatuses(statuses,fullFetch, pos);
break;
}
case BOTTOM: {
@ -546,7 +568,7 @@ public class TimelineFragment extends SFragment implements
if (previous != null) {
uptoId = previous.uri.getQueryParameter("since_id");
}
updateStatuses(statuses, fromId, uptoId);
updateStatuses(statuses, fromId, uptoId, fullFetch);
}
break;
}
@ -560,8 +582,17 @@ public class TimelineFragment extends SFragment implements
swipeRefreshLayout.setRefreshing(false);
}
public void onFetchTimelineFailure(Exception exception, FetchEnd fetchEnd) {
private void onFetchTimelineFailure(Exception exception, FetchEnd fetchEnd, int position) {
swipeRefreshLayout.setRefreshing(false);
if(fetchEnd == FetchEnd.MIDDLE && statuses.getPairedItem(position).isPlaceholder()) {
StatusViewData newViewData = new StatusViewData.Builder(statuses.getPairedItem(position))
.setPlaceholderLoading(false).createStatusViewData();
statuses.setPairedItem(position, newViewData);
adapter.changeItem(position, newViewData, true);
}
Log.e(TAG, "Fetch Failure: " + exception.getMessage());
fulfillAnyQueuedFetches(fetchEnd);
}
@ -587,7 +618,7 @@ public class TimelineFragment extends SFragment implements
}
}
protected void filterStatuses(List<Status> statuses) {
private void filterStatuses(List<Status> statuses) {
Iterator<Status> it = statuses.iterator();
while (it.hasNext()) {
Status status = it.next();
@ -599,7 +630,7 @@ public class TimelineFragment extends SFragment implements
}
private void updateStatuses(List<Status> newStatuses, @Nullable String fromId,
@Nullable String toId) {
@Nullable String toId, boolean fullFetch) {
if (ListUtils.isEmpty(newStatuses)) {
return;
}
@ -610,16 +641,21 @@ public class TimelineFragment extends SFragment implements
topId = toId;
}
if (statuses.isEmpty()) {
// This construction removes duplicates while preserving order.
statuses.addAll(new LinkedHashSet<>(newStatuses));
statuses.addAll(newStatuses);
} else {
Status lastOfNew = newStatuses.get(newStatuses.size() - 1);
int index = statuses.indexOf(lastOfNew);
for (int i = 0; i < index; i++) {
statuses.remove(0);
}
int newIndex = newStatuses.indexOf(statuses.get(0));
if (newIndex == -1) {
if(index == -1 && fullFetch) {
Status placeholder = new Status();
placeholder.placeholder = true;
newStatuses.add(placeholder);
}
statuses.addAll(0, newStatuses);
} else {
statuses.addAll(0, newStatuses.subList(0, newIndex));
@ -641,7 +677,7 @@ public class TimelineFragment extends SFragment implements
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 == %d newViewDatas.size == %d, statuses.size == %d",
newStatuses.size(), newViewDatas.size(), statuses.size());
throw new AssertionError(error);
}
@ -652,6 +688,28 @@ public class TimelineFragment extends SFragment implements
}
}
private void insertStatuses(List<Status> newStatuses, boolean fullFetch, int pos) {
if(statuses.get(pos).placeholder) {
statuses.remove(pos);
}
if (ListUtils.isEmpty(newStatuses)) {
adapter.update(statuses.getPairedCopy());
return;
}
if(fullFetch) {
Status placeholder = new Status();
placeholder.placeholder = true;
newStatuses.add(placeholder);
}
statuses.addAll(pos, newStatuses);
adapter.update(statuses.getPairedCopy());
}
private static boolean findStatus(List<Status> statuses, String id) {
for (Status status : statuses) {
if (status.id.equals(id)) {

View file

@ -243,6 +243,11 @@ public class ViewThreadFragment extends SFragment implements
adapter.setItem(position, newViewData, false);
}
@Override
public void onLoadMore(int pos) {
}
@Override
public void onViewTag(String tag) {
super.viewTag(tag);