Esempio n. 1
0
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    log.d(this, "onCreateView()");

    View view = inflater.inflate(R.layout.chapter_list, container, false);
    if (view == null) {
      log.w(this, "Problem inflating view, returned null");
      return null;
    }

    View search = view.findViewById(R.id.button_search);
    if (search != null) {
      search.setVisibility(View.INVISIBLE);
    } else {
      search = view.findViewById(R.id.sv_search);
      if (search != null) {
        search.setVisibility(View.INVISIBLE);
      }
    }

    setHasOptionsMenu(true);
    //        getSherlockActivity().getSupportActionBar().setSubtitle("Search Result");
    //        getSherlockActivity().getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    return view;
  }
Esempio n. 2
0
 private String getQueryPart(String content, String query) {
   log.v(this, "getQueryPart(content:" + content + "|query:" + query + ")");
   content = content.toLowerCase();
   int pos = content.indexOf(query);
   int start = pos - 30;
   if (start < 0) {
     start = 0;
   }
   String result = content.substring(start, pos);
   result += "<b>" + query + "</b>";
   int end = pos + (query.length());
   if (result.length() <= 70) {
     end += 70 - result.length();
   }
   if (end > content.length()) {
     end = content.length();
   }
   log.d(this, "start:" + start + "|end:" + end);
   result += content.substring(pos + query.length(), end);
   return result.replaceAll("\n", " ");
 }