private Character getSelectedChannelMaster() {
   try {
     if (channelMasterListView.getCheckedItemPosition() > channelMasterListView.getCount()
         || channelMasterListView.getCheckedItemPosition() == -1) {
       channelMasterListView.setItemChecked(0, true);
     }
     return channelMasterNamesAdapter
         .getItem(channelMasterListView.getCheckedItemPosition())
         .toString()
         .charAt(0);
   } catch (Exception e) {
     return null;
   }
 }
  private Integer getSelectedChannelSlave() {
    try {
      if (channelSlaveListView.getCheckedItemPosition() > channelSlaveListView.getCount()
          || channelSlaveListView.getCheckedItemPosition() == -1) {
        channelSlaveListView.setItemChecked(0, true);
      }

      return Integer.valueOf(
          channelSlaveNamesAdapter
              .getItem(channelSlaveListView.getCheckedItemPosition())
              .toString());
    } catch (Exception e) {
      return null;
    }
  }
Пример #3
0
 @Override
 public void onClick(View v) {
   switch (v.getId()) {
     case R.id.contact_dial:
       int position = listView.getCheckedItemPosition();
       if (position != -1) {
         listView.setSelection(position);
         if (mService != null) {
           mService.sendCommand(
               "AT#CW"
                   + ((TextView)
                           listView
                               .getAdapter()
                               .getView(position, null, null)
                               .findViewById(R.id.textView2))
                       .getText()
                   + "\r\n");
           //			Application.blueMic=true;
         }
       }
       break;
     case R.id.contact:
       startActivity(new Intent(this, ContactActivity.class));
       overridePendingTransition(R.anim.fade, R.anim.hold);
       break;
     case R.id.contact_del:
       int index = listView.getCheckedItemPosition();
       if (index != -1) {
         asyncQuery.startDelete(
             0,
             null,
             CallLogProvider.CONTENT_URI,
             CallLog.Calls._ID + "=?",
             new String[] {list.get(index).getId() + ""});
         list.remove(index);
       } else {
         asyncQuery.startDelete(0, null, CallLogProvider.CONTENT_URI, null, null);
         list.clear();
       }
       adapter.notifyDataSetChanged();
       break;
     case R.id.back:
       finish();
       break;
     default:
       break;
   }
 }
  @Override
  public void onLoadFinished(Loader<Cursor> loader, Cursor data) {
    switch (loader.getId()) {
      case LOADER_HISTORY:
        {
          mAdapter.changeCursor(data);
          if (!mAdapter.isEmpty()
              && mGroupList != null
              && mGroupList.getCheckedItemPosition() == ListView.INVALID_POSITION) {
            selectGroup(0);
          }

          checkIfEmpty();
          break;
        }

      case LOADER_MOST_VISITED:
        {
          mAdapter.changeMostVisitedCursor(data);

          checkIfEmpty();
          break;
        }

      default:
        {
          throw new IllegalArgumentException();
        }
    }
  }
Пример #5
0
  protected boolean prepareModelData(int state, int commandId) {
    switch (state) {
      case STATE_CUSTOM_PLACE:
        {
          if (commandId == CMD_CUSTOM_PLACE_DONE) {
            if (addressEditView != null) {
              String label = addressEditView.getText().trim().toString();
              model.put(KEY_S_PLACE_LABEL, label);
            }
          }
          if (commandId == CMD_CUSTOM_PLACE_DONE || commandId == CMD_ADD_CATEGORY) {
            if (categoryList != null) {
              Vector categories = AddPlaceViewTouch.this.model.getVector(KEY_V_ALL_CATEGORIES);
              int position = categoryList.getCheckedItemPosition();
              if (position >= categoryList.getHeaderViewsCount()
                  && position < categoryList.getHeaderViewsCount() + categories.size() + 1) {
                int selectedCategoryIndex = position - categoryList.getHeaderViewsCount() - 1;
                AddPlaceViewTouch.this.model.put(
                    KEY_I_SELECTED_CATEGORY_INDEX, selectedCategoryIndex);
              }
            }
          }

          break;
        }
      default:
        break;
    }

    return true;
  }
 private String getSelectedModel() {
   try {
     int position = modelListView.getCheckedItemPosition();
     return modelNamesAdapter.getItem(position);
   } catch (Exception e) {
     return null;
   }
 }
Пример #7
0
  // Highlight the selected country : 0 to 4
  public void highlightSelectedCountry() {
    int selectedItem = mDrawerList.getCheckedItemPosition();

    if (selectedItem > 4) mDrawerList.setItemChecked(mPosition, true);
    else mPosition = selectedItem;

    if (mPosition != -1) getSupportActionBar().setTitle(mCountries[mPosition]);
  }
 private String getSelectedBrand() {
   try {
     int position = brandListView.getCheckedItemPosition();
     String brand = brandNamesAdapter.getItem(position).toString();
     return brand;
   } catch (Exception e) {
     return null;
   }
 }
Пример #9
0
 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);
   }
 }
