Exemplo n.º 1
0
  private void setupUIElements() {
    setBadgeDrawable(ContextCompat.getDrawable(getActivity(), R.drawable.banner_shadow));
    setHeadersState(HEADERS_ENABLED);
    setHeadersTransitionOnBackEnabled(true);
    setBrandColor(ContextCompat.getColor(getActivity(), R.color.primary));
    setSearchAffordanceColor(ContextCompat.getColor(getActivity(), R.color.accent));

    setHeaderPresenterSelector(
        new PresenterSelector() {
          @Override
          public Presenter getPresenter(Object o) {
            return new IconHeaderItemPresenter();
          }
        });

    boolean shouldAutoLoop = mPreferencesHelper.getShouldAutoLoop();
    String optionValue =
        shouldAutoLoop
            ? getString(R.string.text_auto_loop_enabled)
            : getString(R.string.text_auto_loop_disabled);

    mAutoLoopOption =
        new Option(getString(R.string.text_auto_loop_title), optionValue, R.drawable.lopp);

    HeaderItem gridHeader =
        new HeaderItem(mRowsAdapter.size(), getString(R.string.header_text_options));
    mOptionsAdapter = new OptionsAdapter(getActivity());
    mOptionsAdapter.addOption(mAutoLoopOption);
    mRowsAdapter.add(new ListRow(gridHeader, mOptionsAdapter));
  }
Exemplo n.º 2
0
 private void updateActions() {
   boolean shouldAutoLoop = mPreferencesHelper.getShouldAutoLoop();
   List<GuidedAction> actions = getActions();
   for (int i = 0; i < actions.size(); i++) {
     GuidedAction action = actions.get(i);
     action.setChecked((action.getId() == ENABLED) == shouldAutoLoop);
   }
 }
Exemplo n.º 3
0
 @Subscribe
 public void onAutoLoopUpdated(BusEvent.AutoLoopUpdated event) {
   boolean isEnabled = mPreferencesHelper.getShouldAutoLoop();
   mAutoLoopOption.value =
       isEnabled
           ? getString(R.string.text_auto_loop_enabled)
           : getString(R.string.text_auto_loop_disabled);
   mOptionsAdapter.updateOption(mAutoLoopOption);
 }
Exemplo n.º 4
0
 @Override
 public void onGuidedActionClicked(GuidedAction action) {
   if (action != null) {
     mPreferencesHelper.putAutoLoop(action.getId() == ENABLED);
     mEventBus.post(new BusEvent.AutoLoopUpdated());
     getActivity().finish();
   } else {
     getFragmentManager().popBackStack();
   }
 }