Skip to content

Commit

Permalink
Fix multiple default values in filter on repeatable opening.
Browse files Browse the repository at this point in the history
  • Loading branch information
ZelvaJan committed Oct 21, 2016
1 parent 66f0e7c commit 84a8775
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,23 @@ public FilterRecyclerAdapter(Context context, Filters filterData) {
// Add default values
for (FilterType filterType : filterData.getFilters()) {
if (DeserializerFilters.FILTER_TYPE_COLOR.equals(filterType.getType())) {
((FilterTypeColor) filterType).getValues().add(0, new FilterValueColor(DEFAULT_ID, context.getString(R.string.All)));
try {
List<FilterValueColor> colorValues = ((FilterTypeColor) filterType).getValues();
if (colorValues.get(0).getId() != DEFAULT_ID || !colorValues.get(0).getValue().equals(context.getString(R.string.All))) {
colorValues.add(0, new FilterValueColor(DEFAULT_ID, context.getString(R.string.All)));
}
} catch (Exception e) {
Timber.e(e, "Setting default value for color filter failed");
}
} else if (DeserializerFilters.FILTER_TYPE_SELECT.equals(filterType.getType())) {
((FilterTypeSelect) filterType).getValues().add(0, new FilterValueSelect(DEFAULT_ID, context.getString(R.string.All)));
try {
List<FilterValueSelect> selectValues = ((FilterTypeSelect) filterType).getValues();
if (selectValues.get(0).getId() != DEFAULT_ID || !selectValues.get(0).getValue().equals(context.getString(R.string.All))) {
selectValues.add(0, new FilterValueSelect(DEFAULT_ID, context.getString(R.string.All)));
}
} catch (Exception e) {
Timber.e(e, "Setting default value for select filter failed");
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.3'
classpath 'com.android.tools.build:gradle:2.2.0'
classpath 'com.google.gms:google-services:2.0.0-beta2'

// NOTE: Do not place your application dependencies here; they belong
Expand Down

0 comments on commit 84a8775

Please sign in to comment.