mirror of
https://github.com/zxing/zxing.git
synced 2025-02-02 05:41:08 -08:00
Don't use books.google.cn for Book Search -- doesn't exist. Also a few tiny tweaks.
git-svn-id: https://zxing.googlecode.com/svn/trunk@965 59b500cc-1b3d-0410-9834-0bbf25fbcc57
This commit is contained in:
parent
9bc1fe4695
commit
96025842a1
|
@ -43,10 +43,17 @@ public final class LocaleManager {
|
|||
// Google Product Search for mobile is available in fewer countries than web search.
|
||||
private static final Map<Locale,String> GOOGLE_PRODUCT_SEARCH_COUNTRY_TLD;
|
||||
static {
|
||||
GOOGLE_PRODUCT_SEARCH_COUNTRY_TLD = new HashMap<Locale,String>();
|
||||
GOOGLE_PRODUCT_SEARCH_COUNTRY_TLD = new HashMap<Locale,String>(3);
|
||||
GOOGLE_PRODUCT_SEARCH_COUNTRY_TLD.put(Locale.UK, "co.uk");
|
||||
}
|
||||
|
||||
private static final Map<Locale,String> GOOGLE_BOOK_SEARCH_COUNTRY_TLD;
|
||||
static {
|
||||
GOOGLE_BOOK_SEARCH_COUNTRY_TLD = new HashMap<Locale,String>(13);
|
||||
GOOGLE_BOOK_SEARCH_COUNTRY_TLD.putAll(GOOGLE_COUNTRY_TLD);
|
||||
GOOGLE_BOOK_SEARCH_COUNTRY_TLD.remove(Locale.CHINA);
|
||||
}
|
||||
|
||||
private LocaleManager() {}
|
||||
|
||||
/**
|
||||
|
@ -54,15 +61,7 @@ public final class LocaleManager {
|
|||
* (e.g. "co.uk" for the United Kingdom)
|
||||
*/
|
||||
public static String getCountryTLD() {
|
||||
Locale locale = Locale.getDefault();
|
||||
if (locale == null) {
|
||||
return DEFAULT_TLD;
|
||||
}
|
||||
String tld = GOOGLE_COUNTRY_TLD.get(locale);
|
||||
if (tld == null) {
|
||||
return DEFAULT_TLD;
|
||||
}
|
||||
return tld;
|
||||
return doGetTLD(GOOGLE_COUNTRY_TLD);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -70,11 +69,24 @@ public final class LocaleManager {
|
|||
* @return The top-level domain to use.
|
||||
*/
|
||||
public static String getProductSearchCountryTLD() {
|
||||
return doGetTLD(GOOGLE_PRODUCT_SEARCH_COUNTRY_TLD);
|
||||
}
|
||||
|
||||
/**
|
||||
* The same as above, but specifically for Google Book Search.
|
||||
* @return The top-level domain to use.
|
||||
*/
|
||||
public static String getBookSearchCountryTLD() {
|
||||
return doGetTLD(GOOGLE_BOOK_SEARCH_COUNTRY_TLD);
|
||||
}
|
||||
|
||||
|
||||
private static String doGetTLD(Map<Locale,String> map) {
|
||||
Locale locale = Locale.getDefault();
|
||||
if (locale == null) {
|
||||
return DEFAULT_TLD;
|
||||
}
|
||||
String tld = GOOGLE_PRODUCT_SEARCH_COUNTRY_TLD.get(locale);
|
||||
String tld = map.get(locale);
|
||||
if (tld == null) {
|
||||
return DEFAULT_TLD;
|
||||
}
|
||||
|
|
|
@ -138,8 +138,7 @@ public abstract class ResultHandler {
|
|||
long milliseconds = date.getTime();
|
||||
if (when.length() == 16 && when.charAt(15) == 'Z') {
|
||||
Calendar calendar = new GregorianCalendar();
|
||||
int offset = (calendar.get(java.util.Calendar.ZONE_OFFSET) +
|
||||
calendar.get(java.util.Calendar.DST_OFFSET));
|
||||
int offset = calendar.get(Calendar.ZONE_OFFSET) + calendar.get(Calendar.DST_OFFSET);
|
||||
milliseconds += offset;
|
||||
}
|
||||
return milliseconds;
|
||||
|
@ -261,8 +260,8 @@ public abstract class ResultHandler {
|
|||
}
|
||||
|
||||
public final void openBookSearch(String isbn) {
|
||||
Uri uri = Uri.parse("http://books.google." + LocaleManager.getCountryTLD() + "/books?vid=isbn" +
|
||||
isbn);
|
||||
Uri uri = Uri.parse("http://books.google." + LocaleManager.getBookSearchCountryTLD() +
|
||||
"/books?vid=isbn" + isbn);
|
||||
launchIntent(new Intent(Intent.ACTION_VIEW, uri));
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue