/** @see android.app.Activity#onContextItemSelected(android.view.MenuItem) */
  @Override
  public boolean onContextItemSelected(MenuItem menuItem) {
    if (menuItem.getItemId() == MENU_ITEM_CANCEL) {
      return true;
    } else if (menuItem.getItemId() == MENU_ITEM_DELETE) {
      AdapterView.AdapterContextMenuInfo info =
          (AdapterView.AdapterContextMenuInfo) menuItem.getMenuInfo();

      ListView lv = (ListView) findViewById(R.id.query_history_all);
      QueryHistoryListItem item = (QueryHistoryListItem) lv.getItemAtPosition(info.position);
      int count = new TransitQueryDao(this).deleteTransitQuery(item.getQuery().getId());
      if (count == 1) {
        showList();
      }

      return true;
    } else if (menuItem.getItemId() == MENU_ITEM_SET_FROM
        || menuItem.getItemId() == MENU_ITEM_SET_TO) {
      AdapterView.AdapterContextMenuInfo info =
          (AdapterView.AdapterContextMenuInfo) menuItem.getMenuInfo();

      ListView lv = (ListView) findViewById(R.id.query_history_location);
      Location item = (Location) lv.getItemAtPosition(info.position);

      Intent result = new Intent();
      result.putExtra(EXTRA_KEY_LOCATION, item);
      setResult(getResultCode(menuItem.getItemId()), result);
      finish();

      return true;
    }

    return super.onContextItemSelected(menuItem);
  }
  @Override
  public boolean onContextItemSelected(MenuItem item) {
    if (item.getItemId() == R.id.mnuDelete) {
      // they have requested that we delete the selected race
      AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo();
      ListView list = (ListView) info.targetView.getParent();
      DBPathEntry db = (DBPathEntry) list.getItemAtPosition(info.position);

      try {
        if (db.GetFile().delete()) {
          Toast.makeText(this, "Database deleted", Toast.LENGTH_LONG).show();
        } else {
          Toast.makeText(this, "Failed to delete DB", Toast.LENGTH_LONG).show();
        }
      } catch (Exception e) {
        Toast.makeText(this, "Failed to delete file " + e.toString(), Toast.LENGTH_LONG).show();
      }
      FirstTimeSetup(); // refresh the list
      return true;
    } else if (item.getItemId() == R.id.mnuRename) {
      AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo();
      ListView list = (ListView) info.targetView.getParent();
      DBPathEntry db = (DBPathEntry) list.getItemAtPosition(info.position);

      // they have requested that we rename the selected race
      Dialog d = new RenameDialog<DBPathEntry>(this, "Set the new DB name", db, R.id.edtRename);
      d.setOnDismissListener(this);
      d.show();

      return true;
    }
    return false;
  }
  @Override
  public void onListItemClick(ListView l, View v, int position, long id) {

    Object item = l.getItemAtPosition(position);
    if (item != null && item.getClass().equals(Flight.class)) {
      Flight flight = (Flight) l.getItemAtPosition(position);
      if (getListener() != null && flight != null) getListener().onFlightSelectionChanged(flight);
    }
  }
  public void onListItemClick(ListView l, View v, int position, long id) {
    Page selection = (Page) l.getItemAtPosition(position);

    if (selection != null) {

      View view = getActivity().findViewById(R.id.content_right);

      if (view == null) {
        // DisplayFragment (Fragment B) is not in the layout (handset layout),
        // so start DisplayActivity (Activity B)
        // and pass it the info about the selected item
        Intent i = new Intent(getActivity(), PhotoGridActivity.class);

        i.putExtra("folder", selection.getFolder());
        i.putExtra("title", selection.getTitle());
        startActivity(i);

      } else {
        // launch fragment
        FragmentManager fragmentManager = getFragmentManager();
        PhotoGridFragment fragment = new PhotoGridFragment();
        Bundle bundle = new Bundle();
        bundle.putString("folder", selection.getFolder());
        fragment.setArguments(bundle);
        fragmentManager.beginTransaction().replace(R.id.content_right, fragment).commit();
      }
    }
  }
  @Override
  public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
    final NetMusicEntry entry = (NetMusicEntry) mHotMusicListView.getItemAtPosition(position);
    String songId = entry.getSong_id();
    loadingDialog.show();
    MyHttpUtil.getDefaultHttpUtil()
        .send(
            HttpRequest.HttpMethod.GET,
            NetAPIEntry.getUrlBySongId(songId),
            new RequestCallBack<String>() {

              @Override
              public void onSuccess(ResponseInfo<String> stringResponseInfo) {
                loadingDialog.cancel();
                entry.setFile_link(NetMusicEntry.getFileLink(stringResponseInfo.result));
                mPopupWindow =
                    PopupWindowUtil.createPopupWindow(
                        getActivity(), R.layout.layout_popupwindow_download);
                mPopupWindow.showAtLocation(
                    getActivity().getWindow().getDecorView(),
                    Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL,
                    0,
                    0);
                initPopBtnViewAndListener(entry);
              }

              @Override
              public void onFailure(HttpException e, String s) {
                loadingDialog.cancel();
              }
            });
  }
 @SuppressWarnings("unchecked")
 @Override
 protected void onListItemClick(ListView l, View v, int position, long id) {
   Map<String, Object> map = (Map<String, Object>) l.getItemAtPosition(position);
   Intent intent = (Intent) map.get("intent");
   startActivity(intent);
 }
Example #7
0
  @Override
  public boolean onContextItemSelected(MenuItem item) {
    AdapterView.AdapterContextMenuInfo menuInfo =
        (AdapterView.AdapterContextMenuInfo) item.getMenuInfo();
    final int position = (null != menuInfo) ? menuInfo.position : contextMenuItemPosition;
    Object destination = historyListView.getItemAtPosition(position);

    switch (item.getItemId()) {
      case CONTEXT_MENU_NAVIGATE:
        contextMenuItemPosition = position;
        break;

      case CONTEXT_MENU_DELETE_WAYPOINT:
        if (destination instanceof cgDestination) {
          removeFromHistory((cgDestination) destination);
        }
        return true;

      case CONTEXT_MENU_EDIT_WAYPOINT:
        if (destination instanceof cgDestination) {
          final Geopoint gp = ((cgDestination) destination).getCoords();
          latButton.setText(gp.format(GeopointFormatter.Format.LAT_DECMINUTE));
          lonButton.setText(gp.format(GeopointFormatter.Format.LON_DECMINUTE));
        }
        return true;

      default:
        if (destination instanceof cgDestination) {
          return NavigationAppFactory.onMenuItemSelected(
              item, geo, this, res, null, null, null, ((cgDestination) destination).getCoords());
        }
    }

    return super.onContextItemSelected(item);
  }
 @Override
 public boolean onContextItemSelected(MenuItem item) {
   AdapterView.AdapterContextMenuInfo info =
       (AdapterView.AdapterContextMenuInfo) item.getMenuInfo();
   int hitMovie = info.position;
   HashMap hMap = (HashMap) lv.getItemAtPosition(hitMovie);
   String selMovieNumber = hMap.get("id").toString();
   switch (item.getItemId()) {
     case R.id.edit_movie:
       String selMovieName = hMap.get("title").toString();
       // String selRating = hMap.get("rating").toString();
       // String selDate = hMap.get("date").toString();
       editMovie(Integer.parseInt(selMovieNumber), selMovieName);
       return true;
     case R.id.delete_movie:
       mHelper.RemoveMovie(selMovieNumber, lv.getContext());
       try {
         populateMyMovies(lv);
       } catch (ParseException e) {
         e.printStackTrace();
       }
       return true;
     default:
       return super.onContextItemSelected(item);
   }
 }
