FileDocCategorySizeDatePackage
SkbPool.javaAPI DocAndroid 1.5 API2929Wed May 06 22:42:48 BST 2009com.android.inputmethod.pinyin

SkbPool

public class SkbPool extends Object
Class used to cache previously loaded soft keyboard layouts.

Fields Summary
private static SkbPool
mInstance
private Vector
mSkbTemplates
private Vector
mSoftKeyboards
Constructors Summary
private SkbPool()


      
    
Methods Summary
public static com.android.inputmethod.pinyin.SkbPoolgetInstance()

        if (null == mInstance) mInstance = new SkbPool();
        return mInstance;
    
public SkbTemplategetSkbTemplate(int skbTemplateId, android.content.Context context)

        for (int i = 0; i < mSkbTemplates.size(); i++) {
            SkbTemplate t = mSkbTemplates.elementAt(i);
            if (t.getSkbTemplateId() == skbTemplateId) {
                return t;
            }
        }

        if (null != context) {
            XmlKeyboardLoader xkbl = new XmlKeyboardLoader(context);
            SkbTemplate t = xkbl.loadSkbTemplate(skbTemplateId);
            if (null != t) {
                mSkbTemplates.add(t);
                return t;
            }
        }
        return null;
    
public SoftKeyboardgetSoftKeyboard(int skbCacheId, int skbXmlId, int skbWidth, int skbHeight, android.content.Context context)

        for (int i = 0; i < mSoftKeyboards.size(); i++) {
            SoftKeyboard skb = mSoftKeyboards.elementAt(i);
            if (skb.getCacheId() == skbCacheId && skb.getSkbXmlId() == skbXmlId) {
                skb.setSkbCoreSize(skbWidth, skbHeight);
                skb.setNewlyLoadedFlag(false);
                return skb;
            }
        }
        if (null != context) {
            XmlKeyboardLoader xkbl = new XmlKeyboardLoader(context);
            SoftKeyboard skb = xkbl.loadKeyboard(skbXmlId, skbWidth, skbHeight);
            if (skb != null) {
                if (skb.getCacheFlag()) {
                    skb.setCacheId(skbCacheId);
                    mSoftKeyboards.add(skb);
                }
            }
            return skb;
        }
        return null;
    
public voidresetCachedSkb()

        mSoftKeyboards.clear();