@Override
 public void onGuidedActionClicked(GuidedAction action) {
   super.onGuidedActionClicked(action);
   int currentPos = getSelectedActionPosition();
   mPrefs.get(currentPos).onClick();
   setSelectedActionPosition(currentPos);
 }
  private void updateAction(int position) {
    GuidedAction action = mActions.get(position);
    action.setLabel2(mPrefs.get(position).getSubtitle());
    mActions.set(position, action);

    super.onCreateActions(mActions, null);
  }
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    getWindow().setBackgroundDrawable(new ColorDrawable(Color.parseColor("#21272A")));

    GuidedStepFragment fragment = new DialogExampleFragment();
    GuidedStepFragment.addAsRoot(this, fragment, android.R.id.content);
  }
 @Override
 public void onActivityCreated(Bundle savedInstanceState) {
   super.onActivityCreated(savedInstanceState);
   PopcornUpdater.getInstance(getActivity())
       .setListener(
           new PopcornUpdater.Listener() {
             @Override
             public void updateAvailable(String filePath) {
               PTVUpdateActivity.startActivity(getActivity());
             }
           });
 }
  @Override
  public void onCreateActions(@NonNull List<GuidedAction> actions, Bundle savedInstanceState) {

    int index = 0;
    mPrefs = PreferencesHandler.ItemsGenerator.generate(getActivity(), this, true);

    for (PrefItem item : mPrefs) {
      actions.add(generateAction(index, item));
      index++;
    }

    mActions = actions;

    super.onCreateActions(actions, savedInstanceState);
  }
 @Override
 public void onViewCreated(View view, Bundle savedInstanceState) {
   super.onViewCreated(view, savedInstanceState);
   setSelectedActionPosition(0);
 }
  @Override
  public void openListSelection(
      String title,
      String[] items,
      SelectionMode mode,
      Object currentValue,
      final int lowLimit,
      int highLimit,
      final OnSelectionListener onClickListener) {
    PTVPreferencesListFragment fragment;

    switch (mode) {
      case SIMPLE_CHOICE:
      case ADVANCED_CHOICE:
        fragment =
            PTVPreferencesListFragment.newInstance(
                title,
                items,
                (int) currentValue,
                new PTVPreferencesListFragment.SelectionListener() {
                  @Override
                  public void onSelect(int position) {
                    onClickListener.onSelection(position, null);
                    updateAction(getSelectedActionPosition());
                  }
                });
        GuidedStepFragment.add(getFragmentManager(), fragment);
        break;
      case NUMBER:
        final String[] array = new String[highLimit - lowLimit + 1];
        for (int i = 0; i <= highLimit - lowLimit; i++) {
          array[i] = Integer.toString(i + lowLimit);
        }

        fragment =
            PTVPreferencesListFragment.newInstance(
                title,
                array,
                ((int) currentValue - lowLimit),
                new PTVPreferencesListFragment.SelectionListener() {
                  @Override
                  public void onSelect(int position) {
                    onClickListener.onSelection(0, position + lowLimit);
                    updateAction(getSelectedActionPosition());
                  }
                });
        GuidedStepFragment.add(getFragmentManager(), fragment);
        break;
      case COLOR:
        String[] colors = getResources().getStringArray(R.array.subtitle_colors);
        final Integer[] colorCodes =
            new Integer[] {
              Color.WHITE,
              Color.BLACK,
              Color.YELLOW,
              Color.RED,
              Color.BLUE,
              Color.MAGENTA,
              Color.GREEN,
              Color.DKGRAY,
              Color.LTGRAY
            };
        fragment =
            PTVPreferencesListFragment.newInstance(
                title,
                colors,
                Arrays.asList(colorCodes).indexOf(currentValue),
                new PTVPreferencesListFragment.SelectionListener() {
                  @Override
                  public void onSelect(int position) {
                    onClickListener.onSelection(position, colorCodes[position]);
                    updateAction(getSelectedActionPosition());
                  }
                });
        GuidedStepFragment.add(getFragmentManager(), fragment);
        break;

      case DIRECTORY:
      default:
        // Nothing
        break;
    }
  }