Direct scroll in PostAdapter when distance > 20

captchafix
Florens Douwes 11 years ago
parent 0a7cb7f80b
commit 4daeefdaff
  1. 10
      Chan/src/org/floens/chan/ui/adapter/PostAdapter.java

@ -28,6 +28,7 @@ public class PostAdapter extends BaseAdapter {
private boolean endOfLine; private boolean endOfLine;
private final List<Post> postList = new ArrayList<Post>(); private final List<Post> postList = new ArrayList<Post>();
private long lastViewedTime = 0; private long lastViewedTime = 0;
private int lastIndex;
public PostAdapter(Context activity, ThreadManager threadManager, ListView listView) { public PostAdapter(Context activity, ThreadManager threadManager, ListView listView) {
context = activity; context = activity;
@ -47,6 +48,7 @@ public class PostAdapter extends BaseAdapter {
@Override @Override
public Post getItem(int position) { public Post getItem(int position) {
lastIndex = position;
return postList.get(position); return postList.get(position);
} }
@ -150,8 +152,12 @@ public class PostAdapter extends BaseAdapter {
for (int i = 0; i < postList.size(); i++) { for (int i = 0; i < postList.size(); i++) {
if (postList.get(i).no == post.no) { if (postList.get(i).no == post.no) {
ScrollerRunnable r = new ScrollerRunnable(listView); if (Math.abs(i - lastIndex) > 20) {
r.start(i); listView.setSelection(i);
} else {
ScrollerRunnable r = new ScrollerRunnable(listView);
r.start(i);
}
break; break;
} }

Loading…
Cancel
Save