Java Code Examples for com.google.zxing.client.android.LocaleManager#isBookSearchUrl()
The following examples show how to use
com.google.zxing.client.android.LocaleManager#isBookSearchUrl() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SearchBookContentsActivity.java From barcodescanner-lib-aar with MIT License | 6 votes |
@Override protected JSONObject doInBackground(String... args) { try { // These return a JSON result which describes if and where the query was found. This API may // break or disappear at any time in the future. Since this is an API call rather than a // website, we don't use LocaleManager to change the TLD. String theQuery = args[0]; String theIsbn = args[1]; String uri; if (LocaleManager.isBookSearchUrl(theIsbn)) { int equals = theIsbn.indexOf('='); String volumeId = theIsbn.substring(equals + 1); uri = "http://www.google.com/books?id=" + volumeId + "&jscmd=SearchWithinVolume2&q=" + theQuery; } else { uri = "http://www.google.com/books?vid=isbn" + theIsbn + "&jscmd=SearchWithinVolume2&q=" + theQuery; } CharSequence content = HttpHelper.downloadViaHttp(uri, HttpHelper.ContentType.JSON); return new JSONObject(content.toString()); } catch (IOException ioe) { Log.w(TAG, "Error accessing book search", ioe); return null; } catch (JSONException je) { Log.w(TAG, "Error accessing book search", je); return null; } }
Example 2
Source File: SearchBookContentsActivity.java From ZXing-Standalone-library with Apache License 2.0 | 6 votes |
@Override protected JSONObject doInBackground(String... args) { try { // These return a JSON result which describes if and where the query was found. This API may // break or disappear at any time in the future. Since this is an API call rather than a // website, we don't use LocaleManager to change the TLD. String theQuery = args[0]; String theIsbn = args[1]; String uri; if (LocaleManager.isBookSearchUrl(theIsbn)) { int equals = theIsbn.indexOf('='); String volumeId = theIsbn.substring(equals + 1); uri = "http://www.google.com/books?id=" + volumeId + "&jscmd=SearchWithinVolume2&q=" + theQuery; } else { uri = "http://www.google.com/books?vid=isbn" + theIsbn + "&jscmd=SearchWithinVolume2&q=" + theQuery; } CharSequence content = HttpHelper.downloadViaHttp(uri, HttpHelper.ContentType.JSON); return new JSONObject(content.toString()); } catch (IOException ioe) { Log.w(TAG, "Error accessing book search", ioe); return null; } catch (JSONException je) { Log.w(TAG, "Error accessing book search", je); return null; } }
Example 3
Source File: SearchBookContentsActivity.java From reacteu-app with MIT License | 6 votes |
@Override protected JSONObject doInBackground(String... args) { try { // These return a JSON result which describes if and where the query was found. This API may // break or disappear at any time in the future. Since this is an API call rather than a // website, we don't use LocaleManager to change the TLD. String theQuery = args[0]; String theIsbn = args[1]; String uri; if (LocaleManager.isBookSearchUrl(theIsbn)) { int equals = theIsbn.indexOf('='); String volumeId = theIsbn.substring(equals + 1); uri = "http://www.google.com/books?id=" + volumeId + "&jscmd=SearchWithinVolume2&q=" + theQuery; } else { uri = "http://www.google.com/books?vid=isbn" + theIsbn + "&jscmd=SearchWithinVolume2&q=" + theQuery; } CharSequence content = HttpHelper.downloadViaHttp(uri, HttpHelper.ContentType.JSON); return new JSONObject(content.toString()); } catch (IOException ioe) { Log.w(TAG, "Error accessing book search", ioe); return null; } catch (JSONException je) { Log.w(TAG, "Error accessing book search", je); return null; } }
Example 4
Source File: BrowseBookListener.java From analyzer-of-android-for-Apache-Weex with Apache License 2.0 | 6 votes |
@Override public void onItemClick(AdapterView<?> parent, View v, int position, long id) { if (position < 1) { // Clicked header, ignore it return; } int itemOffset = position - 1; if (itemOffset >= items.size()) { return; } String pageId = items.get(itemOffset).getPageId(); String query = SearchBookContentsResult.getQuery(); if (LocaleManager.isBookSearchUrl(activity.getISBN()) && !pageId.isEmpty()) { String uri = activity.getISBN(); int equals = uri.indexOf('='); String volumeId = uri.substring(equals + 1); String readBookURI = "http://books.google." + LocaleManager.getBookSearchCountryTLD(activity) + "/books?id=" + volumeId + "&pg=" + pageId + "&vq=" + query; Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(readBookURI)); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET); activity.startActivity(intent); } }
Example 5
Source File: SearchBookContentsActivity.java From analyzer-of-android-for-Apache-Weex with Apache License 2.0 | 6 votes |
@Override protected JSONObject doInBackground(String... args) { try { // These return a JSON result which describes if and where the query was found. This API may // break or disappear at any time in the future. Since this is an API call rather than a // website, we don't use LocaleManager to change the TLD. String theQuery = args[0]; String theIsbn = args[1]; String uri; if (LocaleManager.isBookSearchUrl(theIsbn)) { int equals = theIsbn.indexOf('='); String volumeId = theIsbn.substring(equals + 1); uri = "http://www.google.com/books?id=" + volumeId + "&jscmd=SearchWithinVolume2&q=" + theQuery; } else { uri = "http://www.google.com/books?vid=isbn" + theIsbn + "&jscmd=SearchWithinVolume2&q=" + theQuery; } CharSequence content = HttpHelper.downloadViaHttp(uri, HttpHelper.ContentType.JSON); return new JSONObject(content.toString()); } catch (IOException ioe) { Log.w(TAG, "Error accessing book search", ioe); return null; } catch (JSONException je) { Log.w(TAG, "Error accessing book search", je); return null; } }
Example 6
Source File: BrowseBookListener.java From android-apps with MIT License | 6 votes |
public void onItemClick(AdapterView<?> parent, View v, int position, long id) { if (position < 1) { // Clicked header, ignore it return; } String pageId = items.get(position - 1).getPageId(); String query = SearchBookContentsResult.getQuery(); if (LocaleManager.isBookSearchUrl(activity.getISBN()) && pageId.length() > 0) { String uri = activity.getISBN(); int equals = uri.indexOf('='); String volumeId = uri.substring(equals + 1); String readBookURI = "http://books.google." + LocaleManager.getBookSearchCountryTLD(activity) + "/books?id=" + volumeId + "&pg=" + pageId + "&vq=" + query; Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(readBookURI)); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET); activity.startActivity(intent); } }
Example 7
Source File: BrowseBookListener.java From weex with Apache License 2.0 | 6 votes |
@Override public void onItemClick(AdapterView<?> parent, View v, int position, long id) { if (position < 1) { // Clicked header, ignore it return; } int itemOffset = position - 1; if (itemOffset >= items.size()) { return; } String pageId = items.get(itemOffset).getPageId(); String query = SearchBookContentsResult.getQuery(); if (LocaleManager.isBookSearchUrl(activity.getISBN()) && !pageId.isEmpty()) { String uri = activity.getISBN(); int equals = uri.indexOf('='); String volumeId = uri.substring(equals + 1); String readBookURI = "http://books.google." + LocaleManager.getBookSearchCountryTLD(activity) + "/books?id=" + volumeId + "&pg=" + pageId + "&vq=" + query; Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(readBookURI)); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET); activity.startActivity(intent); } }
Example 8
Source File: BrowseBookListener.java From zxingfragmentlib with Apache License 2.0 | 6 votes |
@Override public void onItemClick(AdapterView<?> parent, View v, int position, long id) { if (position < 1) { // Clicked header, ignore it return; } int itemOffset = position - 1; if (itemOffset >= items.size()) { return; } String pageId = items.get(itemOffset).getPageId(); String query = SearchBookContentsResult.getQuery(); if (LocaleManager.isBookSearchUrl(activity.getISBN()) && !pageId.isEmpty()) { String uri = activity.getISBN(); int equals = uri.indexOf('='); String volumeId = uri.substring(equals + 1); String readBookURI = "http://books.google." + LocaleManager.getBookSearchCountryTLD(activity) + "/books?id=" + volumeId + "&pg=" + pageId + "&vq=" + query; Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(readBookURI)); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET); activity.startActivity(intent); } }
Example 9
Source File: SearchBookContentsActivity.java From weex with Apache License 2.0 | 6 votes |
@Override protected JSONObject doInBackground(String... args) { try { // These return a JSON result which describes if and where the query was found. This API may // break or disappear at any time in the future. Since this is an API call rather than a // website, we don't use LocaleManager to change the TLD. String theQuery = args[0]; String theIsbn = args[1]; String uri; if (LocaleManager.isBookSearchUrl(theIsbn)) { int equals = theIsbn.indexOf('='); String volumeId = theIsbn.substring(equals + 1); uri = "http://www.google.com/books?id=" + volumeId + "&jscmd=SearchWithinVolume2&q=" + theQuery; } else { uri = "http://www.google.com/books?vid=isbn" + theIsbn + "&jscmd=SearchWithinVolume2&q=" + theQuery; } CharSequence content = HttpHelper.downloadViaHttp(uri, HttpHelper.ContentType.JSON); return new JSONObject(content.toString()); } catch (IOException ioe) { Log.w(TAG, "Error accessing book search", ioe); return null; } catch (JSONException je) { Log.w(TAG, "Error accessing book search", je); return null; } }
Example 10
Source File: BrowseBookListener.java From Study_Android_Demo with Apache License 2.0 | 6 votes |
@Override public void onItemClick(AdapterView<?> parent, View v, int position, long id) { if (position < 1) { // Clicked header, ignore it return; } int itemOffset = position - 1; if (itemOffset >= items.size()) { return; } String pageId = items.get(itemOffset).getPageId(); String query = SearchBookContentsResult.getQuery(); if (LocaleManager.isBookSearchUrl(activity.getISBN()) && !pageId.isEmpty()) { String uri = activity.getISBN(); int equals = uri.indexOf('='); String volumeId = uri.substring(equals + 1); String readBookURI = "http://books.google." + LocaleManager.getBookSearchCountryTLD(activity) + "/books?id=" + volumeId + "&pg=" + pageId + "&vq=" + query; Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(readBookURI)); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET); activity.startActivity(intent); } }
Example 11
Source File: URIResultHandler.java From barcodescanner-lib-aar with MIT License | 5 votes |
@Override public int getButtonCount() { if (LocaleManager.isBookSearchUrl(((URIParsedResult) getResult()).getURI())) { return buttons.length; } return buttons.length - 1; }
Example 12
Source File: SearchBookContentsActivity.java From barcodescanner-lib-aar with MIT License | 5 votes |
@Override public void onCreate(Bundle icicle) { super.onCreate(icicle); // Make sure that expired cookies are removed on launch. CookieSyncManager.createInstance(this); CookieManager.getInstance().removeExpiredCookie(); Intent intent = getIntent(); if (intent == null || !Intents.SearchBookContents.ACTION.equals(intent.getAction())) { finish(); return; } isbn = intent.getStringExtra(Intents.SearchBookContents.ISBN); if (LocaleManager.isBookSearchUrl(isbn)) { setTitle(getString(R.string.sbc_name)); } else { setTitle(getString(R.string.sbc_name) + ": ISBN " + isbn); } setContentView(R.layout.search_book_contents); queryTextView = (EditText) findViewById(R.id.query_text_view); String initialQuery = intent.getStringExtra(Intents.SearchBookContents.QUERY); if (initialQuery != null && !initialQuery.isEmpty()) { // Populate the search box but don't trigger the search queryTextView.setText(initialQuery); } queryTextView.setOnKeyListener(keyListener); queryButton = findViewById(R.id.query_button); queryButton.setOnClickListener(buttonListener); resultListView = (ListView) findViewById(R.id.result_list_view); LayoutInflater factory = LayoutInflater.from(this); headerView = (TextView) factory.inflate(R.layout.search_book_contents_header, resultListView, false); resultListView.addHeaderView(headerView); }
Example 13
Source File: URIResultHandler.java From Study_Android_Demo with Apache License 2.0 | 5 votes |
@Override public int getButtonCount() { if (LocaleManager.isBookSearchUrl(((URIParsedResult) getResult()).getURI())) { return buttons.length; } return buttons.length - 1; }
Example 14
Source File: URIResultHandler.java From zxingfragmentlib with Apache License 2.0 | 5 votes |
@Override public int getButtonCount() { if (LocaleManager.isBookSearchUrl(((URIParsedResult) getResult()).getURI())) { return buttons.length; } return buttons.length - 1; }
Example 15
Source File: SearchBookContentsActivity.java From Study_Android_Demo with Apache License 2.0 | 5 votes |
@Override public void onCreate(Bundle icicle) { super.onCreate(icicle); // Make sure that expired cookies are removed on launch. CookieSyncManager.createInstance(this); CookieManager.getInstance().removeExpiredCookie(); Intent intent = getIntent(); if (intent == null || !Intents.SearchBookContents.ACTION.equals(intent.getAction())) { finish(); return; } isbn = intent.getStringExtra(Intents.SearchBookContents.ISBN); if (LocaleManager.isBookSearchUrl(isbn)) { setTitle(getString(R.string.sbc_name)); } else { setTitle(getString(R.string.sbc_name) + ": ISBN " + isbn); } setContentView(R.layout.search_book_contents); queryTextView = (EditText) findViewById(R.id.query_text_view); String initialQuery = intent.getStringExtra(Intents.SearchBookContents.QUERY); if (initialQuery != null && !initialQuery.isEmpty()) { // Populate the search box but don't trigger the search queryTextView.setText(initialQuery); } queryTextView.setOnKeyListener(keyListener); queryButton = findViewById(R.id.query_button); queryButton.setOnClickListener(buttonListener); resultListView = (ListView) findViewById(R.id.result_list_view); LayoutInflater factory = LayoutInflater.from(this); headerView = (TextView) factory.inflate(R.layout.search_book_contents_header, resultListView, false); resultListView.addHeaderView(headerView); }
Example 16
Source File: URIResultHandler.java From weex with Apache License 2.0 | 5 votes |
@Override public int getButtonCount() { if (LocaleManager.isBookSearchUrl(((URIParsedResult) getResult()).getURI())) { return buttons.length; } return buttons.length - 1; }
Example 17
Source File: SearchBookContentsActivity.java From android-apps with MIT License | 5 votes |
@Override public void onCreate(Bundle icicle) { super.onCreate(icicle); // Make sure that expired cookies are removed on launch. CookieSyncManager.createInstance(this); CookieManager.getInstance().removeExpiredCookie(); Intent intent = getIntent(); if (intent == null || !intent.getAction().equals(Intents.SearchBookContents.ACTION)) { finish(); return; } isbn = intent.getStringExtra(Intents.SearchBookContents.ISBN); if (LocaleManager.isBookSearchUrl(isbn)) { setTitle(getString(R.string.sbc_name)); } else { setTitle(getString(R.string.sbc_name) + ": ISBN " + isbn); } setContentView(R.layout.search_book_contents); queryTextView = (EditText) findViewById(R.id.query_text_view); String initialQuery = intent.getStringExtra(Intents.SearchBookContents.QUERY); if (initialQuery != null && initialQuery.length() > 0) { // Populate the search box but don't trigger the search queryTextView.setText(initialQuery); } queryTextView.setOnKeyListener(keyListener); queryButton = (Button) findViewById(R.id.query_button); queryButton.setOnClickListener(buttonListener); resultListView = (ListView) findViewById(R.id.result_list_view); LayoutInflater factory = LayoutInflater.from(this); headerView = (TextView) factory.inflate(R.layout.search_book_contents_header, resultListView, false); resultListView.addHeaderView(headerView); }
Example 18
Source File: URIResultHandler.java From android-apps with MIT License | 5 votes |
@Override public int getButtonCount() { if (LocaleManager.isBookSearchUrl(((URIParsedResult) getResult()).getURI())) { return buttons.length; } return buttons.length - 1; }
Example 19
Source File: SearchBookContentsActivity.java From ZXing-Standalone-library with Apache License 2.0 | 5 votes |
@Override public void onCreate(Bundle icicle) { super.onCreate(icicle); // Make sure that expired cookies are removed on launch. CookieSyncManager.createInstance(this); CookieManager.getInstance().removeExpiredCookie(); Intent intent = getIntent(); if (intent == null || !Intents.SearchBookContents.ACTION.equals(intent.getAction())) { finish(); return; } isbn = intent.getStringExtra(Intents.SearchBookContents.ISBN); if (LocaleManager.isBookSearchUrl(isbn)) { setTitle(getString(R.string.sbc_name)); } else { setTitle(getString(R.string.sbc_name) + ": ISBN " + isbn); } setContentView(R.layout.search_book_contents); queryTextView = (EditText) findViewById(R.id.query_text_view); String initialQuery = intent.getStringExtra(Intents.SearchBookContents.QUERY); if (initialQuery != null && !initialQuery.isEmpty()) { // Populate the search box but don't trigger the search queryTextView.setText(initialQuery); } queryTextView.setOnKeyListener(keyListener); queryButton = findViewById(R.id.query_button); queryButton.setOnClickListener(buttonListener); resultListView = (ListView) findViewById(R.id.result_list_view); LayoutInflater factory = LayoutInflater.from(this); headerView = (TextView) factory.inflate(R.layout.search_book_contents_header, resultListView, false); resultListView.addHeaderView(headerView); }
Example 20
Source File: SearchBookContentsActivity.java From reacteu-app with MIT License | 4 votes |
@Override public void onCreate(Bundle icicle) { super.onCreate(icicle); fakeR = new FakeR(this); // Make sure that expired cookies are removed on launch. CookieSyncManager.createInstance(this); CookieManager.getInstance().removeExpiredCookie(); Intent intent = getIntent(); if (intent == null || !intent.getAction().equals(Intents.SearchBookContents.ACTION)) { finish(); return; } isbn = intent.getStringExtra(Intents.SearchBookContents.ISBN); if (LocaleManager.isBookSearchUrl(isbn)) { setTitle(getString(fakeR.getId("string", "sbc_name"))); } else { setTitle(getString(fakeR.getId("string", "sbc_name")) + ": ISBN " + isbn); } setContentView(fakeR.getId("layout", "search_book_contents")); queryTextView = (EditText) findViewById(fakeR.getId("id", "query_text_view")); String initialQuery = intent.getStringExtra(Intents.SearchBookContents.QUERY); if (initialQuery != null && initialQuery.length() > 0) { // Populate the search box but don't trigger the search queryTextView.setText(initialQuery); } queryTextView.setOnKeyListener(keyListener); queryButton = (Button) findViewById(fakeR.getId("id", "query_button")); queryButton.setOnClickListener(buttonListener); resultListView = (ListView) findViewById(fakeR.getId("id", "result_list_view")); LayoutInflater factory = LayoutInflater.from(this); headerView = (TextView) factory.inflate(fakeR.getId("layout", "search_book_contents_header"), resultListView, false); resultListView.addHeaderView(headerView); }