|
|
|
@ -65,6 +65,7 @@ import java.io.InputStream;
|
|
|
|
|
import java.text.NumberFormat;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.concurrent.ExecutorService;
|
|
|
|
|
|
|
|
|
|
public class AdapterContact extends RecyclerView.Adapter<AdapterContact.ViewHolder> {
|
|
|
|
|
private Fragment parentFragment;
|
|
|
|
@ -84,6 +85,9 @@ public class AdapterContact extends RecyclerView.Adapter<AdapterContact.ViewHold
|
|
|
|
|
|
|
|
|
|
private NumberFormat NF = NumberFormat.getNumberInstance();
|
|
|
|
|
|
|
|
|
|
private static final ExecutorService executor =
|
|
|
|
|
Helper.getBackgroundExecutor(1, "contacts");
|
|
|
|
|
|
|
|
|
|
public class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener, View.OnLongClickListener {
|
|
|
|
|
private View view;
|
|
|
|
|
private ImageView ivType;
|
|
|
|
@ -377,12 +381,15 @@ public class AdapterContact extends RecyclerView.Adapter<AdapterContact.ViewHold
|
|
|
|
|
|
|
|
|
|
all = contacts;
|
|
|
|
|
|
|
|
|
|
new SimpleTask<List<TupleContactEx>>() {
|
|
|
|
|
@Override
|
|
|
|
|
protected List<TupleContactEx> onExecute(Context context, Bundle args) throws Throwable {
|
|
|
|
|
List<TupleContactEx> filtered;
|
|
|
|
|
if (types.size() == 0)
|
|
|
|
|
filtered = all;
|
|
|
|
|
filtered = contacts;
|
|
|
|
|
else {
|
|
|
|
|
filtered = new ArrayList<>();
|
|
|
|
|
for (TupleContactEx contact : all)
|
|
|
|
|
for (TupleContactEx contact : contacts)
|
|
|
|
|
if (types.contains(contact.type))
|
|
|
|
|
filtered.add(contact);
|
|
|
|
|
}
|
|
|
|
@ -399,6 +406,11 @@ public class AdapterContact extends RecyclerView.Adapter<AdapterContact.ViewHold
|
|
|
|
|
items.add(contact);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return items;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
protected void onExecuted(Bundle args, List<TupleContactEx> items) {
|
|
|
|
|
DiffUtil.DiffResult diff = DiffUtil.calculateDiff(new DiffCallback(selected, items), false);
|
|
|
|
|
|
|
|
|
|
selected = items;
|
|
|
|
@ -424,7 +436,14 @@ public class AdapterContact extends RecyclerView.Adapter<AdapterContact.ViewHold
|
|
|
|
|
Log.d("Changed @" + position + " #" + count);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
diff.dispatchUpdatesTo(this);
|
|
|
|
|
diff.dispatchUpdatesTo(AdapterContact.this);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
protected void onException(Bundle args, Throwable ex) {
|
|
|
|
|
Log.unexpectedError(parentFragment.getParentFragmentManager(), ex);
|
|
|
|
|
}
|
|
|
|
|
}.setExecutor(executor).execute(context, owner, new Bundle(), "contacts:filter");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void search(String query) {
|
|
|
|
|