Skip to content

Commit

Permalink
Fixed Color bug when screen rotate.
Browse files Browse the repository at this point in the history
  • Loading branch information
Mohammad-Tabbara committed Feb 15, 2018
1 parent a44d94e commit 8e912f4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
1 change: 0 additions & 1 deletion uielements/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ dependencies {

implementation 'com.android.support:appcompat-v7:26.1.0'
testImplementation 'junit:junit:4.12'
compile 'com.crystal:crystalrangeseekbar:1.1.3'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
*/

public class JobDoneToggle extends ToggleButton {
private static boolean on = false;
public JobDoneToggle(Context context) {
super(context);
init();
Expand All @@ -36,7 +37,11 @@ private void init(){
setText(getResources().getString(R.string.incomplete));
int padding = (int) getResources().getDimension(R.dimen.small_spacing);
setPadding(padding,padding,padding,padding);
setBackgroundResource(android.R.color.holo_red_light);
if(on){
setBackgroundResource(android.R.color.holo_green_light);
}else{
setBackgroundResource(android.R.color.holo_red_light);
}
setTextOff(getResources().getString(R.string.incomplete));
setTextOn(getResources().getString(R.string.complete));
}
Expand All @@ -45,8 +50,10 @@ private void init(){
public void toggle() {
super.toggle();
if(isChecked()){
on=true;
setBackgroundResource(android.R.color.holo_green_light);
}else{
on=false;
setBackgroundResource(android.R.color.holo_red_light);
}
}
Expand Down

0 comments on commit 8e912f4

Please sign in to comment.