示例#1
0
	/**
	 * Starts searching procedure in backend.
	 */
	public void searchClicked() {
		
		// Convert search string to UTF-8.
		String searchString = searchEdit.getText().toString();
		try {
			searchString = URLEncoder.encode(searchString, "UTF-8");
		} catch (UnsupportedEncodingException e) {}

		// Display progress bar.
		setProgressBarVisibility(true);
		
		// No input? No need to search.
		if("".equals(searchString)) {
			listFragment.updateList(new ArrayList<Book>());
			return;
		}
		
		// Create a new callback object, which refers to our searchDone(). 
		Callback c = new Callback() {
			public void handleMessage(Message msg) {
				SearchFragment.this.searchDone(msg);
			}
		};
		
		// Call backend search.
		BackendFactory.getBackend().search(searchString, 0, c);
		listFragment.setLastSearchString(searchString);
	}
示例#2
0
	/**
	 * Is used to get more search results after the first page has already been
	 * fetched.
	 * @param page - What page do you want?
	 * @param searchString - What are you searching for?
	 */
	public void getMoreSearchResults(int page, String searchString) {
		
		setProgressBarVisibility(true);
		
		// Create a new callback object, which refers to our searchDone(). 
		Callback c = new Callback() {
			public void handleMessage(Message msg) {
				SearchFragment.this.moreSearchDone(msg);
			}
		};
		
		// Call backend search.
		Log.d("Jonis", "searching..... on page    "+page);
		BackendFactory.getBackend().search(searchString, page, c);
	}