Java Code Examples for android.support.v7.widget.SwitchCompat#setText()

The following examples show how to use android.support.v7.widget.SwitchCompat#setText() . 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: TvShowEpisodesFragment.java    From Mizuu with Apache License 2.0 6 votes vote down vote up
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    inflater.inflate(R.menu.episodes_overview, menu);

    int padding = MizLib.convertDpToPixels(getActivity(), 16);

    SwitchCompat switchCompat = (SwitchCompat) menu.findItem(R.id.switch_button).getActionView();
    switchCompat.setChecked(mEpisodeLoader != null ? mEpisodeLoader.showAvailableFiles() : false);
    switchCompat.setText(R.string.choiceAvailableFiles);
    switchCompat.setSwitchPadding(padding);
    switchCompat.setPadding(0, 0, padding, 0);

    switchCompat.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            mEpisodeLoader.setShowAvailableFiles(isChecked);
            mEpisodeLoader.load();
            showProgressBar();
        }
    });

    super.onCreateOptionsMenu(menu, inflater);
}
 
Example 2
Source File: ActorMoviesFragment.java    From Mizuu with Apache License 2.0 6 votes vote down vote up
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    inflater.inflate(R.menu.switch_button, menu);

    int padding = MizLib.convertDpToPixels(getActivity(), 16);

    SwitchCompat switchCompat = (SwitchCompat) menu.findItem(R.id.switch_button).getActionView();
    switchCompat.setChecked(mChecked);
    switchCompat.setText(R.string.inLibrary);
    switchCompat.setSwitchPadding(padding);
    switchCompat.setPadding(0, 0, padding, 0);

    switchCompat.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            mChecked = isChecked;
            mAdapter.notifyDataSetChanged();
        }
    });

    super.onCreateOptionsMenu(menu, inflater);
}
 
Example 3
Source File: ActorTvShowsFragment.java    From Mizuu with Apache License 2.0 6 votes vote down vote up
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    inflater.inflate(R.menu.switch_button, menu);

    int padding = MizLib.convertDpToPixels(getActivity(), 16);

    SwitchCompat switchCompat = (SwitchCompat) menu.findItem(R.id.switch_button).getActionView();
    switchCompat.setChecked(mChecked);
    switchCompat.setText(R.string.inLibrary);
    switchCompat.setSwitchPadding(padding);
    switchCompat.setPadding(0, 0, padding, 0);

    switchCompat.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            mChecked = isChecked;
            mAdapter.notifyDataSetChanged();
        }
    });

    super.onCreateOptionsMenu(menu, inflater);
}
 
Example 4
Source File: SpringSettingsBottomDialog.java    From CircularReveal with MIT License 5 votes vote down vote up
public void addSwitch(String label, boolean defaultState,
    final CompoundButton.OnCheckedChangeListener listener) {
  if (switchAdded) {
    return;
  }

  switchAdded = true;

  final SwitchCompat switchView = new SwitchCompat(getContext());
  switchView.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
    @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
      listener.onCheckedChanged(buttonView, isChecked);

      if (springManagerAdded) {
        stiffnessView.setEnabled(isChecked);
        dampingView.setEnabled(isChecked);
      }
    }
  });
  switchView.setChecked(defaultState);
  switchView.setText(label);

  addView(switchView, createMarginLayoutParams(MATCH_PARENT, WRAP_CONTENT, 0, 0, 0, dp(16)));

  if (springManagerAdded) {
    stiffnessView.setEnabled(defaultState);
    dampingView.setEnabled(defaultState);
  }
}
 
Example 5
Source File: ConfigureReceiverDialogPage4TabbedSummaryFragment.java    From PowerSwitch_Android with GNU General Public License v3.0 4 votes vote down vote up
private void updateUiValues() {
    name.setText(currentName);
    roomName.setText(currentRoomName);
    if (currentBrand == null) {
        brand.setText("");
    } else {
        brand.setText(currentBrand.toString());
    }
    model.setText(currentModel);
    channelMaster.setText(String.valueOf(currentMaster));
    channelSlave.setText(String.valueOf(currentSlave));

    String inflaterString = Context.LAYOUT_INFLATER_SERVICE;
    LayoutInflater inflater = (LayoutInflater) getActivity().getSystemService(inflaterString);

    if (currentDips != null) {
        linearLayoutDips.removeAllViews();
        for (DipSwitch dipSwitch : currentDips) {
            @SuppressLint("InflateParams")
            SwitchCompat switchCompat = (SwitchCompat) inflater.inflate(R.layout.default_switch_compat, null, false);
            switchCompat.setText(dipSwitch.getName());
            switchCompat.setChecked(dipSwitch.isChecked());
            switchCompat.setClickable(false);

            linearLayoutDips.addView(switchCompat, new LinearLayout.LayoutParams(LinearLayout.LayoutParams
                    .WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT));
        }
    }

    seed.setText(String.valueOf(currentSeed));

    if (currentUniversalButtons != null) {
        linearLayoutUniversalButtons.removeAllViews();
        for (Button button : currentUniversalButtons) {
            UniversalButton universalButton = (UniversalButton) button;

            LinearLayout linearLayout = new LinearLayout(getActivity());
            AppCompatTextView textView = new AppCompatTextView(getActivity());
            textView.setText("Name: " + universalButton.getName() + "\n"
                    + "Signal: " + universalButton.getSignal());
            linearLayout.addView(textView);

            linearLayoutUniversalButtons.addView(linearLayout, new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT));
        }
    }
}