Clean ups
This commit is contained in:
parent
2578d74ff8
commit
406529fcbd
2 changed files with 17 additions and 17 deletions
|
|
@ -14,6 +14,7 @@ import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.annotation.NonNull;
|
import android.support.annotation.NonNull;
|
||||||
import android.support.annotation.Nullable;
|
import android.support.annotation.Nullable;
|
||||||
|
import android.support.annotation.StringRes;
|
||||||
import android.support.v4.content.ContextCompat;
|
import android.support.v4.content.ContextCompat;
|
||||||
import android.support.v4.content.res.ResourcesCompat;
|
import android.support.v4.content.res.ResourcesCompat;
|
||||||
import android.support.v7.app.AppCompatActivity;
|
import android.support.v7.app.AppCompatActivity;
|
||||||
|
|
@ -127,7 +128,7 @@ public class ColorChooserDialog extends LeakDetectDialogFragment implements View
|
||||||
} else ((BaseAdapter) mGrid.getAdapter()).notifyDataSetChanged();
|
} else ((BaseAdapter) mGrid.getAdapter()).notifyDataSetChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void show(@NonNull AppCompatActivity activity, int title, int preselect) {
|
public void show(@NonNull AppCompatActivity activity, @StringRes int title, int preselect) {
|
||||||
Bundle args = new Bundle();
|
Bundle args = new Bundle();
|
||||||
args.putInt("preselect", preselect);
|
args.putInt("preselect", preselect);
|
||||||
args.putInt("title", title);
|
args.putInt("title", title);
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ package com.kabouzeid.gramophone.prefs;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.preference.Preference;
|
import android.preference.Preference;
|
||||||
|
import android.support.annotation.ColorInt;
|
||||||
import android.support.annotation.NonNull;
|
import android.support.annotation.NonNull;
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
|
@ -11,18 +12,19 @@ import com.kabouzeid.gramophone.views.ColorView;
|
||||||
|
|
||||||
public class ColorChooserPreference extends Preference {
|
public class ColorChooserPreference extends Preference {
|
||||||
|
|
||||||
private View mView;
|
@ColorInt
|
||||||
private int color;
|
private int color = -1;
|
||||||
|
private ColorView colorView;
|
||||||
|
|
||||||
public ColorChooserPreference(@NonNull Context context, @NonNull AttributeSet attrs) {
|
public ColorChooserPreference(@NonNull Context context) {
|
||||||
|
this(context, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ColorChooserPreference(@NonNull Context context, AttributeSet attrs) {
|
||||||
this(context, attrs, 0);
|
this(context, attrs, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ColorChooserPreference(@NonNull Context context) {
|
public ColorChooserPreference(@NonNull Context context, AttributeSet attrs, int defStyleAttr) {
|
||||||
this(context, null, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
public ColorChooserPreference(@NonNull Context context, @NonNull AttributeSet attrs, int defStyleAttr) {
|
|
||||||
super(context, attrs, defStyleAttr);
|
super(context, attrs, defStyleAttr);
|
||||||
setLayoutResource(R.layout.preference_custom);
|
setLayoutResource(R.layout.preference_custom);
|
||||||
setWidgetLayoutResource(R.layout.preference_color_widget);
|
setWidgetLayoutResource(R.layout.preference_color_widget);
|
||||||
|
|
@ -31,7 +33,7 @@ public class ColorChooserPreference extends Preference {
|
||||||
@Override
|
@Override
|
||||||
protected void onBindView(@NonNull View view) {
|
protected void onBindView(@NonNull View view) {
|
||||||
super.onBindView(view);
|
super.onBindView(view);
|
||||||
mView = view;
|
colorView = (ColorView) view.findViewById(R.id.circle);
|
||||||
invalidateColor();
|
invalidateColor();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -41,14 +43,11 @@ public class ColorChooserPreference extends Preference {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void invalidateColor() {
|
private void invalidateColor() {
|
||||||
if (mView != null) {
|
if (this.color >= 0) {
|
||||||
ColorView colorView = (ColorView) mView.findViewById(R.id.circle);
|
colorView.setVisibility(View.VISIBLE);
|
||||||
if (this.color != 0) {
|
colorView.setBackgroundColor(color);
|
||||||
colorView.setVisibility(View.VISIBLE);
|
} else {
|
||||||
colorView.setBackgroundColor(color);
|
colorView.setVisibility(View.GONE);
|
||||||
} else {
|
|
||||||
colorView.setVisibility(View.GONE);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue