Skip to content

Instantly share code, notes, and snippets.

@loganj
Created August 31, 2010 11:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save loganj/558907 to your computer and use it in GitHub Desktop.
Save loganj/558907 to your computer and use it in GitHub Desktop.
package com.joelapenna.foursquared.widget;
import android.widget.CheckBox;
import android.widget.Checkable;
import android.widget.ProgressBar;
import android.widget.ViewSwitcher;
final public class BusyCheckBox extends ViewSwitcher implements Checkable {
final private CheckBox checkBox;
final private ProgressBar progressBar;
public BusyCheckBox(CheckBox checkBox) {
super(checkBox.getContext());
this.checkBox = checkBox;
progressBar = new ProgressBar(checkBox.getContext());
addView(checkBox);
addView(progressBar);
}
@Override
public void setChecked(boolean b) {
checkBox.setChecked(b);
}
@Override
public boolean isChecked() {
return checkBox.isChecked();
}
@Override
public void toggle() {
checkBox.toggle();
}
@Override
public void setEnabled(boolean enabled) {
if ((enabled && getCurrentView() == progressBar) || (!enabled && getCurrentView() == checkBox)) {
this.showNext();
}
super.setEnabled(enabled);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment