예제 #1
0
 public void selectFormSection(String formSectionName) {
   solo.waitForText("Save");
   solo.clickOnView(solo.getCurrentViews(Spinner.class).get(0));
   solo.waitForText(formSectionName);
   ListAdapter adapter = solo.getCurrentViews(ListView.class).get(0).getAdapter();
   for (int i = 0; i < adapter.getCount(); i++) {
     if (adapter.getItem(i).toString().equalsIgnoreCase(formSectionName)) {
       formPosition = i;
       break;
     }
   }
   solo.clickOnText(adapter.getItem(formPosition).toString());
   solo.waitForText(formSectionName);
   solo.sleep(3);
 }
    @Override
    public Object getItem(int position) {
      // Header (negative positions will throw an ArrayIndexOutOfBoundsException)
      int numHeadersAndPlaceholders = getHeadersCount() * mNumColumns;
      if (position < numHeadersAndPlaceholders) {
        if (position % mNumColumns == 0) {
          return mHeaderViewInfos.get(position / mNumColumns).data;
        }
        return null;
      }

      // Adapter
      final int adjPosition = position - numHeadersAndPlaceholders;
      int adapterCount = 0;
      if (mAdapter != null) {
        adapterCount = getAdapterAndPlaceHolderCount();
        if (adjPosition < adapterCount) {
          if (adjPosition < mAdapter.getCount()) {
            return mAdapter.getItem(adjPosition);
          } else {
            return null;
          }
        }
      }

      // Footer (off-limits positions will throw an IndexOutOfBoundsException)
      final int footerPosition = adjPosition - adapterCount;
      if (footerPosition % mNumColumns == 0) {
        return mFooterViewInfos.get(footerPosition).data;
      } else {
        return null;
      }
    }
예제 #3
0
  String collectTextLogContent() {
    StringBuffer sb = new StringBuffer();

    SysInfoManager.createTextHeader(
        this,
        sb,
        "Android Device Log - " //$NON-NLS-1$
            + new Date().toLocaleString());

    ListAdapter adapter = getListView().getAdapter();
    int cnt = adapter.getCount();

    if (dmesgMode) {
      String head;
      for (int i = 0; i < cnt; i++) {
        LogItem log = (LogItem) adapter.getItem(i);

        head = formatDLog(log) + " :\t"; // $NON-NLS-1$

        if (log.msgList == null) {
          sb.append(head).append(log.msg).append('\n');
        } else {
          for (int k = 0, size = log.msgList.size(); k < size; k++) {
            sb.append(head).append(log.msgList.get(k)).append('\n');
          }
        }
      }
    } else {
      String head;
      for (int i = 0; i < cnt; i++) {
        LogItem log = (LogItem) adapter.getItem(i);

        head = formatCLog(log) + " :\t"; // $NON-NLS-1$

        if (log.msgList == null) {
          sb.append(head).append(log.msg).append('\n');
        } else {
          for (int k = 0, size = log.msgList.size(); k < size; k++) {
            sb.append(head).append(log.msgList.get(k)).append('\n');
          }
        }
      }
    }

    return sb.toString();
  }
예제 #4
0
  private void showNoteInPane(int position) {
    if (rightPane == null) return;

    if (position == -1) position = 0;

    title.setText("");
    content.setText("");

    // save index and top position

    int index = getListView().getFirstVisiblePosition();
    View v = getListView().getChildAt(0);
    int top = (v == null) ? 0 : v.getTop();

    updateNotesList(query, position);

    // restore

    getListView().setSelectionFromTop(index, top);

    if (position >= adapter.getCount()) position = 0;

    Cursor item = (Cursor) adapter.getItem(position);
    if (item == null || item.getCount() == 0) {
      TLog.d(TAG, "Index {0} not found in list", position);
      return;
    }
    TLog.d(TAG, "Getting note {0}", position);

    long noteId = item.getInt(item.getColumnIndexOrThrow(Note.ID));
    uri = Uri.parse(CONTENT_URI + "/" + noteId);

    note = NoteManager.getNote(this, uri);
    TLog.v(TAG, "Note guid: {0}", note.getGuid());

    if (note != null) {
      TLog.d(TAG, "note {0} found", position);
      noteContent =
          new NoteContentBuilder()
              .setCaller(noteContentHandler)
              .setInputSource(note.getXmlContent())
              .setTitle(note.getTitle())
              .build();
      lastIndex = position;
    } else {
      TLog.d(TAG, "The note {0} doesn't exist", uri);
      final boolean proposeShortcutRemoval;
      final boolean calledFromShortcut =
          getIntent().getBooleanExtra(CALLED_FROM_SHORTCUT_EXTRA, false);
      final String shortcutName = getIntent().getStringExtra(SHORTCUT_NAME);
      proposeShortcutRemoval = calledFromShortcut && uri != null && shortcutName != null;

      if (proposeShortcutRemoval) {
        dialogString = shortcutName;
        showDialog(DIALOG_NOT_FOUND_SHORTCUT);
      } else showDialog(DIALOG_NOT_FOUND);
    }
  }
예제 #5
0
 public List<String> getAllFormSections() {
   solo.clickOnText("Enquirer Details", 0);
   solo.waitForText("Tracing Information");
   ListAdapter adapter = solo.getCurrentViews(ListView.class).get(0).getAdapter();
   int totalCount = adapter.getCount();
   List<String> formSections = new ArrayList<String>();
   for (int i = 0; i < totalCount; i++) {
     formSections.add(adapter.getItem(i).toString());
   }
   return formSections;
 }
예제 #6
0
  /* (non-Javadoc)
   * @see android.app.Activity#onCreateContextMenu(android.view.ContextMenu, android.view.View, android.view.ContextMenu.ContextMenuInfo)
   */
  @Override
  public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) { // :-)

    super.onCreateContextMenu(menu, v, menuInfo);
    getMenuInflater().inflate(R.menu.device_context_menu, menu);

    AdapterContextMenuInfo info = (AdapterContextMenuInfo) menuInfo;
    ListAdapter adapter = getListAdapter();
    SoftAPDetails item = (SoftAPDetails) adapter.getItem(info.position);

    if (!item.supportOnboarding) menu.removeItem(R.id.context_menu_onboarding);
  }
예제 #7
0
 @Override
 protected void onListItemClick(ListView l, View v, int position, long id) {
   super.onListItemClick(l, v, position, id);
   if (rightPane != null) {
     if (position == lastIndex) // same index, edit
     this.startEditNote();
     else showNoteInPane(position);
   } else {
     Cursor item = (Cursor) adapter.getItem(position);
     long noteId = item.getInt(item.getColumnIndexOrThrow(Note.ID));
     this.ViewNote(noteId);
   }
 }
예제 #8
0
  @Override
  protected void onListItemClick(ListView l, View v, int position, long id) {
    super.onListItemClick(l, v, position, id);

    Friend friend = (Friend) adapter.getItem(position);

    if (friend.isAvailable() || SteamAdapters.getChatAdapter(friend).getCount() > 0) {
      Intent intent = new Intent(Friends.this, Chat.class);
      intent.putExtra("steamid", friend.getSteamId());
      startActivity(intent);
    } else {
      SteamAlerts.showAlert("Warning", friend.getName() + " is offline", this);
    }
  }
예제 #9
0
  /**
   * Get the data item associated with the specified position in the data set.
   *
   * @param position Position of the item whose data we want
   */
  @Override
  public Object getItem(int position) {
    for (ListAdapter piece : pieces) {
      int size = piece.getCount();

      if (position < size) {
        return (piece.getItem(position));
      }

      position -= size;
    }

    return (null);
  }
 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);
   }
 }
 @Override
 public void setListAdapter(ListAdapter adapter) {
   if (adapter == null) {
     super.setListAdapter(null);
   } else {
     // We don't have access to the hidden getHeaders() method, so grab the headers from
     // the intended adapter and then replace it with our own.
     int headerCount = adapter.getCount();
     List<Header> headers = Lists.newArrayList();
     for (int i = 0; i < headerCount; i++) {
       headers.add((Header) adapter.getItem(i));
     }
     mHeaderAdapter = new HeaderAdapter(this, headers);
     super.setListAdapter(mHeaderAdapter);
   }
 }
  public Object getItem(int position) {
    // Header (negative positions will throw an ArrayIndexOutOfBoundsException)
    int numHeaders = getHeadersCount();
    if (position < numHeaders) {
      return mHeaderViewInfos.get(position).data;
    }

    // Adapter
    final int adjPosition = position - numHeaders;
    int adapterCount = 0;
    if (mAdapter != null) {
      adapterCount = mAdapter.getCount();
      if (adjPosition < adapterCount) {
        return mAdapter.getItem(adjPosition);
      }
    }

    // Footer (off-limits positions will throw an ArrayIndexOutOfBoundsException)
    return mFooterViewInfos.get(adjPosition - adapterCount).data;
  }
