Пример #1
0
    @Override
    public View newView(Context context, Cursor cursor, ViewGroup parent) {
      View view = layoutInflater.inflate(layout, parent, false);

      Chapter chapter = new Chapter();
      chapter.setNo(cursor.getInt(cursor.getColumnIndex(TableVerse.VERSE_NO)));
      chapter.setStart(cursor.getInt(cursor.getColumnIndex(TableChapter.START)));
      chapter.setEnd(cursor.getInt(cursor.getColumnIndex(TableChapter.END)));
      chapter.setTotal(cursor.getInt(cursor.getColumnIndex(TableChapter.TOTAL)));
      chapter.setTitlePali(cursor.getString(cursor.getColumnIndex(TableChapter.TITLE_PALI)));
      chapter.setTitleEng(cursor.getString(cursor.getColumnIndex(TableChapter.TITLE_ENG)));
      chapter.setTitleId(cursor.getString(cursor.getColumnIndex(TableChapter.TITLE_ID)));

      SearchVerse verse = new SearchVerse(chapter, cursor);
      if (verse.getContentPali().indexOf(query) >= 0) {
        verse.setSearchContent(getQueryPart(verse.getContentPali(), query));
      } else if (verse.getContentEng().indexOf(query) >= 0) {
        verse.setSearchContent(getQueryPart(verse.getContentEng(), query));
      } else if (verse.getContentId().indexOf(query) >= 0) {
        verse.setSearchContent(getQueryPart(verse.getContentId(), query));
      }
      verse.setQuery(query);
      view.setTag(verse);

      return view;
    }
Пример #2
0
    @Override
    public void bindView(View view, Context context, Cursor cursor) {
      Chapter chapter = new Chapter();
      chapter.setNo(cursor.getInt(cursor.getColumnIndex(TableVerse.VERSE_NO)));
      chapter.setStart(cursor.getInt(cursor.getColumnIndex(TableChapter.START)));
      chapter.setEnd(cursor.getInt(cursor.getColumnIndex(TableChapter.END)));
      chapter.setTotal(cursor.getInt(cursor.getColumnIndex(TableChapter.TOTAL)));
      chapter.setTitlePali(cursor.getString(cursor.getColumnIndex(TableChapter.TITLE_PALI)));
      chapter.setTitleEng(cursor.getString(cursor.getColumnIndex(TableChapter.TITLE_ENG)));
      chapter.setTitleId(cursor.getString(cursor.getColumnIndex(TableChapter.TITLE_ID)));

      SearchVerse verse = new SearchVerse(chapter, cursor);
      if (verse.getContentPali().toLowerCase().indexOf(query.toLowerCase()) >= 0) {
        verse.setSearchContent(getQueryPart(verse.getContentPali(), query));
      } else if (verse.getContentEng().toLowerCase().indexOf(query.toLowerCase()) >= 0) {
        verse.setSearchContent(getQueryPart(verse.getContentEng(), query));
      } else if (verse.getContentId().toLowerCase().indexOf(query.toLowerCase()) >= 0) {
        verse.setSearchContent(getQueryPart(verse.getContentId(), query));
      }
      verse.setQuery(query);
      view.setTag(verse);
      log.v(this, "verse.getIndex():" + verse.getIndex() + "|" + verse.getContentPali());
      log.v(this, "verse.getIndex():" + verse.getIndex() + "|" + verse.getContentEng());
      log.v(this, "verse.getIndex():" + verse.getIndex() + "|" + verse.getContentId());

      TextView txtSearchChapter = (TextView) view.findViewById(R.id.searchChapter);
      TextView txtSearchVerseIndex = (TextView) view.findViewById(R.id.searchVerseIndex);
      TextView txtSearchVerseContent = (TextView) view.findViewById(R.id.searchVerseContent);

      txtSearchChapter.setTypeface(tf);
      txtSearchVerseIndex.setTypeface(tf);
      //		    txtSearchVerseContent.setTypeface(tf);

      txtSearchChapter.setText(verse.getChapter().getTitlePali());
      txtSearchVerseIndex.setText("" + verse.getIndex());
      log.v(this, "verse.getSearchContent():" + verse.getSearchContent());
      txtSearchVerseContent.setText(Html.fromHtml(verse.getSearchContent()));
    }