Bindings: Move to a separate package

These are really app-independent reusable classes. Moving them to a
separate package helps avoid polluting the main app package, and makes
them easier to upgrade.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
This commit is contained in:
Samuel Holland 2017-11-07 23:34:20 -06:00
parent 6945aa1107
commit 6231bb18ac
9 changed files with 20 additions and 8 deletions

View File

@ -13,6 +13,7 @@ import android.widget.AbsListView;
import android.widget.AdapterView;
import android.widget.ListView;
import com.wireguard.android.bindings.ObservableMapAdapter;
import com.wireguard.android.databinding.ConfigListFragmentBinding;
import com.wireguard.config.Config;

View File

@ -12,6 +12,8 @@ import android.preference.PreferenceManager;
import android.service.quicksettings.TileService;
import android.util.Log;
import com.wireguard.android.bindings.ObservableSortedMap;
import com.wireguard.android.bindings.ObservableTreeMap;
import com.wireguard.config.Config;
import com.wireguard.config.Peer;

View File

@ -1,4 +1,4 @@
package com.wireguard.android;
package com.wireguard.android.bindings;
import android.databinding.BindingAdapter;
import android.databinding.ObservableList;
@ -9,6 +9,8 @@ import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.TextView;
import com.wireguard.android.R;
/**
* Static methods for use by generated code in the Android data binding library.
*/

View File

@ -1,4 +1,4 @@
package com.wireguard.android;
package com.wireguard.android.bindings;
import android.databinding.DataBindingUtil;
import android.databinding.ObservableList;
@ -7,6 +7,8 @@ import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.wireguard.android.BR;
import java.lang.ref.WeakReference;
/**

View File

@ -1,4 +1,4 @@
package com.wireguard.android;
package com.wireguard.android.bindings;
import android.content.Context;
import android.databinding.DataBindingUtil;
@ -10,6 +10,8 @@ import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ListAdapter;
import com.wireguard.android.BR;
import java.lang.ref.WeakReference;
/**

View File

@ -1,4 +1,4 @@
package com.wireguard.android;
package com.wireguard.android.bindings;
import android.content.Context;
import android.databinding.DataBindingUtil;
@ -10,6 +10,8 @@ import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ListAdapter;
import com.wireguard.android.BR;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.Collections;
@ -18,7 +20,8 @@ import java.util.Collections;
* A generic ListAdapter backed by a TreeMap that adds observability.
*/
class ObservableMapAdapter<K extends Comparable<K>, V> extends BaseAdapter implements ListAdapter {
public class ObservableMapAdapter<K extends Comparable<K>, V> extends BaseAdapter
implements ListAdapter {
private final OnMapChangedCallback<K, V> callback = new OnMapChangedCallback<>(this);
private ArrayList<K> keys;
private final int layoutId;

View File

@ -1,4 +1,4 @@
package com.wireguard.android;
package com.wireguard.android.bindings;
import android.databinding.ObservableMap;

View File

@ -1,4 +1,4 @@
package com.wireguard.android;
package com.wireguard.android.bindings;
import android.databinding.MapChangeRegistry;
import android.databinding.ObservableMap;

View File

@ -7,7 +7,7 @@
<!--suppress AndroidDomInspection -->
<variable
name="configs"
type="com.wireguard.android.ObservableSortedMap&lt;String, com.wireguard.config.Config&gt;" />
type="com.wireguard.android.bindings.ObservableSortedMap&lt;String, com.wireguard.config.Config&gt;" />
</data>
<ListView