aboutsummaryrefslogtreecommitdiffstats
path: root/java/src/com/android/inputmethod/dictionarypack/DictionaryListInterfaceState.java
diff options
context:
space:
mode:
authorAmin Bandali <bandali@kelar.org>2024-12-16 21:45:41 -0500
committerAmin Bandali <bandali@kelar.org>2025-01-11 14:17:35 -0500
commite9a0e66716dab4dd3184d009d8920de1961efdfa (patch)
tree02dcc096643d74645bf28459c2834c3d4a2ad7f2 /java/src/com/android/inputmethod/dictionarypack/DictionaryListInterfaceState.java
parentfb3b9360d70596d7e921de8bf7d3ca99564a077e (diff)
downloadlatinime-e9a0e66716dab4dd3184d009d8920de1961efdfa.tar.gz
latinime-e9a0e66716dab4dd3184d009d8920de1961efdfa.tar.xz
latinime-e9a0e66716dab4dd3184d009d8920de1961efdfa.zip
Rename to Kelar Keyboard (org.kelar.inputmethod.latin)
Diffstat (limited to 'java/src/com/android/inputmethod/dictionarypack/DictionaryListInterfaceState.java')
-rw-r--r--java/src/com/android/inputmethod/dictionarypack/DictionaryListInterfaceState.java85
1 files changed, 0 insertions, 85 deletions
diff --git a/java/src/com/android/inputmethod/dictionarypack/DictionaryListInterfaceState.java b/java/src/com/android/inputmethod/dictionarypack/DictionaryListInterfaceState.java
deleted file mode 100644
index 836340a75..000000000
--- a/java/src/com/android/inputmethod/dictionarypack/DictionaryListInterfaceState.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/**
- * Copyright (C) 2013 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy
- * of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations
- * under the License.
- */
-
-package com.android.inputmethod.dictionarypack;
-
-import android.view.View;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-
-/**
- * Helper class to maintain the interface state of word list preferences.
- *
- * This is necessary because the views are created on-demand by calling code. There are many
- * situations where views are renewed with little relation with user interaction. For example,
- * when scrolling, the view is reused so it doesn't keep its state, which means we need to keep
- * it separately. Also whenever the underlying dictionary list undergoes a change (for example,
- * update the metadata, or finish downloading) the whole list has to be thrown out and recreated
- * in case some dictionaries appeared, disappeared, changed states etc.
- */
-public class DictionaryListInterfaceState {
- static class State {
- public boolean mOpen = false;
- public int mStatus = MetadataDbHelper.STATUS_UNKNOWN;
- }
-
- 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);
- if (null == state) return false;
- return state.mOpen;
- }
-
- public int getStatus(final String wordlistId) {
- final State state = mWordlistToState.get(wordlistId);
- if (null == state) return MetadataDbHelper.STATUS_UNKNOWN;
- return state.mStatus;
- }
-
- public void setOpen(final String wordlistId, final int status) {
- final State newState;
- final State state = mWordlistToState.get(wordlistId);
- newState = null == state ? new State() : state;
- newState.mOpen = true;
- newState.mStatus = status;
- mWordlistToState.put(wordlistId, newState);
- }
-
- public void closeAll() {
- for (final State state : mWordlistToState.values()) {
- state.mOpen = false;
- }
- }
-
- public View findFirstOrphanedView() {
- for (final View v : mViewCache) {
- if (null == v.getParent()) return v;
- }
- return null;
- }
-
- public View addToCacheAndReturnView(final View view) {
- mViewCache.add(view);
- return view;
- }
-
- public void removeFromCache(final View view) {
- mViewCache.remove(view);
- }
-}