use of android.widget.CompoundButton in project android_frameworks_base by ResurrectionRemix.
the class TransformsAndAnimationsActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.transforms_and_animations);
button1 = (Button) findViewById(R.id.button1);
button2 = (Button) findViewById(R.id.button2);
button3 = (Button) findViewById(R.id.button3);
button1a = (Button) findViewById(R.id.button1a);
button2a = (Button) findViewById(R.id.button2a);
button3a = (Button) findViewById(R.id.button3a);
button1b = (Button) findViewById(R.id.button1b);
button2b = (Button) findViewById(R.id.button2b);
button3b = (Button) findViewById(R.id.button3b);
button4 = (Button) findViewById(R.id.button4);
button5 = (Button) findViewById(R.id.button5);
button6 = (Button) findViewById(R.id.button6);
button7 = (Button) findViewById(R.id.button7);
button8 = (Button) findViewById(R.id.button8);
layersNoneCB = (CheckBox) findViewById(R.id.layersNoneCB);
layersHardwareCB = (CheckBox) findViewById(R.id.layersHwCB);
layersSoftwareCB = (CheckBox) findViewById(R.id.layersSwCB);
layersNoneCB.setOnCheckedChangeListener(new CheckBox.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (isChecked) {
setLayerType(View.LAYER_TYPE_NONE);
layersHardwareCB.setChecked(false);
layersSoftwareCB.setChecked(false);
}
}
});
layersSoftwareCB.setOnCheckedChangeListener(new CheckBox.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (isChecked) {
setLayerType(View.LAYER_TYPE_SOFTWARE);
layersHardwareCB.setChecked(false);
layersNoneCB.setChecked(false);
}
}
});
layersHardwareCB.setOnCheckedChangeListener(new CheckBox.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (isChecked) {
setLayerType(View.LAYER_TYPE_HARDWARE);
layersNoneCB.setChecked(false);
layersSoftwareCB.setChecked(false);
}
}
});
button1a.setAlpha(.5f);
button2a.setAlpha(.5f);
button3a.setAlpha(.5f);
button3.setTranslationX(50);
button7.setTranslationX(50);
button8.setTranslationX(50);
final AlphaAnimation alphaAnim = new AlphaAnimation(1, 0);
alphaAnim.setDuration(1000);
alphaAnim.setRepeatCount(Animation.INFINITE);
alphaAnim.setRepeatMode(Animation.REVERSE);
final TranslateAnimation transAnim = new TranslateAnimation(0, -50, 0, 0);
transAnim.setDuration(1000);
transAnim.setRepeatCount(Animation.INFINITE);
transAnim.setRepeatMode(Animation.REVERSE);
getWindow().getDecorView().postDelayed(new Runnable() {
@Override
public void run() {
button1.startAnimation(alphaAnim);
button2.startAnimation(alphaAnim);
button3.startAnimation(alphaAnim);
button1a.startAnimation(alphaAnim);
button2a.startAnimation(alphaAnim);
button3a.startAnimation(alphaAnim);
button1b.startAnimation(alphaAnim);
button2b.startAnimation(alphaAnim);
button3b.startAnimation(alphaAnim);
startAnimator(button1b);
startAnimator(button2b);
startAnimator(button3b);
button7.startAnimation(transAnim);
button8.startAnimation(transAnim);
}
}, 2000);
}
use of android.widget.CompoundButton in project android_frameworks_base by ResurrectionRemix.
the class VectorDrawable01 method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
GridLayout container = new GridLayout(this);
container.setColumnCount(5);
container.setBackgroundColor(0xFF888888);
final Button[] bArray = new Button[icon.length];
CheckBox toggle = new CheckBox(this);
toggle.setText("Toggle");
toggle.setChecked(true);
toggle.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
ViewGroup vg = (ViewGroup) buttonView.getParent();
for (int i = 0, count = vg.getChildCount(); i < count; i++) {
View child = vg.getChildAt(i);
if (child != buttonView) {
child.setEnabled(isChecked);
}
}
}
});
container.addView(toggle);
for (int i = 0; i < icon.length; i++) {
Button button = new Button(this);
bArray[i] = button;
button.setWidth(200);
button.setBackgroundResource(icon[i]);
container.addView(button);
VectorDrawable vd = (VectorDrawable) button.getBackground();
vd.setAlpha((i + 1) * (0xFF / (icon.length + 1)));
}
setContentView(container);
}
use of android.widget.CompoundButton in project android_packages_apps_Torch by CyanogenMod.
the class MainActivity method onCreate.
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
mButtonOn = (ToggleButton) findViewById(R.id.buttonOn);
mStrobeSwitch = (Switch) findViewById(R.id.strobe_switch);
mStrobeLabel = (TextView) findViewById(R.id.strobeTimeLabel);
mSlider = (SeekBar) findViewById(R.id.slider);
mBrightSwitch = (Switch) findViewById(R.id.bright_switch);
mStrobePeriod = 100;
mTorchOn = false;
mWidgetProvider = TorchWidgetProvider.getInstance();
// Preferences
mPrefs = PreferenceManager.getDefaultSharedPreferences(this);
mHasBrightSetting = getResources().getBoolean(R.bool.hasHighBrightness);
if (mHasBrightSetting) {
mBright = mPrefs.getBoolean("bright", false);
mBrightSwitch.setChecked(mBright);
mBrightSwitch.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (isChecked && mPrefs.getBoolean("bright", false)) {
mBright = true;
} else if (isChecked) {
openBrightDialog();
} else {
mBright = false;
mPrefs.edit().putBoolean("bright", false).commit();
}
}
});
} else {
// Fully hide the UI elements on Crespo since we can't use them
mBrightSwitch.setVisibility(View.GONE);
findViewById(R.id.ruler2).setVisibility(View.GONE);
}
// Set the state of the strobing section and hide as appropriate
final boolean isStrobing = mPrefs.getBoolean("strobe", false);
final LinearLayout strobeLayout = (LinearLayout) findViewById(R.id.strobeRow);
int visibility = isStrobing ? View.VISIBLE : View.GONE;
strobeLayout.setVisibility(visibility);
mStrobeSwitch.setChecked(isStrobing);
mStrobeSwitch.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
int visibility = isChecked ? View.VISIBLE : View.GONE;
strobeLayout.setVisibility(visibility);
mPrefs.edit().putBoolean("strobe", isChecked).commit();
}
});
mButtonOn.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(TorchSwitch.TOGGLE_FLASHLIGHT);
intent.putExtra("strobe", mStrobeSwitch.isChecked());
intent.putExtra("period", mStrobePeriod);
intent.putExtra("bright", mBright);
sendBroadcast(intent);
}
});
// Strobe frequency slider bar handling
setProgressBarVisibility(true);
updateStrobePeriod(mPrefs.getInt("strobeperiod", 100));
mSlider.setHorizontalScrollBarEnabled(true);
mSlider.setProgress(400 - mStrobePeriod);
mSlider.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {
@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
updateStrobePeriod(Math.max(20, 401 - progress));
Intent intent = new Intent("net.cactii.flash2.SET_STROBE");
intent.putExtra("period", mStrobePeriod);
sendBroadcast(intent);
}
@Override
public void onStartTrackingTouch(SeekBar seekBar) {
}
@Override
public void onStopTrackingTouch(SeekBar seekBar) {
}
});
// Show the about dialog, the first time the user runs the app.
if (!mPrefs.getBoolean("aboutSeen", false)) {
openAboutDialog();
mPrefs.edit().putBoolean("aboutSeen", true).commit();
}
}
use of android.widget.CompoundButton in project BaseRecyclerViewAdapterHelper by CymChad.
the class BaseViewHolder method setOnCheckedChangeListener.
/**
* Sets the on checked change listener of the view.
*
* @param viewId The view id.
* @param listener The checked change listener of compound button.
* @return The BaseViewHolder for chaining.
*/
public BaseViewHolder setOnCheckedChangeListener(int viewId, CompoundButton.OnCheckedChangeListener listener) {
CompoundButton view = getView(viewId);
view.setOnCheckedChangeListener(listener);
return this;
}
use of android.widget.CompoundButton in project BaseRecyclerViewAdapterHelper by CymChad.
the class AnimationUseActivity method initMenu.
private void initMenu() {
MaterialSpinner spinner = (MaterialSpinner) findViewById(R.id.spinner);
spinner.setItems("AlphaIn", "ScaleIn", "SlideInBottom", "SlideInLeft", "SlideInRight", "Custom");
spinner.setOnItemSelectedListener(new MaterialSpinner.OnItemSelectedListener<String>() {
@Override
public void onItemSelected(MaterialSpinner view, int position, long id, String item) {
switch(position) {
case 0:
mAnimationAdapter.openLoadAnimation(BaseQuickAdapter.ALPHAIN);
break;
case 1:
mAnimationAdapter.openLoadAnimation(BaseQuickAdapter.SCALEIN);
break;
case 2:
mAnimationAdapter.openLoadAnimation(BaseQuickAdapter.SLIDEIN_BOTTOM);
break;
case 3:
mAnimationAdapter.openLoadAnimation(BaseQuickAdapter.SLIDEIN_LEFT);
break;
case 4:
mAnimationAdapter.openLoadAnimation(BaseQuickAdapter.SLIDEIN_RIGHT);
break;
case 5:
mAnimationAdapter.openLoadAnimation(new CustomAnimation());
break;
default:
break;
}
mRecyclerView.setAdapter(mAnimationAdapter);
}
});
SwitchButton switchButton = (SwitchButton) findViewById(R.id.switch_button);
switchButton.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(final CompoundButton buttonView, final boolean isChecked) {
if (isChecked) {
mAnimationAdapter.isFirstOnly(true);
} else {
mAnimationAdapter.isFirstOnly(false);
}
mAnimationAdapter.notifyDataSetChanged();
}
});
}
Aggregations