예제 #13
0
파일: BookmarksDlg.java 프로젝트: pesgh/cr3
 @Override
 public boolean performItemClick(View view, int position, long id) {
   if (mShortcutMode) {
     Bookmark b = mBookInfo.findShortcutBookmark(position + 1);
     if (b == null) {
       mReaderView.addBookmark(position + 1);
       mThis.dismiss();
       return true;
     }
     selectedItem = position;
     openContextMenu(this);
   } else {
     Bookmark bm = (Bookmark) mAdapter.getItem(position);
     if (bm != null) {
       mReaderView.goToBookmark(bm);
       dismiss();
     }
   }
   return true;
 }
  private String getContent(ListAdapter adapter) {
    StringBuilder builder = new StringBuilder();
    char separator = ',';
    StockHistoryRepository historyRepository =
        new StockHistoryRepository(mContext.getApplicationContext());

    int itemCount = adapter.getCount();

    for (int i = 0; i < itemCount; i++) {
      Cursor cursor = (Cursor) adapter.getItem(i);

      // symbol.
      String symbol = cursor.getString(cursor.getColumnIndex(StockRepository.SYMBOL));
      // use the latest price date here.
      String date;
      ContentValues latestPrice = historyRepository.getLatestPriceFor(symbol);
      if (latestPrice == null) continue;

      if (latestPrice.containsKey(StockHistory.DATE)) {
        date = (String) latestPrice.get(StockHistory.DATE);
      } else {
        date = getTodayAsString();
      }
      // format date
      String csvDate = getDateInCsvFormat(date);
      // price.
      String price = cursor.getString(cursor.getColumnIndex(StockRepository.CURRENTPRICE));

      // code
      builder.append(symbol);
      builder.append(separator);
      // price
      builder.append(price);
      builder.append(separator);
      // date
      builder.append(csvDate);
      builder.append(System.lineSeparator());
    }

    return builder.toString();
  }
예제 #15
0
 @Override
 public Object getItem(int position) {
   // Header (negative positions will throw an
   // ArrayIndexOutOfBoundsException)
   int numHeadersAndPlaceholders = getHeadersCount() * mNumColumns;
   if (position < numHeadersAndPlaceholders) {
     if (position % mNumColumns == 0) {
       return mHeaderViewInfos.get(position / mNumColumns).data;
     }
     return null;
   }
   // Adapter
   final int adjPosition = position - numHeadersAndPlaceholders;
   int adapterCount = 0;
   if (mAdapter != null) {
     adapterCount = mAdapter.getCount();
     if (adjPosition < adapterCount) {
       return mAdapter.getItem(adjPosition);
     }
   }
   throw new ArrayIndexOutOfBoundsException(position);
 }
예제 #16
0
파일: BookmarksDlg.java 프로젝트: pesgh/cr3
 public Bookmark getSelectedBookmark() {
   return (Bookmark) mAdapter.getItem(selectedItem);
 }
예제 #17
0
 @Override
 public Object getItem(final int position) {
   return wrapped.getItem(position);
 }
예제 #18
0
 public void makeSamplePodcastWithUrl(String title, String url) {
   ListAdapter adapter = activity.getListAdapter();
   PodcastItem item = ((PodcastVisual) adapter.getItem(0)).podcast;
   item.title = title;
   item.audioUri = url;
 }
예제 #19
0
 private PodcastItem clickOnPodcastItem(int index) {
   ListAdapter adapter = activity.getListAdapter();
   PodcastVisual pv = (PodcastVisual) adapter.getItem(index);
   clickInList(index);
   return pv.podcast;
 }
