Exemplo 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;
  }
Exemplo n.º 2
0
  @SuppressWarnings("unchecked")
  private String prepareArtForDelivery() {

    List<ArticolCLP> listArticole = new ArrayList<ArticolCLP>();

    String retVal = "";
    try {

      cmdFasonate = true;
      int nrArt = listArtSelClp.size(), ii = 0;

      for (ii = 0; ii < nrArt; ii++) {
        artMap = (HashMap<String, String>) adapterListArtClp.getItem(ii);

        if (!isFasonat(artMap.get("sintetic"))) {
          cmdFasonate = false;
        }

        ArticolCLP articolCLP = new ArticolCLP();
        articolCLP.setCod(artMap.get("codArt"));
        articolCLP.setCantitate(artMap.get("cantArt"));
        articolCLP.setUmBaza(artMap.get("Umb"));
        articolCLP.setDepozit(artMap.get("depozit"));
        articolCLP.setDepart(artMap.get("depart"));
        listArticole.add(articolCLP);

        retVal +=
            artMap.get("codArt")
                + "#"
                + artMap.get("cantArt")
                + "#"
                + artMap.get("Umb")
                + "#"
                + artMap.get("depozit")
                + "@";
      }

      Collections.sort(listArticole, new ClpDepartComparator());
      comandaCLP.setListaArticoleComanda(listArticole);

    } catch (Exception ex) {
      Toast.makeText(getActivity(), ex.toString(), Toast.LENGTH_SHORT).show();
    }

    return retVal;
  }
Exemplo n.º 3
0
 @Override
 public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
   String codecName = (String) buttonView.getTag();
   if (codecName != null) {
     HashMap<String, Object> codec = null;
     for (int i = 0; i < mAdapter.getCount(); i++) {
       @SuppressWarnings("unchecked")
       HashMap<String, Object> tCodec = (HashMap<String, Object>) mAdapter.getItem(i);
       if (codecName.equalsIgnoreCase((String) tCodec.get(CODEC_NAME))) {
         codec = tCodec;
         break;
       }
     }
     if (codec != null) {
       userActivateCodec(codec, isChecked);
     }
   }
 }
Exemplo n.º 4
0
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
      case R.id.trackdetail_menu_save:
        String enteredName = etName.getText().toString().trim();
        if ((enteredName.length() > 0) && (!enteredName.equals(trackNameInDB))) {
          DataHelper.setTrackName(trackId, enteredName, getContentResolver());
        }

        // All done
        finish();
        break;
      case R.id.trackdetail_menu_cancel:
        finish();
        break;
      case R.id.trackdetail_menu_display:
        Intent i;
        boolean useOpenStreetMapBackground =
            PreferenceManager.getDefaultSharedPreferences(this)
                .getBoolean(
                    OSMTracker.Preferences.KEY_UI_DISPLAYTRACK_OSM,
                    OSMTracker.Preferences.VAL_UI_DISPLAYTRACK_OSM);
        if (useOpenStreetMapBackground) {
          i = new Intent(this, DisplayTrackMap.class);
        } else {
          i = new Intent(this, DisplayTrack.class);
        }
        i.putExtra(Schema.COL_TRACK_ID, trackId);
        startActivity(i);
        break;
      case R.id.trackdetail_menu_export:
        new ExportTrackTask(this, trackId).execute();
        // Pick last list item (Exported date) and update it
        SimpleAdapter adapter = ((SimpleAdapter) lv.getAdapter());
        @SuppressWarnings("unchecked")
        Map<String, String> data = (Map<String, String>) adapter.getItem(adapter.getCount() - 1);
        data.put(
            ITEM_VALUE,
            DateFormat.getDateTimeInstance().format(new Date(System.currentTimeMillis())));
        adapter.notifyDataSetChanged();
        break;
    }
    return super.onOptionsItemSelected(item);
  }
Exemplo n.º 5
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);
  }
 public void onListItemClick(ListView parent, View view, int position, long id) {
   Bundle bundle = new Bundle();
   if (searchChooser == 0) {
     Intent intent = new Intent(this, BuildingInfoActivity.class);
     Cursor cursor = (Cursor) listAdapter.getItem(position);
     bundle.putInt("BUILDING_ID", cursor.getInt(cursor.getColumnIndex("_id")));
     intent.putExtras(bundle);
     startActivity(intent);
   } else if (searchChooser == 1) {
     Intent intent = new Intent(this, DepartmentInfoActivity.class);
     Cursor cursor = (Cursor) listAdapter.getItem(position);
     bundle.putInt("DEPARTMENT_ID", cursor.getInt(cursor.getColumnIndex("_id")));
     intent.putExtras(bundle);
     startActivity(intent);
   } else if (searchChooser == -1) {
     Intent intent = new Intent(this, PersonInfoActivity.class);
     HashMap<String, String> personResults = null;
     HashMap<String, String> listResults = null;
     try {
       listResults = (HashMap<String, String>) simpleAdapter.getItem(position);
       personResults = readSingleResultStream(listResults.get("ucinetid")).get(0);
     } catch (InterruptedException e) {
       e.printStackTrace();
     } catch (ExecutionException e) {
       e.printStackTrace();
     }
     // bundle.putSerializable("person", personResults);
     intent.putExtra("person", personResults);
     startActivity(intent);
   } else if (searchChooser == 2) {
     Intent intent = new Intent(this, ServicesInfoActivity.class);
     Cursor cursor = (Cursor) listAdapter.getItem(position);
     bundle.putInt("SERVICE_ID", cursor.getInt(cursor.getColumnIndex("_id")));
     intent.putExtras(bundle);
     startActivity(intent);
   }
 }