am 6726bc90: Merge "Use Java 7 diamond operator"

* commit '6726bc90014c8d9c1710e4b52aa019d3e945f407':
  Use Java 7 diamond operator
main
Tadashi G. Takaoka 2014-05-23 16:44:51 +00:00 committed by Android Git Automerger
commit 3b500f7bd1
141 changed files with 366 additions and 592 deletions

View File

@ -17,7 +17,8 @@
# Keep classes that are used as a parameter type of methods that are also marked as keep
# to preserve changing those methods' signature.
-keep class com.android.inputmethod.latin.utils.LanguageModelParam
-keep class com.android.inputmethod.latin.AssetFileAddress
-keep class com.android.inputmethod.latin.makedict.ProbabilityInfo
-keep class com.android.inputmethod.latin.Dictionary
-keep class com.android.inputmethod.latin.PrevWordsInfo
-keep class com.android.inputmethod.latin.makedict.ProbabilityInfo
-keep class com.android.inputmethod.latin.utils.LanguageModelParam

View File

@ -17,13 +17,8 @@
package com.android.inputmethod.accessibility;
import android.content.Context;
import android.os.SystemClock;
import android.support.v4.view.accessibility.AccessibilityEventCompat;
import android.support.v4.view.accessibility.AccessibilityNodeInfoCompat;
import android.util.SparseIntArray;
import android.view.MotionEvent;
import com.android.inputmethod.keyboard.Key;
import com.android.inputmethod.keyboard.KeyDetector;
import com.android.inputmethod.keyboard.Keyboard;
import com.android.inputmethod.keyboard.KeyboardId;

View File

