summaryrefslogtreecommitdiff
path: root/ui/common
diff options
context:
space:
mode:
authorByteHamster <info@bytehamster.com>2022-08-07 21:36:15 +0200
committerByteHamster <info@bytehamster.com>2022-09-18 19:12:41 +0200
commit37b49b1e386be9449f8c093ab0b23c83d4b57ac1 (patch)
treeb69f969940220b925a7f0ac46eb5dba25bf6a444 /ui/common
parent2740816bb85041d4d67fe242bcf0dddb5ad06116 (diff)
downloadAntennaPod-37b49b1e386be9449f8c093ab0b23c83d4b57ac1.zip
Use segmented buttons for filter
Diffstat (limited to 'ui/common')
-rw-r--r--ui/common/src/main/java/de/danoeh/antennapod/ui/common/RecursiveRadioGroup.java79
1 files changed, 0 insertions, 79 deletions
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<RadioButton> 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;
- }
-}