summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorSamuel Holland <samuel@sholland.org>2018-01-06 23:07:17 -0600
committerSamuel Holland <samuel@sholland.org>2018-01-06 23:07:17 -0600
commit4f2b6bef84f75bc17101a17c60251fc0df43aae1 (patch)
treec51c8fdfec422779d921f0455f029d55b52b34db
parent4d38993832839da2c4567ec5c412ecd4464b5d33 (diff)
Keyed...: Rename all the things
Hooray for diamond interface inheritance. Signed-off-by: Samuel Holland <samuel@sholland.org>
-rw-r--r--app/src/main/java/com/wireguard/android/QuickTileService.java4
-rw-r--r--app/src/main/java/com/wireguard/android/databinding/BindingAdapters.java12
-rw-r--r--app/src/main/java/com/wireguard/android/databinding/ObservableKeyedListAdapter.java (renamed from app/src/main/java/com/wireguard/android/databinding/KeyedObservableListAdapter.java)20
-rw-r--r--app/src/main/java/com/wireguard/android/model/TunnelManager.java10
-rw-r--r--app/src/main/java/com/wireguard/android/util/ObservableKeyedArrayList.java (renamed from app/src/main/java/com/wireguard/android/util/KeyedObservableArrayList.java)4
-rw-r--r--app/src/main/java/com/wireguard/android/util/ObservableKeyedList.java (renamed from app/src/main/java/com/wireguard/android/util/KeyedObservableList.java)2
-rw-r--r--app/src/main/java/com/wireguard/android/util/ObservableSortedKeyedArrayList.java (renamed from app/src/main/java/com/wireguard/android/util/SortedKeyedObservableArrayList.java)9
-rw-r--r--app/src/main/res/layout/tunnel_list_fragment.xml2
-rw-r--r--app/src/main/res/layout/tunnel_list_item.xml2
9 files changed, 32 insertions, 33 deletions
diff --git a/app/src/main/java/com/wireguard/android/QuickTileService.java b/app/src/main/java/com/wireguard/android/QuickTileService.java
index 10563b6e..3b652a5b 100644
--- a/app/src/main/java/com/wireguard/android/QuickTileService.java
+++ b/app/src/main/java/com/wireguard/android/QuickTileService.java
@@ -21,7 +21,7 @@ import com.wireguard.android.activity.SettingsActivity;
import com.wireguard.android.model.Tunnel;
import com.wireguard.android.model.Tunnel.State;
import com.wireguard.android.model.TunnelManager;
-import com.wireguard.android.util.KeyedObservableList;
+import com.wireguard.android.util.ObservableKeyedList;
import java.util.Objects;
@@ -104,7 +104,7 @@ public class QuickTileService extends TileService implements OnSharedPreferenceC
final String currentName = tunnel != null ? tunnel.getName() : null;
final String newName = preferences.getString(TunnelManager.KEY_PRIMARY_TUNNEL, null);
if (!Objects.equals(currentName, newName)) {
- final KeyedObservableList<String, Tunnel> tunnels = tunnelManager.getTunnels();
+ final ObservableKeyedList<String, Tunnel> tunnels = tunnelManager.getTunnels();
final Tunnel newTunnel = newName != null ? tunnels.get(newName) : null;
if (tunnel != null)
tunnel.removeOnPropertyChangedCallback(tunnelCallback);
diff --git a/app/src/main/java/com/wireguard/android/databinding/BindingAdapters.java b/app/src/main/java/com/wireguard/android/databinding/BindingAdapters.java
index f4dd2aff..34ddb010 100644
--- a/app/src/main/java/com/wireguard/android/databinding/BindingAdapters.java
+++ b/app/src/main/java/com/wireguard/android/databinding/BindingAdapters.java
@@ -11,7 +11,7 @@ import android.widget.TextView;
import com.wireguard.android.R;
import com.wireguard.android.util.Keyed;
-import com.wireguard.android.util.KeyedObservableList;
+import com.wireguard.android.util.ObservableKeyedList;
import com.wireguard.android.widget.ToggleSwitch;
import com.wireguard.android.widget.ToggleSwitch.OnBeforeCheckedChangeListener;
@@ -68,13 +68,13 @@ public final class BindingAdapters {
@BindingAdapter({"items", "layout"})
public static <K, E extends Keyed<? extends K>>
void setItems(final ListView view,
- final KeyedObservableList<K, E> oldList, final int oldLayoutId,
- final KeyedObservableList<K, E> newList, final int newLayoutId) {
+ final ObservableKeyedList<K, E> oldList, final int oldLayoutId,
+ final ObservableKeyedList<K, E> newList, final int newLayoutId) {
if (oldList == newList && oldLayoutId == newLayoutId)
return;
// The ListAdapter interface is not generic, so this cannot be checked.
- @SuppressWarnings("unchecked") KeyedObservableListAdapter<K, E> adapter =
- (KeyedObservableListAdapter<K, E>) view.getAdapter();
+ @SuppressWarnings("unchecked") ObservableKeyedListAdapter<K, E> adapter =
+ (ObservableKeyedListAdapter<K, E>) view.getAdapter();
// If the layout changes, any existing adapter must be replaced.
if (adapter != null && oldList != null && oldLayoutId != newLayoutId) {
adapter.setList(null);
@@ -84,7 +84,7 @@ public final class BindingAdapters {
if (newList == null || newLayoutId == 0)
return;
if (adapter == null) {
- adapter = new KeyedObservableListAdapter<>(view.getContext(), newLayoutId, newList);
+ adapter = new ObservableKeyedListAdapter<>(view.getContext(), newLayoutId, newList);
view.setAdapter(adapter);
}
// Either the list changed, or this is an entirely new listener because the layout changed.
diff --git a/app/src/main/java/com/wireguard/android/databinding/KeyedObservableListAdapter.java b/app/src/main/java/com/wireguard/android/databinding/ObservableKeyedListAdapter.java
index d1d377aa..b22c8909 100644
--- a/app/src/main/java/com/wireguard/android/databinding/KeyedObservableListAdapter.java
+++ b/app/src/main/java/com/wireguard/android/databinding/ObservableKeyedListAdapter.java
@@ -11,22 +11,22 @@ import android.widget.BaseAdapter;
import com.wireguard.android.BR;
import com.wireguard.android.util.Keyed;
-import com.wireguard.android.util.KeyedObservableList;
+import com.wireguard.android.util.ObservableKeyedList;
import java.lang.ref.WeakReference;
/**
- * A generic {@code ListAdapter} backed by a {@code KeyedObservableList}.
+ * A generic {@code ListAdapter} backed by a {@code ObservableKeyedList}.
*/
-class KeyedObservableListAdapter<K, E extends Keyed<? extends K>> extends BaseAdapter {
+class ObservableKeyedListAdapter<K, E extends Keyed<? extends K>> extends BaseAdapter {
private final OnListChangedCallback<E> callback = new OnListChangedCallback<>(this);
private final int layoutId;
private final LayoutInflater layoutInflater;
- private KeyedObservableList<K, E> list;
+ private ObservableKeyedList<K, E> list;
- KeyedObservableListAdapter(final Context context, final int layoutId,
- final KeyedObservableList<K, E> list) {
+ ObservableKeyedListAdapter(final Context context, final int layoutId,
+ final ObservableKeyedList<K, E> list) {
this.layoutId = layoutId;
layoutInflater = LayoutInflater.from(context);
setList(list);
@@ -72,7 +72,7 @@ class KeyedObservableListAdapter<K, E extends Keyed<? extends K>> extends BaseAd
return true;
}
- void setList(final KeyedObservableList<K, E> newList) {
+ void setList(final ObservableKeyedList<K, E> newList) {
if (list != null)
list.removeOnListChangedCallback(callback);
list = newList;
@@ -85,15 +85,15 @@ class KeyedObservableListAdapter<K, E extends Keyed<? extends K>> extends BaseAd
private static final class OnListChangedCallback<E extends Keyed<?>>
extends ObservableList.OnListChangedCallback<ObservableList<E>> {
- private final WeakReference<KeyedObservableListAdapter<?, E>> weakAdapter;
+ private final WeakReference<ObservableKeyedListAdapter<?, E>> weakAdapter;
- private OnListChangedCallback(final KeyedObservableListAdapter<?, E> adapter) {
+ private OnListChangedCallback(final ObservableKeyedListAdapter<?, E> adapter) {
weakAdapter = new WeakReference<>(adapter);
}
@Override
public void onChanged(final ObservableList<E> sender) {
- final KeyedObservableListAdapter adapter = weakAdapter.get();
+ final ObservableKeyedListAdapter adapter = weakAdapter.get();
if (adapter != null)
adapter.notifyDataSetChanged();
else
diff --git a/app/src/main/java/com/wireguard/android/model/TunnelManager.java b/app/src/main/java/com/wireguard/android/model/TunnelManager.java
index 123f5b51..68bb541a 100644
--- a/app/src/main/java/com/wireguard/android/model/TunnelManager.java
+++ b/app/src/main/java/com/wireguard/android/model/TunnelManager.java
@@ -8,8 +8,8 @@ import com.wireguard.android.configStore.ConfigStore;
import com.wireguard.android.model.Tunnel.State;
import com.wireguard.android.model.Tunnel.Statistics;
import com.wireguard.android.util.ExceptionLoggers;
-import com.wireguard.android.util.KeyedObservableList;
-import com.wireguard.android.util.SortedKeyedObservableArrayList;
+import com.wireguard.android.util.ObservableKeyedList;
+import com.wireguard.android.util.ObservableSortedKeyedArrayList;
import com.wireguard.config.Config;
import java.util.Collections;
@@ -37,8 +37,8 @@ public final class TunnelManager {
private final Backend backend;
private final ConfigStore configStore;
private final SharedPreferences preferences;
- private final KeyedObservableList<String, Tunnel> tunnels =
- new SortedKeyedObservableArrayList<>();
+ private final ObservableKeyedList<String, Tunnel> tunnels =
+ new ObservableSortedKeyedArrayList<>();
@Inject
public TunnelManager(final Backend backend, final ConfigStore configStore,
@@ -82,7 +82,7 @@ public final class TunnelManager {
return backend.getStatistics(tunnel).thenApply(tunnel::onStatisticsChanged);
}
- public KeyedObservableList<String, Tunnel> getTunnels() {
+ public ObservableKeyedList<String, Tunnel> getTunnels() {
return tunnels;
}
diff --git a/app/src/main/java/com/wireguard/android/util/KeyedObservableArrayList.java b/app/src/main/java/com/wireguard/android/util/ObservableKeyedArrayList.java
index 101f0ba7..6ba76207 100644
--- a/app/src/main/java/com/wireguard/android/util/KeyedObservableArrayList.java
+++ b/app/src/main/java/com/wireguard/android/util/ObservableKeyedArrayList.java
@@ -14,8 +14,8 @@ import java.util.Objects;
* operations, require O(n) time.
*/
-public class KeyedObservableArrayList<K, E extends Keyed<? extends K>>
- extends ObservableArrayList<E> implements KeyedObservableList<K, E> {
+public class ObservableKeyedArrayList<K, E extends Keyed<? extends K>>
+ extends ObservableArrayList<E> implements ObservableKeyedList<K, E> {
@Override
public boolean add(final E e) {
if (e == null)
diff --git a/app/src/main/java/com/wireguard/android/util/KeyedObservableList.java b/app/src/main/java/com/wireguard/android/util/ObservableKeyedList.java
index 15df0bba..af9fd34d 100644
--- a/app/src/main/java/com/wireguard/android/util/KeyedObservableList.java
+++ b/app/src/main/java/com/wireguard/android/util/ObservableKeyedList.java
@@ -6,6 +6,6 @@ import android.databinding.ObservableList;
* A list that is both keyed and observable.
*/
-public interface KeyedObservableList<K, E extends Keyed<? extends K>>
+public interface ObservableKeyedList<K, E extends Keyed<? extends K>>
extends KeyedList<K, E>, ObservableList<E> {
}
diff --git a/app/src/main/java/com/wireguard/android/util/SortedKeyedObservableArrayList.java b/app/src/main/java/com/wireguard/android/util/ObservableSortedKeyedArrayList.java
index 21fcccd3..9ccc1c10 100644
--- a/app/src/main/java/com/wireguard/android/util/SortedKeyedObservableArrayList.java
+++ b/app/src/main/java/com/wireguard/android/util/ObservableSortedKeyedArrayList.java
@@ -14,9 +14,8 @@ import java.util.List;
* key still require O(n) time.
*/
-public class SortedKeyedObservableArrayList<K extends Comparable<? super K>,
- E extends Keyed<? extends K>> extends KeyedObservableArrayList<K, E> {
-
+public class ObservableSortedKeyedArrayList<K extends Comparable<? super K>,
+ E extends Keyed<? extends K>> extends ObservableKeyedArrayList<K, E> {
private final transient List<K> keyList = new KeyList<>(this);
@Override
@@ -87,9 +86,9 @@ public class SortedKeyedObservableArrayList<K extends Comparable<? super K>,
private static final class KeyList<K extends Comparable<? super K>,
E extends Keyed<? extends K>> extends AbstractList<K> {
- private final SortedKeyedObservableArrayList<K, E> list;
+ private final ObservableSortedKeyedArrayList<K, E> list;
- private KeyList(final SortedKeyedObservableArrayList<K, E> list) {
+ private KeyList(final ObservableSortedKeyedArrayList<K, E> list) {
this.list = list;
}
diff --git a/app/src/main/res/layout/tunnel_list_fragment.xml b/app/src/main/res/layout/tunnel_list_fragment.xml
index fa489840..ba3728a3 100644
--- a/app/src/main/res/layout/tunnel_list_fragment.xml
+++ b/app/src/main/res/layout/tunnel_list_fragment.xml
@@ -12,7 +12,7 @@
<variable
name="tunnels"
- type="com.wireguard.android.util.KeyedObservableList&lt;String, Tunnel&gt;" />
+ type="com.wireguard.android.util.ObservableKeyedList&lt;String, Tunnel&gt;" />
</data>
<com.commonsware.cwac.crossport.design.widget.CoordinatorLayout
diff --git a/app/src/main/res/layout/tunnel_list_item.xml b/app/src/main/res/layout/tunnel_list_item.xml
index 8ae0dd23..8de2b3c2 100644
--- a/app/src/main/res/layout/tunnel_list_item.xml
+++ b/app/src/main/res/layout/tunnel_list_item.xml
@@ -10,7 +10,7 @@
<variable
name="collection"
- type="com.wireguard.android.util.KeyedObservableList&lt;String, Tunnel&gt;" />
+ type="com.wireguard.android.util.ObservableKeyedList&lt;String, Tunnel&gt;" />
<variable
name="key"