CustomSwitchPreference.java
Go to the documentation of this file.
1 package com.introlab.rtabmap;
2 
3 import android.content.Context;
4 import android.preference.SwitchPreference;
5 import android.util.AttributeSet;
6 import android.view.View;
7 import android.view.ViewGroup;
8 import android.widget.Switch;
9 
18 public class CustomSwitchPreference extends SwitchPreference {
19 
27  public CustomSwitchPreference(Context context, AttributeSet attrs, int defStyle) {
28  super(context, attrs, defStyle);
29  }
30 
37  public CustomSwitchPreference(Context context, AttributeSet attrs) {
38  super(context, attrs);
39  }
40 
46  public CustomSwitchPreference(Context context) {
47  super(context, null);
48  }
49 
50  @Override
51  protected void onBindView(View view) {
52  // Clean listener before invoke SwitchPreference.onBindView
53  ViewGroup viewGroup= (ViewGroup)view;
54  clearListenerInViewGroup(viewGroup);
55  super.onBindView(view);
56  }
57 
63  private void clearListenerInViewGroup(ViewGroup viewGroup) {
64  if (null == viewGroup) {
65  return;
66  }
67 
68  int count = viewGroup.getChildCount();
69  for(int n = 0; n < count; ++n) {
70  View childView = viewGroup.getChildAt(n);
71  if(childView instanceof Switch) {
72  final Switch switchView = (Switch) childView;
73  switchView.setOnCheckedChangeListener(null);
74  return;
75  } else if (childView instanceof ViewGroup){
76  ViewGroup childGroup = (ViewGroup)childView;
77  clearListenerInViewGroup(childGroup);
78  }
79  }
80  }
81 
82 }
com.introlab.rtabmap.CustomSwitchPreference.CustomSwitchPreference
CustomSwitchPreference(Context context)
Definition: CustomSwitchPreference.java:46
com.introlab.rtabmap.CustomSwitchPreference.clearListenerInViewGroup
void clearListenerInViewGroup(ViewGroup viewGroup)
Definition: CustomSwitchPreference.java:63
count
Index count
com.introlab.rtabmap.CustomSwitchPreference.onBindView
void onBindView(View view)
Definition: CustomSwitchPreference.java:51
n
int n
view
set noclip points set clip one set noclip two set bar set border lt lw set xdata set ydata set zdata set x2data set y2data set boxwidth set dummy y set format x g set format y g set format x2 g set format y2 g set format z g set angles radians set nogrid set key title set key left top Right noreverse box linetype linewidth samplen spacing width set nolabel set noarrow set nologscale set logscale x set set pointsize set encoding default set nopolar set noparametric set view
com.introlab.rtabmap.CustomSwitchPreference.CustomSwitchPreference
CustomSwitchPreference(Context context, AttributeSet attrs)
Definition: CustomSwitchPreference.java:37
com.introlab.rtabmap.CustomSwitchPreference.CustomSwitchPreference
CustomSwitchPreference(Context context, AttributeSet attrs, int defStyle)
Definition: CustomSwitchPreference.java:27
com.introlab.rtabmap.CustomSwitchPreference
Definition: CustomSwitchPreference.java:18


rtabmap
Author(s): Mathieu Labbe
autogenerated on Thu Jul 25 2024 02:50:08