am ecfbf462
: Add static construct method for SparseArray
* commit 'ecfbf4625c8afd9cde7b79e0c7846b87e20f79e9': Add static construct method for SparseArray
This commit is contained in:
commit
9779374771
8 changed files with 16 additions and 8 deletions
|
@ -35,6 +35,7 @@ import android.view.inputmethod.EditorInfo;
|
|||
import com.android.inputmethod.keyboard.Key;
|
||||
import com.android.inputmethod.keyboard.Keyboard;
|
||||
import com.android.inputmethod.keyboard.KeyboardView;
|
||||
import com.android.inputmethod.latin.CollectionUtils;
|
||||
|
||||
/**
|
||||
* Exposes a virtual view sub-tree for {@link KeyboardView} and generates
|
||||
|
@ -55,7 +56,7 @@ public class AccessibilityEntityProvider extends AccessibilityNodeProviderCompat
|
|||
private final AccessibilityUtils mAccessibilityUtils;
|
||||
|
||||
/** A map of integer IDs to {@link Key}s. */
|
||||
private final SparseArray<Key> mVirtualViewIdToKey = new SparseArray<Key>();
|
||||
private final SparseArray<Key> mVirtualViewIdToKey = CollectionUtils.newSparseArray();
|
||||
|
||||
/** Temporary rect used to calculate in-screen bounds. */
|
||||
private final Rect mTempBoundsInScreen = new Rect();
|
||||
|
|
|
@ -135,7 +135,7 @@ public class Keyboard {
|
|||
public final Key[] mAltCodeKeysWhileTyping;
|
||||
public final KeyboardIconsSet mIconsSet;
|
||||
|
||||
private final SparseArray<Key> mKeyCache = new SparseArray<Key>();
|
||||
private final SparseArray<Key> mKeyCache = CollectionUtils.newSparseArray();
|
||||
|
||||
private final ProximityInfo mProximityInfo;
|
||||
private final boolean mProximityCharsCorrectionEnabled;
|
||||
|
|
|
@ -117,7 +117,7 @@ public class KeyboardLayoutSet {
|
|||
int mWidth;
|
||||
// Sparse array of KeyboardLayoutSet element parameters indexed by element's id.
|
||||
final SparseArray<ElementParams> mKeyboardLayoutSetElementIdToParamsMap =
|
||||
new SparseArray<ElementParams>();
|
||||
CollectionUtils.newSparseArray();
|
||||
|
||||
static class ElementParams {
|
||||
int mKeyboardXmlId;
|
||||
|
|
|
@ -130,9 +130,9 @@ public class KeyboardView extends View implements PointerTracker.DrawingProxy {
|
|||
private final Paint mPaint = new Paint();
|
||||
private final Paint.FontMetrics mFontMetrics = new Paint.FontMetrics();
|
||||
// This sparse array caches key label text height in pixel indexed by key label text size.
|
||||
private static final SparseArray<Float> sTextHeightCache = new SparseArray<Float>();
|
||||
private static final SparseArray<Float> sTextHeightCache = CollectionUtils.newSparseArray();
|
||||
// This sparse array caches key label text width in pixel indexed by key label text size.
|
||||
private static final SparseArray<Float> sTextWidthCache = new SparseArray<Float>();
|
||||
private static final SparseArray<Float> sTextWidthCache = CollectionUtils.newSparseArray();
|
||||
private static final char[] KEY_LABEL_REFERENCE_CHAR = { 'M' };
|
||||
private static final char[] KEY_NUMERIC_HINT_LABEL_REFERENCE_CHAR = { '8' };
|
||||
|
||||
|
|
|
@ -91,7 +91,7 @@ public class KeyStyles {
|
|||
|
||||
private class DeclaredKeyStyle extends KeyStyle {
|
||||
private final String mParentStyleName;
|
||||
private final SparseArray<Object> mStyleAttributes = new SparseArray<Object>();
|
||||
private final SparseArray<Object> mStyleAttributes = CollectionUtils.newSparseArray();
|
||||
|
||||
public DeclaredKeyStyle(String parentStyleName) {
|
||||
mParentStyleName = parentStyleName;
|
||||
|
|
|
@ -28,6 +28,7 @@ import android.util.SparseArray;
|
|||
import android.widget.RelativeLayout;
|
||||
|
||||
import com.android.inputmethod.keyboard.PointerTracker;
|
||||
import com.android.inputmethod.latin.CollectionUtils;
|
||||
import com.android.inputmethod.latin.R;
|
||||
import com.android.inputmethod.latin.StaticInnerHandlerWrapper;
|
||||
|
||||
|
@ -47,7 +48,7 @@ public class PreviewPlacerView extends RelativeLayout {
|
|||
private int mXOrigin;
|
||||
private int mYOrigin;
|
||||
|
||||
private final SparseArray<PointerTracker> mPointers = new SparseArray<PointerTracker>();
|
||||
private final SparseArray<PointerTracker> mPointers = CollectionUtils.newSparseArray();
|
||||
|
||||
private String mGestureFloatingPreviewText;
|
||||
private int mLastPointerX;
|
||||
|
|
|
@ -63,7 +63,7 @@ public class BinaryDictionary extends Dictionary {
|
|||
private final boolean mUseFullEditDistance;
|
||||
|
||||
private final SparseArray<DicTraverseSession> mDicTraverseSessions =
|
||||
new SparseArray<DicTraverseSession>();
|
||||
CollectionUtils.newSparseArray();
|
||||
|
||||
// TODO: There should be a way to remove used DicTraverseSession objects from
|
||||
// {@code mDicTraverseSessions}.
|
||||
|
|
|
@ -16,6 +16,8 @@
|
|||
|
||||
package com.android.inputmethod.latin;
|
||||
|
||||
import android.util.SparseArray;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
|
@ -86,4 +88,8 @@ public class CollectionUtils {
|
|||
public static <E> CopyOnWriteArrayList<E> newCopyOnWriteArrayList(final E[] array) {
|
||||
return new CopyOnWriteArrayList<E>(array);
|
||||
}
|
||||
|
||||
public static <E> SparseArray<E> newSparseArray() {
|
||||
return new SparseArray<E>();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue