No watching when the thread is closed.

captchafix
Florens Douwes 11 years ago
parent f5181f7922
commit b229ad3cc6
  1. 2
      Chan/src/org/floens/chan/ChanApplication.java
  2. 5
      Chan/src/org/floens/chan/core/loader/Loader.java
  3. 21
      Chan/src/org/floens/chan/core/manager/ThreadManager.java
  4. 4
      Chan/src/org/floens/chan/ui/adapter/PostAdapter.java

@ -22,7 +22,7 @@ import com.android.volley.toolbox.ImageLoader;
import com.android.volley.toolbox.Volley;
public class ChanApplication extends Application implements PinListener {
public static final boolean DEVELOPER_MODE = false;
public static final boolean DEVELOPER_MODE = true;
private static ChanApplication instance;
private static RequestQueue volleyRequestQueue;

@ -175,6 +175,10 @@ public class Loader {
return lastLoadTime + waitTime - System.currentTimeMillis();
}
}
public List<Post> getCachedPosts() {
return cachedPosts;
}
private void setTimer(int postCount) {
clearTimer();
@ -259,6 +263,7 @@ public class Loader {
}
lastLoadTime = System.currentTimeMillis();
if (loadable.isThreadMode()) {
setTimer(result.size());
}

@ -65,7 +65,7 @@ public class ThreadManager implements Loader.LoaderListener {
public void onStart() {
if (loader != null) {
if (loader.getLoadable().isThreadMode()) {
if (shouldWatch()) {
loader.setAutoLoadMore(true);
loader.requestMoreDataAndResetTimer();
}
@ -84,7 +84,7 @@ public class ThreadManager implements Loader.LoaderListener {
}
loader = LoaderPool.getInstance().obtain(loadable, this);
if (loadable.isThreadMode()) {
if (shouldWatch()) {
loader.setAutoLoadMore(true);
}
}
@ -110,6 +110,11 @@ public class ThreadManager implements Loader.LoaderListener {
}
}
public boolean shouldWatch() {
boolean closed = loader.getCachedPosts().size() > 0 && loader.getCachedPosts().get(0).closed;
return loader.getLoadable().isThreadMode() && !closed;
}
public void requestData() {
if (loader != null) {
loader.requestData();
@ -136,6 +141,10 @@ public class ThreadManager implements Loader.LoaderListener {
@Override
public void onData(List<Post> result, boolean append) {
if (!shouldWatch()) {
loader.setAutoLoadMore(false);
}
threadManagerListener.onThreadLoaded(result, append);
}
@ -292,7 +301,7 @@ public class ThreadManager implements Loader.LoaderListener {
* When the user clicks a post: a. when there's one linkable, open the
* linkable. b. when there's more than one linkable, show the user multiple
* options to select from.
*
*
* @param post
* The post that was clicked.
*/
@ -338,7 +347,7 @@ public class ThreadManager implements Loader.LoaderListener {
/**
* Handle when a linkable has been clicked.
*
*
* @param linkable
* the selected linkable.
*/
@ -369,7 +378,7 @@ public class ThreadManager implements Loader.LoaderListener {
/**
* When a linkable to a post has been clicked, show a dialog with the
* referenced post in it.
*
*
* @param linkable
* the clicked linkable.
*/
@ -399,7 +408,7 @@ public class ThreadManager implements Loader.LoaderListener {
/**
* Open an url.
*
*
* @param linkable
* Linkable with an url.
*/

@ -37,7 +37,7 @@ public class PostAdapter extends BaseAdapter {
@Override
public int getCount() {
if (threadManager.getLoadable().isBoardMode() || threadManager.getLoadable().isThreadMode()) {
if (threadManager.getLoadable().isBoardMode() || threadManager.shouldWatch()) {
return postList.size() + 1;
} else {
return postList.size();
@ -86,7 +86,7 @@ public class PostAdapter extends BaseAdapter {
}
private View createThreadEndView() {
if (threadManager.getLoadable().isThreadMode()) {
if (threadManager.shouldWatch()) {
ThreadWatchCounterView view = new ThreadWatchCounterView(context);
Utils.setPressedDrawable(view);
view.init(threadManager, listView, this);

Loading…
Cancel
Save