android.support.v17.leanback.widget.GuidedAction Java Examples

The following examples show how to use android.support.v17.leanback.widget.GuidedAction. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: WizardExample1stStepFragment.java    From leanback-showcase with Apache License 2.0 6 votes vote down vote up
@Override
public void onCreateActions(@NonNull List<GuidedAction> actions, Bundle savedInstanceState) {
    GuidedAction action = new GuidedAction.Builder(getActivity())
            .id(ACTION_ID_BUY_HD)
            .title(R.string.wizard_example_rent_hd)
            .editable(false)
            .description(mMovie.getPriceHd() + " " +
                    getString(R.string.wizard_example_watch_hd))
            .build();
    actions.add(action);
    action = new GuidedAction.Builder(getActivity())
            .id(ACTION_ID_BUY_SD)
            .title(getString(R.string.wizard_example_rent_sd))
            .editable(false)
            .description(mMovie.getPriceSd() + " " +
                    getString(R.string.wizard_example_watch_sd))
            .build();
    actions.add(action);
}
 
Example #2
Source File: SettingsActivity.java    From alltv with MIT License 6 votes vote down vote up
@Override
public boolean onSubGuidedActionClicked(GuidedAction action) {

    if (action.getId() == GuidedId.OksusuAuto.ordinal()) {
        mSettings.mOksusuSettings.mQualityType = SettingsData.OksusuQualityType.AUTO;
    } else if (action.getId() == GuidedId.OksusuFullHd.ordinal()) {
        mSettings.mOksusuSettings.mQualityType = SettingsData.OksusuQualityType.FullHD;
    } else if (action.getId() == GuidedId.OksusuHd.ordinal()) {
        mSettings.mOksusuSettings.mQualityType = SettingsData.OksusuQualityType.HD;
    } else if (action.getId() == GuidedId.OksusuSd.ordinal()) {
        mSettings.mOksusuSettings.mQualityType = SettingsData.OksusuQualityType.SD;
    }

    Utils.showToast(getContext(), mSettings.mOksusuSettings.mQualityType.toString() + " " + getStringById(R.string.select));

    return true;
}
 
Example #3
Source File: SettingsActivity.java    From alltv with MIT License 6 votes vote down vote up
@Override
public boolean onSubGuidedActionClicked(GuidedAction action) {

    if (action.getId() == GuidedId.TvingMD.ordinal()) {
        mSettings.mTvingSettings.mQualityType = SettingsData.TvingQualityType.MD;
    } else if (action.getId() == GuidedId.TvingSD.ordinal()) {
        mSettings.mTvingSettings.mQualityType = SettingsData.TvingQualityType.SD;
    } else if (action.getId() == GuidedId.TvingHD.ordinal()) {
        mSettings.mTvingSettings.mQualityType = SettingsData.TvingQualityType.HD;
    } else if (action.getId() == GuidedId.TvingFHD.ordinal()) {
        mSettings.mTvingSettings.mQualityType = SettingsData.TvingQualityType.FHD;
    }

    Utils.showToast(getContext(), mSettings.mTvingSettings.mQualityType.toString() + " " + getStringById(R.string.select));

    return true;
}
 
Example #4
Source File: WizardExample2ndStepFragment.java    From leanback-showcase with Apache License 2.0 6 votes vote down vote up
@Override
public void onCreateActions(@NonNull List<GuidedAction> actions, Bundle savedInstanceState) {
    boolean rentHighDefinition = getArguments().getBoolean(ARG_HD);

    GuidedAction action = new GuidedAction.Builder(getActivity())
            .id(ACTION_ID_CONFIRM)
            .title(R.string.wizard_example_rent)
            .description(rentHighDefinition ? mMovie.getPriceHd() : mMovie.getPriceSd())
            .editable(false)
            .build();
    action.setEnabled(false);
    actions.add(action);
    List<GuidedAction> subActions = new ArrayList();
    action = new GuidedAction.Builder(getActivity())
            .id(ACTION_ID_PAYMENT_METHOD)
            .title(R.string.wizard_example_payment_method)
            .editTitle("")
            .description(R.string.wizard_example_input_credit)
            .subActions(subActions)
            .build();
    actions.add(action);
}
 
