Loading src/com/android/deskclock/HandleApiCalls.java +2 −1 Original line number Diff line number Diff line Loading @@ -382,7 +382,8 @@ public class HandleApiCalls extends Activity { } else { startActivity(new Intent(this, DeskClock.class) .putExtra(DeskClock.SELECT_TAB_INTENT_EXTRA, DeskClock.TIMER_TAB_INDEX) .putExtra(Timers.FIRST_LAUNCH_FROM_API_CALL, true)); .putExtra(Timers.FIRST_LAUNCH_FROM_API_CALL, true) .putExtra(Timers.SCROLL_TO_TIMER_ID, timer.mTimerId)); } Voice.notifySuccess(this, getString(R.string.timer_created)); LogUtils.i("HandleApiCalls timer created: %s", timer); Loading src/com/android/deskclock/timer/TimerFragment.java +6 −2 Original line number Diff line number Diff line Loading @@ -228,9 +228,13 @@ public class TimerFragment extends DeskClockFragment implements OnSharedPreferen // and b. this fragment is resumed for the first time. If both are true, // we should show the timer view instead of setup view. goToSetUpView = false; // Show the first timer because that's the newly created one highlightPageIndicator(0); mViewPager.setCurrentItem(0); // Find the id of the timer to scroll to. Timers are loaded from SharedPrefs using a // HashSet as an intermediary, so we need to find the position in this specific // Adapter instance instead of just passing the position through the intent. final int timerPosition = ((TimerFragmentAdapter) mViewPager.getAdapter()) .getTimerPosition(newIntent.getIntExtra(Timers.SCROLL_TO_TIMER_ID, 0)); mViewPager.setCurrentItem(timerPosition); // Reset the extra to false to ensure when next time the fragment resume, // we no longer care if it's from api call or not. Loading src/com/android/deskclock/timer/TimerFragmentAdapter.java +12 −0 Original line number Diff line number Diff line Loading @@ -94,4 +94,16 @@ public class TimerFragmentAdapter extends FragmentStatePagerAdapter2 { notifyDataSetChanged(); return; } // Return position of the timer with the given timerId. If the timer is not in the list, // return 0 so we get the position of the newest timer. public int getTimerPosition(int id) { for (int i = 0; i < mTimerList.size(); i++) { TimerObj timer = mTimerList.get(i); if (timer.mTimerId == id) { return i; } } return 0; } } src/com/android/deskclock/timer/Timers.java +1 −0 Original line number Diff line number Diff line Loading @@ -44,6 +44,7 @@ public class Timers { public static final String NOTIF_TIMES_UP_SHOW = "notif_times_up_show"; public static final String NOTIF_TIMES_UP_CANCEL = "notif_times_up_cancel"; public static final String FIRST_LAUNCH_FROM_API_CALL = "first_launch_from_api_call"; public static final String SCROLL_TO_TIMER_ID = "scroll_to_timer_id"; public static final String TIMESUP_MODE = "times_up"; Loading Loading
src/com/android/deskclock/HandleApiCalls.java +2 −1 Original line number Diff line number Diff line Loading @@ -382,7 +382,8 @@ public class HandleApiCalls extends Activity { } else { startActivity(new Intent(this, DeskClock.class) .putExtra(DeskClock.SELECT_TAB_INTENT_EXTRA, DeskClock.TIMER_TAB_INDEX) .putExtra(Timers.FIRST_LAUNCH_FROM_API_CALL, true)); .putExtra(Timers.FIRST_LAUNCH_FROM_API_CALL, true) .putExtra(Timers.SCROLL_TO_TIMER_ID, timer.mTimerId)); } Voice.notifySuccess(this, getString(R.string.timer_created)); LogUtils.i("HandleApiCalls timer created: %s", timer); Loading
src/com/android/deskclock/timer/TimerFragment.java +6 −2 Original line number Diff line number Diff line Loading @@ -228,9 +228,13 @@ public class TimerFragment extends DeskClockFragment implements OnSharedPreferen // and b. this fragment is resumed for the first time. If both are true, // we should show the timer view instead of setup view. goToSetUpView = false; // Show the first timer because that's the newly created one highlightPageIndicator(0); mViewPager.setCurrentItem(0); // Find the id of the timer to scroll to. Timers are loaded from SharedPrefs using a // HashSet as an intermediary, so we need to find the position in this specific // Adapter instance instead of just passing the position through the intent. final int timerPosition = ((TimerFragmentAdapter) mViewPager.getAdapter()) .getTimerPosition(newIntent.getIntExtra(Timers.SCROLL_TO_TIMER_ID, 0)); mViewPager.setCurrentItem(timerPosition); // Reset the extra to false to ensure when next time the fragment resume, // we no longer care if it's from api call or not. Loading
src/com/android/deskclock/timer/TimerFragmentAdapter.java +12 −0 Original line number Diff line number Diff line Loading @@ -94,4 +94,16 @@ public class TimerFragmentAdapter extends FragmentStatePagerAdapter2 { notifyDataSetChanged(); return; } // Return position of the timer with the given timerId. If the timer is not in the list, // return 0 so we get the position of the newest timer. public int getTimerPosition(int id) { for (int i = 0; i < mTimerList.size(); i++) { TimerObj timer = mTimerList.get(i); if (timer.mTimerId == id) { return i; } } return 0; } }
src/com/android/deskclock/timer/Timers.java +1 −0 Original line number Diff line number Diff line Loading @@ -44,6 +44,7 @@ public class Timers { public static final String NOTIF_TIMES_UP_SHOW = "notif_times_up_show"; public static final String NOTIF_TIMES_UP_CANCEL = "notif_times_up_cancel"; public static final String FIRST_LAUNCH_FROM_API_CALL = "first_launch_from_api_call"; public static final String SCROLL_TO_TIMER_ID = "scroll_to_timer_id"; public static final String TIMESUP_MODE = "times_up"; Loading