Android Open Source - HexaKey Letter Recources Cache






From Project

Back to project page HexaKey.

License

The source code is released under:

Apache License

If you think the Android project HexaKey listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package es.csc.android.hexakey;
/*w w  w.  j  a  va  2 s .  c  om*/
import java.util.HashMap;

import android.content.Context;
import android.view.inputmethod.InputMethodSubtype;

public class LetterRecourcesCache extends HashMap<String, Integer> {
  private static final String LETTERS_XML_PREFIX = "letters_";  
  private static final String DEFAULT_LOCALE = "default";
  
  public int get(Context context, InputMethodSubtype subtype) {
    String locale = subtype.getLocale();
    if (this.containsKey(locale)) {
      return get(locale);
    }
    else {
      int resourceId = findLocaleOrDefault(context, locale);
      put(locale, resourceId);
      return resourceId;
    }
  }

  private int findLocaleOrDefault(Context context, String locale) {
    int resourceId = context.getResources().getIdentifier(LETTERS_XML_PREFIX + locale, "xml", context.getPackageName());    
    if (resourceId == 0) {
      resourceId = context.getResources().getIdentifier(LETTERS_XML_PREFIX + DEFAULT_LOCALE, "xml", context.getPackageName());
    }
    return resourceId;
  }
}




Java Source Code List

es.csc.android.hexakey.HexaKey.java
es.csc.android.hexakey.ImePreferences.java
es.csc.android.hexakey.LatinKeyboardSet.java
es.csc.android.hexakey.LatinKeyboardView.java
es.csc.android.hexakey.LatinKeyboard.java
es.csc.android.hexakey.LetterRecourcesCache.java
es.csc.android.hexakey.inputmethodcommon.InputMethodSettingsFragment.java
es.csc.android.hexakey.inputmethodcommon.InputMethodSettingsImpl.java
es.csc.android.hexakey.inputmethodcommon.InputMethodSettingsInterface.java