aboutsummaryrefslogtreecommitdiffstats
path: root/app/src/main/java/net/lacolaco/smileessence/view/adapter/OrderedCustomListAdapter.java
diff options
context:
space:
mode:
Diffstat (limited to 'app/src/main/java/net/lacolaco/smileessence/view/adapter/OrderedCustomListAdapter.java')
-rw-r--r--app/src/main/java/net/lacolaco/smileessence/view/adapter/OrderedCustomListAdapter.java66
1 files changed, 11 insertions, 55 deletions
diff --git a/app/src/main/java/net/lacolaco/smileessence/view/adapter/OrderedCustomListAdapter.java b/app/src/main/java/net/lacolaco/smileessence/view/adapter/OrderedCustomListAdapter.java
index 43d04b2e..3de58658 100644
--- a/app/src/main/java/net/lacolaco/smileessence/view/adapter/OrderedCustomListAdapter.java
+++ b/app/src/main/java/net/lacolaco/smileessence/view/adapter/OrderedCustomListAdapter.java
@@ -1,66 +1,31 @@
-/*
- * The MIT License (MIT)
- *
- * Copyright (c) 2012-2014 lacolaco.net
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
package net.lacolaco.smileessence.view.adapter;
-import android.app.Activity;
import net.lacolaco.smileessence.entity.IdObject;
-import net.lacolaco.smileessence.viewmodel.IViewModel;
import java.util.*;
-public class OrderedCustomListAdapter<T extends IViewModel & IdObject> extends CustomListAdapter<T> {
-
- // ------------------------------ FIELDS ------------------------------
-
+public abstract class OrderedCustomListAdapter<T extends IdObject> extends CustomListAdapter<T> {
private final Map<Long, T> treeMap;
- // --------------------------- CONSTRUCTORS ---------------------------
-
- public OrderedCustomListAdapter(Activity activity) {
- this(activity, Long::compare);
+ public OrderedCustomListAdapter() {
+ this(Long::compare);
}
- public OrderedCustomListAdapter(Activity activity, Comparator<Long> comparator) {
- super(activity);
- this.treeMap = new TreeMap<>(Collections.reverseOrder(comparator)); // 降順
+ public OrderedCustomListAdapter(Comparator<Long> comparator) {
+ super();
+ this.treeMap = new TreeMap<>(Collections.reverseOrder(comparator));
}
- // ------------------------ OVERRIDE METHODS ------------------------
-
@Override
- protected synchronized List<T> getFrozenList() {
- return Collections.unmodifiableList(new ArrayList<>(treeMap.values()));
+ protected synchronized List<T> getList() {
+ return new ArrayList<>(treeMap.values());
}
- // -------------------------- OTHER METHODS --------------------------
-
- public synchronized void addItem(T item) {
+ public synchronized void add(T item) {
treeMap.put(item.getId(), item);
}
- public synchronized void addItems(List<T> items) {
+ public synchronized void addAll(Collection<T> items) {
for (T item : items) {
treeMap.put(item.getId(), item);
}
@@ -70,16 +35,7 @@ public class OrderedCustomListAdapter<T extends IViewModel & IdObject> extends C
treeMap.clear();
}
- public synchronized T removeItem(T item) {
+ public synchronized T remove(T item) {
return treeMap.remove(item.getId());
}
-
- public synchronized int removeItemById(long id) {
- T item = treeMap.remove(id);
- if (item == null) {
- return 0;
- } else {
- return 1;
- }
- }
}