Skip to content
This repository has been archived by the owner on May 1, 2021. It is now read-only.

Commit

Permalink
cleaned some code
Browse files Browse the repository at this point in the history
  • Loading branch information
AndroidDeveloperLB committed Jun 23, 2018
1 parent 4443648 commit 3628e6c
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
import android.preference.Preference;
import android.preference.PreferenceGroup;
import android.preference.PreferenceScreen;
import androidx.annotation.XmlRes;
import androidx.appcompat.widget.Toolbar;
import android.util.TypedValue;
import android.view.View;
import android.view.ViewGroup;
Expand All @@ -17,6 +15,9 @@
import java.util.Map;
import java.util.Stack;

import androidx.annotation.XmlRes;
import androidx.appcompat.widget.Toolbar;

public abstract class PreferenceActivity extends AppCompatPreferenceActivity {
private Toolbar _toolbar;

Expand Down Expand Up @@ -45,7 +46,7 @@ protected void onCreate(final Bundle savedInstanceState) {
addPreferencesFromResource(getPreferencesXmlId());
final Map<Preference, PreferenceGroup> preferenceToParentMap = buildPreferenceParentTree(this);
for (PreferenceGroup preferenceGroup : preferenceToParentMap.values())
if (preferenceGroup != null && preferenceGroup instanceof PreferenceScreen)
if (preferenceGroup instanceof PreferenceScreen)
preferenceGroup.setLayoutResource(R.layout.mpl__preference);
_toolbar.setClickable(true);
_toolbar.setNavigationIcon(getResIdFromAttribute(this, R.attr.homeAsUpIndicator));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public CheckBoxPreference(Context context) {
protected void onBindView(View view) {
super.onBindView(view);
View checkboxView = view.findViewById(android.R.id.checkbox);
if (checkboxView != null && checkboxView instanceof Checkable)
if (checkboxView instanceof Checkable)
((Checkable) checkboxView).setChecked(mChecked);
syncSummaryView(view);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@

import android.content.Context;
import android.content.res.TypedArray;
import androidx.appcompat.widget.SwitchCompat;
import android.util.AttributeSet;
import android.view.View;
import android.widget.Checkable;
import android.widget.CompoundButton;

import com.lb.material_preferences_library.R;

import androidx.appcompat.widget.SwitchCompat;

/**
* A {@link Preference} that provides a two-state toggleable option.
* <p/>
Expand Down Expand Up @@ -114,7 +115,7 @@ protected void init(final Context context, final AttributeSet attrs, final int d
protected void onBindView(View view) {
super.onBindView(view);
View checkableView = view.findViewById(android.R.id.checkbox);
if (checkableView != null && checkableView instanceof Checkable) {
if (checkableView instanceof Checkable) {
if (checkableView instanceof SwitchCompat) {
final SwitchCompat switchView = (SwitchCompat) checkableView;
switchView.setOnCheckedChangeListener(null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public boolean isChecked() {

@Override
public boolean shouldDisableDependents() {
boolean shouldDisable = mDisableDependentsState ? mChecked : !mChecked;
boolean shouldDisable = mDisableDependentsState == mChecked;
return shouldDisable || super.shouldDisableDependents();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
inside android.R.layout.preference. -->
<androidx.appcompat.widget.AppCompatCheckBox xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+android:id/checkbox"
android:id="@android:id/checkbox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@null"
Expand Down

0 comments on commit 3628e6c

Please sign in to comment.