use of android.widget.RadioButton in project grafika by google.
the class HardwareScalerActivity method onRadioButtonClicked.
/**
* onClick handler for radio buttons.
*/
public void onRadioButtonClicked(View view) {
int newSize;
RadioButton rb = (RadioButton) view;
if (!rb.isChecked()) {
Log.d(TAG, "Got click on non-checked radio button");
return;
}
switch(rb.getId()) {
case R.id.surfaceSizeTiny_radio:
newSize = SURFACE_SIZE_TINY;
break;
case R.id.surfaceSizeSmall_radio:
newSize = SURFACE_SIZE_SMALL;
break;
case R.id.surfaceSizeMedium_radio:
newSize = SURFACE_SIZE_MEDIUM;
break;
case R.id.surfaceSizeFull_radio:
newSize = SURFACE_SIZE_FULL;
break;
default:
throw new RuntimeException("Click from unknown id " + rb.getId());
}
mSelectedSize = newSize;
int[] wh = mWindowWidthHeight[newSize];
// Update the Surface size. This causes a "surface changed" event, but does not
// destroy and re-create the Surface.
SurfaceView sv = (SurfaceView) findViewById(R.id.hardwareScaler_surfaceView);
SurfaceHolder sh = sv.getHolder();
Log.d(TAG, "setting size to " + wh[0] + "x" + wh[1]);
sh.setFixedSize(wh[0], wh[1]);
}
use of android.widget.RadioButton in project grafika by google.
the class RecordFBOActivity method onRadioButtonClicked.
/**
* onClick handler for radio buttons.
*/
public void onRadioButtonClicked(View view) {
RadioButton rb = (RadioButton) view;
if (!rb.isChecked()) {
Log.d(TAG, "Got click on non-checked radio button");
return;
}
switch(rb.getId()) {
case R.id.recDrawTwice_radio:
mSelectedRecordMethod = RECMETHOD_DRAW_TWICE;
break;
case R.id.recFbo_radio:
mSelectedRecordMethod = RECMETHOD_FBO;
break;
case R.id.recFramebuffer_radio:
mSelectedRecordMethod = RECMETHOD_BLIT_FRAMEBUFFER;
break;
default:
throw new RuntimeException("Click from unknown id " + rb.getId());
}
Log.d(TAG, "Selected rec mode " + mSelectedRecordMethod);
RenderHandler rh = mRenderThread.getHandler();
if (rh != null) {
rh.setRecordMethod(mSelectedRecordMethod);
}
}
use of android.widget.RadioButton in project grafika by google.
the class RecordFBOActivity method updateControls.
/**
* Updates the on-screen controls to reflect the current state of the app.
*/
private void updateControls() {
Button toggleRelease = (Button) findViewById(R.id.fboRecord_button);
int id = mRecordingEnabled ? R.string.toggleRecordingOff : R.string.toggleRecordingOn;
toggleRelease.setText(id);
RadioButton rb;
rb = (RadioButton) findViewById(R.id.recDrawTwice_radio);
rb.setChecked(mSelectedRecordMethod == RECMETHOD_DRAW_TWICE);
rb = (RadioButton) findViewById(R.id.recFbo_radio);
rb.setChecked(mSelectedRecordMethod == RECMETHOD_FBO);
rb = (RadioButton) findViewById(R.id.recFramebuffer_radio);
rb.setChecked(mSelectedRecordMethod == RECMETHOD_BLIT_FRAMEBUFFER);
rb.setEnabled(mBlitFramebufferAllowed);
TextView tv = (TextView) findViewById(R.id.nowRecording_text);
if (mRecordingEnabled) {
tv.setText(getString(R.string.nowRecording));
} else {
tv.setText("");
}
}
use of android.widget.RadioButton in project bdcodehelper by boredream.
the class IndicatorRadioGroup method setViewPager.
public void setViewPager(ViewPager vp, final int count) {
if (vp == null || vp.getAdapter() == null) {
return;
}
if (count <= 1) {
setVisibility(View.GONE);
return;
}
setVisibility(View.VISIBLE);
vp.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
@Override
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
}
@Override
public void onPageSelected(int position) {
if (getChildCount() > 1) {
View child = getChildAt(position % count);
if (child != null && child instanceof RadioButton) {
((RadioButton) child).setChecked(true);
}
}
}
@Override
public void onPageScrollStateChanged(int state) {
}
});
removeAllViews();
for (int i = 0; i < count; i++) {
RadioButton rb = new RadioButton(getContext());
LayoutParams params = new LayoutParams(DisplayUtils.dp2px(getContext(), 6), DisplayUtils.dp2px(getContext(), 6));
if (i > 0) {
params.setMargins(DisplayUtils.dp2px(getContext(), 10), 0, 0, 0);
}
rb.setLayoutParams(params);
rb.setButtonDrawable(new ColorDrawable());
rb.setBackgroundResource(indicatorRes);
rb.setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(View view, MotionEvent motionEvent) {
// do nothing
return true;
}
});
addView(rb);
}
((RadioButton) getChildAt(0)).setChecked(true);
}
use of android.widget.RadioButton in project StatusBarCompat by niorgai.
the class MainActivity method changeButtonStatus.
private void changeButtonStatus(int index, boolean check) {
RadioButton button;
switch(index) {
case PAGE_COMMON:
button = mCommon;
break;
case PAGE_TRANSLUCENT:
button = mTranslucent;
break;
case PAGE_COORDINATOR:
button = mCoordinator;
break;
case PAGE_COLLAPSING_TOOLBAR:
button = mCollapsingToolbar;
break;
default:
button = mCommon;
}
button.setOnCheckedChangeListener(null);
button.setChecked(check);
button.setOnCheckedChangeListener(this);
if (check) {
button.setTextColor(ContextCompat.getColor(this, R.color.colorAccent));
} else {
button.setTextColor(ContextCompat.getColor(this, R.color.colorBlack));
}
}
Aggregations