Java Code Examples for java.util.Locale

The following code examples are extracted from open source projects. You can click to vote up the examples that are useful to you.

Example 1

From project acceleo-modules, under directory /psm-gen-scala/plugins/com.github.sbegaudeau.acceleo.modules.psm.gen.scala/src/com/github/sbegaudeau/acceleo/modules/psm/gen/scala/services/.

Source file: CommonServices.java

  32 
vote

/** 
 * Get the date in a long format : January 12, 1952
 * @return String representing the long format date
 */
public static String genLongDate(){
  Date date=new Date();
  Locale locale=Locale.getDefault();
  DateFormat dateFormatShort=DateFormat.getDateInstance(DateFormat.LONG,locale);
  return dateFormatShort.format(date);
}
 

Example 2

From project aether-core, under directory /aether-util/src/test/java/org/eclipse/aether/util/version/.

Source file: GenericVersionTest.java

  32 
vote

@Test public void testCaseInsensitiveOrderingOfQualifiersIsLocaleIndependent(){
  Locale orig=Locale.getDefault();
  try {
    Locale[] locales={Locale.ENGLISH,new Locale("tr")};
    for (    Locale locale : locales) {
      Locale.setDefault(locale);
      assertOrder(X_EQ_Y,"1-abcdefghijklmnopqrstuvwxyz","1-ABCDEFGHIJKLMNOPQRSTUVWXYZ");
    }
  }
  finally {
    Locale.setDefault(orig);
  }
}
 

Example 3

From project alphaportal_dev, under directory /sys-src/alphaportal/web/src/main/java/alpha/portal/webapp/controller/.

Source file: CardFileUploadController.java

  32 
vote

/** 
 * shows the card file upload site.
 * @param request the request
 * @return FileUpload
 * @see cardfileupload.jsp
 */
@ModelAttribute @RequestMapping(method=RequestMethod.GET) public FileUpload showForm(final HttpServletRequest request){
  final String caseId=request.getParameter("case");
  final String cardId=request.getParameter("card");
  final Locale locale=request.getLocale();
  request.setAttribute("case",caseId);
  request.setAttribute("card",cardId);
  this.setCancelView("redirect:/caseform?caseId=" + caseId + "&activeCardId="+ cardId);
  this.setSuccessView("redirect:/caseform?caseId=" + caseId + "&activeCardId="+ cardId);
  return new FileUpload();
}
 

Example 4

From project AmDroid, under directory /httpclientandroidlib/src/ch/boye/httpclientandroidlib/impl/.

Source file: DefaultHttpResponseFactory.java

  32 
vote

public HttpResponse newHttpResponse(final ProtocolVersion ver,final int status,HttpContext context){
  if (ver == null) {
    throw new IllegalArgumentException("HTTP version may not be null");
  }
  final Locale loc=determineLocale(context);
  final String reason=reasonCatalog.getReason(status,loc);
  StatusLine statusline=new BasicStatusLine(ver,status,reason);
  return new BasicHttpResponse(statusline,reasonCatalog,loc);
}
 

Example 5

From project android-context, under directory /defunct/.

Source file: ContextBrowserActivity.java

  32 
vote

public void onInit(int status){
  Locale loc=Locale.getDefault();
  if (tts.isLanguageAvailable(loc) >= TextToSpeech.LANG_AVAILABLE) {
    tts.setLanguage(loc);
  }
  tts.speak("Text to Speach Initialized",TextToSpeech.QUEUE_FLUSH,null);
}
 

Example 6

From project android-thaiime, under directory /latinime/src/com/android/inputmethod/compat/.

Source file: InputMethodManagerCompatWrapper.java

  32 
vote

@SuppressWarnings("unused") private InputMethodSubtypeCompatWrapper getLastResortSubtype(String mode){
  if (VOICE_MODE.equals(mode) && !FORCE_ENABLE_VOICE_EVEN_WITH_NO_VOICE_SUBTYPES)   return null;
  Locale inputLocale=SubtypeSwitcher.getInstance().getInputLocale();
  if (inputLocale == null)   return null;
  return new InputMethodSubtypeCompatWrapper(0,0,inputLocale.toString(),mode,"");
}
 

Example 7

From project activejdbc, under directory /activejdbc/src/test/java/org/javalite/activejdbc/.

Source file: ValidationWithResourceBundlesTest.java

  31 
vote

@Test public void shouldPullCorrectMessageWithParametersGerman(){
  School s=new School();
  s.set("school_name","School of Computer Science");
  s.set("email","computer#science.edu");
  s.validate();
  a(s.errors(new Locale("de","DE")).get("email",s.get("school_name"),s.get("email"),"computer@science.edu")).shouldBeEqual("EMail Format f\u00fcr die Schule School of Computer Science ist falsch: computer#science.edu, ein geeignetes Format w\u00e4re so etwas wie dieses: computer@science.edu");
}
 

