Skip to content

Commit

Permalink
Merge pull request #23 from pchmn/dev
Browse files Browse the repository at this point in the history
v1.0.8
  • Loading branch information
pchmn authored May 18, 2017
2 parents f270ab0 + 9f1b460 commit c4360d7
Showing 11 changed files with 44 additions and 35 deletions.
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
*.iml
.gradle
/local.properties
/.idea/workspace.xml
/.idea/libraries
/.idea
.DS_Store
/build
/captures
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
# CHANGELOG

# 1.0.8

Fixed bug related with [issue #16](https://github.com/pchmn/MaterialChipsInput/issues/16)

# 1.0.6 - 1.0.7

Fixed bug related with [issue #7](https://github.com/pchmn/MaterialChipsInput/issues/7)

# 1.0.5

Fixed bug related with [issue #13](https://github.com/pchmn/MaterialChipsInput/issues/13)

# 1.0.4

Fixed bug with `ChipView` label in v1.0.3
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -7,7 +7,7 @@ Implementation of Material Design [Chips](https://material.io/guidelines/compone
<img src="https://github.com/pchmn/MaterialChipsInput/blob/master/docs/demo2.gif" alt="Demo" height="600px"/>

## Demo
[Download sample-v1.0.4.apk](https://github.com/pchmn/MaterialChipsInput/raw/master/docs/material-chips-input-sample-v1.0.4.apk)
[Download sample-v1.0.8.apk](https://github.com/pchmn/MaterialChipsInput/raw/master/docs/material-chips-input-sample-v1.0.8.apk)

## Setup

@@ -26,7 +26,7 @@ allprojects {
In your app level build.gradle :
```java
dependencies {
compile 'com.github.pchmn:MaterialChipsInput:1.0.5'
compile 'com.github.pchmn:MaterialChipsInput:1.0.8'
}
```
<br><br>
Binary file added docs/material-chips-input-sample-v1.0.6.apk
Binary file not shown.
Binary file not shown.
Binary file added docs/material-chips-input-sample-v1.0.8.apk
Binary file not shown.
4 changes: 2 additions & 2 deletions library/build.gradle
Original file line number Diff line number Diff line change
@@ -8,8 +8,8 @@ android {
defaultConfig {
minSdkVersion 15
targetSdkVersion 25
versionCode 5
versionName "1.0.4"
versionCode 9
versionName "1.0.8"

testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

Original file line number Diff line number Diff line change
@@ -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;
@@ -24,6 +25,7 @@
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Locale;
@@ -48,6 +50,9 @@ public class FilterableAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
private ColorStateList mTextColor;
// recycler
private RecyclerView mRecyclerView;
// sort
private Comparator<ChipInterface> mComparator;
private Collator mCollator;


public FilterableAdapter(Context context,
@@ -58,14 +63,21 @@ public FilterableAdapter(Context context,
ColorStateList textColor) {
mContext = context;
mRecyclerView = recyclerView;
Collections.sort(chipList, new Comparator<ChipInterface>() {
mCollator = Collator.getInstance(Locale.getDefault());
mCollator.setStrength(Collator.PRIMARY);
mComparator = 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());
return mCollator.compare(o1.getLabel(), o2.getLabel());
}
});
};
// remove chips that do not have label
Iterator<? extends ChipInterface> iterator = chipList.iterator();
while(iterator.hasNext()) {
if(iterator.next().getLabel() == null)
iterator.remove();
}
sortList(chipList);
mOriginalList.addAll(chipList);
mChipList.addAll(chipList);
mFilteredList.addAll(chipList);
@@ -241,23 +253,9 @@ private void addChip(ChipInterface chip) {
mChipList.add(chip);
mFilteredList.add(chip);
// sort original list
Collections.sort(mChipList, 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());
}
});
sortList(mChipList);
// sort filtered list
Collections.sort(mFilteredList, 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());
}
});
sortList(mFilteredList);

notifyDataSetChanged();
}
@@ -271,5 +269,7 @@ private boolean contains(ChipInterface chip) {
return false;
}


private void sortList(List<? extends ChipInterface> list) {
Collections.sort(list, mComparator);
}
}
Original file line number Diff line number Diff line change
@@ -18,7 +18,7 @@ public ChipsInputEditText(Context context, AttributeSet attrs) {
}

public boolean isFilterableListVisible() {
return filterableListView.getVisibility() == VISIBLE;
return filterableListView != null && filterableListView.getVisibility() == VISIBLE;
}

public FilterableListView getFilterableListView() {
4 changes: 2 additions & 2 deletions sample/build.gradle
Original file line number Diff line number Diff line change
@@ -9,8 +9,8 @@ android {
applicationId "com.pchmn.sample.materialchipsinput"
minSdkVersion 15
targetSdkVersion 25
versionCode 5
versionName "1.0.4"
versionCode 9
versionName "1.0.8"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
Original file line number Diff line number Diff line change
@@ -5,17 +5,14 @@
import android.net.Uri;
import android.os.Bundle;
import android.provider.ContactsContract;
import android.support.v4.content.ContextCompat;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;

import com.pchmn.materialchips.ChipView;
import com.pchmn.materialchips.ChipsInput;
import com.pchmn.materialchips.model.Chip;
import com.pchmn.materialchips.model.ChipInterface;
import com.tbruyelle.rxpermissions2.RxPermissions;

@@ -31,14 +28,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)

0 comments on commit c4360d7

Please sign in to comment.