Esempio n. 1
0
  @Override
  @SuppressWarnings("unchecked")
  public boolean onContextItemSelected(MenuItem item) {
    AdapterView.AdapterContextMenuInfo info;
    try {
      info = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo();
    } catch (ClassCastException e) {
      Log.e(THIS_FILE, "bad menuInfo", e);
      return false;
    }

    HashMap<String, Object> codec = null;
    codec = (HashMap<String, Object>) mAdapter.getItem(info.position);

    if (codec == null) {
      // If for some reason the requested item isn't available, do nothing
      return false;
    }
    int selId = item.getItemId();
    if (selId == MENU_ITEM_ACTIVATE) {
      boolean isDisabled = ((Short) codec.get(CODEC_PRIORITY) == 0);
      userActivateCodec(codec, isDisabled);
      return true;
    }
    return false;
  }
Esempio n. 2
0
  @Override
  protected void onListItemClick(ListView l, View v, int position, long id) {
    Log.w(THIS_FILE, "Click at index " + position + " id " + id);
    super.onListItemClick(l, v, position, id);

    PrefGroup pref_gp = adapter.getItem(position);
    startActivity(pref_gp.intent);
  }
Esempio n. 3
0
  /** Initialize datas list */
  private void initDatas() {
    if (codecsList == null) {
      codecsList = new ArrayList<Map<String, Object>>();
    } else {
      codecsList.clear();
    }

    bandtype = (String) getArguments().get(BAND_TYPE);
    mediatype = (Integer) getArguments().get(MEDIA_TYPE);

    String[] codecNames;
    if (mediatype == MEDIA_AUDIO) {
      codecNames = prefsWrapper.getCodecList();
    } else {
      codecNames = prefsWrapper.getVideoCodecList();
    }

    int current_prio = 130;
    for (String codecName : codecNames) {
      Log.d(THIS_FILE, "Fill codec " + codecName + " for " + bandtype);
      String[] codecParts = codecName.split("/");
      if (codecParts.length >= 2) {
        HashMap<String, Object> codecInfo = new HashMap<String, Object>();
        codecInfo.put(CODEC_ID, codecName);
        if (mediatype == MEDIA_AUDIO) {
          codecInfo.put(
              CODEC_NAME,
              codecParts[0]
                  + " "
                  + codecParts[1].substring(0, codecParts[1].length() - 3)
                  + " kHz");
        } else if (mediatype == MEDIA_VIDEO) {
          codecInfo.put(CODEC_NAME, codecParts[0]);
        }
        codecInfo.put(
            CODEC_PRIORITY,
            prefsWrapper.getCodecPriority(codecName, bandtype, Integer.toString(current_prio)));
        codecsList.add(codecInfo);
        current_prio--;
        Log.d(THIS_FILE, "Found priority is " + codecInfo.get(CODEC_PRIORITY));
      }
    }

    Collections.sort(codecsList, codecsComparator);
  }
Esempio n. 4
0
  @Override
  @SuppressWarnings("unchecked")
  public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
    AdapterView.AdapterContextMenuInfo info;
    try {
      info = (AdapterView.AdapterContextMenuInfo) menuInfo;
    } catch (ClassCastException e) {
      Log.e(THIS_FILE, "bad menuInfo", e);
      return;
    }

    HashMap<String, Object> codec = (HashMap<String, Object>) mAdapter.getItem(info.position);
    if (codec == null) {
      // If for some reason the requested item isn't available, do nothing
      return;
    }

    boolean isDisabled = ((Short) codec.get(CODEC_PRIORITY) == 0);
    menu.add(0, MENU_ITEM_ACTIVATE, 0, isDisabled ? R.string.activate : R.string.deactivate);
  }