private void prepareNextPage() { try { preparingWindow = forward ? slidingWindows.getNextWindow() : slidingWindows.getPreviousWindow(); //// System.out.println("preparingWindow" + preparingWindow); if (preparingWindow.isLoading()) { // Log.d("SLIDING", "register on load listener..."); handler.post( new Runnable() { public void run() { preparingWindow.registerOnLoadListener( new com.goal98.flipdroid.model.Window.OnLoadListener() { public void onWindowLoaded(com.goal98.flipdroid.model.Window window) { if (forward) next = preparingWindow.get(); else { previous = preparingWindow.get(); } prepareFail = false; } public void onWindowSkipped( com.goal98.flipdroid.model.Window pageViewWindow) { prepareNextPage(); } }); } }); return; } else if (preparingWindow.isSkip()) { // Log.d("SLIDING", "slide to next page..."); prepareNextPage(); return; } else { if (forward) next = preparingWindow.get(); else previous = preparingWindow.get(); handler.post( new Runnable() { public void run() { renderNextPageIfNotRendered(); if (forward) next.removeLoadingIfNecessary(); else previous.removeLoadingIfNecessary(); } }); prepareFail = false; } } catch (LastWindowException e) { prepareFail = true; e.printStackTrace(); next = pageViewFactory.createLastPage(); } }
private void slideToNextPage() { System.out.println("debug slide to next"); try { if (preparingWindow == null && !prepareFail) preparingWindow = forward ? slidingWindows.getNextWindow() : slidingWindows.getPreviousWindow(); else { if (previousDirection != forward) { if (previousDirection) { if (currentPageIndex == 0) { finishActivity(); return; } preparingWindow = slidingWindows.getPreviousWindow(); preparingWindow = slidingWindows.getPreviousWindow(); } else { preparingWindow = slidingWindows.getNextWindow(); preparingWindow = slidingWindows.getNextWindow(); } } if (next.isLastPage()) { handler.post( new Runnable() { public void run() { showAnimation(); } }); return; } boolean preparingWindowReady = preparingWindow.isLoaded(); if (!preparingWindowReady) { preparingWindow.registerOnLoadListener(PageActivity.this); handler.post( new Runnable() { public void run() { current.showLoading(); } }); return; } } final com.goal98.flipdroid.model.Window nextWindow = preparingWindow; preparingWindow = null; if (nextWindow.isLoading()) { // Log.d("SLIDING", "register on load listener..."); handler.post( new Runnable() { public void run() { nextWindow.registerOnLoadListener(PageActivity.this); current.showLoading(); } }); return; } else if (nextWindow.isSkip()) { // Log.d("SLIDING", "slide to next page..."); current.setLoadingNext(false); slideToNextPage(); return; } else { if (next.isLastPage()) { //// System.out.println("lastpage"); } else { if (forward) next = nextWindow.get(); else previous = nextWindow.get(); } handler.post( new Runnable() { public void run() { if (forward) next.removeLoadingIfNecessary(); else { if (previous == null) return; previous.removeLoadingIfNecessary(); } showAnimation(); } }); } } catch (Exception e) { e.printStackTrace(); next = pageViewFactory.createLastPage(); handler.post( new Runnable() { public void run() { showAnimation(); } }); } }