Skip to content

Commit

Permalink
Fixed bug sample app
Browse files Browse the repository at this point in the history
  • Loading branch information
pchmn committed Apr 26, 2017
1 parent 35190f6 commit f6c1ea2
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import android.widget.Filter;
import android.widget.Filterable;
import android.widget.TextView;
import android.widget.Toast;

import com.pchmn.materialchips.ChipsInput;
import com.pchmn.materialchips.R;
Expand Down Expand Up @@ -58,17 +59,23 @@ public FilterableAdapter(Context context,
ColorStateList textColor) {
mContext = context;
mRecyclerView = recyclerView;
Collections.sort(chipList, new Comparator<ChipInterface>() {
@Override
public int compare(ChipInterface o1, ChipInterface o2) {
Collator collator = Collator.getInstance(Locale.getDefault());
collator.setStrength(Collator.PRIMARY);
return collator.compare(o1.getLabel(), o2.getLabel());
}
});
mOriginalList.addAll(chipList);
mChipList.addAll(chipList);
mFilteredList.addAll(chipList);
if(chipList == null) {
Log.e(TAG, "The filterable list is null");
Toast.makeText(context, "The filterable list is null", Toast.LENGTH_LONG).show();
}
else {
Collections.sort(chipList, new Comparator<ChipInterface>() {
@Override
public int compare(ChipInterface o1, ChipInterface o2) {
Collator collator = Collator.getInstance(Locale.getDefault());
collator.setStrength(Collator.PRIMARY);
return collator.compare(o1.getLabel(), o2.getLabel());
}
});
mOriginalList.addAll(chipList);
mChipList.addAll(chipList);
mFilteredList.addAll(chipList);
}
mLetterTileProvider = new LetterTileProvider(mContext);
mBackgroundColor = backgroundColor;
mTextColor = textColor;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,15 @@ public class ContactListActivity extends AppCompatActivity {
@BindView(R.id.chips_input) ChipsInput mChipsInput;
@BindView(R.id.validate) Button mValidateButton;
@BindView(R.id.chip_list) TextView mChipListText;
private List<ContactChip> mContactList = new ArrayList<>();
private List<ContactChip> mContactList;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_contact_list);
// butter knife
ButterKnife.bind(this);
mContactList = new ArrayList<>();

// get contact list
new RxPermissions(this)
Expand Down

0 comments on commit f6c1ea2

Please sign in to comment.