private void updateSettings() { final Settings settings = Settings.instance(); mChosenBitrate.setText( Formatter.formatShortFileSize(getActivity(), settings.getChoosedBitrate())); mChosenResolution.setText(settings.getChosenRes()); mChosenRotate.setText( settings.isRotate() ? getActivity().getString(R.string.rotate_on) : getActivity().getString(R.string.rotate_off)); }
private void onClickMenuItem(int menuId) { final Settings settings = Settings.instance(); if (mOpenedMenuId == menuId) { mOpenedMenuId = -1; // close menu mSubMenuContrainer.setVisibility(View.INVISIBLE); mSubMenuContrainer.removeAllViews(); } else { mOpenedMenuId = menuId; // open menu here ArrayList<String> values = new ArrayList<String>(); int chosenIndex = 0; if (menuId == R.id.resolution_menu) { values = settings.getAvailResList(); chosenIndex = settings.getChosenResIndex(); } else if (menuId == R.id.bitrate_menu) { int[] bitrates = settings.getBitrates(); for (int bitrate : bitrates) { values.add(Formatter.formatShortFileSize(getActivity(), bitrate)); } chosenIndex = settings.getChosenBitrateIndex(); } else if (menuId == R.id.rotate_menu) { values.add(getActivity().getString(R.string.rotate_on)); values.add(getActivity().getString(R.string.rotate_off)); chosenIndex = settings.isRotate() ? 0 : 1; } if (values != null) { mSubMenuContrainer.removeAllViews(); for (int index = 0; index < values.size(); ++index) { CheckedTextView ctv = mSubMenuItems.get(index); ctv.setText(values.get(index)); ctv.setChecked(chosenIndex == index); mSubMenuContrainer.addView(ctv); } mSubMenuContrainer.setVisibility(View.VISIBLE); } } }