Minor cleanups

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
This commit is contained in:
Samuel Holland 2017-08-19 18:48:07 -05:00
parent a49fe9adf5
commit fbd923a060
2 changed files with 5 additions and 10 deletions

View File

@ -31,8 +31,7 @@ public final class BindingAdapters {
adapter = null; adapter = null;
// Add a new binding if there was none, or if it must be replaced due to a layout change. // Add a new binding if there was none, or if it must be replaced due to a layout change.
if (adapter == null) { if (adapter == null) {
adapter = new ObservableListAdapter<>(view.getContext(), newLayoutId, newList); view.setAdapter(new ObservableListAdapter<>(view.getContext(), newLayoutId, newList));
view.setAdapter(adapter);
} else if (newList != oldList) { } else if (newList != oldList) {
// Changing the list only requires modifying the existing adapter. // Changing the list only requires modifying the existing adapter.
adapter.setList(newList); adapter.setList(newList);
@ -40,11 +39,9 @@ public final class BindingAdapters {
} }
@BindingAdapter({"items", "layout"}) @BindingAdapter({"items", "layout"})
public static <K extends Comparable<K>, V> void sortedMapBinding(final ListView view, public static <K extends Comparable<K>, V> void sortedMapBinding(
final ObservableSortedMap<K, V> oldMap, final ListView view, final ObservableSortedMap<K, V> oldMap, final int oldLayoutId,
final int oldLayoutId, final ObservableSortedMap<K, V> newMap, final int newLayoutId) {
final ObservableSortedMap<K, V> newMap,
final int newLayoutId) {
// Remove any existing binding when there is no new map. // Remove any existing binding when there is no new map.
if (newMap == null) { if (newMap == null) {
view.setAdapter(null); view.setAdapter(null);
@ -58,8 +55,7 @@ public final class BindingAdapters {
adapter = null; adapter = null;
// Add a new binding if there was none, or if it must be replaced due to a layout change. // Add a new binding if there was none, or if it must be replaced due to a layout change.
if (adapter == null) { if (adapter == null) {
adapter = new ObservableMapAdapter<>(view.getContext(), newLayoutId, newMap); view.setAdapter(new ObservableMapAdapter<>(view.getContext(), newLayoutId, newMap));
view.setAdapter(adapter);
} else if (newMap != oldMap) { } else if (newMap != oldMap) {
// Changing the list only requires modifying the existing adapter. // Changing the list only requires modifying the existing adapter.
adapter.setMap(newMap); adapter.setMap(newMap);

View File

@ -1,7 +1,6 @@
package com.wireguard.android; package com.wireguard.android;
import android.content.res.Resources; import android.content.res.Resources;
import android.databinding.ObservableArrayMap;
import android.os.Bundle; import android.os.Bundle;
import android.util.Log; import android.util.Log;
import android.view.ActionMode; import android.view.ActionMode;