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