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

Commit 3628e6c

Browse files
cleaned some code
1 parent 4443648 commit 3628e6c

File tree

5 files changed

+10
-8
lines changed

5 files changed

+10
-8
lines changed

material_preferences_library/src/main/java/com/lb/material_preferences_library/PreferenceActivity.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77
import android.preference.Preference;
88
import android.preference.PreferenceGroup;
99
import android.preference.PreferenceScreen;
10-
import androidx.annotation.XmlRes;
11-
import androidx.appcompat.widget.Toolbar;
1210
import android.util.TypedValue;
1311
import android.view.View;
1412
import android.view.ViewGroup;
@@ -17,6 +15,9 @@
1715
import java.util.Map;
1816
import java.util.Stack;
1917

18+
import androidx.annotation.XmlRes;
19+
import androidx.appcompat.widget.Toolbar;
20+
2021
public abstract class PreferenceActivity extends AppCompatPreferenceActivity {
2122
private Toolbar _toolbar;
2223

@@ -45,7 +46,7 @@ protected void onCreate(final Bundle savedInstanceState) {
4546
addPreferencesFromResource(getPreferencesXmlId());
4647
final Map<Preference, PreferenceGroup> preferenceToParentMap = buildPreferenceParentTree(this);
4748
for (PreferenceGroup preferenceGroup : preferenceToParentMap.values())
48-
if (preferenceGroup != null && preferenceGroup instanceof PreferenceScreen)
49+
if (preferenceGroup instanceof PreferenceScreen)
4950
preferenceGroup.setLayoutResource(R.layout.mpl__preference);
5051
_toolbar.setClickable(true);
5152
_toolbar.setNavigationIcon(getResIdFromAttribute(this, R.attr.homeAsUpIndicator));

material_preferences_library/src/main/java/com/lb/material_preferences_library/custom_preferences/CheckBoxPreference.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public CheckBoxPreference(Context context) {
6767
protected void onBindView(View view) {
6868
super.onBindView(view);
6969
View checkboxView = view.findViewById(android.R.id.checkbox);
70-
if (checkboxView != null && checkboxView instanceof Checkable)
70+
if (checkboxView instanceof Checkable)
7171
((Checkable) checkboxView).setChecked(mChecked);
7272
syncSummaryView(view);
7373
}

material_preferences_library/src/main/java/com/lb/material_preferences_library/custom_preferences/SwitchPreference.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,15 @@
22

33
import android.content.Context;
44
import android.content.res.TypedArray;
5-
import androidx.appcompat.widget.SwitchCompat;
65
import android.util.AttributeSet;
76
import android.view.View;
87
import android.widget.Checkable;
98
import android.widget.CompoundButton;
109

1110
import com.lb.material_preferences_library.R;
1211

12+
import androidx.appcompat.widget.SwitchCompat;
13+
1314
/**
1415
* A {@link Preference} that provides a two-state toggleable option.
1516
* <p/>
@@ -114,7 +115,7 @@ protected void init(final Context context, final AttributeSet attrs, final int d
114115
protected void onBindView(View view) {
115116
super.onBindView(view);
116117
View checkableView = view.findViewById(android.R.id.checkbox);
117-
if (checkableView != null && checkableView instanceof Checkable) {
118+
if (checkableView instanceof Checkable) {
118119
if (checkableView instanceof SwitchCompat) {
119120
final SwitchCompat switchView = (SwitchCompat) checkableView;
120121
switchView.setOnCheckedChangeListener(null);

material_preferences_library/src/main/java/com/lb/material_preferences_library/custom_preferences/TwoStatePreference.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ public boolean isChecked() {
7979

8080
@Override
8181
public boolean shouldDisableDependents() {
82-
boolean shouldDisable = mDisableDependentsState ? mChecked : !mChecked;
82+
boolean shouldDisable = mDisableDependentsState == mChecked;
8383
return shouldDisable || super.shouldDisableDependents();
8484
}
8585

material_preferences_library/src/main/res/layout/mpl__preference_widget_checkbox.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
inside android.R.layout.preference. -->
1818
<androidx.appcompat.widget.AppCompatCheckBox xmlns:android="http://schemas.android.com/apk/res/android"
1919
xmlns:tools="http://schemas.android.com/tools"
20-
android:id="@+android:id/checkbox"
20+
android:id="@android:id/checkbox"
2121
android:layout_width="wrap_content"
2222
android:layout_height="wrap_content"
2323
android:background="@null"

0 commit comments

Comments
 (0)