Example #5
Source File: WizardExample2ndStepFragment.java    From leanback-showcase with Apache License 2.0 6 votes vote down vote up
@Override
public boolean onSubGuidedActionClicked(GuidedAction action) {

    if (action.isChecked()) {
        String payment = action.getTitle().toString();
        if ( (sSelectedCard = sCards.indexOf(payment)) != -1 ) {
            findActionById(ACTION_ID_PAYMENT_METHOD).setDescription(payment);
            notifyActionChanged(findActionPositionById(ACTION_ID_PAYMENT_METHOD));
            findActionById(ACTION_ID_CONFIRM).setEnabled(true);
            notifyActionChanged(findActionPositionById(ACTION_ID_CONFIRM));
        }
        return true;
    } else {
        FragmentManager fm = getFragmentManager();
        GuidedStepFragment fragment = new WizardNewPaymentStepFragment();
        fragment.setArguments(getArguments());
        add(fm, fragment);
        return false;
    }
}
 
Example #6
Source File: SettingsActivity.java    From alltv with MIT License 6 votes vote down vote up
@Override
public boolean onSubGuidedActionClicked(GuidedAction action) {

    if (action.getId() == GuidedId.PooqMobile.ordinal()) {
        mSettings.mPooqSettings.mQualityType = SettingsData.PooqQualityType.Mobile;
    } else if (action.getId() == GuidedId.PooqSD.ordinal()) {
        mSettings.mPooqSettings.mQualityType = SettingsData.PooqQualityType.SD;
    } else if (action.getId() == GuidedId.PooqHD.ordinal()) {
        mSettings.mPooqSettings.mQualityType = SettingsData.PooqQualityType.HD;
    } else if (action.getId() == GuidedId.PooqFHD.ordinal()) {
        mSettings.mPooqSettings.mQualityType = SettingsData.PooqQualityType.FHD;
    }

    Utils.showToast(getContext(), mSettings.mPooqSettings.mQualityType.toString() + " " + getStringById(R.string.select));

    return true;
}
 
Example #7
Source File: PublishChannelFragment.java    From leanback-showcase with Apache License 2.0 6 votes vote down vote up
@Override
public void onCreateActions(@NonNull List<GuidedAction> actions, Bundle savedInstanceState) {
    ChannelContents.initializePlaylists(this.getActivity());

    mChannelContents = ChannelContents.sChannelContents;

    /**
     * The id of check box was set to the index of current channel
     */
    for (int i = 0; i < mChannelContents.size(); i++) {
        addCheckedAction(actions,
                OPTION_DRAWABLE,
                getActivity(),
                mChannelContents.get(i).getName(),
                mChannelContents.get(i).getDescription(),
                i,
                mChannelContents.get(i).isChannelPublished());
    }
}
 
Example #8
Source File: SettingsFragment.java    From BuildingForAndroidTV with MIT License 6 votes vote down vote up
@Override
public void onCreateActions(@NonNull List<GuidedAction> actions, Bundle savedInstanceState) {
    actions.add(new GuidedAction.Builder()
            .id(R.id.settings_category_id)
            .infoOnly(true)
            .title(getString(R.string.settings_category))
            .build());

    actions.add(new GuidedAction.Builder()
            .id(R.id.settings_toggle_nav_id)
            .title(getString(R.string.settings_toggle_nav_title))
            .checked(!MainActivity.isUsingStandardBrowseFragment())
            .description(getString(R.string.settings_toggle_nav_desc))
            .build());

    super.onCreateActions(actions, savedInstanceState);
}
 
Example #9
Source File: PublishChannelFragment.java    From leanback-showcase with Apache License 2.0 6 votes vote down vote up
/**
 * Helper function to add checked Action to this fragment
 * <p>
 * In this fragment, the checked action is customized as checkbox
 */
private static void addCheckedAction(List<GuidedAction> actions,
                                     int iconResId,
                                     Context context,
                                     String title,
                                     String desc,
                                     int id,
                                     boolean isActionChecked) {
    GuidedAction guidedAction = new GuidedAction.Builder(context)
            .title(title)
            .description(desc)
            .checkSetId(GuidedAction.CHECKBOX_CHECK_SET_ID)
            .icon(context.getResources().getDrawable(iconResId))
            .build();
    guidedAction.setId(id);
    /**
     * Set checkbox status to false initially
     */
    guidedAction.setChecked(isActionChecked);
    actions.add(guidedAction);
}
 
