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 onClickSubMenuItem(int id) {
    final Settings settings = Settings.instance();
    if (mOpenedMenuId == R.id.resolution_menu) {
      settings.setChoosedRes(id);
    } else if (mOpenedMenuId == R.id.bitrate_menu) {
      settings.setChoosedBitrate(id);
    } else if (mOpenedMenuId == R.id.rotate_menu) {
      settings.setRotate(id == 0);
    }
    mOpenedMenuId = -1;
    // close menu
    mSubMenuContrainer.setVisibility(View.INVISIBLE);
    mSubMenuContrainer.removeAllViews();

    updateSettings();
  }
 private void start_rec() {
   // Send init request
   Intent intent = new Intent(getActivity(), RecorderService.class);
   String fileName = StorageHelper.sStorageHelper.generateFileName();
   LogUtil.i(MODULE_TAG, "start_rec fileName:" + fileName);
   intent.setAction(Constants.Action.START_REC);
   intent.putExtra(Constants.Key.FILE_NAME, fileName);
   intent.putExtra(Constants.Key.TIME_LIMIT, 24 * 60 * 60);
   String res = Settings.instance().getChosenRes();
   String[] values = res.split("x");
   intent.putExtra(Constants.Key.WIDTH, Integer.valueOf(values[0]));
   intent.putExtra(Constants.Key.HEIGHT, Integer.valueOf(values[1]));
   intent.putExtra(Constants.Key.BITRATE, Settings.instance().getChoosedBitrate());
   intent.putExtra(Constants.Key.ROTATE, Settings.instance().isRotate());
   getActivity().startService(intent);
 }
 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);
     }
   }
 }