mirror of
https://github.com/nuclearfog/Shitter.git
synced 2025-01-25 13:58:36 +01:00
bug fix
This commit is contained in:
parent
394ad911fd
commit
f1db94bb6b
@ -71,11 +71,7 @@ public class TweetAdapter extends Adapter<ViewHolder> {
|
||||
*/
|
||||
@MainThread
|
||||
public void insertAt(@NonNull List<Tweet> data, int index) {
|
||||
if (loadingIndex != NO_INDEX) {
|
||||
int oldIndex = loadingIndex;
|
||||
loadingIndex = NO_INDEX;
|
||||
notifyItemChanged(oldIndex);
|
||||
}
|
||||
disableLoading();
|
||||
if (data.size() > MIN_COUNT) {
|
||||
if (tweets.isEmpty() || tweets.get(index) != null) {
|
||||
// Add placeholder
|
||||
@ -138,6 +134,16 @@ public class TweetAdapter extends Adapter<ViewHolder> {
|
||||
return tweets.isEmpty();
|
||||
}
|
||||
|
||||
/**
|
||||
* disable placeholder load animation
|
||||
*/
|
||||
public void disableLoading() {
|
||||
if (loadingIndex != NO_INDEX) {
|
||||
int oldIndex = loadingIndex;
|
||||
loadingIndex = NO_INDEX;
|
||||
notifyItemChanged(oldIndex);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getItemId(int index) {
|
||||
|
@ -77,10 +77,8 @@ public class UserAdapter extends Adapter<ViewHolder> {
|
||||
// remove footer
|
||||
users.remove(end);
|
||||
notifyItemRemoved(end);
|
||||
} else if (loadingIndex != NO_INDEX) {
|
||||
int oldIndex = loadingIndex;
|
||||
loadingIndex = NO_INDEX;
|
||||
notifyItemChanged(oldIndex);
|
||||
} else {
|
||||
disableLoading();
|
||||
}
|
||||
users.addAll(end, data.getUsers());
|
||||
notifyItemRangeInserted(end, data.getSize());
|
||||
@ -88,6 +86,17 @@ public class UserAdapter extends Adapter<ViewHolder> {
|
||||
nextCursor = data.getNext();
|
||||
}
|
||||
|
||||
/**
|
||||
* disable loading animation in footer
|
||||
*/
|
||||
public void disableLoading() {
|
||||
if (loadingIndex != NO_INDEX) {
|
||||
int oldIndex = loadingIndex;
|
||||
loadingIndex = NO_INDEX;
|
||||
notifyItemChanged(oldIndex);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
|
@ -195,6 +195,7 @@ public class TweetFragment extends Fragment implements OnRefreshListener, TweetC
|
||||
if (getContext() != null) {
|
||||
ErrorHandler.handleFailure(getContext(), error);
|
||||
}
|
||||
adapter.disableLoading();
|
||||
}
|
||||
|
||||
|
||||
|
@ -160,6 +160,7 @@ public class UserFragment extends Fragment implements OnRefreshListener, UserCli
|
||||
if (getContext() != null) {
|
||||
ErrorHandler.handleFailure(getContext(), error);
|
||||
}
|
||||
adapter.disableLoading();
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user