Example #9
0
  /**
   * Este método se llama al pulsar en el botón de borrar como se definió en el layout
   * res/layout/main.xml
   */
  public void deleteSelected(View view) {
    // Obtengo los elementos seleccionados de mi lista
    SparseBooleanArray seleccionados = miLista.getCheckedItemPositions();

    if (seleccionados == null || seleccionados.size() == 0) {
      // Si no había elementos seleccionados...
      Toast.makeText(this, "No hay elementos seleccionados", Toast.LENGTH_SHORT).show();
    } else {
      // si los había, miro sus valores

      // Esto es para ir creando un mensaje largo que mostraré al final
      StringBuilder resultado = new StringBuilder();
      resultado.append("Se eliminarán los siguientes elementos:\n");

      // Recorro my "array" de elementos seleccionados
      final int size = seleccionados.size();
      for (int i = 0; i < size; i++) {
        // Si valueAt(i) es true, es que estaba seleccionado
        if (seleccionados.valueAt(i)) {
          // en keyAt(i) obtengo su posición
          Cursor c = (Cursor) miLista.getItemAtPosition(seleccionados.keyAt(i));

          resultado.append("El elemento " + c.getString(2) + " estaba seleccionado\n");
        }
      }
      Toast.makeText(this, resultado.toString(), Toast.LENGTH_LONG).show();
    }
  }
Example #10
0
  @Override
  protected void onListItemClick(ListView l, View v, int position, long id) {
    super.onListItemClick(l, v, position, id);
    String selection = l.getItemAtPosition(position).toString();

    selection = selection.replaceAll(" ", "_");

    dialog = new Dialog(SubExercise.this);
    dialog.setContentView(R.layout.instructions);
    dialog.setTitle("Exercise Instructions");
    dialog.setCancelable(true);

    Button close = (Button) dialog.findViewById(R.id.btnInstrCancel);
    TextView instr = (TextView) dialog.findViewById(R.id.lblReturnInstr);

    close.setOnClickListener(
        new OnClickListener() {
          @Override
          public void onClick(View v) {
            dialog.dismiss();
          }
        });

    int res_id = getResources().getIdentifier(selection, "string", this.getPackageName());
    if (res_id != 0) {
      String instructions = getResources().getString(res_id);
      instr.setText(instructions);
    } else {
      instr.setText("Instructions Coming Soon!");
    }
    dialog.show();
  }
 // [region] events
 @Override
 public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
   CompInfo item = (CompInfo) lvReceiver.getItemAtPosition(position);
   boolean bRet = false;
   if (item.enabled) {
     // item.component.getComponentName()
     LogApi.logDisableComponent(item.component.getComponentName().toString());
     bRet = ComponentUtils.doDisableComponent(item.component.getComponentName());
     if (bRet) {
       item.enabled = false;
       ((TextView) view.findViewById(R.id.itemReceiverStatus)).setText(R.string.comp_disabled);
       ((TextView) view.findViewById(R.id.itemReceiverStatus)).setTextColor(Color.RED);
     } else {
       Toast.makeText(this, R.string.operation_failed, Toast.LENGTH_LONG).show();
     }
   } else if (!item.enabled) {
     LogApi.logEnableComponent(item.component.getComponentName().toString());
     bRet = ComponentUtils.doEnabledComponent(item.component.getComponentName());
     if (bRet) {
       item.enabled = true;
       ((TextView) view.findViewById(R.id.itemReceiverStatus)).setText(R.string.comp_enabled);
       ((TextView) view.findViewById(R.id.itemReceiverStatus)).setTextColor(0xFF008000);
     } else {
       Toast.makeText(this, R.string.operation_failed, Toast.LENGTH_LONG).show();
     }
   }
   setResult(RESULT_OK);
   return false;
 }
 @Override
 public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
   if (onTagSelectedListener != null) {
     VideoListItem selectedVideoListItem = (VideoListItem) listView.getItemAtPosition(position);
     selectedVideoListItem.fireCallback((ActivityStarterWithContext) getActivity(), this);
   }
 }
  /**
   * Funcion que muestra opciones al dejar una fila presionada. Discrimina por permisologia.
   *
   * @param lv ListView que llamo al evento onLongClick
   * @param position Numero de positicion que ocupa la fila que se longClikeo
   */
  private void mostrarListaOpciones(ListView l, int position) {
    Cursor cursor = (Cursor) l.getItemAtPosition(position);
    final String id = cursor.getString(cursor.getColumnIndex("_id"));
    final String nombre = cursor.getString(cursor.getColumnIndex("nombre"));
    String tipoCliente = null;

    if (l.getId() == android.R.id.list) {
      tipoCliente = "empleado";
    } else if (l.getId() == R.id.listEmpresas) {
      tipoCliente = "empresa";
    }

    if (permisos.contains(Permiso.ELIMINAR_TODO)) {
      mostrarOpcionActualizarEliminar(id, tipoCliente, nombre);

      /*}else if(permisos.contains(Permiso.ELIMINAR_PROPIOS)){

      String idUsuarioCreador = cursor.getString(cursor.getColumnIndex("idUsuario"));
      String idUsuarioSesion = SesionUsuario.getIdUsuario(getActivity());

      if(idUsuarioCreador==idUsuarioSesion){
      	mostrarOpcionActualizarEliminar(id, tipoCliente, nombre);
      }else{
      	mostrarOpcionActualizar(id, tipoCliente, nombre);
      }*/

    } else {
      mostrarOpcionActualizar(id, tipoCliente, nombre);
    }
  }
 @Override
 protected void onListItemClick(ListView l, View v, int position, long id) {
   String clickedItem = (String) l.getItemAtPosition(position);
   if (clickedItem.equals(getString(R.string.backup_everything))) {
     ConfigUtil.importExportDialog(this, ConfigUtil.ImportExportOperation.EXPORT_EVERYTHING);
     return;
   }
   if (clickedItem.equals(getString(R.string.backup_config))) {
     ConfigUtil.importExportDialog(this, ConfigUtil.ImportExportOperation.EXPORT_CONFIG);
     return;
   }
   if (clickedItem.equals(getString(R.string.backup_preferences))) {
     ConfigUtil.importExportDialog(this, ConfigUtil.ImportExportOperation.EXPORT_PREFERENCES);
     return;
   }
   if (clickedItem.equals(getString(R.string.backup_keybindings))) {
     ConfigUtil.importExportDialog(this, ConfigUtil.ImportExportOperation.EXPORT_KEYBINDINGS);
     return;
   }
   if (clickedItem.equals(getString(R.string.import_config))) {
     ConfigUtil.importExportDialog(this, ConfigUtil.ImportExportOperation.IMPORT_CONFIG);
     return;
   }
   if (clickedItem.equals(getString(R.string.import_preferences))) {
     ConfigUtil.importExportDialog(this, ConfigUtil.ImportExportOperation.IMPORT_PREFERENCES);
     return;
   }
   if (clickedItem.equals(getString(R.string.import_keybindings))) {
     ConfigUtil.importExportDialog(this, ConfigUtil.ImportExportOperation.IMPORT_KEYBINDINGS);
     return;
   }
 }
 @SuppressWarnings("unchecked")
 @Override
 protected void onListItemClick(ListView l, View v, int position, long id) {
   Map<String, Object> map = (Map<String, Object>) l.getItemAtPosition(position);
   Intent intent = new Intent(this, (Class<? extends Activity>) map.get("activity"));
   startActivity(intent);
 }
 public boolean onItemLongClick(ListView l, View v, int position, long id) {
   Node n = (Node) l.getItemAtPosition(position);
   l.setItemChecked(position, true);
   boolean b = startSelection(v, n);
   ((MainActivity) getActivity()).addPropertiesFragment(n);
   return b;
 };
