public ATESwitchPreference(Context context) { super(context); init(context, null); }
private void init(Context context, AttributeSet attrs) { setLayoutResource(R.layout.ate_preference_custom); setWidgetLayoutResource(R.layout.ate_preference_switch); if (attrs != null) { TypedArray a = context.getTheme().obtainStyledAttributes(attrs, R.styleable.ATESwitchPreference, 0, 0); try { mKey = a.getString(R.styleable.ATESwitchPreference_ateKey_pref_switch); } finally { a.recycle(); } } }
statusBarPref.setChecked(Config.coloredStatusBar(getActivity(), mAteKey)); statusBarPref.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { @Override public boolean onPreferenceChange(Preference preference, Object newValue) { navBarPref.setChecked(Config.coloredNavigationBar(getActivity(), mAteKey)); navBarPref.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { @Override public boolean onPreferenceChange(Preference preference, Object newValue) { statusBarPref.setEnabled(false); statusBarPref.setSummary(R.string.not_available_below_lollipop); navBarPref.setEnabled(false); navBarPref.setSummary(R.string.not_available_below_lollipop);
@Override protected void onBindView(View view) { super.onBindView(view); mSwitch = (SwitchCompat) view.findViewById(R.id.switchWidget); mSwitch.setChecked(isChecked()); ATE.apply(view, mKey); }
private void init(Context context, AttributeSet attrs) { setLayoutResource(R.layout.ate_preference_custom); setWidgetLayoutResource(R.layout.ate_preference_switch); if (attrs != null) { TypedArray a = context.getTheme().obtainStyledAttributes(attrs, R.styleable.ATESwitchPreference, 0, 0); try { mKey = a.getString(R.styleable.ATESwitchPreference_ateKey_pref_switch); } finally { a.recycle(); } } try { Field canRecycleLayoutField = Preference.class.getDeclaredField("mCanRecycleLayout"); canRecycleLayoutField.setAccessible(true); canRecycleLayoutField.setBoolean(this, true); } catch (Exception ignored) { } try { Field hasSpecifiedLayout = Preference.class.getDeclaredField("mHasSpecifiedLayout"); hasSpecifiedLayout.setAccessible(true); hasSpecifiedLayout.setBoolean(this, true); } catch (Exception ignored) { } }
@Override protected void onBindView(View view) { super.onBindView(view); mSwitch = (ATESwitch) view.findViewById(R.id.switchWidget); mSwitch.setChecked(isChecked()); mSwitch.setKey(mKey); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) mSwitch.setBackground(null); ATE.themeView(view, mKey); }
public ATESwitchPreference(Context context, AttributeSet attrs) { super(context, attrs); init(context, attrs); }
public ATESwitchPreference(Context context, AttributeSet attrs) { super(context, attrs); init(context, attrs); }
public ATESwitchPreference(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); init(context, attrs); }
public ATESwitchPreference(Context context) { super(context); init(context, null); }
public ATESwitchPreference(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); init(context, attrs); }
@TargetApi(Build.VERSION_CODES.LOLLIPOP) public ATESwitchPreference(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { super(context, attrs, defStyleAttr, defStyleRes); init(context, attrs); }
@TargetApi(Build.VERSION_CODES.LOLLIPOP) public ATESwitchPreference(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { super(context, attrs, defStyleAttr, defStyleRes); init(context, attrs); }