예제 #20
0
  String collectHtmlLogContent() {
    StringBuffer sb = new StringBuffer();

    SysInfoManager.createHtmlHeader(
        this,
        sb,
        SysInfoManager.escapeHtml(
            "Android Device Log - " + new Date().toLocaleString())); // $NON-NLS-1$

    ListAdapter adapter = getListView().getAdapter();
    int cnt = adapter.getCount();

    if (dmesgMode) {
      sb.append(SysInfoManager.openHeaderRow)
          .append(
              "Dmesg " //$NON-NLS-1$
                  + getString(R.string.log))
          .append(SysInfoManager.closeHeaderRow);

      sb.append(SysInfoManager.openTitleRow)
          .append("<b>") // $NON-NLS-1$
          .append(getString(R.string.log_level))
          .append("</b>") // $NON-NLS-1$
          .append(SysInfoManager.nextColumn)
          .append("<b>") // $NON-NLS-1$
          .append(getString(R.string.time))
          .append("</b>") // $NON-NLS-1$
          .append(SysInfoManager.nextColumn)
          .append("<b>") // $NON-NLS-1$
          .append(getString(R.string.message))
          .append("</b>") // $NON-NLS-1$
          .append(SysInfoManager.closeRow);

      for (int i = 0; i < cnt; i++) {
        LogItem log = (LogItem) adapter.getItem(i);

        sb.append(SysInfoManager.openRow)
            .append("<" + log.level + ">") // $NON-NLS-1$ //$NON-NLS-2$
            .append(SysInfoManager.nextColumn);

        sb.append(
                log.time == null
                    ? "&nbsp;" //$NON-NLS-1$
                    : SysInfoManager.escapeHtml(log.time))
            .append(SysInfoManager.nextColumn);

        sb.append(SysInfoManager.escapeHtml(log.getMsg())).append(SysInfoManager.closeRow);
      }
    } else {
      sb.append(SysInfoManager.openHeaderRow)
          .append(
              "Logcat " //$NON-NLS-1$
                  + getString(R.string.log))
          .append(SysInfoManager.closeHeaderRow);

      sb.append(SysInfoManager.openTitleRow)
          .append("<b>") // $NON-NLS-1$
          .append(getString(R.string.time))
          .append("</b>") // $NON-NLS-1$
          .append(SysInfoManager.nextColumn)
          .append("<b>") // $NON-NLS-1$
          .append(getString(R.string.log_level))
          .append("</b>") // $NON-NLS-1$
          .append(SysInfoManager.nextColumn)
          .append("<b>") // $NON-NLS-1$
          .append(getString(R.string.tag))
          .append("</b>") // $NON-NLS-1$
          .append(SysInfoManager.nextColumn)
          .append("<b>") // $NON-NLS-1$
          .append(getString(R.string.pid))
          .append("</b>") // $NON-NLS-1$
          .append(SysInfoManager.nextColumn)
          .append("<b>") // $NON-NLS-1$
          .append(getString(R.string.message))
          .append("</b>") // $NON-NLS-1$
          .append(SysInfoManager.closeRow);

      for (int i = 0; i < cnt; i++) {
        LogItem log = (LogItem) adapter.getItem(i);

        sb.append(SysInfoManager.openRow)
            .append(SysInfoManager.escapeHtml(log.time))
            .append(SysInfoManager.nextColumn);

        sb.append(log.level).append(SysInfoManager.nextColumn);
        sb.append(SysInfoManager.escapeHtml(log.tag)).append(SysInfoManager.nextColumn);
        sb.append(log.pid).append(SysInfoManager.nextColumn);

        sb.append(SysInfoManager.escapeHtml(log.getMsg())).append(SysInfoManager.closeRow);
      }
    }

    sb.append(SysInfoManager.emptyRow);

    sb.append("</table></font></body></html>"); // $NON-NLS-1$

    return sb.toString();
  }
예제 #21
0
  String collectCSVLogContent() {
    StringBuffer sb = new StringBuffer();

    ListAdapter adapter = getListView().getAdapter();
    int cnt = adapter.getCount();

    if (dmesgMode) {
      sb.append("LEVEL,TIME,MSG\n"); // $NON-NLS-1$

      for (int i = 0; i < cnt; i++) {
        LogItem log = (LogItem) adapter.getItem(i);

        if (log.msgList == null) {
          sb.append(log.level).append(',');

          if (log.time != null) {
            sb.append(SysInfoManager.escapeCsv(log.time));
          }

          sb.append(',').append(SysInfoManager.escapeCsv(log.msg)).append('\n');
        } else {
          for (int k = 0, size = log.msgList.size(); k < size; k++) {
            sb.append(log.level).append(',');

            if (log.time != null) {
              sb.append(SysInfoManager.escapeCsv(log.time));
            }

            sb.append(',').append(SysInfoManager.escapeCsv(log.msgList.get(k))).append('\n');
          }
        }
      }
    } else {
      sb.append("TIME,LEVEL,TAG,PID,MSG\n"); // $NON-NLS-1$

      for (int i = 0; i < cnt; i++) {
        LogItem log = (LogItem) adapter.getItem(i);

        if (log.msgList == null) {
          sb.append(SysInfoManager.escapeCsv(log.time))
              .append(',')
              .append(log.level)
              .append(',')
              .append(SysInfoManager.escapeCsv(log.tag))
              .append(',')
              .append(log.pid)
              .append(',')
              .append(SysInfoManager.escapeCsv(log.msg))
              .append('\n');
        } else {
          for (int k = 0, size = log.msgList.size(); k < size; k++) {
            sb.append(SysInfoManager.escapeCsv(log.time))
                .append(',')
                .append(log.level)
                .append(',')
                .append(SysInfoManager.escapeCsv(log.tag))
                .append(',')
                .append(log.pid)
                .append(',')
                .append(SysInfoManager.escapeCsv(log.msgList.get(k)))
                .append('\n');
          }
        }
      }
    }

    return sb.toString();
  }
예제 #22
0
 @Override
 public Object getItem(final int position) {
   return isSectionHeaderPosition(position)
       ? mSections.get(position)
       : mBaseAdapter.getItem(sectionedPositionToPosition(position));
 }
예제 #23
0
 @Override
 public Object getItem(int i) {
   if (pattern.insertForIndex(i)) return null;
   return wrappedAdapter.getItem(i - getOffsetForIndex(i));
 }
예제 #24
0
 @Override
 public Object getItem(int position) {
   return mAdapter.getItem(position);
 }
 @Override
 public Object getItem(final int position) {
   return adapter.getItem(position);
 }