Example #17
0
  @Override
  // ListView内のボタンのイベント処理
  protected void onListItemClick(ListView lv, View v, int pos, long id) {
    super.onListItemClick(lv, v, pos, id);
    CustomData item = (CustomData) lv.getItemAtPosition(pos);

    // いいねボタンが押された場合
    if (id == 0) {
      // user_idとcomment_idを取得してAPIを叩く
      iineTask = new IineTask(this, item);
      iineTask.execute();

      try {
        Thread.sleep(1000);
      } catch (InterruptedException e) {
        e.printStackTrace();
      }

      task = new ListTask(lv, this);
      task.execute();

      // コメント欄ボタンが押された場合
    } else if (id == 1) {
      ImageCache.clearCache();
      Intent intent = new Intent(ImageTwActivity.this, CommentActivity.class);
      intent.putExtra("commentId", item.getCommentId());
      intent.putExtra("comment", item.getTitleName());
      startActivity(intent);
    }
  }
  private void updateCalendarInfoFromListItem(int position) {
    Cursor cursor = (Cursor) calendarListView.getItemAtPosition(position);
    currentSelection.setDisplayName(cursor.getString(0));
    currentSelection.setId(cursor.getInt(1));

    updateListener.onUpdate(getCurrentSelection());
  }
Example #19
0
  public void testProbarFrescoSinAzucar() {

    frescosinazucar = view.getItemAtPosition(2);
    String obtenido = frescosinazucar.toString();
    String esperado = "Fresco sin azúcar: Fresa";
    assertEquals("El nombre no concuerda.", esperado, obtenido);
  }
Example #20
0
  @Override
  protected void onListItemClick(ListView l, View v, int position, long id) {
    Map map = (Map) l.getItemAtPosition(position);

    Intent intent = (Intent) map.get("intent");
    startActivity(intent);
  }
Example #21
0
  public void testProbarFresco1() {

    fresco1 = view.getItemAtPosition(0);
    String obtenido = fresco1.toString();
    String esperado = "Fresco 1: Cas";
    assertEquals("El nombre no concuerda.", esperado, obtenido);
  }
Example #22
0
  public void testProbarFresco2() {

    fresco2 = view.getItemAtPosition(1);
    String obtenido = fresco2.toString();
    String esperado = "Fresco 2: Naranja/Zanahoria";
    assertEquals("El nombre no concuerda.", esperado, obtenido);
  }
Example #23
0
  @Override
  public ContextMenuSubject getSubject(ContextMenu menu, View view, ContextMenuInfo menuInfo) {
    ContextMenuSubject subject = null;

    if (!(menuInfo instanceof AdapterView.AdapterContextMenuInfo)) {
      Log.e(LOGTAG, "menuInfo is not AdapterContextMenuInfo");
      return subject;
    }

    ListView list = (ListView) view;
    AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) menuInfo;
    subject = ((AwesomeBarItem) list.getItemAtPosition(info.position)).getSubject();

    if (subject == null) return subject;

    MenuInflater inflater = new MenuInflater(mContext);
    inflater.inflate(R.menu.awesomebar_contextmenu, menu);
    menu.findItem(R.id.remove_bookmark).setVisible(false);
    menu.findItem(R.id.edit_bookmark).setVisible(false);
    menu.findItem(R.id.open_in_reader).setVisible(subject.display == Combined.DISPLAY_READER);

    // Hide "Remove" item if there isn't a valid history ID
    if (subject.id < 0) menu.findItem(R.id.remove_history).setVisible(false);

    menu.setHeaderTitle(subject.title);
    return subject;
  }
Example #24
0
  public void handleItemClick(AdapterView<?> parent, View view, int position, long id) {
    ListView listview = getListView();
    if (listview == null) return;

    AwesomeBarItem item = (AwesomeBarItem) listview.getItemAtPosition(position);
    item.onClick();
  }
  @Override
  public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
    ListView listView = (ListView) parent;
    String guid = (String) listView.getItemAtPosition(position);
    guid = guid.trim();
    int tid = StringUtil.getUrlParameter(guid, "tid");
    toDeleteTid = tid;
    DialogInterface.OnClickListener dialogClickListener =
        new DialogInterface.OnClickListener() {
          @Override
          public void onClick(DialogInterface dialog, int which) {
            switch (which) {
              case DialogInterface.BUTTON_POSITIVE:
                DeleteBookmarkTask task = new DeleteBookmarkTask(FlexibleTopicListActivity.this);
                task.execute(String.valueOf(toDeleteTid));
                break;

              case DialogInterface.BUTTON_NEGATIVE:
                // Do nothing
                break;
            }
          }
        };

    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder
        .setMessage(this.getString(R.string.delete_favo_confirm_text))
        .setPositiveButton(R.string.confirm, dialogClickListener)
        .setNegativeButton(R.string.cancle, dialogClickListener)
        .show();
    return true;
  }
