Skip to content

Commit

Permalink
Merge pull request #13 from lzyzsd/master
Browse files Browse the repository at this point in the history
save ifDrawText state
  • Loading branch information
daimajia committed Oct 31, 2014
2 parents e8a47fe + bbf687e commit 2913c3f
Showing 1 changed file with 8 additions and 5 deletions.
Expand Up @@ -91,6 +91,7 @@ public class NumberProgressBar extends View {
private static final String INSTANCE_PROGRESS = "progress";
private static final String INSTANCE_SUFFIX = "suffix";
private static final String INSTANCE_PREFIX = "prefix";
private static final String INSTANCE_TEXT_VISBILITY = "text_visibility";

private static final int PROGRESS_TEXT_VISIBLE = 0;
private static final int PROGRESS_TEXT_INVISIBLE = 1;
Expand Down Expand Up @@ -452,6 +453,7 @@ protected Parcelable onSaveInstanceState() {
bundle.putInt(INSTANCE_PROGRESS,getProgress());
bundle.putString(INSTANCE_SUFFIX,getSuffix());
bundle.putString(INSTANCE_PREFIX,getPrefix());
bundle.putBoolean(INSTANCE_TEXT_VISBILITY, getProgressTextVisibility());
return bundle;
}

Expand All @@ -470,6 +472,7 @@ protected void onRestoreInstanceState(Parcelable state) {
setProgress(bundle.getInt(INSTANCE_PROGRESS));
setPrefix(bundle.getString(INSTANCE_PREFIX));
setSuffix(bundle.getString(INSTANCE_SUFFIX));
setProgressTextVisibility(bundle.getBoolean(INSTANCE_TEXT_VISBILITY) ? ProgressTextVisibility.Visible : ProgressTextVisibility.Invisible);
super.onRestoreInstanceState(bundle.getParcelable(INSTANCE_STATE));
return;
}
Expand All @@ -487,12 +490,12 @@ public float sp2px(float sp){
}

public void setProgressTextVisibility(ProgressTextVisibility visibility){
if(visibility == ProgressTextVisibility.Visible){
mIfDrawText = true;
}else{
mIfDrawText = false;
}
mIfDrawText = visibility == ProgressTextVisibility.Visible;
invalidate();
}

public boolean getProgressTextVisibility() {
return mIfDrawText;
}

}

0 comments on commit 2913c3f

Please sign in to comment.