Example 8

From project and-bible, under directory /AndBible/src/net/bible/android/.

Source file: BibleApplication.java

  31 
vote

@Override public void onCreate(){
  super.onCreate();
  singleton=this;
  Log.i(TAG,"OS:" + System.getProperty("os.name") + " ver "+ System.getProperty("os.version"));
  Log.i(TAG,"Java:" + System.getProperty("java.vendor") + " ver "+ System.getProperty("java.version"));
  Log.i(TAG,"Java home:" + System.getProperty("java.home"));
  Log.i(TAG,"User dir:" + System.getProperty("user.dir") + " Timezone:"+ System.getProperty("user.timezone"));
  Thread.currentThread().setContextClassLoader(getClass().getClassLoader());
  installJSwordErrorReportListener();
  upgradePersistentData();
  ProgressNotificationManager.getInstance().initialise();
  allowLocaleOverride();
  Locale locale=Locale.getDefault();
  Log.i(TAG,"Locale language:" + locale.getLanguage() + " Variant:"+ locale.getDisplayName());
}
 

Example 9

From project android_aosp_packages_apps_Settings, under directory /src/com/android/settings/.

Source file: TetherSettings.java

  31 
vote

@Override protected Dialog onCreateDialog(int id){
  if (id == DIALOG_TETHER_HELP) {
    Locale locale=Locale.getDefault();
    AssetManager am=getAssets();
    String path=HELP_PATH.replace("%y",locale.getLanguage().toLowerCase());
    path=path.replace("%z","_" + locale.getCountry().toLowerCase());
    boolean useCountry=true;
    InputStream is=null;
    try {
      is=am.open(path);
    }
 catch (    Exception e) {
      useCountry=false;
    }
 finally {
      if (is != null) {
        try {
          is.close();
        }
 catch (        Exception e) {
        }
      }
    }
    String url=HELP_URL.replace("%y",locale.getLanguage().toLowerCase());
    url=url.replace("%z",(useCountry ? "_" + locale.getCountry().toLowerCase() : ""));
    if ((mUsbRegexs.length != 0) && (mWifiRegexs.length == 0)) {
      url=url.replace("%x",USB_HELP_MODIFIER);
    }
 else     if ((mWifiRegexs.length != 0) && (mUsbRegexs.length == 0)) {
      url=url.replace("%x",WIFI_HELP_MODIFIER);
    }
 else {
      url=url.replace("%x","");
    }
    mView.loadUrl(url);
    return new AlertDialog.Builder(this).setCancelable(true).setTitle(R.string.tethering_help_button_text).setView(mView).create();
  }
  return null;
}
 

Example 10

From project android_8, under directory /src/com/google/gson/.

Source file: DefaultTypeAdapters.java

  30 
vote

@Override public Locale deserialize(JsonElement json,Type typeOfT,JsonDeserializationContext context) throws JsonParseException {
  String locale=json.getAsString();
  StringTokenizer tokenizer=new StringTokenizer(locale,"_");
  String language=null;
  String country=null;
  String variant=null;
  if (tokenizer.hasMoreElements()) {
    language=tokenizer.nextToken();
  }
  if (tokenizer.hasMoreElements()) {
    country=tokenizer.nextToken();
  }
  if (tokenizer.hasMoreElements()) {
    variant=tokenizer.nextToken();
  }
  if (country == null && variant == null) {
    return new Locale(language);
  }
 else   if (variant == null) {
    return new Locale(language,country);
  }
 else {
    return new Locale(language,country,variant);
  }
}
 

Example 11

From project 2Degrees-Toolbox, under directory /ActionBarSherlock/src/com/actionbarsherlock/internal/widget/.

Source file: CapitalizingButton.java

  29 
vote

public void setTextCompat(CharSequence text){
  if (SANS_ICE_CREAM && mAllCaps && text != null) {
    if (IS_GINGERBREAD) {
      setText(text.toString().toUpperCase(Locale.ROOT));
    }
 else {
      setText(text.toString().toUpperCase());
    }
  }
 else {
    setText(text);
  }
}
 

Example 12

From project 3Dto2DApplet, under directory /src/java/nl/dannyarends/generator/model/.

Source file: AbstractGenerator.java

  29 
vote

public Map<String,Object> createArguments(){
  Map<String,Object> args=new TreeMap<String,Object>();
  Calendar calendar=Calendar.getInstance();
  args.put("year",calendar.get(Calendar.YEAR));
  DateFormat formatter=new SimpleDateFormat("MMMM d, yyyy, HH:mm:ss",Locale.US);
  args.put("datetime",formatter.format(new Date()));
  formatter=new SimpleDateFormat("MMMM d, yyyy",Locale.US);
  args.put("date",formatter.format(new Date()));
  return args;
}
 

