use of de.danoeh.antennapod.ui.common.RecursiveRadioGroup in project AntennaPod by AntennaPod.
the class FilterDialog method openDialog.
public void openDialog() {
final Set<String> filterValues = new HashSet<>(Arrays.asList(filter.getValues()));
AlertDialog.Builder builder = new AlertDialog.Builder(context);
builder.setTitle(R.string.filter);
LayoutInflater inflater = LayoutInflater.from(this.context);
View layout = inflater.inflate(R.layout.filter_dialog, null, false);
LinearLayout rows = layout.findViewById(R.id.filter_rows);
builder.setView(layout);
for (FeedItemFilterGroup item : FeedItemFilterGroup.values()) {
RecursiveRadioGroup row = (RecursiveRadioGroup) inflater.inflate(R.layout.filter_dialog_row, null, false);
RadioButton filter1 = row.findViewById(R.id.filter_dialog_radioButton1);
RadioButton filter2 = row.findViewById(R.id.filter_dialog_radioButton2);
filter1.setText(item.values[0].displayName);
filter1.setTag(item.values[0].filterId);
filter2.setText(item.values[1].displayName);
filter2.setTag(item.values[1].filterId);
rows.addView(row);
}
for (String filterId : filterValues) {
if (!TextUtils.isEmpty(filterId)) {
RadioButton button = layout.findViewWithTag(filterId);
if (button != null) {
button.setChecked(true);
}
}
}
builder.setPositiveButton(R.string.confirm_label, (dialog, which) -> {
filterValues.clear();
for (int i = 0; i < rows.getChildCount(); i++) {
if (!(rows.getChildAt(i) instanceof RecursiveRadioGroup)) {
continue;
}
RecursiveRadioGroup group = (RecursiveRadioGroup) rows.getChildAt(i);
if (group.getCheckedButton() != null) {
String tag = (String) group.getCheckedButton().getTag();
if (tag != null) {
// Clear buttons use no tag
filterValues.add((String) group.getCheckedButton().getTag());
}
}
}
updateFilter(filterValues);
});
builder.setNegativeButton(R.string.cancel_label, null);
builder.create().show();
}
use of de.danoeh.antennapod.ui.common.RecursiveRadioGroup in project AntennaPod by AntennaPod.
the class SubscriptionsFilterDialog method showDialog.
public static void showDialog(Context context) {
SubscriptionsFilter subscriptionsFilter = UserPreferences.getSubscriptionsFilter();
final Set<String> filterValues = new HashSet<>(Arrays.asList(subscriptionsFilter.getValues()));
AlertDialog.Builder builder = new AlertDialog.Builder(context);
builder.setTitle(context.getString(R.string.pref_filter_feed_title));
LayoutInflater inflater = LayoutInflater.from(context);
View layout = inflater.inflate(R.layout.filter_dialog, null, false);
LinearLayout rows = layout.findViewById(R.id.filter_rows);
builder.setView(layout);
for (SubscriptionsFilterGroup item : SubscriptionsFilterGroup.values()) {
RecursiveRadioGroup row = (RecursiveRadioGroup) inflater.inflate(R.layout.filter_dialog_row, null);
RadioButton filter1 = row.findViewById(R.id.filter_dialog_radioButton1);
RadioButton filter2 = row.findViewById(R.id.filter_dialog_radioButton2);
filter1.setText(item.values[0].displayName);
filter1.setTag(item.values[0].filterId);
if (item.values.length == 2) {
filter2.setText(item.values[1].displayName);
filter2.setTag(item.values[1].filterId);
} else {
filter2.setVisibility(View.GONE);
}
rows.addView(row);
}
for (String filterId : filterValues) {
if (!TextUtils.isEmpty(filterId)) {
((RadioButton) layout.findViewWithTag(filterId)).setChecked(true);
}
}
builder.setPositiveButton(R.string.confirm_label, (dialog, which) -> {
filterValues.clear();
for (int i = 0; i < rows.getChildCount(); i++) {
if (!(rows.getChildAt(i) instanceof RecursiveRadioGroup)) {
continue;
}
RecursiveRadioGroup group = (RecursiveRadioGroup) rows.getChildAt(i);
if (group.getCheckedButton() != null) {
String tag = (String) group.getCheckedButton().getTag();
if (tag != null) {
// Clear buttons use no tag
filterValues.add((String) group.getCheckedButton().getTag());
}
}
}
updateFilter(filterValues);
});
builder.setNegativeButton(R.string.cancel_label, null);
builder.show();
}
Aggregations