From 37b49b1e386be9449f8c093ab0b23c83d4b57ac1 Mon Sep 17 00:00:00 2001 From: ByteHamster Date: Sun, 7 Aug 2022 21:36:15 +0200 Subject: Use segmented buttons for filter --- .../antennapod/ui/common/RecursiveRadioGroup.java | 79 ---------------------- 1 file changed, 79 deletions(-) delete mode 100644 ui/common/src/main/java/de/danoeh/antennapod/ui/common/RecursiveRadioGroup.java (limited to 'ui/common') diff --git a/ui/common/src/main/java/de/danoeh/antennapod/ui/common/RecursiveRadioGroup.java b/ui/common/src/main/java/de/danoeh/antennapod/ui/common/RecursiveRadioGroup.java deleted file mode 100644 index 578208be4..000000000 --- a/ui/common/src/main/java/de/danoeh/antennapod/ui/common/RecursiveRadioGroup.java +++ /dev/null @@ -1,79 +0,0 @@ -package de.danoeh.antennapod.ui.common; - -import android.content.Context; -import android.util.AttributeSet; -import android.view.View; -import android.view.ViewGroup; -import android.widget.LinearLayout; -import android.widget.RadioButton; -import android.widget.RadioGroup; -import androidx.annotation.Nullable; - -import java.util.ArrayList; - -/** - * An alternative to {@link android.widget.RadioGroup} that allows to nest children. - * Basend on https://stackoverflow.com/a/14309274. - */ -public class RecursiveRadioGroup extends LinearLayout { - private final ArrayList radioButtons = new ArrayList<>(); - private RadioButton checkedButton = null; - @Nullable - private RadioGroup.OnCheckedChangeListener checkedChangeListener; - - public RecursiveRadioGroup(Context context) { - super(context); - } - - public RecursiveRadioGroup(Context context, AttributeSet attrs) { - this(context, attrs, 0); - } - - public RecursiveRadioGroup(Context context, AttributeSet attrs, int defStyle) { - super(context, attrs, defStyle); - } - - @Override - public void addView(View child, int index, ViewGroup.LayoutParams params) { - super.addView(child, index, params); - parseChild(child); - } - - public void setOnCheckedChangeListener(@Nullable RadioGroup.OnCheckedChangeListener listener) { - checkedChangeListener = listener; - } - - public void parseChild(final View child) { - if (child instanceof RadioButton) { - RadioButton button = (RadioButton) child; - radioButtons.add(button); - button.setOnCheckedChangeListener((buttonView, isChecked) -> { - if (!isChecked) { - return; - } - checkedButton = (RadioButton) buttonView; - if (checkedChangeListener != null) { - checkedChangeListener.onCheckedChanged(null, checkedButton.getId()); - } - - for (RadioButton view : radioButtons) { - if (view != buttonView) { - view.setChecked(false); - } - } - }); - } else if (child instanceof ViewGroup) { - parseChildren((ViewGroup) child); - } - } - - public void parseChildren(final ViewGroup child) { - for (int i = 0; i < child.getChildCount(); i++) { - parseChild(child.getChildAt(i)); - } - } - - public RadioButton getCheckedButton() { - return checkedButton; - } -} -- cgit v1.2.3