Example 13

From project 4308Cirrus, under directory /Extras/actionbarsherlock/src/com/actionbarsherlock/internal/widget/.

Source file: CapitalizingButton.java

  29 
vote

public void setTextCompat(CharSequence text){
  if (SANS_ICE_CREAM && mAllCaps && text != null) {
    if (IS_GINGERBREAD) {
      setText(text.toString().toUpperCase(Locale.ROOT));
    }
 else {
      setText(text.toString().toUpperCase());
    }
  }
 else {
    setText(text);
  }
}
 

Example 14

From project ActionBarSherlock, under directory /library/src/com/actionbarsherlock/internal/widget/.

Source file: CapitalizingButton.java

  29 
vote

public void setTextCompat(CharSequence text){
  if (SANS_ICE_CREAM && mAllCaps && text != null) {
    if (IS_GINGERBREAD) {
      setText(text.toString().toUpperCase(Locale.ROOT));
    }
 else {
      setText(text.toString().toUpperCase());
    }
  }
 else {
    setText(text);
  }
}
 

Example 15

From project activemq-apollo, under directory /apollo-util/src/main/scala/org/apache/activemq/apollo/util/tar/.

Source file: TarEntry.java

  29 
vote

/** 
 * Strips Windows' drive letter as well as any leading slashes, turns path separators into forward slahes.
 */
private static String normalizeFileName(String fileName,boolean preserveLeadingSlashes){
  String osname=System.getProperty("os.name").toLowerCase(Locale.ENGLISH);
  if (osname != null) {
    if (osname.startsWith("windows")) {
      if (fileName.length() > 2) {
        char ch1=fileName.charAt(0);
        char ch2=fileName.charAt(1);
        if (ch2 == ':' && ((ch1 >= 'a' && ch1 <= 'z') || (ch1 >= 'A' && ch1 <= 'Z'))) {
          fileName=fileName.substring(2);
        }
      }
    }
 else     if (osname.indexOf("netware") > -1) {
      int colon=fileName.indexOf(':');
      if (colon != -1) {
        fileName=fileName.substring(colon + 1);
      }
    }
  }
  fileName=fileName.replace(File.separatorChar,'/');
  while (!preserveLeadingSlashes && fileName.startsWith("/")) {
    fileName=fileName.substring(1);
  }
  return fileName;
}
 

Example 16

From project activiti-explorer, under directory /src/main/java/org/activiti/explorer/.

Source file: ExplorerApp.java

  29 
vote

public void setLocale(Locale locale){
  super.setLocale(locale);
  if (i18nManager != null) {
    i18nManager.createResourceBundle();
  }
}
 

Example 17

From project AdServing, under directory /modules/services/tracking/src/main/java/net/mad/ads/services/tracking/impl/local/h2/example/.

Source file: H2Test.java

  29 
vote

private static void trackData(TrackingService ts,int index,String id,boolean click) throws ServiceException {
  Calendar created=Calendar.getInstance(Locale.GERMANY);
  created.set(Calendar.MONTH,Calendar.JANUARY);
  created.set(Calendar.DAY_OF_WEEK,Calendar.MONDAY);
  created.set(Calendar.MINUTE,0);
  created.set(Calendar.HOUR_OF_DAY,0);
  created.set(Calendar.SECOND,0);
  created.add(Calendar.SECOND,index);
  TrackEvent event=null;
  if (click) {
    event=new ClickTrackEvent();
  }
 else {
    event=new ImpressionTrackEvent();
  }
  event.put(EventAttribute.TIME,DateHelper.format(created.getTime()));
  event.setTime(created.getTime().getTime());
  event.setCampaign("c1");
  event.setSite("demo Site");
  event.put(EventAttribute.AD_ID,"b1");
  event.setUser("user1");
  event.setId(id);
  event.setIp("ip1");
  ts.track(event);
}
 

Example 18

From project aether-ant, under directory /src/main/java/org/eclipse/aether/ant/.

Source file: AntRepoSys.java

  29 
vote

private Properties getEnvProperties(Properties props){
  if (props == null) {
    props=new Properties();
  }
  boolean envCaseInsensitive=OS_WINDOWS;
  for (  Map.Entry<String,String> entry : System.getenv().entrySet()) {
    String key=entry.getKey();
    if (envCaseInsensitive) {
      key=key.toUpperCase(Locale.ENGLISH);
    }
    key="env." + key;
    props.put(key,entry.getValue());
  }
  return props;
}
 

Example 19

From project aether-demo, under directory /aether-demo-snippets/src/main/java/org/eclipse/aether/examples/util/.

Source file: ConsoleTransferListener.java

  29 
vote

@Override public void transferSucceeded(TransferEvent event){
  transferCompleted(event);
  TransferResource resource=event.getResource();
  long contentLength=event.getTransferredBytes();
  if (contentLength >= 0) {
    String type=(event.getRequestType() == TransferEvent.RequestType.PUT ? "Uploaded" : "Downloaded");
    String len=contentLength >= 1024 ? toKB(contentLength) + " KB" : contentLength + " B";
    String throughput="";
    long duration=System.currentTimeMillis() - resource.getTransferStartTime();
    if (duration > 0) {
      DecimalFormat format=new DecimalFormat("0.0",new DecimalFormatSymbols(Locale.ENGLISH));
      double kbPerSec=(contentLength / 1024.0) / (duration / 1000.0);
      throughput=" at " + format.format(kbPerSec) + " KB/sec";
    }
    out.println(type + ": " + resource.getRepositoryUrl()+ resource.getResourceName()+ " ("+ len+ throughput+ ")");
  }
}
 

Example 20

From project agileBase, under directory /gtpb_server/src/com/gtwm/pb/model/manageData/fields/.

Source file: DateValueDefn.java

  29 
vote

public String toString(){
  if (this.isNull()) {
    return "";
  }
 else {
switch (this.dateResolution) {
case Calendar.YEAR:
      return String.format(Locale.UK,"%1$tY",this.getValueDate());
case Calendar.MONTH:
    return String.format(Locale.UK,"%1$tb-%1$tY",this.getValueDate());
case Calendar.DAY_OF_MONTH:
  return String.format(Locale.UK,"%1$td-%1$tb-%1$tY",this.getValueDate());
case Calendar.HOUR_OF_DAY:
return String.format(Locale.UK,"%1$td-%1$tb-%1$tY %1$tH",this.getValueDate());
case Calendar.MINUTE:
return String.format(Locale.UK,"%1$td-%1$tb-%1$tY %1$tH:%1$tM",this.getValueDate());
case Calendar.SECOND:
return String.format(Locale.UK,"%1$td-%1$tb-%1$tY %1$tH:%1$tM:%1$tS",this.getValueDate());
}
return String.format(Locale.UK,"%1$td-%1$tb-%1$tY %1$tH:%1$tM:%1$tS",this.getValueDate());
}
}
 

Example 21

From project agorava-facebook, under directory /agorava-facebook-api/src/main/java/org/agorava/facebook/model/.

Source file: FacebookProfile.java

  29 
vote

public FacebookProfile(String id,String username,String name,String firstName,String lastName,String gender,Locale locale){
  super(id);
  this.username=username;
  this.name=name;
  this.firstName=firstName;
  this.lastName=lastName;
  this.gender=gender;
  this.locale=locale;
}
 

Example 22

From project agorava-twitter, under directory /agorava-twitter-cdi/src/main/java/org/agorava/twitter/jackson/.

Source file: TimelineDateDeserializer.java

  29 
vote

@Override public Date deserialize(JsonParser jp,DeserializationContext ctxt) throws IOException, JsonProcessingException {
  try {
    return new SimpleDateFormat(TIMELINE_DATE_FORMAT,Locale.ENGLISH).parse(jp.getText());
  }
 catch (  ParseException e) {
    return null;
  }
}
 

Example 23

From project ajah, under directory /ajah-spring-mvc/src/main/java/com/ajah/spring/mvc/servlet/tag/.

Source file: SpringTag.java

  29 
vote

protected String getMessage(final MessageSourceResolvable resolvable){
  final ApplicationContext appContext=(ApplicationContext)this.pageContext.getServletContext().getAttribute("appContext");
  final MessageSource messageSource=appContext.getBean(MessageSource.class);
  if (log.isLoggable(Level.FINEST)) {
    log.finest(StringUtils.join(resolvable.getCodes()));
  }
  return messageSource.getMessage(resolvable,Locale.getDefault());
}
 

Example 24

From project Alerte-voirie-android, under directory /src/com/fabernovel/alertevoirie/.

Source file: ReportDetailsActivity.java

  29 
vote

private String getFormatedDate(String dateString){
  SimpleDateFormat parser=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
  SimpleDateFormat formatter=new SimpleDateFormat("EEEE dd MMMM - HH:mm",Locale.FRENCH);
  try {
    return formatter.format(parser.parse(dateString));
  }
 catch (  ParseException e) {
    e.printStackTrace();
  }
  return dateString;
}
 

Example 25

From project alg-vis, under directory /src/algvis/core/.

Source file: WordGenerator.java

  29 
vote

public static Vector<String> parseString(String ss){
  Vector<String> ll=new Vector<String>(Arrays.asList(ss.replaceAll("'"," ").split("(\\s|,)+")));
  Vector<String> result=new Vector<String>();
  Pattern p=Pattern.compile("[\\p{InCombiningDiacriticalMarks}\\p{IsLm}\\p{IsSk}]+");
  for (  String s : ll) {
    s=Normalizer.normalize(s,Normalizer.Form.NFD);
    s=p.matcher(s).replaceAll("");
    s=s.toUpperCase(Locale.ENGLISH);
    s=s.replaceAll("[^A-Z]","");
    result.add(s + "$");
  }
  return result;
}
 

Example 26

From project almira-sample, under directory /almira-sample-web-components/src/main/java/almira/sample/web/panel/.

Source file: LocaleDropDownPanel.java

  29 
vote

/** 
 * Add the language panel.
 * @param id the language id
 * @param supportedLocales the list of supported locales
 */
@edu.umd.cs.findbugs.annotations.SuppressWarnings(value={"SE_INNER_CLASS","SIC_INNER_SHOULD_BE_STATIC_ANON"},justification="This is the Wicket way") public LocaleDropDownPanel(String id,List<?> supportedLocales){
  super(id);
  DropDownChoice<Object> localeDropDown=new DropDownChoice<Object>(CHOICE_PATH,supportedLocales){
    @Override protected boolean wantOnSelectionChangedNotifications(){
      return true;
    }
  }
;
  localeDropDown.setChoiceRenderer(new ChoiceRenderer<Object>(){
    @Override public String getDisplayValue(    Object locale){
      return ((Locale)locale).getDisplayName(getLocale());
    }
  }
);
  localeDropDown.setModel(new IModel<Object>(){
    @Override public Object getObject(){
      return getSession().getLocale();
    }
    @Override public void setObject(    Object object){
      getSession().setLocale((Locale)object);
    }
    @Override public void detach(){
    }
  }
);
  add(localeDropDown);
}
 

Example 27

From project Amantech, under directory /Android/action_bar_sherlock/src/com/actionbarsherlock/internal/widget/.

Source file: CapitalizingButton.java

  29 
vote

public void setTextCompat(CharSequence text){
  if (SANS_ICE_CREAM && mAllCaps && text != null) {
    if (IS_GINGERBREAD) {
      setText(text.toString().toUpperCase(Locale.ROOT));
    }
 else {
      setText(text.toString().toUpperCase());
    }
  }
 else {
    setText(text);
  }
}
 

Example 28

From project andlytics, under directory /actionbarsherlock/src/com/actionbarsherlock/internal/widget/.

Source file: CapitalizingButton.java

  29 
vote

public void setTextCompat(CharSequence text){
  if (SANS_ICE_CREAM && mAllCaps && text != null) {
    if (IS_GINGERBREAD) {
      setText(text.toString().toUpperCase(Locale.ROOT));
    }
 else {
      setText(text.toString().toUpperCase());
    }
  }
 else {
    setText(text);
  }
}
 

Example 29

From project Android, under directory /AndroidNolesCore/src/util/.

Source file: News.java

  29 
vote

private SimpleDateFormat getDateFormat(String format){
  SimpleDateFormat sdf=mThreadDate.get();
  if (sdf == null) {
    sdf=new SimpleDateFormat(format,Locale.US);
    mThreadDate.set(sdf);
  }
  return sdf;
}
 

Example 30

From project android-api_1, under directory /android-lib/src/com/catchnotes/api/.

Source file: CatchAPI.java

  29 
vote

/** 
 * Constructor.
 * @param appName The name of your application.
 * @param context Android context.
 */
public CatchAPI(String appName,Context context){
  source=appName;
  mContext=context;
  String version="x.xx";
  try {
    PackageInfo info=mContext.getPackageManager().getPackageInfo(mContext.getPackageName(),0);
    version=info.versionName;
  }
 catch (  Exception e) {
  }
  StringBuilder locale=new StringBuilder(5);
  String language=Locale.getDefault().getLanguage();
  if (language != null) {
    locale.append(language);
    String country=Locale.getDefault().getCountry();
    if (country != null) {
      locale.append('-');
      locale.append(country);
    }
  }
  userAgent=appName + '/' + version+ " (Android; "+ Build.VERSION.RELEASE+ "; "+ Build.BRAND+ "; "+ Build.MODEL+ "; "+ locale.toString()+ ')';
  try {
    if (Integer.parseInt(Build.VERSION.SDK) >= Build.VERSION_CODES.ECLAIR_0_1) {
      timestamper=new Time();
    }
  }
 catch (  Exception e) {
  }
}
 

Example 31

From project android-database-sqlcipher, under directory /src/net/sqlcipher/database/.

Source file: SQLiteDatabase.java

  29 
vote

/** 
 * Private constructor. See  {@link #create} and {@link #openDatabase}.
 * @param path The full path to the database
 * @param factory The factory to use when creating cursors, may be NULL.
 * @param flags 0 or {@link #NO_LOCALIZED_COLLATORS}.  If the database file already exists, mFlags will be updated appropriately.
 */
public SQLiteDatabase(String path,String password,CursorFactory factory,int flags,SQLiteDatabaseHook databaseHook){
  if (path == null) {
    throw new IllegalArgumentException("path should not be null");
  }
  mFlags=flags;
  mPath=path;
  mSlowQueryThreshold=-1;
  mStackTrace=new DatabaseObjectNotClosedException().fillInStackTrace();
  mFactory=factory;
  dbopen(mPath,mFlags);
  if (databaseHook != null) {
    databaseHook.preKey(this);
  }
  execSQL("PRAGMA key = '" + password + "'");
  if (databaseHook != null) {
    databaseHook.postKey(this);
  }
  if (SQLiteDebug.DEBUG_SQL_CACHE) {
    mTimeOpened=getTime();
  }
  mPrograms=new WeakHashMap<SQLiteClosable,Object>();
  try {
    setLocale(Locale.getDefault());
  }
 catch (  RuntimeException e) {
    Log.e(TAG,"Failed to setLocale() when constructing, closing the database",e);
    dbclose();
    if (SQLiteDebug.DEBUG_SQL_CACHE) {
      mTimeClosed=getTime();
    }
    throw e;
  }
}
 

Example 32

From project android-joedayz, under directory /Proyectos/androidMDWCompleto/src/com/android/mdw/demo/.

Source file: Main.java

  29 
vote

protected void updateLocation(Location location){
  MapView mapView=(MapView)findViewById(R.id.mapview);
  MapController mapController=mapView.getController();
  GeoPoint point=new GeoPoint((int)(location.getLatitude() * 1E6),(int)(location.getLongitude() * 1E6));
  mapController.animateTo(point);
  mapController.setZoom(15);
  Geocoder geoCoder=new Geocoder(this,Locale.getDefault());
  try {
    List<Address> addresses=geoCoder.getFromLocation(point.getLatitudeE6() / 1E6,point.getLongitudeE6() / 1E6,1);
    String address="";
    if (addresses.size() > 0) {
      for (int i=0; i < addresses.get(0).getMaxAddressLineIndex(); i++)       address+=addresses.get(0).getAddressLine(i) + "\n";
    }
    Toast.makeText(getBaseContext(),address,Toast.LENGTH_SHORT).show();
  }
 catch (  IOException e) {
    e.printStackTrace();
  }
  List<Overlay> mapOverlays=mapView.getOverlays();
  MyOverlay marker=new MyOverlay(point);
  mapOverlays.add(marker);
  mapView.invalidate();
}
 

Example 33

From project android-pedometer, under directory /src/name/bagi/levente/pedometer/.

Source file: Utils.java

  29 
vote

public void onInit(int status){
  if (status == TextToSpeech.SUCCESS) {
    int result=mTts.setLanguage(Locale.US);
    if (result == TextToSpeech.LANG_MISSING_DATA || result == TextToSpeech.LANG_NOT_SUPPORTED) {
      Log.e(TAG,"Language is not available.");
    }
 else {
      Log.i(TAG,"TextToSpeech Initialized.");
      mSpeakingEngineAvailable=true;
    }
  }
 else {
    Log.e(TAG,"Could not initialize TextToSpeech.");
  }
}
 

Example 34

From project android-sdk, under directory /src/main/java/com/mobeelizer/mobile/android/model/.

Source file: MobeelizerAndroidModel.java

  29 
vote

public MobeelizerAndroidModel(final MobeelizerModelImpl model,final String currentUser,final String currentGroup){
  this.model=model;
  this.currentUser=currentUser;
  this.currentGroup=currentGroup;
  for (  MobeelizerField field : this.model.getFields()) {
    fields.put(field.getName(),new MobeelizerAndroidField((MobeelizerFieldImpl)field));
  }
  tableName=model.getName().toLowerCase(Locale.ENGLISH);
  valuesForDelete=new ContentValues();
  valuesForDelete.put(_MODIFIED,1);
  valuesForDelete.put(_DELETED,1);
}
 

Example 35

From project Android-Terminal-Emulator, under directory /src/jackpal/androidterm/.

Source file: Term.java

  29 
vote

private String makePathFromBundle(Bundle extras){
  if (extras == null || extras.size() == 0) {
    return "";
  }
  String[] keys=new String[extras.size()];
  keys=extras.keySet().toArray(keys);
  Collator collator=Collator.getInstance(Locale.US);
  Arrays.sort(keys,collator);
  StringBuilder path=new StringBuilder();
  for (  String key : keys) {
    String dir=extras.getString(key);
    if (dir != null && !dir.equals("")) {
      path.append(dir);
      path.append(":");
    }
  }
  return path.substring(0,path.length() - 1);
}
 

Example 36

From project android-wheel, under directory /wheel-demo/src/kankan/wheel/demo/.

Source file: Time2Activity.java

  29 
vote

@Override public void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  setContentView(R.layout.time2_layout);
  final WheelView hours=(WheelView)findViewById(R.id.hour);
  NumericWheelAdapter hourAdapter=new NumericWheelAdapter(this,0,23);
  hourAdapter.setItemResource(R.layout.wheel_text_item);
  hourAdapter.setItemTextResource(R.id.text);
  hours.setViewAdapter(hourAdapter);
  final WheelView mins=(WheelView)findViewById(R.id.mins);
  NumericWheelAdapter minAdapter=new NumericWheelAdapter(this,0,59,"%02d");
  minAdapter.setItemResource(R.layout.wheel_text_item);
  minAdapter.setItemTextResource(R.id.text);
  mins.setViewAdapter(minAdapter);
  mins.setCyclic(true);
  final WheelView ampm=(WheelView)findViewById(R.id.ampm);
  ArrayWheelAdapter<String> ampmAdapter=new ArrayWheelAdapter<String>(this,new String[]{"AM","PM"});
  ampmAdapter.setItemResource(R.layout.wheel_text_item);
  ampmAdapter.setItemTextResource(R.id.text);
  ampm.setViewAdapter(ampmAdapter);
  Calendar calendar=Calendar.getInstance(Locale.US);
  hours.setCurrentItem(calendar.get(Calendar.HOUR));
  mins.setCurrentItem(calendar.get(Calendar.MINUTE));
  ampm.setCurrentItem(calendar.get(Calendar.AM_PM));
  final WheelView day=(WheelView)findViewById(R.id.day);
  day.setViewAdapter(new DayArrayAdapter(this,calendar));
}
 

Example 37

From project android-wheel-datetime-picker, under directory /src/kankan/wheel/demo/.

Source file: Time2Activity.java

  29 
vote

@Override public void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  setContentView(R.layout.time2_layout);
  final WheelView hours=(WheelView)findViewById(R.id.hour);
  NumericWheelAdapter hourAdapter=new NumericWheelAdapter(this,0,23,"%2d ?");
  hourAdapter.setItemResource(R.layout.wheel_text_item);
  hourAdapter.setItemTextResource(R.id.text);
  hours.setViewAdapter(hourAdapter);
  hours.setCyclic(true);
  final WheelView mins=(WheelView)findViewById(R.id.mins);
  NumericWheelAdapter minAdapter=new NumericWheelAdapter(this,0,59,"%02d ?");
  minAdapter.setItemResource(R.layout.wheel_text_item);
  minAdapter.setItemTextResource(R.id.text);
  mins.setViewAdapter(minAdapter);
  mins.setCyclic(true);
  Calendar calendar=Calendar.getInstance(Locale.JAPAN);
  hours.setCurrentItem(calendar.get(Calendar.HOUR));
  mins.setCurrentItem(calendar.get(Calendar.MINUTE));
  final WheelView day=(WheelView)findViewById(R.id.day);
  day.setViewAdapter(new DayArrayAdapter(this,calendar));
  day.setCyclic(true);
}
 

Example 38

From project android-wheel_1, under directory /wheel-demo/src/kankan/wheel/demo/.

Source file: Time2Activity.java

  29 
vote

@Override public void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  setContentView(R.layout.time2_layout);
  final WheelView hours=(WheelView)findViewById(R.id.hour);
  NumericWheelAdapter hourAdapter=new NumericWheelAdapter(this,0,23);
  hourAdapter.setItemResource(R.layout.wheel_text_item);
  hourAdapter.setItemTextResource(R.id.text);
  hours.setViewAdapter(hourAdapter);
  final WheelView mins=(WheelView)findViewById(R.id.mins);
  NumericWheelAdapter minAdapter=new NumericWheelAdapter(this,0,59,"%02d");
  minAdapter.setItemResource(R.layout.wheel_text_item);
  minAdapter.setItemTextResource(R.id.text);
  mins.setViewAdapter(minAdapter);
  mins.setCyclic(true);
  final WheelView ampm=(WheelView)findViewById(R.id.ampm);
  ArrayWheelAdapter<String> ampmAdapter=new ArrayWheelAdapter<String>(this,new String[]{"AM","PM"});
  ampmAdapter.setItemResource(R.layout.wheel_text_item);
  ampmAdapter.setItemTextResource(R.id.text);
  ampm.setViewAdapter(ampmAdapter);
  Calendar calendar=Calendar.getInstance(Locale.US);
  hours.setCurrentItem(calendar.get(Calendar.HOUR));
  mins.setCurrentItem(calendar.get(Calendar.MINUTE));
  ampm.setCurrentItem(calendar.get(Calendar.AM_PM));
  final WheelView day=(WheelView)findViewById(R.id.day);
  day.setViewAdapter(new DayArrayAdapter(this,calendar));
}
 

Example 39

From project androidannotations, under directory /AndroidAnnotations/functional-test-1-5-tests/src/test/java/com/googlecode/androidannotations/test15/roboguice/.

Source file: FakeDateProvider.java

  29 
vote

public void setDate(String dateString){
  try {
    date=DateFormat.getDateInstance(DateFormat.LONG,Locale.US).parse(dateString);
  }
 catch (  ParseException e) {
    throw new RuntimeException("bad date!!");
  }
}
 

Example 40

From project androidquery, under directory /src/com/androidquery/service/.

Source file: MarketService.java

  29 
vote

/** 
 * Instantiates a new MarketService.
 * @param act Current activity.
 */
public MarketService(Activity act){
  this.act=act;
  this.aq=new AQuery(act);
  this.handler=new Handler();
  this.locale=Locale.getDefault().toString();
  this.rateUrl=getMarketUrl();
  this.updateUrl=rateUrl;
}
 

Example 41

From project androidZenWriter, under directory /library/src/com/actionbarsherlock/internal/widget/.

Source file: CapitalizingButton.java

  29 
vote

public void setTextCompat(CharSequence text){
  if (SANS_ICE_CREAM && mAllCaps && text != null) {
    if (IS_GINGERBREAD) {
      setText(text.toString().toUpperCase(Locale.ROOT));
    }
 else {
      setText(text.toString().toUpperCase());
    }
  }
 else {
    setText(text);
  }
}
 

Example 42

From project Android_1, under directory /org.eclipse.ecf.android/src/org/eclipse/ecf/android/.

Source file: NLS.java

  29 
vote

private static String[] buildVariants(String root){
  if (nlSuffixes == null) {
    String nl=Locale.getDefault().toString();
    ArrayList result=new ArrayList(4);
    int lastSeparator;
    while (true) {
      result.add('_' + nl + EXTENSION);
      lastSeparator=nl.lastIndexOf('_');
      if (lastSeparator == -1)       break;
      nl=nl.substring(0,lastSeparator);
    }
    result.add(EXTENSION);
    nlSuffixes=(String[])result.toArray(new String[result.size()]);
  }
  root=root.replace('.','/');
  String[] variants=new String[nlSuffixes.length];
  for (int i=0; i < variants.length; i++)   variants[i]=root + nlSuffixes[i];
  return variants;
}
 

Example 43

From project android_7, under directory /src/org/immopoly/android/fragments/.

Source file: HudFragment.java

  29 
vote

public void updateHud(){
  Button hudButton=(Button)getView().findViewById(R.id.hud_text);
  View spacer=(View)getView().findViewById(R.id.hud_progress_spacer);
  View progress=(View)getView().findViewById(R.id.hud_progress);
  if (hudButton != null) {
    if (UserDataManager.instance.getState() == UserDataManager.LOGGED_IN) {
      progress.setVisibility(View.GONE);
      spacer.setVisibility(View.GONE);
      hudButton.setVisibility(View.VISIBLE);
      NumberFormat nFormat=NumberFormat.getCurrencyInstance(Locale.GERMANY);
      nFormat.setMinimumIntegerDigits(1);
      nFormat.setMaximumFractionDigits(0);
      hudButton.setText(nFormat.format(ImmopolyUser.getInstance().getBalance()));
    }
 else     if (UserDataManager.instance.getState() == UserDataManager.USER_UNKNOWN) {
      progress.setVisibility(View.GONE);
      spacer.setVisibility(View.GONE);
      hudButton.setVisibility(View.VISIBLE);
      hudButton.setText(R.string.login_button);
    }
 else     if (UserDataManager.instance.getState() == UserDataManager.LOGIN_PENDING) {
      progress.setVisibility(View.VISIBLE);
      spacer.setVisibility(View.VISIBLE);
      hudButton.setVisibility(View.GONE);
    }
 else {
      Log.i(Const.LOG_TAG,"unknown state " + UserDataManager.instance.getState());
    }
  }
}