From e865889715b8511dd432b89958e27975592d98ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Parm=C3=A9nides=20GV?= Date: Mon, 2 Sep 2013 19:52:17 +0200 Subject: 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. --- src/se/leap/leapclient/ProviderListAdapter.java | 29 +++++++++++++++++++------ 1 file changed, 22 insertions(+), 7 deletions(-) (limited to 'src/se/leap/leapclient') 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 extends ArrayAdapter { - 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 extends ArrayAdapter { public ProviderListAdapter(Context mContext, int layout, List 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 extends ArrayAdapter { ProviderListContent.ProviderItem data = ProviderListContent.ITEMS.get(position); row.getText1().setText(data.domain); row.getText2().setText(data.name); - - return row; } -- cgit v1.2.3