summaryrefslogtreecommitdiff
path: root/src/se/leap/leapclient
diff options
context:
space:
mode:
authorParménides GV <parmegv@sdf.org>2013-09-02 19:52:17 +0200
committercyBerta <richy@cyborgsociety.org>2013-11-15 23:25:16 +0100
commite865889715b8511dd432b89958e27975592d98ea (patch)
tree62496deb4f66cd3127b6511a9c5068557c5fb0cd /src/se/leap/leapclient
parent1d57d052814b8d46f3bdc850893171f238cdb2ef (diff)
New provider hides other providers.
If a new provider is added, it gets selected automatically hiding all other providers, as if it had been selected clicking on it.
Diffstat (limited to 'src/se/leap/leapclient')
-rw-r--r--src/se/leap/leapclient/ProviderListAdapter.java29
1 files changed, 22 insertions, 7 deletions
diff --git a/src/se/leap/leapclient/ProviderListAdapter.java b/src/se/leap/leapclient/ProviderListAdapter.java
index 61fe6bfa..e8782130 100644
--- a/src/se/leap/leapclient/ProviderListAdapter.java
+++ b/src/se/leap/leapclient/ProviderListAdapter.java
@@ -10,19 +10,25 @@ import android.widget.ArrayAdapter;
import android.widget.TwoLineListItem;
public class ProviderListAdapter<T> extends ArrayAdapter<T> {
- T[] items = null;
- boolean[] hidden = null;
+ private T[] items = null;
+ private static boolean[] hidden = null;
public void hide(int position) {
hidden[getRealPosition(position)] = true;
notifyDataSetChanged();
notifyDataSetInvalidated();
}
+
public void unHide(int position) {
hidden[getRealPosition(position)] = false;
notifyDataSetChanged();
notifyDataSetInvalidated();
}
+
+ public void unHideAll() {
+ for (int provider_index = 0; provider_index < hidden.length; provider_index++)
+ hidden[provider_index] = false;
+ }
private int getRealPosition(int position) {
int hElements = getHiddenCountUpTo(position);
@@ -58,9 +64,20 @@ public class ProviderListAdapter<T> extends ArrayAdapter<T> {
public ProviderListAdapter(Context mContext, int layout, List<T> objects) {
super(mContext, layout, objects);
items = objects.toArray((T[])new Object[0]);
- hidden = new boolean[items.length];
- for (int i = 0; i < items.length; i++)
- hidden[i] = false;
+ if(hidden == null) {
+ hidden = new boolean[items.length];
+ for (int i = 0; i < items.length; i++)
+ hidden[i] = false;
+ }
+ }
+
+ @Override
+ public void add(T item) {
+ super.add(item);
+ boolean[] new_hidden = new boolean[hidden.length+1];
+ System.arraycopy(hidden, 0, new_hidden, 0, hidden.length);
+ new_hidden[hidden.length] = false;
+ hidden = new_hidden;
}
@Override
@@ -76,8 +93,6 @@ public class ProviderListAdapter<T> extends ArrayAdapter<T> {
ProviderListContent.ProviderItem data = ProviderListContent.ITEMS.get(position);
row.getText1().setText(data.domain);
row.getText2().setText(data.name);
-
-
return row;
}