Java Code Examples for com.google.zxing.client.android.LocaleManager#getBookSearchCountryTLD()
The following examples show how to use
com.google.zxing.client.android.LocaleManager#getBookSearchCountryTLD() .
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: BrowseBookListener.java From ZXing-Standalone-library 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 2
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 3
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 4
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 5
Source File: BrowseBookListener.java From barcodescanner-lib-aar with MIT License | 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 6
Source File: BrowseBookListener.java From reacteu-app with MIT License | 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.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 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 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: BookResultInfoRetriever.java From ZXing-Standalone-library with Apache License 2.0 | 4 votes |
@Override void retrieveSupplementalInfo() throws IOException { CharSequence contents = HttpHelper.downloadViaHttp("https://www.googleapis.com/books/v1/volumes?q=isbn:" + isbn, HttpHelper.ContentType.JSON); if (contents.length() == 0) { return; } String title; String pages; Collection<String> authors = null; try { JSONObject topLevel = (JSONObject) new JSONTokener(contents.toString()).nextValue(); JSONArray items = topLevel.optJSONArray("items"); if (items == null || items.isNull(0)) { return; } JSONObject volumeInfo = ((JSONObject) items.get(0)).getJSONObject("volumeInfo"); if (volumeInfo == null) { return; } title = volumeInfo.optString("title"); pages = volumeInfo.optString("pageCount"); JSONArray authorsArray = volumeInfo.optJSONArray("authors"); if (authorsArray != null && !authorsArray.isNull(0)) { authors = new ArrayList<>(authorsArray.length()); for (int i = 0; i < authorsArray.length(); i++) { authors.add(authorsArray.getString(i)); } } } catch (JSONException e) { throw new IOException(e); } Collection<String> newTexts = new ArrayList<>(); maybeAddText(title, newTexts); maybeAddTextSeries(authors, newTexts); maybeAddText(pages == null || pages.isEmpty() ? null : pages + "pp.", newTexts); String baseBookUri = "http://www.google." + LocaleManager.getBookSearchCountryTLD(context) + "/search?tbm=bks&source=zxing&q="; append(isbn, source, newTexts.toArray(new String[newTexts.size()]), baseBookUri + isbn); }
Example 10
Source File: BookResultInfoRetriever.java From analyzer-of-android-for-Apache-Weex with Apache License 2.0 | 4 votes |
@Override void retrieveSupplementalInfo() throws IOException { CharSequence contents = HttpHelper.downloadViaHttp("https://www.googleapis.com/books/v1/volumes?q=isbn:" + isbn, HttpHelper.ContentType.JSON); if (contents.length() == 0) { return; } String title; String pages; Collection<String> authors = null; try { JSONObject topLevel = (JSONObject) new JSONTokener(contents.toString()).nextValue(); JSONArray items = topLevel.optJSONArray("items"); if (items == null || items.isNull(0)) { return; } JSONObject volumeInfo = ((JSONObject) items.get(0)).getJSONObject("volumeInfo"); if (volumeInfo == null) { return; } title = volumeInfo.optString("title"); pages = volumeInfo.optString("pageCount"); JSONArray authorsArray = volumeInfo.optJSONArray("authors"); if (authorsArray != null && !authorsArray.isNull(0)) { authors = new ArrayList<>(authorsArray.length()); for (int i = 0; i < authorsArray.length(); i++) { authors.add(authorsArray.getString(i)); } } } catch (JSONException e) { throw new IOException(e); } Collection<String> newTexts = new ArrayList<>(); maybeAddText(title, newTexts); maybeAddTextSeries(authors, newTexts); maybeAddText(pages == null || pages.isEmpty() ? null : pages + "pp.", newTexts); String baseBookUri = "http://www.google." + LocaleManager.getBookSearchCountryTLD(context) + "/search?tbm=bks&source=zxing&q="; append(isbn, source, newTexts.toArray(new String[newTexts.size()]), baseBookUri + isbn); }
Example 11
Source File: BookResultInfoRetriever.java From weex with Apache License 2.0 | 4 votes |
@Override void retrieveSupplementalInfo() throws IOException { CharSequence contents = HttpHelper.downloadViaHttp("https://www.googleapis.com/books/v1/volumes?q=isbn:" + isbn, HttpHelper.ContentType.JSON); if (contents.length() == 0) { return; } String title; String pages; Collection<String> authors = null; try { JSONObject topLevel = (JSONObject) new JSONTokener(contents.toString()).nextValue(); JSONArray items = topLevel.optJSONArray("items"); if (items == null || items.isNull(0)) { return; } JSONObject volumeInfo = ((JSONObject) items.get(0)).getJSONObject("volumeInfo"); if (volumeInfo == null) { return; } title = volumeInfo.optString("title"); pages = volumeInfo.optString("pageCount"); JSONArray authorsArray = volumeInfo.optJSONArray("authors"); if (authorsArray != null && !authorsArray.isNull(0)) { authors = new ArrayList<>(authorsArray.length()); for (int i = 0; i < authorsArray.length(); i++) { authors.add(authorsArray.getString(i)); } } } catch (JSONException e) { throw new IOException(e); } Collection<String> newTexts = new ArrayList<>(); maybeAddText(title, newTexts); maybeAddTextSeries(authors, newTexts); maybeAddText(pages == null || pages.isEmpty() ? null : pages + "pp.", newTexts); String baseBookUri = "http://www.google." + LocaleManager.getBookSearchCountryTLD(context) + "/search?tbm=bks&source=zxing&q="; append(isbn, source, newTexts.toArray(new String[newTexts.size()]), baseBookUri + isbn); }
Example 12
Source File: BookResultInfoRetriever.java From Study_Android_Demo with Apache License 2.0 | 4 votes |
@Override void retrieveSupplementalInfo() throws IOException { CharSequence contents = HttpHelper.downloadViaHttp("https://www.googleapis.com/books/v1/volumes?q=isbn:" + isbn, HttpHelper.ContentType.JSON); if (contents.length() == 0) { return; } String title; String pages; Collection<String> authors = null; try { JSONObject topLevel = (JSONObject) new JSONTokener(contents.toString()).nextValue(); JSONArray items = topLevel.optJSONArray("items"); if (items == null || items.isNull(0)) { return; } JSONObject volumeInfo = ((JSONObject) items.get(0)).getJSONObject("volumeInfo"); if (volumeInfo == null) { return; } title = volumeInfo.optString("title"); pages = volumeInfo.optString("pageCount"); JSONArray authorsArray = volumeInfo.optJSONArray("authors"); if (authorsArray != null && !authorsArray.isNull(0)) { authors = new ArrayList<>(authorsArray.length()); for (int i = 0; i < authorsArray.length(); i++) { authors.add(authorsArray.getString(i)); } } } catch (JSONException e) { throw new IOException(e); } Collection<String> newTexts = new ArrayList<>(); maybeAddText(title, newTexts); maybeAddTextSeries(authors, newTexts); maybeAddText(pages == null || pages.isEmpty() ? null : pages + "pp.", newTexts); String baseBookUri = "http://www.google." + LocaleManager.getBookSearchCountryTLD(context) + "/search?tbm=bks&source=zxing&q="; append(isbn, source, newTexts.toArray(new String[newTexts.size()]), baseBookUri + isbn); }
Example 13
Source File: BookResultInfoRetriever.java From barcodescanner-lib-aar with MIT License | 4 votes |
@Override void retrieveSupplementalInfo() throws IOException { CharSequence contents = HttpHelper.downloadViaHttp("https://www.googleapis.com/books/v1/volumes?q=isbn:" + isbn, HttpHelper.ContentType.JSON); if (contents.length() == 0) { return; } String title; String pages; Collection<String> authors = null; try { JSONObject topLevel = (JSONObject) new JSONTokener(contents.toString()).nextValue(); JSONArray items = topLevel.optJSONArray("items"); if (items == null || items.isNull(0)) { return; } JSONObject volumeInfo = ((JSONObject) items.get(0)).getJSONObject("volumeInfo"); if (volumeInfo == null) { return; } title = volumeInfo.optString("title"); pages = volumeInfo.optString("pageCount"); JSONArray authorsArray = volumeInfo.optJSONArray("authors"); if (authorsArray != null && !authorsArray.isNull(0)) { authors = new ArrayList<>(authorsArray.length()); for (int i = 0; i < authorsArray.length(); i++) { authors.add(authorsArray.getString(i)); } } } catch (JSONException e) { throw new IOException(e); } Collection<String> newTexts = new ArrayList<>(); maybeAddText(title, newTexts); maybeAddTextSeries(authors, newTexts); maybeAddText(pages == null || pages.isEmpty() ? null : pages + "pp.", newTexts); String baseBookUri = "http://www.google." + LocaleManager.getBookSearchCountryTLD(context) + "/search?tbm=bks&source=zxing&q="; append(isbn, source, newTexts.toArray(new String[newTexts.size()]), baseBookUri + isbn); }
Example 14
Source File: BookResultInfoRetriever.java From reacteu-app with MIT License | 4 votes |
@Override void retrieveSupplementalInfo() throws IOException { CharSequence contents = HttpHelper.downloadViaHttp("https://www.googleapis.com/books/v1/volumes?q=isbn:" + isbn, HttpHelper.ContentType.JSON); if (contents.length() == 0) { return; } String title; String pages; Collection<String> authors = null; try { JSONObject topLevel = (JSONObject) new JSONTokener(contents.toString()).nextValue(); JSONArray items = topLevel.optJSONArray("items"); if (items == null || items.isNull(0)) { return; } JSONObject volumeInfo = ((JSONObject) items.get(0)).getJSONObject("volumeInfo"); if (volumeInfo == null) { return; } title = volumeInfo.optString("title"); pages = volumeInfo.optString("pageCount"); JSONArray authorsArray = volumeInfo.optJSONArray("authors"); if (authorsArray != null && !authorsArray.isNull(0)) { authors = new ArrayList<String>(authorsArray.length()); for (int i = 0; i < authorsArray.length(); i++) { authors.add(authorsArray.getString(i)); } } } catch (JSONException e) { throw new IOException(e.toString()); } Collection<String> newTexts = new ArrayList<String>(); if (title != null && title.length() > 0) { newTexts.add(title); } if (authors != null && !authors.isEmpty()) { boolean first = true; StringBuilder authorsText = new StringBuilder(); for (String author : authors) { if (first) { first = false; } else { authorsText.append(", "); } authorsText.append(author); } newTexts.add(authorsText.toString()); } if (pages != null && pages.length() > 0) { newTexts.add(pages + "pp."); } String baseBookUri = "http://www.google." + LocaleManager.getBookSearchCountryTLD(context) + "/search?tbm=bks&source=zxing&q="; append(isbn, source, newTexts.toArray(new String[newTexts.size()]), baseBookUri + isbn); }
Example 15
Source File: BookResultInfoRetriever.java From android-apps with MIT License | 4 votes |
@Override void retrieveSupplementalInfo() throws IOException, InterruptedException { String contents = HttpHelper.downloadViaHttp("https://www.googleapis.com/books/v1/volumes?q=isbn:" + isbn, HttpHelper.ContentType.JSON); if (contents.length() == 0) { return; } String title; String pages; Collection<String> authors = null; try { JSONObject topLevel = (JSONObject) new JSONTokener(contents).nextValue(); JSONArray items = topLevel.optJSONArray("items"); if (items == null || items.isNull(0)) { return; } JSONObject volumeInfo = ((JSONObject) items.get(0)).getJSONObject("volumeInfo"); if (volumeInfo == null) { return; } title = volumeInfo.optString("title"); pages = volumeInfo.optString("pageCount"); JSONArray authorsArray = volumeInfo.optJSONArray("authors"); if (authorsArray != null && !authorsArray.isNull(0)) { authors = new ArrayList<String>(); for (int i = 0; i < authorsArray.length(); i++) { authors.add(authorsArray.getString(i)); } } } catch (JSONException e) { throw new IOException(e.toString()); } Collection<String> newTexts = new ArrayList<String>(); if (title != null && title.length() > 0) { newTexts.add(title); } if (authors != null && !authors.isEmpty()) { boolean first = true; StringBuilder authorsText = new StringBuilder(); for (String author : authors) { if (first) { first = false; } else { authorsText.append(", "); } authorsText.append(author); } newTexts.add(authorsText.toString()); } if (pages != null && pages.length() > 0) { newTexts.add(pages + "pp."); } String baseBookUri = "http://www.google." + LocaleManager.getBookSearchCountryTLD(context) + "/search?tbm=bks&source=zxing&q="; append(isbn, source, newTexts.toArray(new String[newTexts.size()]), baseBookUri + isbn); }
Example 16
Source File: BookResultInfoRetriever.java From zxingfragmentlib with Apache License 2.0 | 4 votes |
@Override void retrieveSupplementalInfo() throws IOException { CharSequence contents = HttpHelper.downloadViaHttp("https://www.googleapis.com/books/v1/volumes?q=isbn:" + isbn, HttpHelper.ContentType.JSON); if (contents.length() == 0) { return; } String title; String pages; Collection<String> authors = null; try { JSONObject topLevel = (JSONObject) new JSONTokener(contents.toString()).nextValue(); JSONArray items = topLevel.optJSONArray("items"); if (items == null || items.isNull(0)) { return; } JSONObject volumeInfo = ((JSONObject) items.get(0)).getJSONObject("volumeInfo"); if (volumeInfo == null) { return; } title = volumeInfo.optString("title"); pages = volumeInfo.optString("pageCount"); JSONArray authorsArray = volumeInfo.optJSONArray("authors"); if (authorsArray != null && !authorsArray.isNull(0)) { authors = new ArrayList<>(authorsArray.length()); for (int i = 0; i < authorsArray.length(); i++) { authors.add(authorsArray.getString(i)); } } } catch (JSONException e) { throw new IOException(e); } Collection<String> newTexts = new ArrayList<>(); maybeAddText(title, newTexts); maybeAddTextSeries(authors, newTexts); maybeAddText(pages == null || pages.isEmpty() ? null : pages + "pp.", newTexts); String baseBookUri = "http://www.google." + LocaleManager.getBookSearchCountryTLD(context) + "/search?tbm=bks&source=zxing&q="; append(isbn, source, newTexts.toArray(new String[newTexts.size()]), baseBookUri + isbn); }