Example #10
Source File: SettingsActivity.java    From alltv with MIT License 6 votes vote down vote up
@Override
public void onCreateActions(@NonNull List<GuidedAction> actions,
                            Bundle savedInstanceState) {

    addAction(getContext(), actions, GuidedId.Pooq.ordinal(),
            getStringById(R.string.pooqsettings),
            getStringById(R.string.setdesc));

    addAction(getContext(), actions, GuidedId.Tving.ordinal(),
            getStringById(R.string.tvingsettings),
            getStringById(R.string.setdesc));

    addAction(getContext(), actions, GuidedId.Oksusu.ordinal(),
            getStringById(R.string.oksususettings),
            getStringById(R.string.setdesc));

}
 
Example #11
Source File: GuidedStepActivity.java    From BuildingForAndroidTV with MIT License 6 votes vote down vote up
@Override
public void onCreateActions(List<GuidedAction> actions, Bundle savedInstanceState) {
    String desc = getResources().getString(R.string.guidedstep_action_description);
    actions.add(new GuidedAction.Builder()
            .title(getResources().getString(R.string.guidedstep_action_title))
            .description(desc)
            .multilineDescription(true)
            .infoOnly(true)
            .enabled(false)
            .build());
    for (int i = 0; i < OPTION_NAMES.length; i++) {
        addCheckedAction(actions,
                OPTION_DRAWABLES[i],
                getActivity(),
                OPTION_NAMES[i],
                OPTION_DESCRIPTIONS[i],
                OPTION_CHECKED[i]);
    }
}
 
Example #12
Source File: WizardNewPaymentStepFragment.java    From leanback-showcase with Apache License 2.0 6 votes vote down vote up
@Override
public void onCreateActions(List<GuidedAction> actions, Bundle savedInstanceState) {
    actions.add(new GuidedAction.Builder(getActivity())
                    .id(ACTION_ID_CARD_NUMBER)
                    .title(R.string.wizard_example_input_card)
                    .editTitle("")
                    .description(R.string.wizard_example_input_card)
                    .editDescription("Card number")
                    .editable(true)
                    .build()
    );

    actions.add(new GuidedDatePickerAction.Builder(getActivity())
                    .id(ACTION_ID_PAYMENT_EXP)
                    .title(R.string.wizard_example_expiration_date)
                    .datePickerFormat("MY")
                    .build()
    );
}
 
Example #13
Source File: ChannelSetupStepFragment.java    From androidtv-sample-inputs with Apache License 2.0 5 votes vote down vote up
@Override
public void onScanFinished() {
    List<GuidedAction> actions = new ArrayList<>(1);
    actions.add(
            new GuidedAction.Builder(getContext())
                    .id(GuidedAction.ACTION_ID_FINISH)
                    .title(R.string.lb_guidedaction_finish_title)
                    .build());
    setActions(actions);
    setupPeriodicSync();
}
 
Example #14
Source File: PublishChannelFragment.java    From leanback-showcase with Apache License 2.0 5 votes vote down vote up
/**
 * Helper function to add non-checked Action to this fragment
 */
private static void addAction(List<GuidedAction> actions, Context context, long id,
                              String title, String desc) {
    actions.add(new GuidedAction.Builder(context)
            .id(id)
            .title(title)
            .description(desc)
            .build());
}
 
Example #15
Source File: WizardNewPaymentStepFragment.java    From leanback-showcase with Apache License 2.0 5 votes vote down vote up
@Override
public void onGuidedActionClicked(GuidedAction action) {
    if (action.getId() == GuidedAction.ACTION_ID_OK) {
        CharSequence cardNumber = findActionById(ACTION_ID_CARD_NUMBER).getDescription();
        WizardExample2ndStepFragment.sSelectedCard = WizardExample2ndStepFragment.sCards.size();
        WizardExample2ndStepFragment.sCards.add(cardNumber.toString());
        popBackStackToGuidedStepFragment(WizardNewPaymentStepFragment.class,
                FragmentManager.POP_BACK_STACK_INCLUSIVE);
    }
}
 
