public ArrayList<LogLine> performFilteringOnList(List<LogLine> inputList, CharSequence query) { SearchCriteria searchCriteria = new SearchCriteria(query); // search by log level ArrayList<LogLine> allValues = new ArrayList<LogLine>(); ArrayList<LogLine> logLines; synchronized (mLock) { logLines = new ArrayList<LogLine>(inputList); } for (LogLine logLine : logLines) { if (logLine != null && LogLineAdapterUtil.logLevelIsAcceptableGivenLogLevelLimit( logLine.getLogLevel(), logLevelLimit)) { allValues.add(logLine); } } ArrayList<LogLine> finalValues = allValues; // search by criteria if (!searchCriteria.isEmpty()) { final ArrayList<LogLine> values = allValues; final int count = values.size(); final ArrayList<LogLine> newValues = new ArrayList<LogLine>(count); for (int i = 0; i < count; i++) { final LogLine value = values.get(i); // search the logline based on the criteria if (searchCriteria.matches(value)) { newValues.add(value); } } finalValues = newValues; } // sort here to ensure that filtering the list doesn't mess up the // sorting if (mComparator != null) { Collections.sort((List<LogLine>) finalValues, mComparator); } return finalValues; }
private View createViewFromResource(int position, View view, ViewGroup parent, int resource) { Context context = parent.getContext(); LogLineViewWrapper wrapper; if (view == null) { view = mInflater.inflate(resIdLogcatListItem, parent, false); wrapper = new LogLineViewWrapper(view); view.setTag(wrapper); } else { wrapper = (LogLineViewWrapper) view.getTag(); } TextView levelTextView = wrapper.getLevelTextView(); TextView outputTextView = wrapper.getOutputTextView(); TextView tagTextView = wrapper.getTagTextView(); TextView pidTextView = wrapper.getPidTextView(); TextView timestampTextView = wrapper.getTimestampTextView(); LogLine logLine; try { logLine = (LogLine) getItem(position); } catch (IndexOutOfBoundsException e) { // XXX hack - I sometimes get array index out of bounds exceptions // here // no idea how to solve it, so this is the best I can do // logLine = LogLine.newLogLine("", // PreferenceHelper.getExpandedByDefaultPreference(context)); logLine = LogLine.newLogLine("", false); } levelTextView.setText(Character.toString(LogLine.convertLogLevelToChar(logLine.getLogLevel()))); levelTextView.setBackgroundColor( LogLineAdapterUtil.getBackgroundColorForLogLevel(context, logLine.getLogLevel())); levelTextView.setTextColor( LogLineAdapterUtil.getForegroundColorForLogLevel(context, logLine.getLogLevel())); levelTextView.setVisibility(logLine.getLogLevel() == -1 ? View.GONE : View.VISIBLE); // empty tag indicates this is the line like "beginning of dev/log..." CharSequence output = (logLine.isExpanded() || TextUtils.isEmpty(logLine.getTag())) ? logLine.getLogOutput() : StringUtil.ellipsizeString(logLine.getLogOutput(), outputTextView); outputTextView.setSingleLine(!logLine.isExpanded()); outputTextView.setText(output); outputTextView.setTextColor(Color.WHITE); CharSequence tag = logLine.isExpanded() ? logLine.getTag() : StringUtil.ellipsizeString(logLine.getTag(), tagTextView); tagTextView.setSingleLine(!logLine.isExpanded()); tagTextView.setText(tag); tagTextView.setVisibility(logLine.getLogLevel() == -1 ? View.GONE : View.VISIBLE); tagTextView.setTextColor(Color.WHITE); // set the text size based on the preferences // float textSize = PreferenceHelper.getTextSizePreference(context); float textSize = 15; tagTextView.setTextSize(TypedValue.COMPLEX_UNIT_SP, textSize); outputTextView.setTextSize(TypedValue.COMPLEX_UNIT_SP, textSize); levelTextView.setTextSize(TypedValue.COMPLEX_UNIT_SP, textSize); pidTextView.setText( logLine.getProcessId() != -1 ? Integer.toString(logLine.getProcessId()) : null); pidTextView.setTextColor(Color.WHITE); timestampTextView.setText("Time: " + logLine.getTimestamp()); timestampTextView.setTextColor(Color.WHITE); return view; }