use of android.widget.ToggleButton in project android by cSploit.
the class PacketForger method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
SharedPreferences themePrefs = getSharedPreferences("THEME", 0);
Boolean isDark = themePrefs.getBoolean("isDark", false);
if (isDark)
setTheme(R.style.DarkTheme);
else
setTheme(R.style.AppTheme);
super.onCreate(savedInstanceState);
mProtocol = (Spinner) findViewById(R.id.protocolSpinner);
mPort = (EditText) findViewById(R.id.portText);
mWaitResponse = (CheckBox) findViewById(R.id.responseCheckBox);
mData = (EditText) findViewById(R.id.dataText);
mResponse = (EditText) findViewById(R.id.responseText);
mSendButton = (ToggleButton) findViewById(R.id.sendButton);
Button mSendWOL = (Button) findViewById(R.id.sendWOL);
if (System.getCurrentTarget().getType() != Type.ENDPOINT)
mSendWOL.setVisibility(View.INVISIBLE);
mProtocol.setAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, PROTOCOLS));
mSendButton.setOnClickListener(this);
mSendWOL.setOnClickListener(this);
}
use of android.widget.ToggleButton in project TaEmCasa by Dionen.
the class SearchMenu method search.
public void search(final View view) {
String animais = "0";
String tipo_M_F = "2";
String tipo_R_A = "2";
String individual = "0";
String perfil = "2";
final Context context = view.getContext();
EditText maxValue_camp = (EditText) getView().findViewById(R.id.edtMaxPreco);
EditText minValue_camp = (EditText) getView().findViewById(R.id.edtMinPreco);
CheckBox animals_camp = (CheckBox) getView().findViewById(R.id.checkboxAnimais);
if (animals_camp.isChecked())
animais = "1";
ToggleButton apt_camp = (ToggleButton) getView().findViewById(R.id.toggleButtonApt);
ToggleButton rep_camp = (ToggleButton) getView().findViewById(R.id.toggleButtonRep);
if (apt_camp.isChecked() && !rep_camp.isChecked())
tipo_R_A = "0";
if (!apt_camp.isChecked() && rep_camp.isChecked())
tipo_R_A = "1";
CheckBox calmo_camp = (CheckBox) getView().findViewById(R.id.checkBoxCalmo);
CheckBox agitado_camp = (CheckBox) getView().findViewById(R.id.checkBoxAgitado);
if (calmo_camp.isChecked() && !agitado_camp.isChecked())
perfil = "0";
if (!calmo_camp.isChecked() && agitado_camp.isChecked())
perfil = "1";
RadioButton masculino = (RadioButton) getView().findViewById(R.id.masculina);
RadioButton feminina = (RadioButton) getView().findViewById(R.id.feminina);
if (masculino.isChecked())
tipo_M_F = "0";
if (feminina.isChecked())
tipo_M_F = "1";
CheckBox quartoIndividual = (CheckBox) getView().findViewById(R.id.quartoIndividual);
if (quartoIndividual.isChecked())
individual = "1";
final MessagesToUser message = new MessagesToUser();
Response.Listener<String> responseListener = new Response.Listener<String>() {
@Override
public void onResponse(String response) {
JSONObject jsonResponse = null;
// message.ToastMessage(response, context);
try {
jsonResponse = new JSONObject(response);
boolean success = jsonResponse.getBoolean("success");
if (success) {
Intent intent = new Intent(getActivity(), SearchListActivity.class);
JSONArray searchResponse = jsonResponse.getJSONArray("data");
ArrayList<Vaga> vagas = new ArrayList<>();
if (searchResponse.length() <= 0) {
message.ToastMessage("Não há vagas com esses critérios", context);
// return;
}
for (int i = 0; i < searchResponse.length(); i++) {
JSONObject atual = searchResponse.getJSONObject(i);
Vaga vaga = new Vaga();
Endereco end = new Endereco();
vaga.setPrice(atual.getString("vaga.preco"));
vaga.setTitle(atual.getString("republica.nome"));
end.setRua(atual.getString("republica.rua"));
end.setNumero(atual.getString("republica.numero"));
end.setComplemento(atual.getString("republica.complemento"));
end.setCidade(atual.getString("republica.cidade"));
end.setEstado(atual.getString("republica.estado"));
vaga.setAddress(end);
vagas.add(vaga);
}
intent.putExtra("vagas", vagas);
startActivity(intent);
} else {
message.ToastMessage("Falha no request", context);
}
} catch (JSONException e) {
e.printStackTrace();
message.ToastMessage("Falha na conexão", context);
}
}
};
/* ENTRA NA DATABASE ONLINE */
SearchRequest searchRequest = new SearchRequest(minValue_camp.getText().toString(), maxValue_camp.getText().toString(), tipo_M_F, individual, animais, tipo_R_A, perfil, responseListener);
RequestQueue queue = Volley.newRequestQueue(getActivity());
// Executa as tarefas requisitadas
queue.add(searchRequest);
}
use of android.widget.ToggleButton in project android_packages_apps_Gallery2 by LineageOS.
the class ColorPickerDialog method toggleClick.
void toggleClick(ToggleButton v, int[] buttons, boolean isChecked) {
int id = v.getId();
if (!isChecked) {
mSelectedButton = null;
return;
}
for (int i = 0; i < buttons.length; i++) {
if (id != buttons[i]) {
ToggleButton b = (ToggleButton) findViewById(buttons[i]);
b.setChecked(false);
}
}
mSelectedButton = v;
float[] hsv = (float[]) v.getTag();
ColorHueView csv = (ColorHueView) findViewById(R.id.ColorHueView);
ColorSVRectView cwv = (ColorSVRectView) findViewById(R.id.colorRectView);
ColorOpacityView cvv = (ColorOpacityView) findViewById(R.id.colorOpacityView);
cwv.setColor(hsv);
cvv.setColor(hsv);
csv.setColor(hsv);
}
use of android.widget.ToggleButton in project android-betterpickers by code-troopers.
the class RecurrencePickerDialogFragment method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
mRecurrence.wkst = EventRecurrence.timeDay2Day(Utils.getFirstDayOfWeek(getActivity()));
getDialog().getWindow().requestFeature(Window.FEATURE_NO_TITLE);
boolean endCountHasFocus = false;
if (savedInstanceState != null) {
RecurrenceModel m = (RecurrenceModel) savedInstanceState.get(BUNDLE_MODEL);
if (m != null) {
mModel = m;
}
endCountHasFocus = savedInstanceState.getBoolean(BUNDLE_END_COUNT_HAS_FOCUS);
} else {
Bundle bundle = getArguments();
if (bundle != null) {
mTime.set(bundle.getLong(BUNDLE_START_TIME_MILLIS));
String tz = bundle.getString(BUNDLE_TIME_ZONE);
if (!TextUtils.isEmpty(tz)) {
mTime.timezone = tz;
}
mTime.normalize(false);
// Time days of week: Sun=0, Mon=1, etc
mModel.weeklyByDayOfWeek[mTime.weekDay] = true;
String rrule = bundle.getString(BUNDLE_RRULE);
if (!TextUtils.isEmpty(rrule)) {
mModel.recurrenceState = RecurrenceModel.STATE_RECURRENCE;
mRecurrence.parse(rrule);
copyEventRecurrenceToModel(mRecurrence, mModel);
// Leave today's day of week as checked by default in weekly view.
if (mRecurrence.bydayCount == 0) {
mModel.weeklyByDayOfWeek[mTime.weekDay] = true;
}
}
mModel.forceHideSwitchButton = bundle.getBoolean(BUNDLE_HIDE_SWITCH_BUTTON, false);
} else {
mTime.setToNow();
}
}
mResources = getResources();
mView = inflater.inflate(R.layout.recurrencepicker, container, true);
final Activity activity = getActivity();
final Configuration config = activity.getResources().getConfiguration();
mRepeatSwitch = (SwitchCompat) mView.findViewById(R.id.repeat_switch);
if (mModel.forceHideSwitchButton) {
mRepeatSwitch.setChecked(true);
mRepeatSwitch.setVisibility(View.GONE);
mModel.recurrenceState = RecurrenceModel.STATE_RECURRENCE;
} else {
mRepeatSwitch.setChecked(mModel.recurrenceState == RecurrenceModel.STATE_RECURRENCE);
mRepeatSwitch.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
mModel.recurrenceState = isChecked ? RecurrenceModel.STATE_RECURRENCE : RecurrenceModel.STATE_NO_RECURRENCE;
togglePickerOptions();
}
});
}
mFreqSpinner = (Spinner) mView.findViewById(R.id.freqSpinner);
mFreqSpinner.setOnItemSelectedListener(this);
ArrayAdapter<CharSequence> freqAdapter = ArrayAdapter.createFromResource(getActivity(), R.array.recurrence_freq, R.layout.recurrencepicker_freq_item);
freqAdapter.setDropDownViewResource(R.layout.recurrencepicker_freq_item);
mFreqSpinner.setAdapter(freqAdapter);
mInterval = (EditText) mView.findViewById(R.id.interval);
mInterval.addTextChangedListener(new minMaxTextWatcher(1, INTERVAL_DEFAULT, INTERVAL_MAX) {
@Override
void onChange(int v) {
if (mIntervalResId != -1 && mInterval.getText().toString().length() > 0) {
mModel.interval = v;
updateIntervalText();
mInterval.requestLayout();
}
}
});
mIntervalPreText = (TextView) mView.findViewById(R.id.intervalPreText);
mIntervalPostText = (TextView) mView.findViewById(R.id.intervalPostText);
mEndNeverStr = mResources.getString(R.string.recurrence_end_continously);
mEndDateLabel = mResources.getString(R.string.recurrence_end_date_label);
mEndCountLabel = mResources.getString(R.string.recurrence_end_count_label);
mEndSpinnerArray.add(mEndNeverStr);
mEndSpinnerArray.add(mEndDateLabel);
mEndSpinnerArray.add(mEndCountLabel);
mEndSpinner = (Spinner) mView.findViewById(R.id.endSpinner);
mEndSpinner.setOnItemSelectedListener(this);
mEndSpinnerAdapter = new EndSpinnerAdapter(getActivity(), mEndSpinnerArray, R.layout.recurrencepicker_freq_item, R.layout.recurrencepicker_end_text);
mEndSpinnerAdapter.setDropDownViewResource(R.layout.recurrencepicker_freq_item);
mEndSpinner.setAdapter(mEndSpinnerAdapter);
mEndCount = (EditText) mView.findViewById(R.id.endCount);
mEndCount.addTextChangedListener(new minMaxTextWatcher(1, COUNT_DEFAULT, COUNT_MAX) {
@Override
void onChange(int v) {
if (mModel.endCount != v) {
mModel.endCount = v;
updateEndCountText();
mEndCount.requestLayout();
}
}
});
mPostEndCount = (TextView) mView.findViewById(R.id.postEndCount);
mEndDateTextView = (TextView) mView.findViewById(R.id.endDate);
mEndDateTextView.setOnClickListener(this);
if (mModel.endDate == null) {
mModel.endDate = new Time(mTime);
switch(mModel.freq) {
case RecurrenceModel.FREQ_HOURLY:
case RecurrenceModel.FREQ_DAILY:
case RecurrenceModel.FREQ_WEEKLY:
mModel.endDate.month += 1;
break;
case RecurrenceModel.FREQ_MONTHLY:
mModel.endDate.month += 3;
break;
case RecurrenceModel.FREQ_YEARLY:
mModel.endDate.year += 3;
break;
}
mModel.endDate.normalize(false);
}
mWeekGroup = (LinearLayout) mView.findViewById(R.id.weekGroup);
mWeekGroup2 = (LinearLayout) mView.findViewById(R.id.weekGroup2);
// In Calendar.java day of week order e.g Sun = 1 ... Sat = 7
String[] dayOfWeekString = new DateFormatSymbols().getWeekdays();
mMonthRepeatByDayOfWeekStrs = new String[7][];
// from Time.SUNDAY as 0 through Time.SATURDAY as 6
mMonthRepeatByDayOfWeekStrs[0] = mResources.getStringArray(R.array.repeat_by_nth_sun);
mMonthRepeatByDayOfWeekStrs[1] = mResources.getStringArray(R.array.repeat_by_nth_mon);
mMonthRepeatByDayOfWeekStrs[2] = mResources.getStringArray(R.array.repeat_by_nth_tues);
mMonthRepeatByDayOfWeekStrs[3] = mResources.getStringArray(R.array.repeat_by_nth_wed);
mMonthRepeatByDayOfWeekStrs[4] = mResources.getStringArray(R.array.repeat_by_nth_thurs);
mMonthRepeatByDayOfWeekStrs[5] = mResources.getStringArray(R.array.repeat_by_nth_fri);
mMonthRepeatByDayOfWeekStrs[6] = mResources.getStringArray(R.array.repeat_by_nth_sat);
// In Time.java day of week order e.g. Sun = 0
int idx = Utils.getFirstDayOfWeek(getActivity());
// In Calendar.java day of week order e.g Sun = 1 ... Sat = 7
dayOfWeekString = new DateFormatSymbols().getShortWeekdays();
int numOfButtonsInRow1;
int numOfButtonsInRow2;
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB_MR2) {
// Get screen width in dp first
Display display = getActivity().getWindowManager().getDefaultDisplay();
DisplayMetrics outMetrics = new DisplayMetrics();
display.getMetrics(outMetrics);
float density = getResources().getDisplayMetrics().density;
float dpWidth = outMetrics.widthPixels / density;
if (dpWidth > MIN_SCREEN_WIDTH_FOR_SINGLE_ROW_WEEK) {
numOfButtonsInRow1 = 7;
numOfButtonsInRow2 = 0;
mWeekGroup2.setVisibility(View.GONE);
mWeekGroup2.getChildAt(3).setVisibility(View.GONE);
} else {
numOfButtonsInRow1 = 4;
numOfButtonsInRow2 = 3;
mWeekGroup2.setVisibility(View.VISIBLE);
// Set rightmost button on the second row invisible so it takes up
// space and everything centers properly
mWeekGroup2.getChildAt(3).setVisibility(View.INVISIBLE);
}
} else if (mResources.getConfiguration().screenWidthDp > MIN_SCREEN_WIDTH_FOR_SINGLE_ROW_WEEK) {
numOfButtonsInRow1 = 7;
numOfButtonsInRow2 = 0;
mWeekGroup2.setVisibility(View.GONE);
mWeekGroup2.getChildAt(3).setVisibility(View.GONE);
} else {
numOfButtonsInRow1 = 4;
numOfButtonsInRow2 = 3;
mWeekGroup2.setVisibility(View.VISIBLE);
// Set rightmost button on the second row invisible so it takes up
// space and everything centers properly
mWeekGroup2.getChildAt(3).setVisibility(View.INVISIBLE);
}
/* First row */
for (int i = 0; i < 7; i++) {
if (i >= numOfButtonsInRow1) {
mWeekGroup.getChildAt(i).setVisibility(View.GONE);
continue;
}
mWeekByDayButtons[idx] = (ToggleButton) mWeekGroup.getChildAt(i);
mWeekByDayButtons[idx].setTextOff(dayOfWeekString[TIME_DAY_TO_CALENDAR_DAY[idx]]);
mWeekByDayButtons[idx].setTextOn(dayOfWeekString[TIME_DAY_TO_CALENDAR_DAY[idx]]);
mWeekByDayButtons[idx].setOnCheckedChangeListener(this);
if (++idx >= 7) {
idx = 0;
}
}
/* 2nd Row */
for (int i = 0; i < 3; i++) {
if (i >= numOfButtonsInRow2) {
mWeekGroup2.getChildAt(i).setVisibility(View.GONE);
continue;
}
mWeekByDayButtons[idx] = (ToggleButton) mWeekGroup2.getChildAt(i);
mWeekByDayButtons[idx].setTextOff(dayOfWeekString[TIME_DAY_TO_CALENDAR_DAY[idx]]);
mWeekByDayButtons[idx].setTextOn(dayOfWeekString[TIME_DAY_TO_CALENDAR_DAY[idx]]);
mWeekByDayButtons[idx].setOnCheckedChangeListener(this);
if (++idx >= 7) {
idx = 0;
}
}
mMonthGroup = (LinearLayout) mView.findViewById(R.id.monthGroup);
mMonthRepeatByRadioGroup = (RadioGroup) mView.findViewById(R.id.monthGroup);
mMonthRepeatByRadioGroup.setOnCheckedChangeListener(this);
mRepeatMonthlyByNthDayOfWeek = (RadioButton) mView.findViewById(R.id.repeatMonthlyByNthDayOfTheWeek);
mRepeatMonthlyByNthDayOfMonth = (RadioButton) mView.findViewById(R.id.repeatMonthlyByNthDayOfMonth);
mDoneButton = (Button) mView.findViewById(R.id.done_button);
mDoneButton.setOnClickListener(this);
Button cancelButton = (Button) mView.findViewById(R.id.cancel_button);
// FIXME no text color for this one ?
cancelButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
dismiss();
}
});
togglePickerOptions();
updateDialog();
if (endCountHasFocus) {
mEndCount.requestFocus();
}
return mView;
}
use of android.widget.ToggleButton in project fresco by facebook.
the class BitmapAnimationDebugFragment method onViewCreated.
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
// Get the animation container
final ImageView imageView = (ImageView) view.findViewById(R.id.animation_container);
mFrameInformationContainer = (LinearLayout) view.findViewById(R.id.frame_information);
mAnimatedDrawable = new AnimatedDrawable2();
mAnimatedDrawable.setDrawListener(new AnimatedDrawable2DebugDrawListener());
view.findViewById(R.id.invalidate_button).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
imageView.invalidate();
}
});
mAnimationControlsManager = new AnimationControlsManager(mAnimatedDrawable, (SeekBar) getView().findViewById(R.id.seekbar), (ToggleButton) getView().findViewById(R.id.playpause), getView().findViewById(R.id.reset));
new BitmapAnimationCacheSelectorConfigurator((Spinner) view.findViewById(R.id.spinner), mBitmapFrameCacheChangedListener, mFrameCacheListener);
imageView.setImageDrawable(mAnimatedDrawable);
}
Aggregations