Example #26
0
  @Override
  public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
    ProcessInfo processInfo = (ProcessInfo) mProcessListView.getItemAtPosition(position);

    ProcessInfo mProcessInfo = processInfo;

    mInfoTextView.setText("[" + processInfo.getPid() + "] " + processInfo.getProcessName());
  }
  @SuppressLint("NewApi")
  @Override
  public void onListItemClick(ListView parent, View v, int position, long id) {
    final File f = (File) parent.getItemAtPosition(position);
    // Log.i("info", f.getParent()); // /mnt/sdcard/siebenreader
    // Log.i("info", f.getName()); // epub file name from sd card
    // Log.i("info", utils.DIR_OUTPUT + File.separator); //
    // /mnt/sdcard/siebenreader/
    File test = new File(f.getParent() + File.separator + f.getName());
    if (!test.exists()) {
      mFiles.remove(f);
      history.setFiles(mFiles);
      storageHelper.writeHistory(history);
      AlertDialog ad = adb.create();
      ad.setMessage("Кітап табылмады");
      ad.show();
      recreate();
    } else {
      progressDialog = ProgressDialog.show(ArchiveActivity.this, "Жүктелуде", "Күте тұрыңыз");
      new Thread() {
        public void run() {
          try {

            utils.copyFile(
                f.getParent() + File.separator,
                f.getName(),
                utils.DIR_OUTPUT + File.separator); // rename
            // epub
            // file
            // to
            // sieben.epub
            // and
            // copy
            // to
            // /mnt/sdcard/siebenreader/

            EpubExtractor epubExtract = new EpubExtractor();
            epubExtract.unzip(
                utils.DIR_OUTPUT + File.separator + utils.OUTPUT_EPUB_FILE,
                utils.DIR_OUTPUT + File.separator); // extract file
            // /mnt/sdcard/siebenreader/sieben.epub
            // Log.i("info", "file : " + utils.DIR_OUTPUT +
            // File.separator + utils.OUTPUT_EPUB_FILE);
            // Log.i("info", "dest : " + utils.DIR_OUTPUT +
            // File.separator);

            Intent i = new Intent(getApplicationContext(), EpubViewerActivity.class);
            startActivity(i);

          } catch (Exception e) {

          }
          progressDialog.dismiss();
        }
      }.start();
    }
  }
Example #28
0
  @Override
  public void onRowLongPressed(View view, Object item) {
    extrasMenu.forceHide();

    mMultiSelect.setItemCount(
        mSongAdapter.toggleSelection(
            mListView.getChildAt((Integer) item - mListView.getFirstVisiblePosition()),
            ((Song) mListView.getItemAtPosition((Integer) item))));
  }
 private void atualizarTitulo(boolean drawerIsOpen) {
   if (drawerIsOpen) {
     mToolbar.setTitle(R.string.app_name);
   } else {
     int posicaoAtual = mDrawerList.getCheckedItemPosition();
     String opcaoAtual = mDrawerList.getItemAtPosition(posicaoAtual).toString();
     mToolbar.setTitle(opcaoAtual);
   }
 }
 @Override
 public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
   ProgramStageRow row = (ProgramStageRow) listView.getItemAtPosition(position);
   if (row instanceof ProgramStageEventRow) {
     ProgramStageEventRow eventRow = (ProgramStageEventRow) row;
     Event event = eventRow.getEvent();
     showDataEntryFragment(event, event.getProgramStageId());
   }
 }