@ -27,7 +27,6 @@ import com.android.inputmethod.latin.LatinImeLogger;
import com.android.inputmethod.latin.SuggestedWords;
import com.android.inputmethod.latin.SuggestedWords.SuggestedWordInfo;
import com.android.inputmethod.latin.SuggestionSpanPickedNotificationReceiver;
import com.android.inputmethod.latin.utils.CollectionUtils;
import java.lang.reflect.Field;
import java.util.ArrayList;
@ -73,7 +72,7 @@ public final class SuggestionSpanUtils {
return pickedWord;
}
final ArrayList<String> suggestionsList = CollectionUtils.newArrayList();
final ArrayList<String> suggestionsList = new ArrayList<>();
for (int i = 0; i < suggestedWords.size(); ++i) {
if (suggestionsList.size() >= SuggestionSpan.SUGGESTIONS_MAX_SIZE) {
break;

View File

@ -16,7 +16,6 @@
package com.android.inputmethod.dictionarypack;
import android.app.DownloadManager;
import android.app.DownloadManager.Request;
import android.content.ContentValues;
import android.content.Context;
@ -600,7 +599,7 @@ public final class ActionBatch {
private final Queue<Action> mActions;
public ActionBatch() {
mActions = new LinkedList<Action>();
mActions = new LinkedList<>();
}
public void add(final Action a) {

View File

@ -29,7 +29,6 @@ import android.view.View;
import android.widget.ProgressBar;
public class DictionaryDownloadProgressBar extends ProgressBar {
@SuppressWarnings("unused")
private static final String TAG = DictionaryDownloadProgressBar.class.getSimpleName();
private static final int NOT_A_DOWNLOADMANAGER_PENDING_ID = 0;
@ -119,7 +118,6 @@ public class DictionaryDownloadProgressBar extends ProgressBar {
try {
final UpdateHelper updateHelper = new UpdateHelper();
final Query query = new Query().setFilterById(mId);
int lastProgress = 0;
setIndeterminate(true);
while (!isInterrupted()) {
final Cursor cursor = mDownloadManagerWrapper.query(query);

View File

@ -18,8 +18,6 @@ package com.android.inputmethod.dictionarypack;
import android.view.View;
import com.android.inputmethod.latin.utils.CollectionUtils;
import java.util.ArrayList;
import java.util.HashMap;
@ -39,8 +37,8 @@ public class DictionaryListInterfaceState {
public int mStatus = MetadataDbHelper.STATUS_UNKNOWN;
}
private HashMap<String, State> mWordlistToState = CollectionUtils.newHashMap();
private ArrayList<View> mViewCache = CollectionUtils.newArrayList();
private HashMap<String, State> mWordlistToState = new HashMap<>();
private ArrayList<View> mViewCache = new ArrayList<>();
public boolean isOpen(final String wordlistId) {
final State state = mWordlistToState.get(wordlistId);

View File

@ -357,7 +357,7 @@ public final class DictionaryProvider extends ContentProvider {
return Collections.<WordListInfo>emptyList();
}
try {
final HashMap<String, WordListInfo> dicts = new HashMap<String, WordListInfo>();
final HashMap<String, WordListInfo> dicts = new HashMap<>();
final int idIndex = results.getColumnIndex(MetadataDbHelper.WORDLISTID_COLUMN);
final int localeIndex = results.getColumnIndex(MetadataDbHelper.LOCALE_COLUMN);
final int localFileNameIndex =

View File

@ -33,13 +33,13 @@ import android.preference.PreferenceGroup;
import android.text.TextUtils;
import android.text.format.DateUtils;
import android.util.Log;
import android.view.animation.AnimationUtils;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.AnimationUtils;
import com.android.inputmethod.latin.R;
@ -67,8 +67,8 @@ public final class DictionarySettingsFragment extends PreferenceFragment
private boolean mChangedSettings;
private DictionaryListInterfaceState mDictionaryListInterfaceState =
new DictionaryListInterfaceState();
private TreeMap<String, WordListPreference> mCurrentPreferenceMap =
new TreeMap<String, WordListPreference>(); // never null
// never null
private TreeMap<String, WordListPreference> mCurrentPreferenceMap = new TreeMap<>();
private final BroadcastReceiver mConnectivityChangedReceiver = new BroadcastReceiver() {
@Override
@ -280,19 +280,18 @@ public final class DictionarySettingsFragment extends PreferenceFragment
: activity.getContentResolver().query(contentUri, null, null, null, null);
if (null == cursor) {
final ArrayList<Preference> result = new ArrayList<Preference>();
final ArrayList<Preference> result = new ArrayList<>();
result.add(createErrorMessage(activity, R.string.cannot_connect_to_dict_service));
return result;
}
try {
if (!cursor.moveToFirst()) {
final ArrayList<Preference> result = new ArrayList<Preference>();
final ArrayList<Preference> result = new ArrayList<>();
result.add(createErrorMessage(activity, R.string.no_dictionaries_available));
return result;
} else {
final String systemLocaleString = Locale.getDefault().toString();
final TreeMap<String, WordListPreference> prefMap =
new TreeMap<String, WordListPreference>();
final TreeMap<String, WordListPreference> prefMap = new TreeMap<>();
final int idIndex = cursor.getColumnIndex(MetadataDbHelper.WORDLISTID_COLUMN);
final int versionIndex = cursor.getColumnIndex(MetadataDbHelper.VERSION_COLUMN);
final int localeIndex = cursor.getColumnIndex(MetadataDbHelper.LOCALE_COLUMN);

View File

@ -175,7 +175,7 @@ public final class LocaleUtils {
return saveLocale;
}
private static final HashMap<String, Locale> sLocaleCache = new HashMap<String, Locale>();
private static final HashMap<String, Locale> sLocaleCache = new HashMap<>();
/**
* Creates a locale from a string specification.

View File

@ -160,7 +160,7 @@ public class MetadataDbHelper extends SQLiteOpenHelper {
// this legacy database. New clients should make sure to always pass a client ID so as
// to avoid conflicts.
final String clientId = null != clientIdOrNull ? clientIdOrNull : "";
if (null == sInstanceMap) sInstanceMap = new TreeMap<String, MetadataDbHelper>();
if (null == sInstanceMap) sInstanceMap = new TreeMap<>();
MetadataDbHelper helper = sInstanceMap.get(clientId);
if (null == helper) {
helper = new MetadataDbHelper(context, clientId);
@ -639,7 +639,7 @@ public class MetadataDbHelper extends SQLiteOpenHelper {
public static ArrayList<DownloadRecord> getDownloadRecordsForDownloadId(final Context context,
final long downloadId) {
final SQLiteDatabase defaultDb = getDb(context, "");
final ArrayList<DownloadRecord> results = new ArrayList<DownloadRecord>();
final ArrayList<DownloadRecord> results = new ArrayList<>();
final Cursor cursor = defaultDb.query(CLIENT_TABLE_NAME, CLIENT_TABLE_COLUMNS,
null, null, null, null, null);
try {
@ -923,7 +923,7 @@ public class MetadataDbHelper extends SQLiteOpenHelper {
// - Remove the old entry from the table
// - Erase the old file
// We start by gathering the names of the files we should delete.
final List<String> filenames = new LinkedList<String>();
final List<String> filenames = new LinkedList<>();
final Cursor c = db.query(METADATA_TABLE_NAME,
new String[] { LOCAL_FILENAME_COLUMN },
LOCALE_COLUMN + " = ? AND " +

View File

@ -43,7 +43,7 @@ public class MetadataHandler {
* @return the constructed list of wordlist metadata.
*/
private static List<WordListMetadata> makeMetadataObject(final Cursor results) {
final ArrayList<WordListMetadata> buildingMetadata = new ArrayList<WordListMetadata>();
final ArrayList<WordListMetadata> buildingMetadata = new ArrayList<>();
if (null != results && results.moveToFirst()) {
final int localeColumn = results.getColumnIndex(MetadataDbHelper.LOCALE_COLUMN);
final int typeColumn = results.getColumnIndex(MetadataDbHelper.TYPE_COLUMN);

View File

@ -52,7 +52,7 @@ public class MetadataParser {
*/
private static WordListMetadata parseOneWordList(final JsonReader reader)
throws IOException, BadFormatException {
final TreeMap<String, String> arguments = new TreeMap<String, String>();
final TreeMap<String, String> arguments = new TreeMap<>();
reader.beginObject();
while (reader.hasNext()) {
final String name = reader.nextName();
@ -100,7 +100,7 @@ public class MetadataParser {
public static List<WordListMetadata> parseMetadata(final InputStreamReader input)
throws IOException, BadFormatException {
JsonReader reader = new JsonReader(input);
final ArrayList<WordListMetadata> readInfo = new ArrayList<WordListMetadata>();
final ArrayList<WordListMetadata> readInfo = new ArrayList<>();
reader.beginArray();
while (reader.hasNext()) {
final WordListMetadata thisMetadata = parseOneWordList(reader);

View File

@ -177,7 +177,7 @@ public final class UpdateHandler {
*/
public static boolean tryUpdate(final Context context, final boolean updateNow) {
// TODO: loop through all clients instead of only doing the default one.
final TreeSet<String> uris = new TreeSet<String>();
final TreeSet<String> uris = new TreeSet<>();
final Cursor cursor = MetadataDbHelper.queryClientIds(context);
if (null == cursor) return false;
try {
@ -557,7 +557,7 @@ public final class UpdateHandler {
// Instantiation of a parameterized type is not possible in Java, so it's not possible to
// return the same type of list that was passed - probably the same reason why Collections
// does not do it. So we need to decide statically which concrete type to return.
return new LinkedList<T>(src);
return new LinkedList<>(src);
}
/**
@ -740,10 +740,10 @@ public final class UpdateHandler {
final ActionBatch actions = new ActionBatch();
// Upgrade existing word lists
DebugLogUtils.l("Comparing dictionaries");
final Set<String> wordListIds = new TreeSet<String>();
final Set<String> wordListIds = new TreeSet<>();
// TODO: Can these be null?
if (null == from) from = new ArrayList<WordListMetadata>();
if (null == to) to = new ArrayList<WordListMetadata>();
if (null == from) from = new ArrayList<>();
if (null == to) to = new ArrayList<>();
for (WordListMetadata wlData : from) wordListIds.add(wlData.mId);
for (WordListMetadata wlData : to) wordListIds.add(wlData.mId);
for (String id : wordListIds) {

View File

@ -20,7 +20,6 @@ import android.text.SpannableStringBuilder;
import android.text.TextUtils;
import com.android.inputmethod.latin.Constants;
import com.android.inputmethod.latin.utils.CollectionUtils;
import java.util.ArrayList;
import java.util.HashMap;
@ -44,8 +43,8 @@ public class CombinerChain {
private SpannableStringBuilder mStateFeedback;
private final ArrayList<Combiner> mCombiners;
private static final HashMap<String, Class> IMPLEMENTED_COMBINERS
= new HashMap<String, Class>();
private static final HashMap<String, Class<? extends Combiner>> IMPLEMENTED_COMBINERS =
new HashMap<>();
static {
IMPLEMENTED_COMBINERS.put("MyanmarReordering", MyanmarReordering.class);
}
@ -63,7 +62,7 @@ public class CombinerChain {
* @param combinerList A list of combiners to be applied in order.
*/
public CombinerChain(final String initialText, final Combiner... combinerList) {
mCombiners = CollectionUtils.newArrayList();
mCombiners = new ArrayList<>();
// The dead key combiner is always active, and always first
mCombiners.add(new DeadKeyCombiner());
for (final Combiner combiner : combinerList) {
@ -87,7 +86,7 @@ public class CombinerChain {
* @param newEvent the new event to process
*/
public void processEvent(final ArrayList<Event> previousEvents, final Event newEvent) {
final ArrayList<Event> modifiablePreviousEvents = new ArrayList<Event>(previousEvents);
final ArrayList<Event> modifiablePreviousEvents = new ArrayList<>(previousEvents);
Event event = newEvent;
for (final Combiner combiner : mCombiners) {
// A combiner can never return more than one event; it can return several
@ -136,12 +135,13 @@ public class CombinerChain {
final Combiner[] combiners = new Combiner[combinerDescriptors.length];
int i = 0;
for (final String combinerDescriptor : combinerDescriptors) {
final Class combinerClass = IMPLEMENTED_COMBINERS.get(combinerDescriptor);
final Class<? extends Combiner> combinerClass =
IMPLEMENTED_COMBINERS.get(combinerDescriptor);
if (null == combinerClass) {
throw new RuntimeException("Unknown combiner descriptor: " + combinerDescriptor);
}
try {
combiners[i++] = (Combiner)combinerClass.newInstance();
combiners[i++] = combinerClass.newInstance();
} catch (InstantiationException e) {
throw new RuntimeException("Unable to instantiate combiner: " + combinerDescriptor,
e);

View File

@ -17,7 +17,6 @@
package com.android.inputmethod.event;
import com.android.inputmethod.latin.Constants;
import com.android.inputmethod.latin.utils.CollectionUtils;
import java.util.ArrayList;
import java.util.Arrays;
@ -32,7 +31,7 @@ public class MyanmarReordering implements Combiner {
// U+200B ZERO WIDTH SPACE
private final static int ZERO_WIDTH_NON_JOINER = 0x200B; // should be 0x200C
private final ArrayList<Event> mCurrentEvents = CollectionUtils.newArrayList();
private final ArrayList<Event> mCurrentEvents = new ArrayList<>();
// List of consonants :
// U+1000 MYANMAR LETTER KA

View File

@ -22,9 +22,9 @@ import com.android.inputmethod.keyboard.internal.KeyVisualAttributes;
import com.android.inputmethod.keyboard.internal.KeyboardIconsSet;
import com.android.inputmethod.keyboard.internal.KeyboardParams;
import com.android.inputmethod.latin.Constants;
import com.android.inputmethod.latin.utils.CollectionUtils;
import com.android.inputmethod.latin.utils.CoordinateUtils;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
@ -83,7 +83,7 @@ public class Keyboard {
public final List<Key> mAltCodeKeysWhileTyping;
public final KeyboardIconsSet mIconsSet;
private final SparseArray<Key> mKeyCache = CollectionUtils.newSparseArray();
private final SparseArray<Key> mKeyCache = new SparseArray<>();
private final ProximityInfo mProximityInfo;
private final boolean mProximityCharsCorrectionEnabled;
@ -103,8 +103,7 @@ public class Keyboard {
mTopPadding = params.mTopPadding;
mVerticalGap = params.mVerticalGap;
mSortedKeys = Collections.unmodifiableList(
CollectionUtils.newArrayList(params.mSortedKeys));
mSortedKeys = Collections.unmodifiableList(new ArrayList<>(params.mSortedKeys));
mShiftKeys = Collections.unmodifiableList(params.mShiftKeys);
mAltCodeKeysWhileTyping = Collections.unmodifiableList(params.mAltCodeKeysWhileTyping);
mIconsSet = params.mIconsSet;
@ -159,7 +158,7 @@ public class Keyboard {
/**
* Return the sorted list of keys of this keyboard.
* The keys are sorted from top-left to bottom-right order.
* The list may contain {@link Spacer} object as well.
* The list may contain {@link Key.Spacer} object as well.
* @return the sorted unmodifiable list of {@link Key}s of this keyboard.
*/
public List<Key> getSortedKeys() {

View File

@ -41,7 +41,6 @@ import com.android.inputmethod.latin.InputAttributes;
import com.android.inputmethod.latin.LatinImeLogger;
import com.android.inputmethod.latin.R;
import com.android.inputmethod.latin.SubtypeSwitcher;
import com.android.inputmethod.latin.utils.CollectionUtils;
import com.android.inputmethod.latin.utils.InputTypeUtils;
import com.android.inputmethod.latin.utils.SubtypeLocaleUtils;
import com.android.inputmethod.latin.utils.XmlParseUtils;
@ -81,7 +80,7 @@ public final class KeyboardLayoutSet {
// them from disappearing from sKeyboardCache.
private static final Keyboard[] sForcibleKeyboardCache = new Keyboard[FORCIBLE_CACHE_SIZE];
private static final HashMap<KeyboardId, SoftReference<Keyboard>> sKeyboardCache =
CollectionUtils.newHashMap();
new HashMap<>();
private static final KeysCache sKeysCache = new KeysCache();
@SuppressWarnings("serial")
@ -117,7 +116,7 @@ public final class KeyboardLayoutSet {
int mKeyboardHeight;
// Sparse array of KeyboardLayoutSet element parameters indexed by element's id.
final SparseArray<ElementParams> mKeyboardLayoutSetElementIdToParamsMap =
CollectionUtils.newSparseArray();
new SparseArray<>();
}
public static void clearKeyboardCache() {
@ -181,7 +180,7 @@ public final class KeyboardLayoutSet {
}
final KeyboardBuilder<KeyboardParams> builder =
new KeyboardBuilder<KeyboardParams>(mContext, new KeyboardParams());
new KeyboardBuilder<>(mContext, new KeyboardParams());
if (id.isAlphabetKeyboard()) {
builder.setAutoGenerate(sKeysCache);
}
@ -192,7 +191,7 @@ public final class KeyboardLayoutSet {
}
builder.setProximityCharsCorrectionEnabled(elementParams.mProximityCharsCorrectionEnabled);
final Keyboard keyboard = builder.build();
sKeyboardCache.put(id, new SoftReference<Keyboard>(keyboard));
sKeyboardCache.put(id, new SoftReference<>(keyboard));
if ((id.mElementId == KeyboardId.ELEMENT_ALPHABET
|| id.mElementId == KeyboardId.ELEMENT_ALPHABET_AUTOMATIC_SHIFTED)
&& !mParams.mIsSpellChecker) {

View File

@ -38,7 +38,6 @@ import com.android.inputmethod.latin.Constants;
import com.android.inputmethod.latin.LatinImeLogger;
import com.android.inputmethod.latin.R;
import com.android.inputmethod.latin.define.ProductionFlag;
import com.android.inputmethod.latin.utils.CollectionUtils;
import com.android.inputmethod.latin.utils.TypefaceUtils;
import com.android.inputmethod.research.ResearchLogger;
@ -110,7 +109,7 @@ public class KeyboardView extends View {
/** True if all keys should be drawn */
private boolean mInvalidateAllKeys;
/** The keys that should be drawn */
private final HashSet<Key> mInvalidatedKeys = CollectionUtils.newHashSet();
private final HashSet<Key> mInvalidatedKeys = new HashSet<>();
/** The working rectangle variable */
private final Rect mWorkingRect = new Rect();
/** The keyboard bitmap buffer for faster updates */

View File

@ -57,7 +57,6 @@ import com.android.inputmethod.latin.R;
import com.android.inputmethod.latin.SuggestedWords;
import com.android.inputmethod.latin.define.ProductionFlag;
import com.android.inputmethod.latin.settings.DebugSettings;
import com.android.inputmethod.latin.utils.CollectionUtils;
import com.android.inputmethod.latin.utils.CoordinateUtils;
import com.android.inputmethod.latin.utils.SpacebarLanguageUtils;
import com.android.inputmethod.latin.utils.TypefaceUtils;
@ -150,8 +149,7 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack
private final Paint mBackgroundDimAlphaPaint = new Paint();
private boolean mNeedsToDimEntireKeyboard;
private final View mMoreKeysKeyboardContainer;
private final WeakHashMap<Key, Keyboard> mMoreKeysKeyboardCache =
CollectionUtils.newWeakHashMap();
private final WeakHashMap<Key, Keyboard> mMoreKeysKeyboardCache = new WeakHashMap<>();
private final boolean mConfigShowMoreKeysKeyboardAtTouchedPoint;
// More keys panel (used by both more keys keyboard and more suggestions view)
// TODO: Consider extending to support multiple more keys panels

View File

@ -37,7 +37,6 @@ import com.android.inputmethod.latin.LatinImeLogger;
import com.android.inputmethod.latin.R;
import com.android.inputmethod.latin.define.ProductionFlag;
import com.android.inputmethod.latin.settings.Settings;
import com.android.inputmethod.latin.utils.CollectionUtils;
import com.android.inputmethod.latin.utils.CoordinateUtils;
import com.android.inputmethod.latin.utils.ResourceUtils;
import com.android.inputmethod.research.ResearchLogger;
@ -144,7 +143,7 @@ public final class PointerTracker implements PointerTrackerQueue.Element,
// TODO: Device specific parameter would be better for device specific hack?
private static final float PHANTOM_SUDDEN_MOVE_THRESHOLD = 0.25f; // in keyWidth
private static final ArrayList<PointerTracker> sTrackers = CollectionUtils.newArrayList();
private static final ArrayList<PointerTracker> sTrackers = new ArrayList<>();
private static final PointerTrackerQueue sPointerTrackerQueue = new PointerTrackerQueue();
public final int mPointerId;

View File

@ -22,7 +22,6 @@ import android.util.Log;
import com.android.inputmethod.keyboard.internal.TouchPositionCorrection;
import com.android.inputmethod.latin.Constants;
import com.android.inputmethod.latin.utils.CollectionUtils;
import com.android.inputmethod.latin.utils.JniUtils;
import java.util.ArrayList;
@ -55,6 +54,7 @@ public class ProximityInfo {
private final List<Key>[] mGridNeighbors;
private final String mLocaleStr;
@SuppressWarnings("unchecked")
ProximityInfo(final String localeStr, final int gridWidth, final int gridHeight,
final int minWidth, final int height, final int mostCommonKeyWidth,
final int mostCommonKeyHeight, final List<Key> sortedKeys,
@ -360,7 +360,7 @@ y |---+---+---+---+-v-+-|-+---+---+---+---+---| | thresholdBase and get
for (int i = 0; i < gridSize; ++i) {
final int indexStart = i * keyCount;
final int indexEnd = indexStart + neighborCountPerCell[i];
final ArrayList<Key> neighbors = CollectionUtils.newArrayList(indexEnd - indexStart);
final ArrayList<Key> neighbors = new ArrayList<>(indexEnd - indexStart);
for (int index = indexStart; index < indexEnd; index++) {
neighbors.add(neighborsFlatBuffer[index]);
}

View File

@ -23,7 +23,6 @@ import android.util.Log;
import com.android.inputmethod.keyboard.Key;
import com.android.inputmethod.keyboard.Keyboard;
import com.android.inputmethod.latin.settings.Settings;
import com.android.inputmethod.latin.utils.CollectionUtils;
import com.android.inputmethod.latin.utils.JsonUtils;
import java.util.ArrayDeque;
@ -47,8 +46,8 @@ final class DynamicGridKeyboard extends Keyboard {
private final int mColumnsNum;
private final int mMaxKeyCount;
private final boolean mIsRecents;
private final ArrayDeque<GridKey> mGridKeys = CollectionUtils.newArrayDeque();
private final ArrayDeque<Key> mPendingKeys = CollectionUtils.newArrayDeque();
private final ArrayDeque<GridKey> mGridKeys = new ArrayDeque<>();
private final ArrayDeque<Key> mPendingKeys = new ArrayDeque<>();
private List<Key> mCachedGridKeys;
@ -131,7 +130,7 @@ final class DynamicGridKeyboard extends Keyboard {
}
private void saveRecentKeys() {
final ArrayList<Object> keys = CollectionUtils.newArrayList();
final ArrayList<Object> keys = new ArrayList<>();
for (final Key key : mGridKeys) {
if (key.getOutputText() != null) {
keys.add(key.getOutputText());

View File

@ -31,7 +31,6 @@ import com.android.inputmethod.keyboard.KeyboardLayoutSet;
import com.android.inputmethod.latin.Constants;
import com.android.inputmethod.latin.R;
import com.android.inputmethod.latin.settings.Settings;
import com.android.inputmethod.latin.utils.CollectionUtils;
import java.util.ArrayList;
import java.util.Collections;
@ -101,12 +100,11 @@ final class EmojiCategory {
private final Resources mRes;
private final int mMaxPageKeyCount;
private final KeyboardLayoutSet mLayoutSet;
private final HashMap<String, Integer> mCategoryNameToIdMap = CollectionUtils.newHashMap();
private final HashMap<String, Integer> mCategoryNameToIdMap = new HashMap<>();
private final int[] mCategoryTabIconId = new int[sCategoryName.length];
private final ArrayList<CategoryProperties> mShownCategories =
CollectionUtils.newArrayList();
private final ConcurrentHashMap<Long, DynamicGridKeyboard>
mCategoryKeyboardMap = new ConcurrentHashMap<Long, DynamicGridKeyboard>();
private final ArrayList<CategoryProperties> mShownCategories = new ArrayList<>();
private final ConcurrentHashMap<Long, DynamicGridKeyboard> mCategoryKeyboardMap =
new ConcurrentHashMap<>();
private int mCurrentCategoryId = EmojiCategory.ID_UNSPECIFIED;
private int mCurrentCategoryPageId = 0;
@ -257,7 +255,7 @@ final class EmojiCategory {
final int temp = sum;
sum += properties.mPageCount;
if (sum > position) {
return new Pair<Integer, Integer>(properties.mCategoryId, position - temp);
return new Pair<>(properties.mCategoryId, position - temp);
}
}
return null;
@ -343,7 +341,7 @@ final class EmojiCategory {
};
private static Key[][] sortKeysIntoPages(final List<Key> inKeys, final int maxPageCount) {
final ArrayList<Key> keys = CollectionUtils.newArrayList(inKeys);
final ArrayList<Key> keys = new ArrayList<>(inKeys);
Collections.sort(keys, EMOJI_KEY_COMPARATOR);
final int pageCount = (keys.size() - 1) / maxPageCount + 1;
final Key[][] retval = new Key[pageCount][maxPageCount];

View File

@ -27,7 +27,6 @@ import com.android.inputmethod.keyboard.Key;
import com.android.inputmethod.keyboard.Keyboard;
import com.android.inputmethod.keyboard.KeyboardView;
import com.android.inputmethod.latin.R;
import com.android.inputmethod.latin.utils.CollectionUtils;
final class EmojiPalettesAdapter extends PagerAdapter {
private static final String TAG = EmojiPalettesAdapter.class.getSimpleName();
@ -35,8 +34,7 @@ final class EmojiPalettesAdapter extends PagerAdapter {
private final EmojiPageKeyboardView.OnKeyEventListener mListener;
private final DynamicGridKeyboard mRecentsKeyboard;
private final SparseArray<EmojiPageKeyboardView> mActiveKeyboardViews =
CollectionUtils.newSparseArray();
private final SparseArray<EmojiPageKeyboardView> mActiveKeyboardViews = new SparseArray<>();
private final EmojiCategory mEmojiCategory;
private int mActivePosition = 0;

View File

@ -24,7 +24,6 @@ import android.graphics.PorterDuffXfermode;
import android.util.AttributeSet;
import android.widget.RelativeLayout;
import com.android.inputmethod.latin.utils.CollectionUtils;
import com.android.inputmethod.latin.utils.CoordinateUtils;
import java.util.ArrayList;
@ -32,7 +31,7 @@ import java.util.ArrayList;
public final class DrawingPreviewPlacerView extends RelativeLayout {
private final int[] mKeyboardViewOrigin = CoordinateUtils.newInstance();
private final ArrayList<AbstractDrawingPreview> mPreviews = CollectionUtils.newArrayList();
private final ArrayList<AbstractDrawingPreview> mPreviews = new ArrayList<>();
public DrawingPreviewPlacerView(final Context context, final AttributeSet attrs) {
super(context, attrs);

View File

@ -29,15 +29,13 @@ import android.util.SparseArray;
import android.view.View;
import com.android.inputmethod.keyboard.PointerTracker;
import com.android.inputmethod.latin.utils.CollectionUtils;
import com.android.inputmethod.latin.utils.LeakGuardHandlerWrapper;
/**
* Draw preview graphics of multiple gesture trails during gesture input.
*/
public final class GestureTrailsDrawingPreview extends AbstractDrawingPreview {
private final SparseArray<GestureTrailDrawingPoints> mGestureTrails =
CollectionUtils.newSparseArray();
private final SparseArray<GestureTrailDrawingPoints> mGestureTrails = new SparseArray<>();
private final GestureTrailDrawingParams mDrawingParams;
private final Paint mGesturePaint;
private int mOffscreenWidth;

View File

@ -32,7 +32,6 @@ import android.widget.TextView;
import com.android.inputmethod.keyboard.Key;
import com.android.inputmethod.latin.R;
import com.android.inputmethod.latin.utils.CollectionUtils;
import com.android.inputmethod.latin.utils.CoordinateUtils;
import com.android.inputmethod.latin.utils.ViewLayoutUtils;
@ -48,9 +47,9 @@ import java.util.HashSet;
*/
public final class KeyPreviewChoreographer {
// Free {@link TextView} pool that can be used for key preview.
private final ArrayDeque<TextView> mFreeKeyPreviewTextViews = CollectionUtils.newArrayDeque();
private final ArrayDeque<TextView> mFreeKeyPreviewTextViews = new ArrayDeque<>();
// Map from {@link Key} to {@link TextView} that is currently being displayed as key preview.
private final HashMap<Key,TextView> mShowingKeyPreviewTextViews = CollectionUtils.newHashMap();
private final HashMap<Key,TextView> mShowingKeyPreviewTextViews = new HashMap<>();
private final KeyPreviewDrawParams mParams;
@ -83,7 +82,7 @@ public final class KeyPreviewChoreographer {
}
public void dismissAllKeyPreviews() {
for (final Key key : new HashSet<Key>(mShowingKeyPreviewTextViews.keySet())) {
for (final Key key : new HashSet<>(mShowingKeyPreviewTextViews.keySet())) {
dismissKeyPreview(key, false /* withAnimation */);
}
}

View File

@ -21,7 +21,6 @@ import android.util.Log;
import android.util.SparseArray;
import com.android.inputmethod.latin.R;
import com.android.inputmethod.latin.utils.CollectionUtils;
import com.android.inputmethod.latin.utils.XmlParseUtils;
import org.xmlpull.v1.XmlPullParser;
@ -34,7 +33,7 @@ public final class KeyStylesSet {
private static final String TAG = KeyStylesSet.class.getSimpleName();
private static final boolean DEBUG = false;
private final HashMap<String, KeyStyle> mStyles = CollectionUtils.newHashMap();
private final HashMap<String, KeyStyle> mStyles = new HashMap<>();
private final KeyboardTextsSet mTextsSet;
private final KeyStyle mEmptyKeyStyle;
@ -75,7 +74,7 @@ public final class KeyStylesSet {
private static final class DeclaredKeyStyle extends KeyStyle {
private final HashMap<String, KeyStyle> mStyles;
private final String mParentStyleName;
private final SparseArray<Object> mStyleAttributes = CollectionUtils.newSparseArray();
private final SparseArray<Object> mStyleAttributes = new SparseArray<>();
public DeclaredKeyStyle(final String parentStyleName, final KeyboardTextsSet textsSet,
final HashMap<String, KeyStyle> styles) {

View File

@ -17,14 +17,13 @@
package com.android.inputmethod.keyboard.internal;
import com.android.inputmethod.latin.Constants;
import com.android.inputmethod.latin.utils.CollectionUtils;
import java.util.HashMap;
public final class KeyboardCodesSet {
public static final String PREFIX_CODE = "!code/";
private static final HashMap<String, Integer> sNameToIdMap = CollectionUtils.newHashMap();
private static final HashMap<String, Integer> sNameToIdMap = new HashMap<>();
private KeyboardCodesSet() {
// This utility class is not publicly instantiable.

View File

@ -23,7 +23,6 @@ import android.util.Log;
import android.util.SparseIntArray;
import com.android.inputmethod.latin.R;
import com.android.inputmethod.latin.utils.CollectionUtils;
import java.util.HashMap;
@ -60,7 +59,7 @@ public final class KeyboardIconsSet {
private static final SparseIntArray ATTR_ID_TO_ICON_ID = new SparseIntArray();
// Icon name to icon id map.
private static final HashMap<String, Integer> sNameToIdsMap = CollectionUtils.newHashMap();
private static final HashMap<String, Integer> sNameToIdsMap = new HashMap<>();
private static final Object[] NAMES_AND_ATTR_IDS = {
NAME_UNDEFINED, ATTR_UNDEFINED,

View File

@ -21,7 +21,6 @@ import android.util.SparseIntArray;
import com.android.inputmethod.keyboard.Key;
import com.android.inputmethod.keyboard.KeyboardId;
import com.android.inputmethod.latin.Constants;
import com.android.inputmethod.latin.utils.CollectionUtils;
import java.util.ArrayList;
import java.util.Comparator;
@ -61,9 +60,9 @@ public class KeyboardParams {
public int GRID_HEIGHT;
// Keys are sorted from top-left to bottom-right order.
public final SortedSet<Key> mSortedKeys = new TreeSet<Key>(ROW_COLUMN_COMPARATOR);
public final ArrayList<Key> mShiftKeys = CollectionUtils.newArrayList();
public final ArrayList<Key> mAltCodeKeysWhileTyping = CollectionUtils.newArrayList();
public final SortedSet<Key> mSortedKeys = new TreeSet<>(ROW_COLUMN_COMPARATOR);
public final ArrayList<Key> mShiftKeys = new ArrayList<>();
public final ArrayList<Key> mAltCodeKeysWhileTyping = new ArrayList<>();
public final KeyboardIconsSet mIconsSet = new KeyboardIconsSet();
public final KeyboardTextsSet mTextsSet = new KeyboardTextsSet();
public final KeyStylesSet mKeyStyles = new KeyStylesSet(mTextsSet);

View File

@ -23,7 +23,6 @@ import android.util.Xml;
import com.android.inputmethod.keyboard.Key;
import com.android.inputmethod.keyboard.Keyboard;
import com.android.inputmethod.latin.R;
import com.android.inputmethod.latin.utils.CollectionUtils;
import com.android.inputmethod.latin.utils.ResourceUtils;
import org.xmlpull.v1.XmlPullParser;
@ -44,7 +43,7 @@ public final class KeyboardRow {
/** The height of this row. */
private final int mRowHeight;
private final ArrayDeque<RowAttributes> mRowAttributesStack = CollectionUtils.newArrayDeque();
private final ArrayDeque<RowAttributes> mRowAttributesStack = new ArrayDeque<>();
private static class RowAttributes {
/** Default width of a key in this row. */

View File

@ -22,7 +22,6 @@ import android.text.TextUtils;
import com.android.inputmethod.annotations.UsedForTesting;
import com.android.inputmethod.latin.Constants;
import com.android.inputmethod.latin.utils.CollectionUtils;
import com.android.inputmethod.latin.utils.RunInLocale;
import com.android.inputmethod.latin.utils.SubtypeLocaleUtils;
@ -38,7 +37,7 @@ public final class KeyboardTextsSet {
private String[] mTextsTable;
// Resource name to text map.
private HashMap<String, String> mResourceNameToTextsMap = CollectionUtils.newHashMap();
private HashMap<String, String> mResourceNameToTextsMap = new HashMap<>();
public void setLocale(final Locale locale, final Context context) {
mTextsTable = KeyboardTextsTable.getTextsTable(locale);

View File

@ -16,8 +16,6 @@
package com.android.inputmethod.keyboard.internal;
import com.android.inputmethod.latin.utils.CollectionUtils;
import java.util.HashMap;
import java.util.Locale;
@ -44,14 +42,12 @@ import java.util.Locale;
*/
public final class KeyboardTextsTable {
// Name to index map.
private static final HashMap<String, Integer> sNameToIndexesMap = CollectionUtils.newHashMap();
private static final HashMap<String, Integer> sNameToIndexesMap = new HashMap<>();
// Locale to texts table map.
private static final HashMap<String, String[]> sLocaleToTextsTableMap =
CollectionUtils.newHashMap();
private static final HashMap<String, String[]> sLocaleToTextsTableMap = new HashMap<>();
// TODO: Remove this variable after debugging.
// Texts table to locale maps.
private static final HashMap<String[], String> sTextsTableToLocaleMap =
CollectionUtils.newHashMap();
private static final HashMap<String[], String> sTextsTableToLocaleMap = new HashMap<>();
public static String getText(final String name, final String[] textsTable) {
final Integer indexObj = sNameToIndexesMap.get(name);

View File

@ -17,12 +17,11 @@
package com.android.inputmethod.keyboard.internal;
import com.android.inputmethod.keyboard.Key;
import com.android.inputmethod.latin.utils.CollectionUtils;
import java.util.HashMap;
public final class KeysCache {
private final HashMap<Key, Key> mMap = CollectionUtils.newHashMap();
private final HashMap<Key, Key> mMap = new HashMap<>();
public void clear() {
mMap.clear();

View File

@ -149,7 +149,7 @@ public final class MoreKeySpec {
// Skip empty entry.
if (pos - start > 0) {
if (list == null) {
list = CollectionUtils.newArrayList();
list = new ArrayList<>();
}
list.add(text.substring(start, pos));
}

View File

@ -18,8 +18,6 @@ package com.android.inputmethod.keyboard.internal;
import android.util.Log;
import com.android.inputmethod.latin.utils.CollectionUtils;
import java.util.ArrayList;
public final class PointerTrackerQueue {
@ -37,7 +35,7 @@ public final class PointerTrackerQueue {
// Note: {@link #mExpandableArrayOfActivePointers} and {@link #mArraySize} are synchronized by
// {@link #mExpandableArrayOfActivePointers}
private final ArrayList<Element> mExpandableArrayOfActivePointers =
CollectionUtils.newArrayList(INITIAL_CAPACITY);
new ArrayList<>(INITIAL_CAPACITY);
private int mArraySize = 0;
public int size() {

View File

@ -30,7 +30,6 @@ import com.android.inputmethod.latin.makedict.UnsupportedFormatException;
import com.android.inputmethod.latin.makedict.WordProperty;
import com.android.inputmethod.latin.settings.NativeSuggestOptions;
import com.android.inputmethod.latin.utils.BinaryDictionaryUtils;
import com.android.inputmethod.latin.utils.CollectionUtils;
import com.android.inputmethod.latin.utils.FileUtils;
import com.android.inputmethod.latin.utils.JniUtils;
import com.android.inputmethod.latin.utils.LanguageModelParam;
@ -104,8 +103,7 @@ public final class BinaryDictionary extends Dictionary {
private final NativeSuggestOptions mNativeSuggestOptions = new NativeSuggestOptions();
private final SparseArray<DicTraverseSession> mDicTraverseSessions =
CollectionUtils.newSparseArray();
private final SparseArray<DicTraverseSession> mDicTraverseSessions = new SparseArray<>();
// TODO: There should be a way to remove used DicTraverseSession objects from
// {@code mDicTraverseSessions}.
@ -248,11 +246,11 @@ public final class BinaryDictionary extends Dictionary {
}
final int[] outHeaderSize = new int[1];
final int[] outFormatVersion = new int[1];
final ArrayList<int[]> outAttributeKeys = CollectionUtils.newArrayList();
final ArrayList<int[]> outAttributeValues = CollectionUtils.newArrayList();
final ArrayList<int[]> outAttributeKeys = new ArrayList<>();
final ArrayList<int[]> outAttributeValues = new ArrayList<>();
getHeaderInfoNative(mNativeDict, outHeaderSize, outFormatVersion, outAttributeKeys,
outAttributeValues);
final HashMap<String, String> attributes = new HashMap<String, String>();
final HashMap<String, String> attributes = new HashMap<>();
for (int i = 0; i < outAttributeKeys.size(); i++) {
final String attributeKey = StringUtils.getStringFromNullTerminatedCodePointArray(
outAttributeKeys.get(i));
@ -312,7 +310,7 @@ public final class BinaryDictionary extends Dictionary {
inOutLanguageWeight[0] = mInputOutputLanguageWeight[0];
}
final int count = mOutputSuggestionCount[0];
final ArrayList<SuggestedWordInfo> suggestions = CollectionUtils.newArrayList();
final ArrayList<SuggestedWordInfo> suggestions = new ArrayList<>();
for (int j = 0; j < count; ++j) {
final int start = j * MAX_WORD_LENGTH;
int len = 0;
@ -386,10 +384,10 @@ public final class BinaryDictionary extends Dictionary {
final boolean[] outFlags = new boolean[FORMAT_WORD_PROPERTY_OUTPUT_FLAG_COUNT];
final int[] outProbabilityInfo =
new int[FORMAT_WORD_PROPERTY_OUTPUT_PROBABILITY_INFO_COUNT];
final ArrayList<int[]> outBigramTargets = CollectionUtils.newArrayList();
final ArrayList<int[]> outBigramProbabilityInfo = CollectionUtils.newArrayList();
final ArrayList<int[]> outShortcutTargets = CollectionUtils.newArrayList();
final ArrayList<Integer> outShortcutProbabilities = CollectionUtils.newArrayList();
final ArrayList<int[]> outBigramTargets = new ArrayList<>();
final ArrayList<int[]> outBigramProbabilityInfo = new ArrayList<>();
final ArrayList<int[]> outShortcutTargets = new ArrayList<>();
final ArrayList<Integer> outShortcutProbabilities = new ArrayList<>();
getWordPropertyNative(mNativeDict, codePoints, outCodePoints, outFlags, outProbabilityInfo,
outBigramTargets, outBigramProbabilityInfo, outShortcutTargets,
outShortcutProbabilities);

View File

@ -29,7 +29,6 @@ import android.util.Log;
import com.android.inputmethod.dictionarypack.DictionaryPackConstants;
import com.android.inputmethod.dictionarypack.MD5Calculator;
import com.android.inputmethod.latin.utils.CollectionUtils;
import com.android.inputmethod.latin.utils.DictionaryInfoUtils;
import com.android.inputmethod.latin.utils.DictionaryInfoUtils.DictionaryInfo;
import com.android.inputmethod.latin.utils.FileTransforms;
@ -44,8 +43,8 @@ import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Locale;
@ -165,7 +164,7 @@ public final class BinaryDictionaryFileDumper {
if (cursor.getCount() <= 0 || !cursor.moveToFirst()) {
return Collections.<WordListInfo>emptyList();
}
final ArrayList<WordListInfo> list = CollectionUtils.newArrayList();
final ArrayList<WordListInfo> list = new ArrayList<>();
do {
final String wordListId = cursor.getString(0);
final String wordListLocale = cursor.getString(1);

View File

@ -24,7 +24,6 @@ import android.util.Log;
import com.android.inputmethod.latin.makedict.DictionaryHeader;
import com.android.inputmethod.latin.makedict.UnsupportedFormatException;
import com.android.inputmethod.latin.utils.BinaryDictionaryUtils;
import com.android.inputmethod.latin.utils.CollectionUtils;
import com.android.inputmethod.latin.utils.DictionaryInfoUtils;
import com.android.inputmethod.latin.utils.LocaleUtils;
@ -160,7 +159,7 @@ final public class BinaryDictionaryGetter {
public static File[] getCachedWordLists(final String locale, final Context context) {
final File[] directoryList = DictionaryInfoUtils.getCachedDirectoryList(context);
if (null == directoryList) return EMPTY_FILE_ARRAY;
final HashMap<String, FileAndMatchLevel> cacheFiles = CollectionUtils.newHashMap();
final HashMap<String, FileAndMatchLevel> cacheFiles = new HashMap<>();
for (File directory : directoryList) {
if (!directory.isDirectory()) continue;
final String dirLocale =
@ -273,7 +272,7 @@ final public class BinaryDictionaryGetter {
final DictPackSettings dictPackSettings = new DictPackSettings(context);
boolean foundMainDict = false;
final ArrayList<AssetFileAddress> fileList = CollectionUtils.newArrayList();
final ArrayList<AssetFileAddress> fileList = new ArrayList<>();
// cachedWordLists may not be null, see doc for getCachedDictionaryList
for (final File f : cachedWordLists) {
final String wordListId = DictionaryInfoUtils.getWordListIdFromFileName(f.getName());

View File

@ -31,7 +31,6 @@ import android.util.Log;
import com.android.inputmethod.annotations.UsedForTesting;
import com.android.inputmethod.latin.personalization.AccountUtils;
import com.android.inputmethod.latin.utils.CollectionUtils;
import com.android.inputmethod.latin.utils.ExecutorUtils;
import com.android.inputmethod.latin.utils.StringUtils;
@ -180,7 +179,7 @@ public class ContactsBinaryDictionary extends ExpandableBinaryDictionary {
private void addWordsLocked(final Cursor cursor) {
int count = 0;
final ArrayList<String> names = CollectionUtils.newArrayList();
final ArrayList<String> names = new ArrayList<>();
while (!cursor.isAfterLast() && count < MAX_CONTACT_COUNT) {
String name = cursor.getString(INDEX_NAME);
if (isValidName(name)) {
@ -298,7 +297,7 @@ public class ContactsBinaryDictionary extends ExpandableBinaryDictionary {
if (null == cursor) {
return false;
}
final ArrayList<String> names = CollectionUtils.newArrayList();
final ArrayList<String> names = new ArrayList<>();
try {
if (cursor.moveToFirst()) {
while (!cursor.isAfterLast()) {

View File

@ -20,7 +20,6 @@ import android.util.Log;
import com.android.inputmethod.keyboard.ProximityInfo;
import com.android.inputmethod.latin.SuggestedWords.SuggestedWordInfo;
import com.android.inputmethod.latin.utils.CollectionUtils;
import java.util.ArrayList;
import java.util.Collection;
@ -36,22 +35,22 @@ public final class DictionaryCollection extends Dictionary {
public DictionaryCollection(final String dictType) {
super(dictType);
mDictionaries = CollectionUtils.newCopyOnWriteArrayList();
mDictionaries = new CopyOnWriteArrayList<>();
}
public DictionaryCollection(final String dictType, final Dictionary... dictionaries) {
super(dictType);
if (null == dictionaries) {
mDictionaries = CollectionUtils.newCopyOnWriteArrayList();
mDictionaries = new CopyOnWriteArrayList<>();
} else {
mDictionaries = CollectionUtils.newCopyOnWriteArrayList(dictionaries);
mDictionaries = new CopyOnWriteArrayList<>(dictionaries);
mDictionaries.removeAll(Collections.singleton(null));
}
}
public DictionaryCollection(final String dictType, final Collection<Dictionary> dictionaries) {
super(dictType);
mDictionaries = CollectionUtils.newCopyOnWriteArrayList(dictionaries);
mDictionaries = new CopyOnWriteArrayList<>(dictionaries);
mDictionaries.removeAll(Collections.singleton(null));
}
@ -67,7 +66,7 @@ public final class DictionaryCollection extends Dictionary {
ArrayList<SuggestedWordInfo> suggestions = dictionaries.get(0).getSuggestions(composer,
prevWordsInfo, proximityInfo, blockOffensiveWords, additionalFeaturesOptions,
sessionId, inOutLanguageWeight);
if (null == suggestions) suggestions = CollectionUtils.newArrayList();
if (null == suggestions) suggestions = new ArrayList<>();
final int length = dictionaries.size();
for (int i = 1; i < length; ++ i) {
final ArrayList<SuggestedWordInfo> sugg = dictionaries.get(i).getSuggestions(composer,

View File

@ -29,7 +29,6 @@ import com.android.inputmethod.latin.personalization.PersonalizationDataChunk;
import com.android.inputmethod.latin.personalization.PersonalizationDictionary;
import com.android.inputmethod.latin.personalization.UserHistoryDictionary;
import com.android.inputmethod.latin.settings.SpacingAndPunctuations;
import com.android.inputmethod.latin.utils.CollectionUtils;
import com.android.inputmethod.latin.utils.DistracterFilter;
import com.android.inputmethod.latin.utils.ExecutorUtils;
import com.android.inputmethod.latin.utils.LanguageModelParam;
@ -41,10 +40,10 @@ import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
@ -75,7 +74,7 @@ public class DictionaryFacilitator {
};
private static final Map<String, Class<? extends ExpandableBinaryDictionary>>
DICT_TYPE_TO_CLASS = CollectionUtils.newHashMap();
DICT_TYPE_TO_CLASS = new HashMap<>();
static {
DICT_TYPE_TO_CLASS.put(Dictionary.TYPE_USER_HISTORY, UserHistoryDictionary.class);
@ -100,7 +99,7 @@ public class DictionaryFacilitator {
public final Locale mLocale;
private Dictionary mMainDict;
public final ConcurrentHashMap<String, ExpandableBinaryDictionary> mSubDictMap =
CollectionUtils.newConcurrentHashMap();
new ConcurrentHashMap<>();
public Dictionaries() {
mLocale = null;
@ -212,7 +211,7 @@ public class DictionaryFacilitator {
// We always try to have the main dictionary. Other dictionaries can be unused.
final boolean reloadMainDictionary = localeHasBeenChanged || forceReloadMainDictionary;
// TODO: Make subDictTypesToUse configurable by resource or a static final list.
final Set<String> subDictTypesToUse = CollectionUtils.newHashSet();
final HashSet<String> subDictTypesToUse = new HashSet<>();
if (useContactsDict) {
subDictTypesToUse.add(Dictionary.TYPE_CONTACTS);
}
@ -231,7 +230,7 @@ public class DictionaryFacilitator {
newMainDict = mDictionaries.getDict(Dictionary.TYPE_MAIN);
}
final Map<String, ExpandableBinaryDictionary> subDicts = CollectionUtils.newHashMap();
final Map<String, ExpandableBinaryDictionary> subDicts = new HashMap<>();
for (final String dictType : SUB_DICT_TYPES) {
if (!subDictTypesToUse.contains(dictType)) {
// This dictionary will not be used.
@ -304,7 +303,7 @@ public class DictionaryFacilitator {
final ArrayList<String> dictionaryTypes, final HashMap<String, File> dictionaryFiles,
final Map<String, Map<String, String>> additionalDictAttributes) {
Dictionary mainDictionary = null;
final Map<String, ExpandableBinaryDictionary> subDicts = CollectionUtils.newHashMap();
final Map<String, ExpandableBinaryDictionary> subDicts = new HashMap<>();
for (final String dictType : dictionaryTypes) {
if (dictType.equals(Dictionary.TYPE_MAIN)) {

View File

@ -23,7 +23,6 @@ import android.content.res.Resources;
import android.util.Log;
import com.android.inputmethod.annotations.UsedForTesting;
import com.android.inputmethod.latin.utils.CollectionUtils;
import com.android.inputmethod.latin.utils.DictionaryInfoUtils;
import java.io.File;
@ -55,7 +54,7 @@ public final class DictionaryFactory {
createReadOnlyBinaryDictionary(context, locale));
}
final LinkedList<Dictionary> dictList = CollectionUtils.newLinkedList();
final LinkedList<Dictionary> dictList = new LinkedList<>();
final ArrayList<AssetFileAddress> assetFileList =
BinaryDictionaryGetter.getDictionaryFiles(locale, context);
if (null != assetFileList) {

View File

@ -53,7 +53,6 @@ abstract public class ExpandableBinaryDictionary extends Dictionary {
private static final String TAG = ExpandableBinaryDictionary.class.getSimpleName();
/** Whether to print debug output to log */
private static boolean DEBUG = false;
private static final boolean DBG_STRESS_TEST = false;
private static final int TIMEOUT_FOR_READ_OPS_IN_MILLISECONDS = 100;
@ -192,7 +191,7 @@ abstract public class ExpandableBinaryDictionary extends Dictionary {
}
protected Map<String, String> getHeaderAttributeMap() {
HashMap<String, String> attributeMap = new HashMap<String, String>();
HashMap<String, String> attributeMap = new HashMap<>();
if (mAdditionalAttributeMap != null) {
attributeMap.putAll(mAdditionalAttributeMap);
}

View File

@ -20,7 +20,6 @@ import android.text.InputType;
import android.util.Log;
import android.view.inputmethod.EditorInfo;
import com.android.inputmethod.latin.utils.CollectionUtils;
import com.android.inputmethod.latin.utils.InputTypeUtils;
import com.android.inputmethod.latin.utils.StringUtils;
@ -214,7 +213,7 @@ public final class InputAttributes {
}
private static String toFlagsString(final int flags) {
final ArrayList<String> flagsArray = CollectionUtils.newArrayList();
final ArrayList<String> flagsArray = new ArrayList<>();
if (0 != (flags & InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS))
flagsArray.add("TYPE_TEXT_FLAG_NO_SUGGESTIONS");
if (0 != (flags & InputType.TYPE_TEXT_FLAG_MULTI_LINE))

View File

@ -69,7 +69,7 @@ public final class LastComposedWord {
mInputPointers.copy(inputPointers);
}
mTypedWord = typedWord;
mEvents = new ArrayList<Event>(events);
mEvents = new ArrayList<>(events);
mCommittedWord = committedWord;
mSeparatorString = separatorString;
mActive = true;

View File

@ -81,7 +81,6 @@ import com.android.inputmethod.latin.suggestions.SuggestionStripView;
import com.android.inputmethod.latin.suggestions.SuggestionStripViewAccessor;
import com.android.inputmethod.latin.utils.ApplicationUtils;
import com.android.inputmethod.latin.utils.CapsModeUtils;
import com.android.inputmethod.latin.utils.CollectionUtils;
import com.android.inputmethod.latin.utils.CoordinateUtils;
import com.android.inputmethod.latin.utils.DialogUtils;
import com.android.inputmethod.latin.utils.DistracterFilterUsingSuggestion;
@ -130,8 +129,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
this /* SuggestionStripViewAccessor */, mDictionaryFacilitator);
// We expect to have only one decoder in almost all cases, hence the default capacity of 1.
// If it turns out we need several, it will get grown seamlessly.
final SparseArray<HardwareEventDecoder> mHardwareEventDecoders
= new SparseArray<HardwareEventDecoder>(1);
final SparseArray<HardwareEventDecoder> mHardwareEventDecoders = new SparseArray<>(1);
private View mExtractArea;
private View mKeyPreviewBackingView;

View File

@ -17,8 +17,6 @@
package com.android.inputmethod.latin;
import com.android.inputmethod.keyboard.internal.KeySpecParser;
import com.android.inputmethod.latin.SuggestedWords.SuggestedWordInfo;
import com.android.inputmethod.latin.utils.CollectionUtils;
import com.android.inputmethod.latin.utils.StringUtils;
import java.util.ArrayList;
@ -49,7 +47,7 @@ public final class PunctuationSuggestions extends SuggestedWords {
*/
public static PunctuationSuggestions newPunctuationSuggestions(
final String[] punctuationSpecs) {
final ArrayList<SuggestedWordInfo> puncuationsList = CollectionUtils.newArrayList();
final ArrayList<SuggestedWordInfo> puncuationsList = new ArrayList<>();
for (final String puncSpec : punctuationSpecs) {
puncuationsList.add(newHardCodedWordInfo(puncSpec));
}

View File

@ -31,7 +31,6 @@ import android.view.inputmethod.InputMethodSubtype;
import com.android.inputmethod.compat.InputMethodManagerCompatWrapper;
import com.android.inputmethod.latin.settings.Settings;
import com.android.inputmethod.latin.utils.AdditionalSubtypeUtils;
import com.android.inputmethod.latin.utils.CollectionUtils;
import com.android.inputmethod.latin.utils.SubtypeLocaleUtils;
import java.util.Collections;
@ -53,9 +52,9 @@ public final class RichInputMethodManager {
private InputMethodManagerCompatWrapper mImmWrapper;
private InputMethodInfoCache mInputMethodInfoCache;
final HashMap<InputMethodInfo, List<InputMethodSubtype>>
mSubtypeListCacheWithImplicitlySelectedSubtypes = CollectionUtils.newHashMap();
mSubtypeListCacheWithImplicitlySelectedSubtypes = new HashMap<>();
final HashMap<InputMethodInfo, List<InputMethodSubtype>>
mSubtypeListCacheWithoutImplicitlySelectedSubtypes = CollectionUtils.newHashMap();
mSubtypeListCacheWithoutImplicitlySelectedSubtypes = new HashMap<>();
private static final int INDEX_NOT_FOUND = -1;

View File

@ -255,8 +255,7 @@ public final class SubtypeSwitcher {
public boolean isSystemLocaleSameAsLocaleOfAllEnabledSubtypesOfEnabledImes() {
final Locale systemLocale = mResources.getConfiguration().locale;
final Set<InputMethodSubtype> enabledSubtypesOfEnabledImes =
new HashSet<InputMethodSubtype>();
final Set<InputMethodSubtype> enabledSubtypesOfEnabledImes = new HashSet<>();
final InputMethodManager inputMethodManager = mRichImm.getInputMethodManager();
final List<InputMethodInfo> enabledInputMethodInfoList =
inputMethodManager.getEnabledInputMethodList();

View File

@ -24,7 +24,6 @@ import com.android.inputmethod.latin.SuggestedWords.SuggestedWordInfo;
import com.android.inputmethod.latin.define.ProductionFlag;
import com.android.inputmethod.latin.utils.AutoCorrectionUtils;
import com.android.inputmethod.latin.utils.BinaryDictionaryUtils;
import com.android.inputmethod.latin.utils.CollectionUtils;
import com.android.inputmethod.latin.utils.StringUtils;
import com.android.inputmethod.latin.utils.SuggestionResults;
@ -106,7 +105,7 @@ public final class Suggest {
final ArrayList<SuggestedWordInfo> rawSuggestions;
if (ProductionFlag.INCLUDE_RAW_SUGGESTIONS) {
rawSuggestions = CollectionUtils.newArrayList();
rawSuggestions = new ArrayList<>();
} else {
rawSuggestions = null;
}
@ -175,7 +174,7 @@ public final class Suggest {
}
final ArrayList<SuggestedWordInfo> suggestionsContainer =
CollectionUtils.newArrayList(suggestionResults);
new ArrayList<>(suggestionResults);
final int suggestionsCount = suggestionsContainer.size();
if (isFirstCharCapitalized || isAllUpperCase || 0 != trailingSingleQuotesCount) {
for (int i = 0; i < suggestionsCount; ++i) {
@ -227,7 +226,7 @@ public final class Suggest {
final OnGetSuggestedWordsCallback callback) {
final ArrayList<SuggestedWordInfo> rawSuggestions;
if (ProductionFlag.INCLUDE_RAW_SUGGESTIONS) {
rawSuggestions = CollectionUtils.newArrayList();
rawSuggestions = new ArrayList<>();
} else {
rawSuggestions = null;
}
@ -239,7 +238,7 @@ public final class Suggest {
}
final ArrayList<SuggestedWordInfo> suggestionsContainer =
CollectionUtils.newArrayList(suggestionResults);
new ArrayList<>(suggestionResults);
final int suggestionsCount = suggestionsContainer.size();
final boolean isFirstCharCapitalized = wordComposer.wasShiftedNoLock();
final boolean isAllUpperCase = wordComposer.isAllUpperCase();
@ -282,8 +281,7 @@ public final class Suggest {
final SuggestedWordInfo typedWordInfo = suggestions.get(0);
typedWordInfo.setDebugString("+");
final int suggestionsSize = suggestions.size();
final ArrayList<SuggestedWordInfo> suggestionsList =
CollectionUtils.newArrayList(suggestionsSize);
final ArrayList<SuggestedWordInfo> suggestionsList = new ArrayList<>(suggestionsSize);
suggestionsList.add(typedWordInfo);
// Note: i here is the index in mScores[], but the index in mSuggestions is one more
// than i because we added the typed word to mSuggestions without touching mScores.

View File

@ -19,7 +19,6 @@ package com.android.inputmethod.latin;
import android.text.TextUtils;
import android.view.inputmethod.CompletionInfo;
import com.android.inputmethod.latin.utils.CollectionUtils;
import com.android.inputmethod.latin.utils.StringUtils;
import java.util.ArrayList;
@ -34,8 +33,7 @@ public class SuggestedWords {
// The maximum number of suggestions available.
public static final int MAX_SUGGESTIONS = 18;
private static final ArrayList<SuggestedWordInfo> EMPTY_WORD_INFO_LIST =
CollectionUtils.newArrayList(0);
private static final ArrayList<SuggestedWordInfo> EMPTY_WORD_INFO_LIST = new ArrayList<>(0);
public static final SuggestedWords EMPTY = new SuggestedWords(
EMPTY_WORD_INFO_LIST, null /* rawSuggestions */, false, false, false, false);
@ -165,7 +163,7 @@ public class SuggestedWords {
public static ArrayList<SuggestedWordInfo> getFromApplicationSpecifiedCompletions(
final CompletionInfo[] infos) {
final ArrayList<SuggestedWordInfo> result = CollectionUtils.newArrayList();
final ArrayList<SuggestedWordInfo> result = new ArrayList<>();
for (final CompletionInfo info : infos) {
if (null == info || null == info.getText()) {
continue;
@ -179,8 +177,8 @@ public class SuggestedWords {
// and replace it with what the user currently typed.
public static ArrayList<SuggestedWordInfo> getTypedWordAndPreviousSuggestions(
final String typedWord, final SuggestedWords previousSuggestions) {
final ArrayList<SuggestedWordInfo> suggestionsList = CollectionUtils.newArrayList();
final HashSet<String> alreadySeen = CollectionUtils.newHashSet();
final ArrayList<SuggestedWordInfo> suggestionsList = new ArrayList<>();
final HashSet<String> alreadySeen = new HashSet<>();
suggestionsList.add(new SuggestedWordInfo(typedWord, SuggestedWordInfo.MAX_SCORE,
SuggestedWordInfo.KIND_TYPED, Dictionary.DICTIONARY_USER_TYPED,
SuggestedWordInfo.NOT_AN_INDEX /* indexOfTouchPointOfSecondWord */,
@ -337,7 +335,7 @@ public class SuggestedWords {
// SuggestedWords is an immutable object, as much as possible. We must not just remove
// words from the member ArrayList as some other parties may expect the object to never change.
public SuggestedWords getSuggestedWordsExcludingTypedWord() {
final ArrayList<SuggestedWordInfo> newSuggestions = CollectionUtils.newArrayList();
final ArrayList<SuggestedWordInfo> newSuggestions = new ArrayList<>();
String typedWord = null;
for (int i = 0; i < mSuggestedWordInfoList.size(); ++i) {
final SuggestedWordInfo info = mSuggestedWordInfoList.get(i);
@ -361,7 +359,7 @@ public class SuggestedWords {
// we should only suggest replacements for this last word.
// TODO: make this work with languages without spaces.
public SuggestedWords getSuggestedWordsForLastWordOfPhraseGesture() {
final ArrayList<SuggestedWordInfo> newSuggestions = CollectionUtils.newArrayList();
final ArrayList<SuggestedWordInfo> newSuggestions = new ArrayList<>();
for (int i = 0; i < mSuggestedWordInfoList.size(); ++i) {
final SuggestedWordInfo info = mSuggestedWordInfoList.get(i);
final int indexOfLastSpace = info.mWord.lastIndexOf(Constants.CODE_SPACE) + 1;

View File

@ -18,7 +18,6 @@ package com.android.inputmethod.latin;
import com.android.inputmethod.event.CombinerChain;
import com.android.inputmethod.event.Event;
import com.android.inputmethod.latin.utils.CollectionUtils;
import com.android.inputmethod.latin.utils.CoordinateUtils;
import com.android.inputmethod.latin.utils.StringUtils;
@ -79,7 +78,7 @@ public final class WordComposer {
public WordComposer() {
mCombinerChain = new CombinerChain("");
mEvents = CollectionUtils.newArrayList();
mEvents = new ArrayList<>();
mAutoCorrection = null;
mIsResumed = false;
mIsBatchMode = false;

View File

@ -27,7 +27,6 @@ import com.android.inputmethod.latin.BinaryDictionaryFileDumper;
import com.android.inputmethod.latin.BinaryDictionaryGetter;
import com.android.inputmethod.latin.R;
import com.android.inputmethod.latin.makedict.DictionaryHeader;
import com.android.inputmethod.latin.utils.CollectionUtils;
import com.android.inputmethod.latin.utils.DialogUtils;
import com.android.inputmethod.latin.utils.DictionaryInfoUtils;
import com.android.inputmethod.latin.utils.LocaleUtils;
@ -50,7 +49,7 @@ public class ExternalDictionaryGetterForDebug {
private static String[] findDictionariesInTheDownloadedFolder() {
final File[] files = new File(SOURCE_FOLDER).listFiles();
final ArrayList<String> eligibleList = CollectionUtils.newArrayList();
final ArrayList<String> eligibleList = new ArrayList<>();
for (File f : files) {
final DictionaryHeader header = DictionaryInfoUtils.getDictionaryFileHeaderOrNull(f);
if (null == header) continue;

View File

@ -49,7 +49,6 @@ import com.android.inputmethod.latin.settings.SettingsValues;
import com.android.inputmethod.latin.settings.SpacingAndPunctuations;
import com.android.inputmethod.latin.suggestions.SuggestionStripViewAccessor;
import com.android.inputmethod.latin.utils.AsyncResultHolder;
import com.android.inputmethod.latin.utils.CollectionUtils;
import com.android.inputmethod.latin.utils.InputTypeUtils;
import com.android.inputmethod.latin.utils.LatinImeLoggerUtils;
import com.android.inputmethod.latin.utils.RecapitalizeStatus;
@ -89,7 +88,7 @@ public final class InputLogic {
private int mDeleteCount;
private long mLastKeyTime;
public final TreeSet<Long> mCurrentlyPressedHardwareKeys = CollectionUtils.newTreeSet();
public final TreeSet<Long> mCurrentlyPressedHardwareKeys = new TreeSet<>();
// Keeps track of most recently inserted text (multi-character key) for reverting
private String mEnteredText;
@ -1270,7 +1269,7 @@ public final class InputLogic {
return;
}
final AsyncResultHolder<SuggestedWords> holder = new AsyncResultHolder<SuggestedWords>();
final AsyncResultHolder<SuggestedWords> holder = new AsyncResultHolder<>();
mInputLogicHandler.getSuggestedWords(Suggest.SESSION_TYPING,
SuggestedWords.NOT_A_SEQUENCE_NUMBER, new OnGetSuggestedWordsCallback() {
@Override
@ -1350,7 +1349,7 @@ public final class InputLogic {
// we just do not resume because it's safer.
final int numberOfCharsInWordBeforeCursor = range.getNumberOfCharsInWordBeforeCursor();
if (numberOfCharsInWordBeforeCursor > expectedCursorPosition) return;
final ArrayList<SuggestedWordInfo> suggestions = CollectionUtils.newArrayList();
final ArrayList<SuggestedWordInfo> suggestions = new ArrayList<>();
final String typedWord = range.mWord.toString();
if (includeResumedWordInSuggestions) {
suggestions.add(new SuggestedWordInfo(typedWord,
@ -1473,7 +1472,7 @@ public final class InputLogic {
committedWord.length(), Object.class);
final int lastCharIndex = textToCommit.length() - 1;
// We will collect all suggestions in the following array.
final ArrayList<String> suggestions = CollectionUtils.newArrayList();
final ArrayList<String> suggestions = new ArrayList<>();
// First, add the committed word to the list of suggestions.
suggestions.add(committedWordString);
for (final Object span : spans) {

View File

@ -18,7 +18,6 @@ package com.android.inputmethod.latin.makedict;
import com.android.inputmethod.annotations.UsedForTesting;
import com.android.inputmethod.latin.BinaryDictionary;
import com.android.inputmethod.latin.utils.CollectionUtils;
import com.android.inputmethod.latin.utils.CombinedFormatUtils;
import com.android.inputmethod.latin.utils.StringUtils;
@ -78,8 +77,8 @@ public final class WordProperty implements Comparable<WordProperty> {
final ArrayList<Integer> shortcutProbabilities) {
mWord = StringUtils.getStringFromNullTerminatedCodePointArray(codePoints);
mProbabilityInfo = createProbabilityInfoFromArray(probabilityInfo);
mShortcutTargets = CollectionUtils.newArrayList();
mBigrams = CollectionUtils.newArrayList();
mShortcutTargets = new ArrayList<>();
mBigrams = new ArrayList<>();
mIsBeginningOfSentence = false;
mIsNotAWord = isNotAWord;
mIsBlacklistEntry = isBlacklisted;

View File

@ -35,7 +35,7 @@ public class AccountUtils {
}
public static List<String> getDeviceAccountsEmailAddresses(final Context context) {
final ArrayList<String> retval = new ArrayList<String>();
final ArrayList<String> retval = new ArrayList<>();
for (final Account account : getAccounts(context)) {
final String name = account.name;
if (Patterns.EMAIL_ADDRESS.matcher(name).matches()) {
@ -54,7 +54,7 @@ public class AccountUtils {
*/
public static List<String> getDeviceAccountsWithDomain(
final Context context, final String domain) {
final ArrayList<String> retval = new ArrayList<String>();
final ArrayList<String> retval = new ArrayList<>();
final String atDomain = "@" + domain.toLowerCase(Locale.ROOT);
for (final Account account : getAccounts(context)) {
if (account.name.toLowerCase(Locale.ROOT).endsWith(atDomain)) {

View File

@ -31,7 +31,6 @@ import java.util.Map;
* model.
*/
public abstract class DecayingExpandableBinaryDictionaryBase extends ExpandableBinaryDictionary {
private static final String TAG = DecayingExpandableBinaryDictionaryBase.class.getSimpleName();
private static final boolean DBG_DUMP_ON_CLOSE = false;
/** Any pair being typed or picked */

View File

@ -16,12 +16,11 @@
package com.android.inputmethod.latin.personalization;
import com.android.inputmethod.latin.utils.CollectionUtils;
import com.android.inputmethod.latin.utils.FileUtils;
import android.content.Context;
import android.util.Log;
import com.android.inputmethod.latin.utils.FileUtils;
import java.io.File;
import java.io.FilenameFilter;
import java.lang.ref.SoftReference;
@ -33,9 +32,9 @@ public class PersonalizationHelper {
private static final String TAG = PersonalizationHelper.class.getSimpleName();
private static final boolean DEBUG = false;
private static final ConcurrentHashMap<String, SoftReference<UserHistoryDictionary>>
sLangUserHistoryDictCache = CollectionUtils.newConcurrentHashMap();
sLangUserHistoryDictCache = new ConcurrentHashMap<>();
private static final ConcurrentHashMap<String, SoftReference<PersonalizationDictionary>>
sLangPersonalizationDictCache = CollectionUtils.newConcurrentHashMap();
sLangPersonalizationDictCache = new ConcurrentHashMap<>();
public static UserHistoryDictionary getUserHistoryDictionary(
final Context context, final Locale locale) {
@ -54,8 +53,7 @@ public class PersonalizationHelper {
}
}
final UserHistoryDictionary dict = new UserHistoryDictionary(context, locale);
sLangUserHistoryDictCache.put(localeStr,
new SoftReference<UserHistoryDictionary>(dict));
sLangUserHistoryDictCache.put(localeStr, new SoftReference<>(dict));
return dict;
}
}
@ -108,8 +106,7 @@ public class PersonalizationHelper {
}
}
final PersonalizationDictionary dict = new PersonalizationDictionary(context, locale);
sLangPersonalizationDictCache.put(
localeStr, new SoftReference<PersonalizationDictionary>(dict));
sLangPersonalizationDictCache.put(localeStr, new SoftReference<>(dict));
return dict;
}
}

View File

@ -47,7 +47,6 @@ import com.android.inputmethod.latin.Constants;
import com.android.inputmethod.latin.R;
import com.android.inputmethod.latin.RichInputMethodManager;
import com.android.inputmethod.latin.utils.AdditionalSubtypeUtils;
import com.android.inputmethod.latin.utils.CollectionUtils;
import com.android.inputmethod.latin.utils.DialogUtils;
import com.android.inputmethod.latin.utils.IntentUtils;
import com.android.inputmethod.latin.utils.SubtypeLocaleUtils;
@ -101,7 +100,7 @@ public final class AdditionalSubtypeSettings extends PreferenceFragment {
super(context, android.R.layout.simple_spinner_item);
setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
final TreeSet<SubtypeLocaleItem> items = CollectionUtils.newTreeSet();
final TreeSet<SubtypeLocaleItem> items = new TreeSet<>();
final InputMethodInfo imi = RichInputMethodManager.getInstance()
.getInputMethodInfoOfThisIme();
final int count = imi.getSubtypeCount();
@ -369,7 +368,6 @@ public final class AdditionalSubtypeSettings extends PreferenceFragment {
mSubtype = (InputMethodSubtype)source.readParcelable(null);
}
@SuppressWarnings("hiding")
public static final Parcelable.Creator<SavedState> CREATOR =
new Parcelable.Creator<SavedState>() {
@Override
@ -516,8 +514,7 @@ public final class AdditionalSubtypeSettings extends PreferenceFragment {
localeString, keyboardLayoutSetName);
}
private AlertDialog createDialog(
@SuppressWarnings("unused") final SubtypePreference subtypePref) {
private AlertDialog createDialog(final SubtypePreference subtypePref) {
final AlertDialog.Builder builder = new AlertDialog.Builder(
DialogUtils.getPlatformDialogThemeContext(getActivity()));
builder.setTitle(R.string.custom_input_styles_title)
@ -555,7 +552,7 @@ public final class AdditionalSubtypeSettings extends PreferenceFragment {
private InputMethodSubtype[] getSubtypes() {
final PreferenceGroup group = getPreferenceScreen();
final ArrayList<InputMethodSubtype> subtypes = CollectionUtils.newArrayList();
final ArrayList<InputMethodSubtype> subtypes = new ArrayList<>();
final int count = group.getPreferenceCount();
for (int i = 0; i < count; i++) {
final Preference pref = group.getPreference(i);

View File

@ -171,7 +171,7 @@ public final class SettingsValues {
ResourceUtils.getFloatFromFraction(
res, R.fraction.config_key_preview_dismiss_end_scale));
mDisplayOrientation = res.getConfiguration().orientation;
mAppWorkarounds = new AsyncResultHolder<AppWorkaroundsUtils>();
mAppWorkarounds = new AsyncResultHolder<>();
final PackageInfo packageInfo = TargetPackageInfoGetterTask.getCachedPackageInfo(
mInputAttributes.mTargetApplicationPackageName);
if (null != packageInfo) {

View File

@ -37,7 +37,6 @@ import com.android.inputmethod.compat.TextViewCompatUtils;
import com.android.inputmethod.compat.ViewCompatUtils;
import com.android.inputmethod.latin.R;
import com.android.inputmethod.latin.settings.SettingsActivity;
import com.android.inputmethod.latin.utils.CollectionUtils;
import com.android.inputmethod.latin.utils.LeakGuardHandlerWrapper;
import java.util.ArrayList;
@ -482,7 +481,7 @@ public final class SetupWizardActivity extends Activity implements View.OnClickL
static final class SetupStepGroup {
private final SetupStepIndicatorView mIndicatorView;
private final ArrayList<SetupStep> mGroup = CollectionUtils.newArrayList();
private final ArrayList<SetupStep> mGroup = new ArrayList<>();
public SetupStepGroup(final SetupStepIndicatorView indicatorView) {
mIndicatorView = indicatorView;

View File

@ -27,7 +27,6 @@ import android.view.inputmethod.InputMethodSubtype;
import android.view.textservice.SuggestionsInfo;
import com.android.inputmethod.keyboard.KeyboardLayoutSet;
import com.android.inputmethod.latin.BinaryDictionary;
import com.android.inputmethod.latin.ContactsBinaryDictionary;
import com.android.inputmethod.latin.Dictionary;
import com.android.inputmethod.latin.DictionaryCollection;
@ -77,7 +76,7 @@ public final class AndroidSpellCheckerService extends SpellCheckerService
private final Object mUseContactsLock = new Object();
private final HashSet<WeakReference<DictionaryCollection>> mDictionaryCollectionsList =
CollectionUtils.newHashSet();
new HashSet<>();
public static final int SCRIPT_LATIN = 0;
public static final int SCRIPT_CYRILLIC = 1;
@ -94,7 +93,7 @@ public final class AndroidSpellCheckerService extends SpellCheckerService
// proximity to pass to the dictionary descent algorithm.
// IMPORTANT: this only contains languages - do not write countries in there.
// Only the language is searched from the map.
mLanguageToScript = CollectionUtils.newTreeMap();
mLanguageToScript = new TreeMap<>();
mLanguageToScript.put("cs", SCRIPT_LATIN);
mLanguageToScript.put("da", SCRIPT_LATIN);
mLanguageToScript.put("de", SCRIPT_LATIN);
@ -255,7 +254,7 @@ public final class AndroidSpellCheckerService extends SpellCheckerService
mOriginalText = originalText;
mRecommendedThreshold = recommendedThreshold;
mMaxLength = maxLength;
mSuggestions = CollectionUtils.newArrayList(maxLength + 1);
mSuggestions = new ArrayList<>(maxLength + 1);
mScores = new int[mMaxLength];
}
@ -441,8 +440,7 @@ public final class AndroidSpellCheckerService extends SpellCheckerService
}
}
dictionaryCollection.addDictionary(mContactsDictionary);
mDictionaryCollectionsList.add(
new WeakReference<DictionaryCollection>(dictionaryCollection));
mDictionaryCollectionsList.add(new WeakReference<>(dictionaryCollection));
}
return new DictAndKeyboard(dictionaryCollection, keyboardLayoutSet);
}

View File

@ -24,7 +24,6 @@ import android.view.textservice.SuggestionsInfo;
import android.view.textservice.TextInfo;
import com.android.inputmethod.latin.PrevWordsInfo;
import com.android.inputmethod.latin.utils.CollectionUtils;
import java.util.ArrayList;
@ -44,10 +43,9 @@ public final class AndroidSpellCheckerSession extends AndroidWordLevelSpellCheck
return null;
}
final int N = ssi.getSuggestionsCount();
final ArrayList<Integer> additionalOffsets = CollectionUtils.newArrayList();
final ArrayList<Integer> additionalLengths = CollectionUtils.newArrayList();
final ArrayList<SuggestionsInfo> additionalSuggestionsInfos =
CollectionUtils.newArrayList();
final ArrayList<Integer> additionalOffsets = new ArrayList<>();
final ArrayList<Integer> additionalLengths = new ArrayList<>();
final ArrayList<SuggestionsInfo> additionalSuggestionsInfos = new ArrayList<>();
String currentWord = null;
for (int i = 0; i < N; ++i) {
final SuggestionsInfo si = ssi.getSuggestionsInfoAt(i);

View File

@ -28,7 +28,6 @@ import android.view.textservice.SuggestionsInfo;
import android.view.textservice.TextInfo;
import com.android.inputmethod.compat.SuggestionsInfoCompatUtils;
import com.android.inputmethod.keyboard.Keyboard;
import com.android.inputmethod.latin.Constants;
import com.android.inputmethod.latin.Dictionary;
import com.android.inputmethod.latin.PrevWordsInfo;
@ -69,7 +68,7 @@ public abstract class AndroidWordLevelSpellCheckerSession extends Session {
private static final char CHAR_DELIMITER = '\uFFFC';
private static final int MAX_CACHE_SIZE = 50;
private final LruCache<String, SuggestionsParams> mUnigramSuggestionsInfoCache =
new LruCache<String, SuggestionsParams>(MAX_CACHE_SIZE);
new LruCache<>(MAX_CACHE_SIZE);
// TODO: Support n-gram input
private static String generateKey(final String query, final PrevWordsInfo prevWordsInfo) {

View File

@ -16,11 +16,11 @@
package com.android.inputmethod.latin.spellcheck;
import com.android.inputmethod.latin.Dictionary;
import com.android.inputmethod.keyboard.Keyboard;
import com.android.inputmethod.keyboard.KeyboardId;
import com.android.inputmethod.keyboard.KeyboardLayoutSet;
import com.android.inputmethod.keyboard.ProximityInfo;
import com.android.inputmethod.latin.Dictionary;
/**
* A container for a Dictionary and a Keyboard.
@ -28,19 +28,15 @@ import com.android.inputmethod.keyboard.ProximityInfo;
public final class DictAndKeyboard {
public final Dictionary mDictionary;
public final Keyboard mKeyboard;
private final Keyboard mManualShiftedKeyboard;
public DictAndKeyboard(
final Dictionary dictionary, final KeyboardLayoutSet keyboardLayoutSet) {
mDictionary = dictionary;
if (keyboardLayoutSet == null) {
mKeyboard = null;
mManualShiftedKeyboard = null;
return;
}
mKeyboard = keyboardLayoutSet.getKeyboard(KeyboardId.ELEMENT_ALPHABET);
mManualShiftedKeyboard =
keyboardLayoutSet.getKeyboard(KeyboardId.ELEMENT_ALPHABET_MANUAL_SHIFTED);
}
public ProximityInfo getProximityInfo() {

View File

@ -23,7 +23,6 @@ import com.android.inputmethod.latin.Dictionary;
import com.android.inputmethod.latin.PrevWordsInfo;
import com.android.inputmethod.latin.SuggestedWords.SuggestedWordInfo;
import com.android.inputmethod.latin.WordComposer;
import com.android.inputmethod.latin.utils.CollectionUtils;
import java.util.ArrayList;
import java.util.Locale;
@ -47,7 +46,7 @@ public final class DictionaryPool extends LinkedBlockingQueue<DictAndKeyboard> {
private final Locale mLocale;
private int mSize;
private volatile boolean mClosed;
final static ArrayList<SuggestedWordInfo> noSuggestions = CollectionUtils.newArrayList();
final static ArrayList<SuggestedWordInfo> noSuggestions = new ArrayList<>();
private final static DictAndKeyboard dummyDict = new DictAndKeyboard(
new Dictionary(Dictionary.TYPE_MAIN) {
// TODO: this dummy dictionary should be a singleton in the Dictionary class.

View File

@ -50,7 +50,6 @@ import com.android.inputmethod.latin.SuggestedWords.SuggestedWordInfo;
import com.android.inputmethod.latin.define.ProductionFlag;
import com.android.inputmethod.latin.settings.Settings;
import com.android.inputmethod.latin.suggestions.MoreSuggestions.MoreSuggestionsListener;
import com.android.inputmethod.latin.utils.CollectionUtils;
import com.android.inputmethod.latin.utils.ImportantNoticeUtils;
import com.android.inputmethod.research.ResearchLogger;
@ -78,9 +77,9 @@ public final class SuggestionStripView extends RelativeLayout implements OnClick
private final MoreSuggestionsView mMoreSuggestionsView;
private final MoreSuggestions.Builder mMoreSuggestionsBuilder;
private final ArrayList<TextView> mWordViews = CollectionUtils.newArrayList();
private final ArrayList<TextView> mDebugInfoViews = CollectionUtils.newArrayList();
private final ArrayList<View> mDividerViews = CollectionUtils.newArrayList();
private final ArrayList<TextView> mWordViews = new ArrayList<>();
private final ArrayList<TextView> mDebugInfoViews = new ArrayList<>();
private final ArrayList<View> mDividerViews = new ArrayList<>();
Listener mListener;
private SuggestedWords mSuggestedWords = SuggestedWords.EMPTY;

View File

@ -256,7 +256,7 @@ public class UserDictionaryAddWordContents {
// The system locale should be inside. We want it at the 2nd spot.
locales.remove(systemLocale); // system locale may not be null
locales.remove(""); // Remove the empty string if it's there
final ArrayList<LocaleRenderer> localesList = new ArrayList<LocaleRenderer>();
final ArrayList<LocaleRenderer> localesList = new ArrayList<>();
// Add the passed locale, then the system locale at the top of the list. Add an
// "all languages" entry at the bottom of the list.
addLocaleDisplayNameToList(activity, localesList, mLocale);

View File

@ -134,8 +134,8 @@ public class UserDictionaryAddWordFragment extends Fragment
final Spinner localeSpinner =
(Spinner)mRootView.findViewById(R.id.user_dictionary_add_locale);
final ArrayAdapter<LocaleRenderer> adapter = new ArrayAdapter<LocaleRenderer>(getActivity(),
android.R.layout.simple_spinner_item, localesList);
final ArrayAdapter<LocaleRenderer> adapter = new ArrayAdapter<>(
getActivity(), android.R.layout.simple_spinner_item, localesList);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
localeSpinner.setAdapter(adapter);
localeSpinner.setOnItemSelectedListener(this);

View File

@ -56,7 +56,7 @@ public class UserDictionaryList extends PreferenceFragment {
final Cursor cursor = activity.getContentResolver().query(UserDictionary.Words.CONTENT_URI,
new String[] { UserDictionary.Words.LOCALE },
null, null, null);
final TreeSet<String> localeSet = new TreeSet<String>();
final TreeSet<String> localeSet = new TreeSet<>();
if (null == cursor) {
// The user dictionary service is not present or disabled. Return null.
return null;

View File

@ -95,8 +95,7 @@ public final class AdditionalSubtypeUtils {
return EMPTY_SUBTYPE_ARRAY;
}
final String[] prefSubtypeArray = prefSubtypes.split(PREF_SUBTYPE_SEPARATOR);
final ArrayList<InputMethodSubtype> subtypesList =
CollectionUtils.newArrayList(prefSubtypeArray.length);
final ArrayList<InputMethodSubtype> subtypesList = new ArrayList<>(prefSubtypeArray.length);
for (final String prefSubtype : prefSubtypeArray) {
final String elems[] = prefSubtype.split(LOCALE_AND_LAYOUT_SEPARATOR);
if (elems.length != LENGTH_WITHOUT_EXTRA_VALUE

View File

@ -16,12 +16,11 @@
package com.android.inputmethod.latin.utils;
import com.android.inputmethod.latin.BinaryDictionary;
import android.util.Log;
import com.android.inputmethod.latin.LatinImeLogger;
import com.android.inputmethod.latin.SuggestedWords.SuggestedWordInfo;
import android.util.Log;
public final class AutoCorrectionUtils {
private static final boolean DBG = LatinImeLogger.sDBG;
private static final String TAG = AutoCorrectionUtils.class.getSimpleName();

View File

@ -16,93 +16,21 @@
package com.android.inputmethod.latin.utils;
import android.util.SparseArray;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.Map;
import java.util.TreeMap;
import java.util.TreeSet;
import java.util.WeakHashMap;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.CopyOnWriteArrayList;
public final class CollectionUtils {
private CollectionUtils() {
// This utility class is not publicly instantiable.
}
public static <K,V> HashMap<K,V> newHashMap() {
return new HashMap<K,V>();
}
public static <K, V> WeakHashMap<K, V> newWeakHashMap() {
return new WeakHashMap<K, V>();
}
public static <K,V> TreeMap<K,V> newTreeMap() {
return new TreeMap<K,V>();
}
public static <K, V> Map<K,V> newSynchronizedTreeMap() {
final TreeMap<K,V> treeMap = newTreeMap();
final TreeMap<K,V> treeMap = new TreeMap<>();
return Collections.synchronizedMap(treeMap);
}
public static <K,V> ConcurrentHashMap<K,V> newConcurrentHashMap() {
return new ConcurrentHashMap<K,V>();
}
public static <E> HashSet<E> newHashSet() {
return new HashSet<E>();
}
public static <E> TreeSet<E> newTreeSet() {
return new TreeSet<E>();
}
public static <E> ArrayList<E> newArrayList() {
return new ArrayList<E>();
}
public static <E> ArrayList<E> newArrayList(final int initialCapacity) {
return new ArrayList<E>(initialCapacity);
}
public static <E> ArrayList<E> newArrayList(final Collection<E> collection) {
return new ArrayList<E>(collection);
}
public static <E> LinkedList<E> newLinkedList() {
return new LinkedList<E>();
}
public static <E> CopyOnWriteArrayList<E> newCopyOnWriteArrayList() {
return new CopyOnWriteArrayList<E>();
}
public static <E> CopyOnWriteArrayList<E> newCopyOnWriteArrayList(
final Collection<E> collection) {
return new CopyOnWriteArrayList<E>(collection);
}
public static <E> CopyOnWriteArrayList<E> newCopyOnWriteArrayList(final E[] array) {
return new CopyOnWriteArrayList<E>(array);
}
public static <E> ArrayDeque<E> newArrayDeque() {
return new ArrayDeque<E>();
}
public static <E> SparseArray<E> newSparseArray() {
return new SparseArray<E>();
}
public static <E> ArrayList<E> arrayAsList(final E[] array, final int start, final int end) {
if (array == null) {
throw new NullPointerException();
@ -111,7 +39,7 @@ public final class CollectionUtils {
throw new IllegalArgumentException();
}
final ArrayList<E> list = newArrayList(end - start);
final ArrayList<E> list = new ArrayList<>(end - start);
for (int i = start; i < end; i++) {
list.add(array[i]);
}

View File

@ -209,7 +209,7 @@ public final class CsvUtils {
@UsedForTesting
public static String[] split(final int splitFlags, final String line) throws CsvParseException {
final boolean trimSpaces = (splitFlags & SPLIT_FLAGS_TRIM_SPACES) != 0;
final ArrayList<String> fields = CollectionUtils.newArrayList();
final ArrayList<String> fields = new ArrayList<>();
final int length = line.length();
int start = 0;
do {

View File

@ -336,7 +336,7 @@ public class DictionaryInfoUtils {
public static ArrayList<DictionaryInfo> getCurrentDictionaryFileNameAndVersionInfo(
final Context context) {
final ArrayList<DictionaryInfo> dictList = CollectionUtils.newArrayList();
final ArrayList<DictionaryInfo> dictList = new ArrayList<>();
// Retrieve downloaded dictionaries
final File[] directoryList = getCachedDirectoryList(context);

View File

@ -203,7 +203,7 @@ public class DistracterFilterUsingSuggestion implements DistracterFilter {
final String consideredWord = trailingSingleQuotesCount > 0 ?
testedWord.substring(0, testedWord.length() - trailingSingleQuotesCount) :
testedWord;
final AsyncResultHolder<Boolean> holder = new AsyncResultHolder<Boolean>();
final AsyncResultHolder<Boolean> holder = new AsyncResultHolder<>();
final OnGetSuggestedWordsCallback callback = new OnGetSuggestedWordsCallback() {
@Override
public void onGetSuggestedWords(final SuggestedWords suggestedWords) {

View File

@ -24,8 +24,9 @@ import java.util.concurrent.ConcurrentHashMap;
* Utilities to manage executors.
*/
public class ExecutorUtils {
private static final ConcurrentHashMap<String, PrioritizedSerialExecutor>
sExecutorMap = CollectionUtils.newConcurrentHashMap();
private static final ConcurrentHashMap<String, PrioritizedSerialExecutor> sExecutorMap =
new ConcurrentHashMap<>();
/**
* Gets the executor for the given dictionary name.
*/

View File

@ -31,7 +31,7 @@ import com.android.inputmethod.research.FeedbackFragment;
import java.util.HashSet;
public class FragmentUtils {
private static final HashSet<String> sLatinImeFragments = new HashSet<String>();
private static final HashSet<String> sLatinImeFragments = new HashSet<>();
static {
sLatinImeFragments.add(DictionarySettingsFragment.class.getName());
sLatinImeFragments.add(AboutPreferences.class.getName());

View File

@ -37,7 +37,7 @@ public final class JsonUtils {
private static final String EMPTY_STRING = "";
public static List<Object> jsonStrToList(final String s) {
final ArrayList<Object> list = CollectionUtils.newArrayList();
final ArrayList<Object> list = new ArrayList<>();
final JsonReader reader = new JsonReader(new StringReader(s));
try {
reader.beginArray();

View File

@ -84,8 +84,7 @@ public final class LanguageModelParam {
final DictionaryFacilitator dictionaryFacilitator,
final SpacingAndPunctuations spacingAndPunctuations,
final DistracterFilter distracterFilter) {
final ArrayList<LanguageModelParam> languageModelParams =
CollectionUtils.newArrayList();
final ArrayList<LanguageModelParam> languageModelParams = new ArrayList<>();
final int N = tokens.size();
PrevWordsInfo prevWordsInfo = PrevWordsInfo.EMPTY_PREV_WORDS_INFO;
for (int i = 0; i < N; ++i) {

View File

@ -33,7 +33,7 @@ public class LeakGuardHandlerWrapper<T> extends Handler {
if (ownerInstance == null) {
throw new NullPointerException("ownerInstance is null");
}
mOwnerInstanceRef = new WeakReference<T>(ownerInstance);
mOwnerInstanceRef = new WeakReference<>(ownerInstance);
}
public T getOwnerInstance() {

View File

@ -159,7 +159,7 @@ public final class LocaleUtils {
return LOCALE_MATCH <= level;
}
private static final HashMap<String, Locale> sLocaleCache = CollectionUtils.newHashMap();
private static final HashMap<String, Locale> sLocaleCache = new HashMap<>();
/**
* Creates a locale from a string specification.

View File

@ -41,8 +41,8 @@ public class PrioritizedSerialExecutor {
private Runnable mActive;
public PrioritizedSerialExecutor() {
mTasks = new ConcurrentLinkedQueue<Runnable>();
mPrioritizedTasks = new ConcurrentLinkedQueue<Runnable>();
mTasks = new ConcurrentLinkedQueue<>();
mPrioritizedTasks = new ConcurrentLinkedQueue<>();
mIsShutdown = false;
mThreadPoolExecutor = new ThreadPoolExecutor(1 /* corePoolSize */, 1 /* maximumPoolSize */,
0 /* keepAliveTime */, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(1));

View File

@ -41,8 +41,7 @@ public final class ResourceUtils {
// This utility class is not publicly instantiable.
}
private static final HashMap<String, String> sDeviceOverrideValueMap =
CollectionUtils.newHashMap();
private static final HashMap<String, String> sDeviceOverrideValueMap = new HashMap<>();
private static final String[] BUILD_KEYS_AND_VALUES = {
"HARDWARE", Build.HARDWARE,
@ -54,8 +53,8 @@ public final class ResourceUtils {
private static final String sBuildKeyValuesDebugString;
static {
sBuildKeyValues = CollectionUtils.newHashMap();
final ArrayList<String> keyValuePairs = CollectionUtils.newArrayList();
sBuildKeyValues = new HashMap<>();
final ArrayList<String> keyValuePairs = new ArrayList<>();
final int keyCount = BUILD_KEYS_AND_VALUES.length / 2;
for (int i = 0; i < keyCount; i++) {
final int index = i * 2;

View File

@ -28,7 +28,6 @@ import java.util.Arrays;
import java.util.Locale;
public final class StringUtils {
private static final String TAG = StringUtils.class.getSimpleName();
public static final int CAPITALIZE_NONE = 0; // No caps, or mixed case
public static final int CAPITALIZE_FIRST = 1; // First only
public static final int CAPITALIZE_ALL = 2; // All caps
@ -110,7 +109,7 @@ public final class StringUtils {
if (!containsInArray(text, elements)) {
return extraValues;
}
final ArrayList<String> result = CollectionUtils.newArrayList(elements.length - 1);
final ArrayList<String> result = new ArrayList<>(elements.length - 1);
for (final String element : elements) {
if (!text.equals(element)) {
result.add(element);

View File

@ -49,17 +49,14 @@ public final class SubtypeLocaleUtils {
private static Resources sResources;
private static String[] sPredefinedKeyboardLayoutSet;
// Keyboard layout to its display name map.
private static final HashMap<String, String> sKeyboardLayoutToDisplayNameMap =
CollectionUtils.newHashMap();
private static final HashMap<String, String> sKeyboardLayoutToDisplayNameMap = new HashMap<>();
// Keyboard layout to subtype name resource id map.
private static final HashMap<String, Integer> sKeyboardLayoutToNameIdsMap =
CollectionUtils.newHashMap();
private static final HashMap<String, Integer> sKeyboardLayoutToNameIdsMap = new HashMap<>();
// Exceptional locale to subtype name resource id map.
private static final HashMap<String, Integer> sExceptionalLocaleToNameIdsMap =
CollectionUtils.newHashMap();
private static final HashMap<String, Integer> sExceptionalLocaleToNameIdsMap = new HashMap<>();
// Exceptional locale to subtype name with layout resource id map.
private static final HashMap<String, Integer> sExceptionalLocaleToWithLayoutNameIdsMap =
CollectionUtils.newHashMap();
new HashMap<>();
private static final String SUBTYPE_NAME_RESOURCE_PREFIX =
"string/subtype_";
private static final String SUBTYPE_NAME_RESOURCE_GENERIC_PREFIX =
@ -71,7 +68,7 @@ public final class SubtypeLocaleUtils {
// Keyboard layout set name for the subtypes that don't have a keyboardLayoutSet extra value.
// This is for compatibility to keep the same subtype ids as pre-JellyBean.
private static final HashMap<String, String> sLocaleAndExtraValueToKeyboardLayoutSetMap =
CollectionUtils.newHashMap();
new HashMap<>();
private SubtypeLocaleUtils() {
// Intentional empty constructor for utility class.

View File

@ -27,8 +27,7 @@ import com.android.inputmethod.compat.AppWorkaroundsUtils;
public final class TargetPackageInfoGetterTask extends
AsyncTask<String, Void, PackageInfo> {
private static final int MAX_CACHE_ENTRIES = 64; // arbitrary
private static final LruCache<String, PackageInfo> sCache =
new LruCache<String, PackageInfo>(MAX_CACHE_ENTRIES);
private static final LruCache<String, PackageInfo> sCache = new LruCache<>(MAX_CACHE_ENTRIES);
public static PackageInfo getCachedPackageInfo(final String packageName) {
if (null == packageName) return null;

View File

@ -30,7 +30,7 @@ public final class TypefaceUtils {
}
// This sparse array caches key label text height in pixel indexed by key label text size.
private static final SparseArray<Float> sTextHeightCache = CollectionUtils.newSparseArray();
private static final SparseArray<Float> sTextHeightCache = new SparseArray<>();
// Working variable for the following method.
private static final Rect sTextHeightBounds = new Rect();
@ -50,7 +50,7 @@ public final class TypefaceUtils {
}
// This sparse array caches key label text width in pixel indexed by key label text size.
private static final SparseArray<Float> sTextWidthCache = CollectionUtils.newSparseArray();
private static final SparseArray<Float> sTextWidthCache = new SparseArray<>();
// Working variable for the following method.
private static final Rect sTextWidthBounds = new Rect();

View File

@ -66,7 +66,7 @@ public final class UserLogRingCharBuffer {
return;
}
if (LatinImeLogger.sUsabilityStudy) {
UsabilityStudyLogUtils.getInstance().writeChar(c, x, y);
UsabilityStudyLogUtils.writeChar(c, x, y);
}
mCharBuf[mEnd] = c;
mXBuf[mEnd] = x;

View File

@ -163,7 +163,7 @@ public class FixedLogBuffer extends LogBuffer {
// Allocate space for n*2 logUnits. There will be at least n, one for each word, and
// there may be additional for punctuation, between-word commands, etc. This should be
// enough that reallocation won't be necessary.
final ArrayList<LogUnit> resultList = new ArrayList<LogUnit>(n * 2);
final ArrayList<LogUnit> resultList = new ArrayList<>(n * 2);
for (final LogUnit logUnit : logUnits) {
n -= logUnit.getNumWords();
if (n < 0) break;

View File

@ -31,7 +31,7 @@ public class LogBuffer {
private final LinkedList<LogUnit> mLogUnits;
public LogBuffer() {
mLogUnits = new LinkedList<LogUnit>();
mLogUnits = new LinkedList<>();
}
protected LinkedList<LogUnit> getLogUnits() {

View File

@ -93,9 +93,9 @@ public class LogUnit {
private SuggestedWords mSuggestedWords;
public LogUnit() {
mLogStatementList = new ArrayList<LogStatement>();
mValuesList = new ArrayList<Object[]>();
mTimeList = new ArrayList<Long>();
mLogStatementList = new ArrayList<>();
mValuesList = new ArrayList<>();
mTimeList = new ArrayList<>();
mIsPartOfMegaword = false;
mCorrectionType = CORRECTIONTYPE_NO_CORRECTION;
mSuggestedWords = null;
@ -311,9 +311,9 @@ public class LogUnit {
// Create the LogUnit containing the later logStatements and associated data.
final LogUnit newLogUnit = new LogUnit(
new ArrayList<LogStatement>(laterLogStatements),
new ArrayList<Object[]>(laterValues),
new ArrayList<Long>(laterTimes),
new ArrayList<>(laterLogStatements),
new ArrayList<>(laterValues),
new ArrayList<>(laterTimes),
true /* isPartOfMegaword */);
newLogUnit.mWords = null;
newLogUnit.mMayContainDigit = mMayContainDigit;

View File

@ -67,11 +67,10 @@ public class MotionEventReader {
@UsedForTesting
static class ReplayData {
final ArrayList<Integer> mActions = new ArrayList<Integer>();
final ArrayList<PointerProperties[]> mPointerPropertiesArrays
= new ArrayList<PointerProperties[]>();
final ArrayList<PointerCoords[]> mPointerCoordsArrays = new ArrayList<PointerCoords[]>();
final ArrayList<Long> mTimes = new ArrayList<Long>();
final ArrayList<Integer> mActions = new ArrayList<>();
final ArrayList<PointerProperties[]> mPointerPropertiesArrays = new ArrayList<>();
final ArrayList<PointerCoords[]> mPointerCoordsArrays = new ArrayList<>();
final ArrayList<Long> mTimes = new ArrayList<>();
}
/**
@ -228,8 +227,7 @@ public class MotionEventReader {
private PointerProperties[] readPointerProperties(final JsonReader jsonReader)
throws IOException {
final ArrayList<PointerProperties> pointerPropertiesArrayList =
new ArrayList<PointerProperties>();
final ArrayList<PointerProperties> pointerPropertiesArrayList = new ArrayList<>();
jsonReader.beginArray();
while (jsonReader.hasNext()) {
final PointerProperties pointerProperties = new PointerProperties();
@ -254,7 +252,7 @@ public class MotionEventReader {
jsonReader.beginArray();
while (jsonReader.hasNext()) { // Array of historical data
jsonReader.beginObject();
final ArrayList<PointerCoords> pointerCoordsArrayList = new ArrayList<PointerCoords>();
final ArrayList<PointerCoords> pointerCoordsArrayList = new ArrayList<>();
while (jsonReader.hasNext()) { // Time/data object
final String name = jsonReader.nextName();
if (name.equals("t")) {

View File

@ -32,7 +32,6 @@ import com.android.inputmethod.latin.Constants;
import com.android.inputmethod.latin.R;
import com.android.inputmethod.latin.RichInputMethodManager;
import com.android.inputmethod.latin.utils.AdditionalSubtypeUtils;
import com.android.inputmethod.latin.utils.CollectionUtils;
import com.android.inputmethod.latin.utils.ResourceUtils;
import com.android.inputmethod.latin.utils.SubtypeLocaleUtils;
@ -42,11 +41,9 @@ import java.util.Locale;
@SmallTest
public class KeyboardLayoutSetTestsBase extends AndroidTestCase {
// All input method subtypes of LatinIME.
private final ArrayList<InputMethodSubtype> mAllSubtypesList = CollectionUtils.newArrayList();
private final ArrayList<InputMethodSubtype> mAsciiCapableSubtypesList =
CollectionUtils.newArrayList();
private final ArrayList<InputMethodSubtype> mAdditionalSubtypesList =
CollectionUtils.newArrayList();
private final ArrayList<InputMethodSubtype> mAllSubtypesList = new ArrayList<>();
private final ArrayList<InputMethodSubtype> mAsciiCapableSubtypesList = new ArrayList<>();
private final ArrayList<InputMethodSubtype> mAdditionalSubtypesList = new ArrayList<>();
private Context mThemeContext;
private int mScreenMetrics;

View File

@ -23,7 +23,6 @@ import android.view.inputmethod.InputMethodInfo;
import android.view.inputmethod.InputMethodSubtype;
import com.android.inputmethod.latin.RichInputMethodManager;
import com.android.inputmethod.latin.utils.CollectionUtils;
import com.android.inputmethod.latin.utils.SubtypeLocaleUtils;
import java.util.ArrayList;
@ -42,7 +41,7 @@ public final class KeyboardTextsSetTests extends AndroidTestCase {
RichInputMethodManager.init(getContext());
final RichInputMethodManager richImm = RichInputMethodManager.getInstance();
final ArrayList<InputMethodSubtype> allSubtypesList = CollectionUtils.newArrayList();
final ArrayList<InputMethodSubtype> allSubtypesList = new ArrayList<>();
final InputMethodInfo imi = richImm.getInputMethodInfoOfThisIme();
final int subtypeCount = imi.getSubtypeCount();
for (int index = 0; index < subtypeCount; index++) {

View File

@ -22,8 +22,6 @@ import android.content.res.Resources;
import android.test.InstrumentationTestCase;
import android.test.suitebuilder.annotation.MediumTest;
import com.android.inputmethod.latin.utils.CollectionUtils;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.Arrays;
@ -53,7 +51,7 @@ public class MoreKeySpecSplitTests extends InstrumentationTestCase {
}
private static String[] getAllResourceIdNames(final Class<?> resourceIdClass) {
final ArrayList<String> names = CollectionUtils.newArrayList();
final ArrayList<String> names = new ArrayList<>();
for (final Field field : resourceIdClass.getFields()) {
if (field.getType() == Integer.TYPE) {
names.add(field.getName());

View File

@ -20,7 +20,6 @@ import com.android.inputmethod.keyboard.Key;
import com.android.inputmethod.keyboard.internal.KeyboardIconsSet;
import com.android.inputmethod.keyboard.internal.MoreKeySpec;
import com.android.inputmethod.latin.Constants;
import com.android.inputmethod.latin.utils.CollectionUtils;
import com.android.inputmethod.latin.utils.StringUtils;
import java.util.ArrayList;
@ -34,7 +33,7 @@ import java.util.List;
*/
public final class ActualKeyboardBuilder extends AbstractKeyboardBuilder<Key> {
private static ArrayList<Key> filterOutSpacer(final List<Key> keys) {
final ArrayList<Key> filteredKeys = CollectionUtils.newArrayList();
final ArrayList<Key> filteredKeys = new ArrayList<>();
for (final Key key : keys) {
if (key.isSpacer()) {
continue;
@ -55,15 +54,15 @@ public final class ActualKeyboardBuilder extends AbstractKeyboardBuilder<Key> {
final ArrayList<Key> filteredSortedKeys = filterOutSpacer(sortedKeys);
// Grouping keys into rows.
final ArrayList<ArrayList<Key>> rows = CollectionUtils.newArrayList();
ArrayList<Key> elements = CollectionUtils.newArrayList();
final ArrayList<ArrayList<Key>> rows = new ArrayList<>();
ArrayList<Key> elements = new ArrayList<>();
int lastY = filteredSortedKeys.get(0).getY();
for (final Key key : filteredSortedKeys) {
if (lastY != key.getY()) {
// A new row is starting.
lastY = key.getY();
rows.add(elements);
elements = CollectionUtils.newArrayList();
elements = new ArrayList<>();
}
elements.add(key);
}

View File

@ -18,7 +18,6 @@ package com.android.inputmethod.keyboard.layout.expected;
import com.android.inputmethod.keyboard.Key;
import com.android.inputmethod.keyboard.internal.MoreKeySpec;
import com.android.inputmethod.latin.utils.CollectionUtils;
import java.util.ArrayList;
import java.util.Arrays;
@ -73,9 +72,8 @@ public class ExpectedKey {
// The additional more keys can be defined independently from other more keys.
// The position of the additional more keys in the long press popup keyboard can be
// controlled by specifying special marker "%" in the usual more keys definitions.
final ArrayList<ExpectedKey> moreKeysList = CollectionUtils.newArrayList();
final ArrayList<ExpectedAdditionalMoreKey> additionalMoreKeys =
CollectionUtils.newArrayList();
final ArrayList<ExpectedKey> moreKeysList = new ArrayList<>();
final ArrayList<ExpectedAdditionalMoreKey> additionalMoreKeys = new ArrayList<>();
int firstAdditionalMoreKeyIndex = -1;
for (int index = 0; index < moreKeys.length; index++) {
final ExpectedKey moreKey = moreKeys[index];

Some files were not shown because too many files have changed in this diff Show More