Example #16
Source File: PublishChannelFragment.java    From leanback-showcase with Apache License 2.0 5 votes vote down vote up
@Override
public void onGuidedActionClicked(GuidedAction action) {
    /**
     * Find channel through action ID
     */
    int currentId = (int) action.getId();
    mSelectedChannelContents = mChannelContents.get(currentId);

    /**
     * When the action cannot select valid mediaItem, just return from from this function
     */
    if (mSelectedChannelContents == null) {
        return;
    }

    /**
     * Add/ Remove channel from Home Screen using Async task
     * to make sure the UI thread will not be blocked
     */
    if (action.isChecked()) {
        /**
         * Create and execute the async task to add channel on home screen
         * Always update publish status through LoadAddedChannels task
         */
        new ChannelContents.CreateChannelInMainScreen(getActivity()).execute(mSelectedChannelContents);
    } else {
        Toast.makeText(this.getActivity(),
                getResources().getString(R.string.channel_removed_from_home_screen),
                Toast.LENGTH_SHORT).show();
        /**
         * Create and execute the async task to remove channel on home screen
         * Always update publish status through LoadAddedChannels task
         */
        new ChannelContents.RemoveChannelInMainScreen(getActivity()).execute(mSelectedChannelContents);
    }
}
 
Example #17
Source File: WizardNewPaymentStepFragment.java    From leanback-showcase with Apache License 2.0 5 votes vote down vote up
@Override
public void onCreateButtonActions(@NonNull List<GuidedAction> actions,
                                  Bundle savedInstanceState) {
    actions.add(new GuidedAction.Builder(getActivity())
                    .clickAction(GuidedAction.ACTION_ID_OK)
                    .build()
    );
    actions.get(actions.size() - 1).setEnabled(false);
}
 
Example #18
Source File: FirstStepFragment.java    From androidtv-sample-inputs with Apache License 2.0 5 votes vote down vote up
@Override
public void onCreateActions(@NonNull List<GuidedAction> actions, Bundle savedInstanceState) {
    actions.add(
            new GuidedAction.Builder(getContext())
                    .id(GuidedAction.ACTION_ID_NEXT)
                    .title(R.string.rich_setup_add_channel)
                    .hasNext(true)
                    .build());
    actions.add(
            new GuidedAction.Builder(getContext())
                    .id(GuidedAction.ACTION_ID_CANCEL)
                    .title(R.string.rich_setup_cancel)
                    .build());
    //TODO add about screen
}
 
Example #19
Source File: FirstStepFragment.java    From androidtv-sample-inputs with Apache License 2.0 5 votes vote down vote up
@Override
public void onGuidedActionClicked(GuidedAction action) {
    if (action.getId() == GuidedAction.ACTION_ID_NEXT) {
        GuidedStepFragment.add(getFragmentManager(), new RichSetupFragment());
    } else if (action.getId() == GuidedAction.ACTION_ID_CANCEL) {
        getActivity().setResult(Activity.RESULT_CANCELED);
        getActivity().finishAfterTransition();
    }
}
 
Example #20
Source File: ChannelSetupStepFragment.java    From androidtv-sample-inputs with Apache License 2.0 5 votes vote down vote up
@Override
public void onCreateActions(List<GuidedAction> actions, Bundle savedInstanceState) {
    actions.add(
            new GuidedAction.Builder(getContext())
                    .id(GuidedAction.ACTION_ID_CANCEL)
                    .title(R.string.tif_channel_setup_cancel)
                    .build());
}
 
Example #21
Source File: ChannelSetupStepFragment.java    From androidtv-sample-inputs with Apache License 2.0 5 votes vote down vote up
@Override
public void onGuidedActionClicked(GuidedAction action) {
    if (action.getId() == GuidedAction.ACTION_ID_FINISH) {
        getActivity().setResult(Activity.RESULT_OK);
        finishGuidedStepFragments();
    } else if (action.getId() == GuidedAction.ACTION_ID_CANCEL) {
        getActivity().setResult(Activity.RESULT_CANCELED);
        getActivity().finishAfterTransition();

    } else {
        Log.w(TAG, "Unexpected action " + action);
    }
}
 
Example #22
Source File: WizardExample3rdStepFragment.java    From leanback-showcase with Apache License 2.0 5 votes vote down vote up
@Override
public void onCreateActions(@NonNull List<GuidedAction> actions, Bundle savedInstanceState) {
    GuidedAction action = new GuidedAction.Builder(getActivity())
            .id(ACTION_ID_PROCESSING)
            .title(R.string.wizard_example_processing)
            .infoOnly(true)
            .build();
    actions.add(action);
}
 
Example #23
Source File: ChannelSetupStepSupportFragment.java    From androidtv-sample-inputs with Apache License 2.0 5 votes vote down vote up
@Override
public void onCreateActions(List<GuidedAction> actions, Bundle savedInstanceState) {
    actions.add(
            new GuidedAction.Builder(getContext())
                    .id(GuidedAction.ACTION_ID_CANCEL)
                    .title(R.string.tif_channel_setup_cancel)
                    .build());
}
 
Example #24
Source File: ChannelSetupStepSupportFragment.java    From androidtv-sample-inputs with Apache License 2.0 5 votes vote down vote up
@Override
public void onGuidedActionClicked(GuidedAction action) {
    if (action.getId() == GuidedAction.ACTION_ID_FINISH) {
        getActivity().setResult(Activity.RESULT_OK);
        finishGuidedStepSupportFragments();
    } else if (action.getId() == GuidedAction.ACTION_ID_CANCEL) {
        getActivity().setResult(Activity.RESULT_CANCELED);
        getActivity().finishAfterTransition();

    } else {
        Log.w(TAG, "Unexpected action " + action);
    }
}
 
Example #25
Source File: ChannelSetupStepSupportFragment.java    From androidtv-sample-inputs with Apache License 2.0 5 votes vote down vote up
@Override
public void onScanFinished() {
    List<GuidedAction> actions = new ArrayList<>(1);
    actions.add(
            new GuidedAction.Builder(getContext())
                    .id(GuidedAction.ACTION_ID_FINISH)
                    .title(R.string.lb_guidedaction_finish_title)
                    .build());
    setActions(actions);
    setupPeriodicSync();
}
 
Example #26
Source File: ChannelSetupStepFragmentTest.java    From androidtv-sample-inputs with Apache License 2.0 5 votes vote down vote up
@Test
public void onResume() {
    Assert.assertEquals(
            "progressBar.isIndeterminate()",
            true,
            guidanceStylist.getProgressBar().isIndeterminate());
    Assert.assertEquals(
            "Channel list count", 0, guidanceStylist.getChannelAdapter().getCount());
    List<GuidedAction> actions = fragment.getActions();
    Assert.assertEquals("action count", 1, actions.size());
    Assert.assertEquals("action id", GuidedAction.ACTION_ID_CANCEL, actions.get(0).getId());
}
 
Example #27
Source File: ChannelSetupStepFragmentTest.java    From androidtv-sample-inputs with Apache License 2.0 5 votes vote down vote up
@Test
public void onScanFinished() {
    fragment.onScanFinished();
    List<GuidedAction> actions = fragment.getActions();
    Assert.assertEquals("action count", 1, actions.size());
    Assert.assertEquals("action id", GuidedAction.ACTION_ID_FINISH, actions.get(0).getId());
}
 
Example #28
Source File: GuidedStepActivity.java    From BuildingForAndroidTV with MIT License 5 votes vote down vote up
private static void addAction(List<GuidedAction> actions, long id, String title, String desc) {
    actions.add(new GuidedAction.Builder()
            .id(id)
            .title(title)
            .description(desc)
            .build());
}
 
Example #29
Source File: GuidedStepActivity.java    From BuildingForAndroidTV with MIT License 5 votes vote down vote up
private static void addCheckedAction(List<GuidedAction> actions, int iconResId, Context context,
        String title, String desc, boolean checked) {
    GuidedAction guidedAction = new GuidedAction.Builder()
            .title(title)
            .description(desc)
            .checkSetId(OPTION_CHECK_SET_ID)
            .iconResourceId(iconResId, context)
            .build();
    guidedAction.setChecked(checked);
    actions.add(guidedAction);
}
 
Example #30
Source File: GuidedStepActivity.java    From BuildingForAndroidTV with MIT License 5 votes vote down vote up
@Override
public void onCreateActions(List<GuidedAction> actions, Bundle savedInstanceState) {
    addAction(actions, CONTINUE,
            getResources().getString(R.string.guidedstep_continue),
            getResources().getString(R.string.guidedstep_letsdoit));
    addAction(actions, BACK,
            getResources().getString(R.string.guidedstep_cancel),
            getResources().getString(R.string.guidedstep_nevermind));
}