From 487da40552cb460a5a34b623541b303fb95201a0 Mon Sep 17 00:00:00 2001 From: Tim Su Date: Sun, 12 Feb 2012 23:53:17 -0800 Subject: [PATCH] hide next button at the end --- astrid/res/layout/welcome_walkthrough.xml | 81 ++++++++++--------- .../welcome/tutorial/ViewPagerAdapter.java | 8 +- .../welcome/tutorial/WelcomeWalkthrough.java | 11 ++- 3 files changed, 56 insertions(+), 44 deletions(-) diff --git a/astrid/res/layout/welcome_walkthrough.xml b/astrid/res/layout/welcome_walkthrough.xml index 77db7f47b..3dd5ead67 100755 --- a/astrid/res/layout/welcome_walkthrough.xml +++ b/astrid/res/layout/welcome_walkthrough.xml @@ -5,46 +5,47 @@ android:layout_width="fill_parent" android:layout_height="fill_parent"> - + - - - - - - + + + + + + \ No newline at end of file diff --git a/astrid/src/com/todoroo/astrid/welcome/tutorial/ViewPagerAdapter.java b/astrid/src/com/todoroo/astrid/welcome/tutorial/ViewPagerAdapter.java index cd632f27c..28fef98fe 100644 --- a/astrid/src/com/todoroo/astrid/welcome/tutorial/ViewPagerAdapter.java +++ b/astrid/src/com/todoroo/astrid/welcome/tutorial/ViewPagerAdapter.java @@ -67,7 +67,13 @@ public class ViewPagerAdapter extends PagerAdapter implements TitleProvider images[images.length - 1] = R.drawable.welcome_walkthrough_1; body[body.length - 1] = R.string.welcome_body_7_return; } + } + + @Override + public void setPrimaryItem(ViewGroup container, int position, Object object) { + super.setPrimaryItem(container, position, object); + parent.onPageChanged(container, position); } @@ -97,7 +103,7 @@ public class ViewPagerAdapter extends PagerAdapter implements TitleProvider } ((ViewPager) pager).addView(pageView, 0); - parent.pageScrolled(position, pageView); + parent.instantiatePage(position); return pageView; } diff --git a/astrid/src/com/todoroo/astrid/welcome/tutorial/WelcomeWalkthrough.java b/astrid/src/com/todoroo/astrid/welcome/tutorial/WelcomeWalkthrough.java index ae18e884f..2f4b01250 100644 --- a/astrid/src/com/todoroo/astrid/welcome/tutorial/WelcomeWalkthrough.java +++ b/astrid/src/com/todoroo/astrid/welcome/tutorial/WelcomeWalkthrough.java @@ -56,15 +56,20 @@ public class WelcomeWalkthrough extends ActFmLoginActivity { protected int getTitleResource() { return 0; } - public void pageScrolled(int position, View view){ - currentView = view; - currentPage = position; + + public void instantiatePage(int position){ if (position == mAdapter.getCount()-1) { initializeUI(); } } + public void onPageChanged(View view, int position) { + currentPage = position; + currentView = view; + findViewById(R.id.next).setVisibility( + position == mAdapter.getCount()-1 ? View.GONE : View.VISIBLE); + } @Override protected void initializeUI() {