package com.nilhcem.hostseditor.list;

import java.util.List;

import javax.inject.Inject;

import android.util.Log;
import android.widget.Filter;

import com.nilhcem.hostseditor.bus.event.RefreshHostsEvent;
import com.nilhcem.hostseditor.core.Host;
import com.nilhcem.hostseditor.core.HostsManager;
import com.squareup.otto.Bus;

public class ListHostsSearchFilter extends Filter {
	private static final String TAG = "ListHostsSearchFilter";

	@Inject Bus mBus;
	@Inject HostsManager mHostsManager;

	@SuppressWarnings("unchecked")
	@Override
	protected void publishResults(CharSequence constraint, FilterResults results) {
		Log.d(TAG, "Publishing result for: " + constraint);
		mBus.post(new RefreshHostsEvent((List<Host>) results.values));
	}

	@Override
	protected FilterResults performFiltering(CharSequence constraint) {
		Log.d(TAG, "Perform filtering for: " + constraint);
		FilterResults results = new FilterResults();
		results.values = mHostsManager.filterHosts(constraint);
		return results;
	}
}

@@ -81,24 +81,55 @@
 ct.Inject;%0A%0A
+import android.text.TextUtils;%0A
 import andro
@@ -645,24 +645,65 @@
  results) %7B%0A
+%09%09if (!TextUtils.isEmpty(constraint)) %7B%0A%09
 %09%09Log.d(TAG,
@@ -744,16 +744,20 @@
 raint);%0A
+%09%09%7D%0A
 %09%09mBus.p
@@ -897,16 +897,57 @@
 aint) %7B%0A
+%09%09if (!TextUtils.isEmpty(constraint)) %7B%0A%09
 %09%09Log.d(
@@ -992,16 +992,20 @@
 raint);%0A
+%09%09%7D%0A
 %09%09Filter

Improve log