diff options
10 files changed, 14 insertions, 18 deletions
diff --git a/app/src/main/java/net/lacolaco/smileessence/activity/EditCommandActivity.java b/app/src/main/java/net/lacolaco/smileessence/activity/EditCommandActivity.java index 4c1c2ac8..a45766bb 100644 --- a/app/src/main/java/net/lacolaco/smileessence/activity/EditCommandActivity.java +++ b/app/src/main/java/net/lacolaco/smileessence/activity/EditCommandActivity.java @@ -158,7 +158,7 @@ public class EditCommandActivity extends Activity { private void initializeViews() { ListView listView = getListView(); - adapter = new CustomListAdapter<>(this, CheckBoxModel.class); + adapter = new CustomListAdapter<>(this); listView.setAdapter(adapter); adapter.addToTop(getCheckBoxItems()); adapter.update(); diff --git a/app/src/main/java/net/lacolaco/smileessence/activity/EditExtractionActivity.java b/app/src/main/java/net/lacolaco/smileessence/activity/EditExtractionActivity.java index 98e7b11c..a4e03ec3 100644 --- a/app/src/main/java/net/lacolaco/smileessence/activity/EditExtractionActivity.java +++ b/app/src/main/java/net/lacolaco/smileessence/activity/EditExtractionActivity.java @@ -201,7 +201,7 @@ public class EditExtractionActivity extends Activity implements AdapterView.OnIt private void initializeViews() { ListView listView = getListView(); - adapter = new CustomListAdapter<>(this, ExtractionWord.class); + adapter = new CustomListAdapter<>(this); listView.setAdapter(adapter); adapter.addToTop(getExtractionWords()); adapter.update(); diff --git a/app/src/main/java/net/lacolaco/smileessence/activity/EditTabActivity.java b/app/src/main/java/net/lacolaco/smileessence/activity/EditTabActivity.java index e167152f..c6457437 100644 --- a/app/src/main/java/net/lacolaco/smileessence/activity/EditTabActivity.java +++ b/app/src/main/java/net/lacolaco/smileessence/activity/EditTabActivity.java @@ -144,7 +144,7 @@ public class EditTabActivity extends Activity { private void initializeViews() { ListView listView = getListView(); - adapter = new CustomListAdapter<>(this, EditableCheckBoxModel.class); + adapter = new CustomListAdapter<>(this); listView.setAdapter(adapter); adapter.addToTop(getCheckBoxItems()); adapter.update(); diff --git a/app/src/main/java/net/lacolaco/smileessence/activity/EditTemplateActivity.java b/app/src/main/java/net/lacolaco/smileessence/activity/EditTemplateActivity.java index b146ec77..25b6ce5d 100644 --- a/app/src/main/java/net/lacolaco/smileessence/activity/EditTemplateActivity.java +++ b/app/src/main/java/net/lacolaco/smileessence/activity/EditTemplateActivity.java @@ -201,7 +201,7 @@ public class EditTemplateActivity extends Activity implements AdapterView.OnItem private void initializeViews() { ListView listView = getListView(); - adapter = new CustomListAdapter<>(this, Template.class); + adapter = new CustomListAdapter<>(this); listView.setAdapter(adapter); adapter.addToTop(getTemplates()); adapter.update(); diff --git a/app/src/main/java/net/lacolaco/smileessence/view/adapter/CustomListAdapter.java b/app/src/main/java/net/lacolaco/smileessence/view/adapter/CustomListAdapter.java index 69c893e5..8b7b47a2 100644 --- a/app/src/main/java/net/lacolaco/smileessence/view/adapter/CustomListAdapter.java +++ b/app/src/main/java/net/lacolaco/smileessence/view/adapter/CustomListAdapter.java @@ -44,18 +44,15 @@ public class CustomListAdapter<T extends IViewModel> extends BaseAdapter { // ------------------------------ FIELDS ------------------------------ protected final Object LOCK = new Object(); - protected Class<T> clss; protected ArrayList<T> list = new ArrayList<>(); - protected T[] array; - protected int count; + protected List<T> frozenList = new ArrayList<>(); protected boolean isNotifiable = true; protected Activity activity; // --------------------------- CONSTRUCTORS --------------------------- - public CustomListAdapter(Activity activity, Class<T> clss) { + public CustomListAdapter(Activity activity) { this.activity = activity; - this.clss = clss; } // --------------------- GETTER / SETTER METHODS --------------------- @@ -66,7 +63,7 @@ public class CustomListAdapter<T extends IViewModel> extends BaseAdapter { @Override public int getCount() { - return count; + return frozenList.size(); } public boolean isNotifiable() { @@ -88,7 +85,7 @@ public class CustomListAdapter<T extends IViewModel> extends BaseAdapter { @Override public Object getItem(int position) { - return array[position]; + return frozenList.get(position); } @Override @@ -106,8 +103,7 @@ public class CustomListAdapter<T extends IViewModel> extends BaseAdapter { @Override public void notifyDataSetChanged() { sort(); - array = Iterables.toArray(list, clss); - count = array.length; + frozenList = Collections.unmodifiableList((ArrayList) list.clone()); super.notifyDataSetChanged(); } diff --git a/app/src/main/java/net/lacolaco/smileessence/view/adapter/EventListAdapter.java b/app/src/main/java/net/lacolaco/smileessence/view/adapter/EventListAdapter.java index 94762845..3bd4e1c0 100644 --- a/app/src/main/java/net/lacolaco/smileessence/view/adapter/EventListAdapter.java +++ b/app/src/main/java/net/lacolaco/smileessence/view/adapter/EventListAdapter.java @@ -33,6 +33,6 @@ public class EventListAdapter extends CustomListAdapter<EventViewModel> { // --------------------------- CONSTRUCTORS --------------------------- public EventListAdapter(Activity activity) { - super(activity, EventViewModel.class); + super(activity); } } diff --git a/app/src/main/java/net/lacolaco/smileessence/view/adapter/MessageListAdapter.java b/app/src/main/java/net/lacolaco/smileessence/view/adapter/MessageListAdapter.java index 7c6b992d..b521e236 100644 --- a/app/src/main/java/net/lacolaco/smileessence/view/adapter/MessageListAdapter.java +++ b/app/src/main/java/net/lacolaco/smileessence/view/adapter/MessageListAdapter.java @@ -37,7 +37,7 @@ public class MessageListAdapter extends CustomListAdapter<MessageViewModel> { // --------------------------- CONSTRUCTORS --------------------------- public MessageListAdapter(Activity activity) { - super(activity, MessageViewModel.class); + super(activity); } // --------------------- GETTER / SETTER METHODS --------------------- diff --git a/app/src/main/java/net/lacolaco/smileessence/view/adapter/StatusListAdapter.java b/app/src/main/java/net/lacolaco/smileessence/view/adapter/StatusListAdapter.java index 80c60b94..f2b4854d 100644 --- a/app/src/main/java/net/lacolaco/smileessence/view/adapter/StatusListAdapter.java +++ b/app/src/main/java/net/lacolaco/smileessence/view/adapter/StatusListAdapter.java @@ -38,7 +38,7 @@ public class StatusListAdapter extends CustomListAdapter<StatusViewModel> { // --------------------------- CONSTRUCTORS --------------------------- public StatusListAdapter(Activity activity) { - super(activity, StatusViewModel.class); + super(activity); } // --------------------- GETTER / SETTER METHODS --------------------- diff --git a/app/src/main/java/net/lacolaco/smileessence/view/dialog/MenuDialogFragment.java b/app/src/main/java/net/lacolaco/smileessence/view/dialog/MenuDialogFragment.java index f16da40d..bcd5e479 100644 --- a/app/src/main/java/net/lacolaco/smileessence/view/dialog/MenuDialogFragment.java +++ b/app/src/main/java/net/lacolaco/smileessence/view/dialog/MenuDialogFragment.java @@ -43,7 +43,7 @@ public abstract class MenuDialogFragment extends StackableDialogFragment { final MainActivity activity = (MainActivity) getActivity(); View body = activity.getLayoutInflater().inflate(R.layout.dialog_menu_list, null); ListView listView = (ListView) body.findViewById(R.id.listview_dialog_menu_list); - final CustomListAdapter<Command> adapter = new CustomListAdapter<>(activity, Command.class); + final CustomListAdapter<Command> adapter = new CustomListAdapter<>(activity); listView.setAdapter(adapter); listView.setOnItemClickListener(onItemClickListener); diff --git a/app/src/main/java/net/lacolaco/smileessence/view/dialog/SelectSearchQueryDialogFragment.java b/app/src/main/java/net/lacolaco/smileessence/view/dialog/SelectSearchQueryDialogFragment.java index 8d7c9728..2e2a05ed 100644 --- a/app/src/main/java/net/lacolaco/smileessence/view/dialog/SelectSearchQueryDialogFragment.java +++ b/app/src/main/java/net/lacolaco/smileessence/view/dialog/SelectSearchQueryDialogFragment.java @@ -84,7 +84,7 @@ public class SelectSearchQueryDialogFragment extends MenuDialogFragment implemen final MainActivity activity = (MainActivity) getActivity(); View body = activity.getLayoutInflater().inflate(R.layout.dialog_menu_list, null); ListView listView = (ListView) body.findViewById(R.id.listview_dialog_menu_list); - final CustomListAdapter<Command> adapter = new CustomListAdapter<>(activity, Command.class); + final CustomListAdapter<Command> adapter = new CustomListAdapter<>(activity); listView.setAdapter(adapter); listView.setOnItemClickListener(onItemClickListener); |