Пример #10
0
 public void onClick(DialogInterface dialog, int which) {
   ListView lv = ((AlertDialog) dialog).getListView();
   if (which == Dialog.BUTTON_POSITIVE)
     // выводим в лог позицию выбранного элемента
     Log.d(LOG_TAG, "pos = " + lv.getCheckedItemPosition());
   else
     // выводим в лог позицию нажатого элемента
     Log.d(LOG_TAG, "which = " + which);
 }
  @Override
  public void onClick(View v) {
    switch (v.getId()) {
      case R.id.ButResistBodyItem:
        String str = ((EditText) findViewById(R.id.ETbodyitem)).getText().toString();
        if (!str.equals("")) {
          int num = MailBodyGenerator.getInstance().getbIMaster().getNextNum(_lineNum);

          ContentValues cv = new ContentValues();
          cv.put(ReturnMailerDBDefinition.MailBodyItemColumns.COL_GID, _lineNum + 1);
          cv.put(ReturnMailerDBDefinition.MailBodyItemColumns.COL_NUM, num);
          cv.put(ReturnMailerDBDefinition.MailBodyItemColumns.COL_ITEM, str);
          Uri uri = DBOperator.insert(ReturnMailerDBDefinition.CONTENT_URI, cv);

          if (uri != null) {
            MailBodyItem mbi = new MailBodyItem(uri.getPathSegments().get(1), _lineNum, num, str);
            MailBodyGenerator.getInstance().getbIMaster().add(_lineNum, mbi);
            ((EditText) findViewById(R.id.ETbodyitem)).setText("");
            _adapter.notifyDataSetChanged();
            Toast.makeText(this, "New Item was added!!", Toast.LENGTH_SHORT).show();
          }
        }
        break;
      case R.id.ButDeleteBodyItem:
        if (MailBodyGenerator.getInstance().getbIMaster().size(_lineNum) <= 1) {
          Toast.makeText(this, "Can't delete all Item!!", Toast.LENGTH_SHORT).show();
          break;
        }
        String _id =
            ((MailBodyItem) _listView.getItemAtPosition(_listView.getCheckedItemPosition()))
                .get_ID();
        if (DBOperator.delete(
                ReturnMailerDBDefinition.CONTENT_URI, MailBodyItemColumns._ID + " = " + _id, null)
            >= 1) {
          MailBodyGenerator.getInstance()
              .getbIMaster()
              .remove(_lineNum, _listView.getCheckedItemPosition());
          _adapter.notifyDataSetChanged();
          Toast.makeText(this, "One Item was deleted!!", Toast.LENGTH_SHORT).show();
        }
        break;
    }
  }
Пример #12
0
  private void startZhenTiFragment() {
    int position = mLeftMenuLV.getCheckedItemPosition();
    int iCourseID = mSelectedCourses.get(position).getICourseID();
    mCurType = TYPE_ZHEN_TI;
    CourseZhenTiFragment courseZhenTiFragment = CourseZhenTiFragment.newInstance(iCourseID);
    FragmentManager fragmentManager = getSupportFragmentManager();
    fragmentManager.beginTransaction().replace(R.id.content_frame, courseZhenTiFragment).commit();

    this.setTitle(
        mSelectedCourses.get(position).getStrCourseName() + ":" + getString(R.string.zhen_ti_test));
  }
 public void setItemDate(String selectedDate) {
   int i = list.getCheckedItemPosition();
   // i = -1 all the time. That is causing it to crash each time when we try to do stuff to it
   adapter.getItem(i).name = selectedDate;
   System.out.println(i);
   adapter.notifyDataSetChanged();
   // THIS ONE DOESN'T WORK
   // Item temp = (Item) list.getItemAtPosition(i);
   // System.out.println(temp.name);
   // System.out.println(selectedDate);
   // temp.name = selectedDate;
 }
Пример #14
0
  private void startCheckErrorFragment() {
    int position = mLeftMenuLV.getCheckedItemPosition();
    int iCourseID = mSelectedCourses.get(position).getICourseID();
    mCurType = TYPE_ERROR;
    CourseErrorFragment courseErrorFragment =
        CourseErrorFragment.newInstance(iCourseID, Util.BASIC_TEST);
    FragmentManager fragmentManager = getSupportFragmentManager();
    fragmentManager.beginTransaction().replace(R.id.content_frame, courseErrorFragment).commit();

    this.setTitle(
        mSelectedCourses.get(position).getStrCourseName() + ":" + getString(R.string.check_error));
  }
Пример #15
0
  public void chat(View view) {
    ListView list = (ListView) findViewById(R.id.instancesList);
    int index = list.getCheckedItemPosition();
    if (index < 0) {
      MainActivity.showMessage("Select a channel", this);
      return;
    }
    this.instance = instances.get(index);
    ChannelConfig config = new ChannelConfig();
    config.id = this.instance.id;
    config.name = this.instance.name;

    HttpAction action = new HttpFetchAction(this, config, true);
    action.execute();
  }
  private void highlightDailyScheduleList(List<Calendar> freeCalendars) {
    // marca os dias livres e rearruma a lista de profissionais

    if (freeCalendars != null) {
      screenCalendar.clearHighlightedDates();

      professionalAdapter.clearAvailableMarks();
      professionalAdapter.removeMark(professionalLV.getCheckedItemPosition());
      System.out.println(professionalLV.getCheckedItemPosition());
      if (selectedDate != null) {
        // Toast.makeText(getActivity(), selectedProfessionalDTO.getName() + " não está livre no dia
        // selecionado.", Toast.LENGTH_LONG).show();
        clearSelectedDate();
      }
      Collection<Date> freeDatesCollection = new ArrayList<>();
      for (Calendar freeCalendar : freeCalendars) {
        freeDatesCollection.add(DateUtilMoti.convertCalendarToDate(freeCalendar));
      }
      screenCalendar.highlightDates(freeDatesCollection);
      if (freeDatesCollection.size() <= 0)
        Toast.makeText(getContext(), "Profissional sem dias livres", Toast.LENGTH_SHORT).show();
    }
    finishUpViewLoad();
  }
Пример #17
0
 // Para el servicio y cambia el aspecto visual.
 private void pararServicio() {
   stopService(intentServicio);
   lstCanciones.setItemChecked(lstCanciones.getCheckedItemPosition(), false);
   btnPlayStop.setImageResource(R.drawable.fab_play);
 }