summaryrefslogtreecommitdiffstats
path: root/samples/SupportLeanbackDemos/src/com/example/android/leanback/GuidedStepActivity.java
diff options
context:
space:
mode:
authorDake Gu <dake@google.com>2015-09-22 15:32:48 -0700
committerDake Gu <dake@google.com>2015-09-22 15:32:48 -0700
commit9e5a6a8fcbc9b5f6266dc757c97bce2bc6c5a721 (patch)
tree2028192defb86ed1195e8d6724aa187896fe71a1 /samples/SupportLeanbackDemos/src/com/example/android/leanback/GuidedStepActivity.java
parent56b56d0f5a896bbbb6d98952885a0b5b8184c1d6 (diff)
downloadandroid_development-9e5a6a8fcbc9b5f6266dc757c97bce2bc6c5a721.tar.gz
android_development-9e5a6a8fcbc9b5f6266dc757c97bce2bc6c5a721.tar.bz2
android_development-9e5a6a8fcbc9b5f6266dc757c97bce2bc6c5a721.zip
Revert "Revert "Add example of vertical grid transition and GuidedStepFragment""
This reverts commit c1e0465a059a8636c257f4a90149d48c67cb0cbf.
Diffstat (limited to 'samples/SupportLeanbackDemos/src/com/example/android/leanback/GuidedStepActivity.java')
-rw-r--r--samples/SupportLeanbackDemos/src/com/example/android/leanback/GuidedStepActivity.java34
1 files changed, 19 insertions, 15 deletions
diff --git a/samples/SupportLeanbackDemos/src/com/example/android/leanback/GuidedStepActivity.java b/samples/SupportLeanbackDemos/src/com/example/android/leanback/GuidedStepActivity.java
index 1c1928283..f189a05c5 100644
--- a/samples/SupportLeanbackDemos/src/com/example/android/leanback/GuidedStepActivity.java
+++ b/samples/SupportLeanbackDemos/src/com/example/android/leanback/GuidedStepActivity.java
@@ -58,12 +58,7 @@ public class GuidedStepActivity extends Activity {
protected void onCreate(Bundle savedInstanceState) {
Log.v(TAG, "onCreate");
super.onCreate(savedInstanceState);
- GuidedStepFragment.add(getFragmentManager(), new FirstStepFragment());
- getWindow().getDecorView().getViewTreeObserver().addOnGlobalLayoutListener(new OnGlobalLayoutListener() {
- @Override public void onGlobalLayout() {
- //Log.v(TAG, "onGlobalLayout", new Exception());
- }
- });
+ GuidedStepFragment.addAsRoot(this, new FirstStepFragment(), android.R.id.content);
}
@Override
@@ -139,14 +134,14 @@ public class GuidedStepActivity extends Activity {
public void onGuidedActionClicked(GuidedAction action) {
FragmentManager fm = getFragmentManager();
if (action.getId() == CONTINUE) {
- GuidedStepFragment.add(fm, new SecondStepFragment());
+ GuidedStepFragment.add(fm, new SecondStepFragment(), android.R.id.content);
} else {
getActivity().finish();
}
}
}
- private static class SecondStepFragment extends GuidedStepFragment {
+ public static class SecondStepFragment extends GuidedStepFragment {
@Override
public Guidance onCreateGuidance(Bundle savedInstanceState) {
@@ -173,7 +168,7 @@ public class GuidedStepActivity extends Activity {
}
- private static class ThirdStepFragment extends GuidedStepFragment {
+ public static class ThirdStepFragment extends GuidedStepFragment {
private int mSelectedOption = DEFAULT_OPTION;
@@ -221,7 +216,11 @@ public class GuidedStepActivity extends Activity {
public void onGuidedActionClicked(GuidedAction action) {
if (action.getId() == CONTINUE) {
FragmentManager fm = getFragmentManager();
- GuidedStepFragment.add(fm, new FourthStepFragment(mSelectedOption));
+ FourthStepFragment f = new FourthStepFragment();
+ Bundle arguments = new Bundle();
+ arguments.putInt(FourthStepFragment.EXTRA_OPTION, mSelectedOption);
+ f.setArguments(arguments);
+ GuidedStepFragment.add(fm, f, android.R.id.content);
} else {
mSelectedOption = getSelectedActionPosition()-1;
}
@@ -229,18 +228,23 @@ public class GuidedStepActivity extends Activity {
}
- private static class FourthStepFragment extends GuidedStepFragment {
- private final int mOption;
+ public static class FourthStepFragment extends GuidedStepFragment {
+ public static final String EXTRA_OPTION = "extra_option";
+
+ public FourthStepFragment() {
+ }
- public FourthStepFragment(int option) {
- mOption = option;
+ public int getOption() {
+ Bundle b = getArguments();
+ if (b == null) return 0;
+ return b.getInt(EXTRA_OPTION, 0);
}
@Override
public Guidance onCreateGuidance(Bundle savedInstanceState) {
String title = getString(R.string.guidedstep_fourth_title);
String breadcrumb = getString(R.string.guidedstep_fourth_breadcrumb);
- String description = "You chose: " + OPTION_NAMES[mOption];
+ String description = "You chose: " + OPTION_NAMES[getOption()];
Drawable icon = getActivity().getDrawable(R.drawable.ic_main_icon);
return new Guidance(title, description, breadcrumb, icon);
}