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.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.annotation.StringRes;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
import android.support.v4.content.res.ResourcesCompat;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
|
|
@ -127,7 +128,7 @@ public class ColorChooserDialog extends LeakDetectDialogFragment implements View
|
|||
} 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();
|
||||
args.putInt("preselect", preselect);
|
||||
args.putInt("title", title);
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ package com.kabouzeid.gramophone.prefs;
|
|||
|
||||
import android.content.Context;
|
||||
import android.preference.Preference;
|
||||
import android.support.annotation.ColorInt;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.View;
|
||||
|
|
@ -11,18 +12,19 @@ import com.kabouzeid.gramophone.views.ColorView;
|
|||
|
||||
public class ColorChooserPreference extends Preference {
|
||||
|
||||
private View mView;
|
||||
private int color;
|
||||
@ColorInt
|
||||
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);
|
||||
}
|
||||
|
||||
public ColorChooserPreference(@NonNull Context context) {
|
||||
this(context, null, 0);
|
||||
}
|
||||
|
||||
public ColorChooserPreference(@NonNull Context context, @NonNull AttributeSet attrs, int defStyleAttr) {
|
||||
public ColorChooserPreference(@NonNull Context context, AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
setLayoutResource(R.layout.preference_custom);
|
||||
setWidgetLayoutResource(R.layout.preference_color_widget);
|
||||
|
|
@ -31,7 +33,7 @@ public class ColorChooserPreference extends Preference {
|
|||
@Override
|
||||
protected void onBindView(@NonNull View view) {
|
||||
super.onBindView(view);
|
||||
mView = view;
|
||||
colorView = (ColorView) view.findViewById(R.id.circle);
|
||||
invalidateColor();
|
||||
}
|
||||
|
||||
|
|
@ -41,14 +43,11 @@ public class ColorChooserPreference extends Preference {
|
|||
}
|
||||
|
||||
private void invalidateColor() {
|
||||
if (mView != null) {
|
||||
ColorView colorView = (ColorView) mView.findViewById(R.id.circle);
|
||||
if (this.color != 0) {
|
||||
colorView.setVisibility(View.VISIBLE);
|
||||
colorView.setBackgroundColor(color);
|
||||
} else {
|
||||
colorView.setVisibility(View.GONE);
|
||||
}
|
||||
if (this.color >= 0) {
|
||||
colorView.setVisibility(View.VISIBLE);
|
||||
colorView.setBackgroundColor(color);
|
||||
} else {
|
||||
colorView.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue