use of com.facebook.accountkit.ui.ButtonType in project facebook-android-sdk by facebook.
the class AccountKitLoginActivity method setupAdvancedUIOptions.
private void setupAdvancedUIOptions() {
advancedUISwitch = (Switch) findViewById(R.id.advanced_ui_switch);
final View advancedUIOptionsLayout = findViewById(R.id.advanced_ui_options);
final List<CharSequence> buttonNames = new ArrayList<>();
buttonNames.add("Default");
for (ButtonType buttonType : ButtonType.values()) {
buttonNames.add(buttonType.name());
}
final ArrayAdapter<CharSequence> buttonNameAdapter = new ArrayAdapter<>(AccountKitLoginActivity.this, android.R.layout.simple_spinner_dropdown_item, buttonNames);
advancedUISwitch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (isChecked) {
if (isSkinSelected()) {
advancedUISwitch.setChecked(false);
Toast.makeText(AccountKitLoginActivity.this, R.string.skin_ui_required, Toast.LENGTH_LONG).show();
return;
}
advancedUIOptionsLayout.setVisibility(View.VISIBLE);
final Spinner entryButtonSpinner = (Spinner) findViewById(R.id.entry_button_spinner);
if (entryButtonSpinner != null) {
entryButtonSpinner.setAdapter(buttonNameAdapter);
entryButtonSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(final AdapterView<?> parent, final View view, final int position, final long id) {
// First position is empty, so anything past that
if (position > 0) {
entryButton = ButtonType.valueOf(entryButtonSpinner.getSelectedItem().toString());
} else {
entryButton = null;
}
}
@Override
public void onNothingSelected(final AdapterView<?> parent) {
entryButton = null;
}
});
}
final Spinner confirmButtonSpinner = (Spinner) findViewById(R.id.confirm_button_spinner);
if (confirmButtonSpinner != null) {
confirmButtonSpinner.setAdapter(buttonNameAdapter);
confirmButtonSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(final AdapterView<?> parent, final View view, final int position, final long id) {
// that
if (position > 0) {
confirmButton = ButtonType.valueOf(confirmButtonSpinner.getSelectedItem().toString());
} else {
confirmButton = null;
}
}
@Override
public void onNothingSelected(final AdapterView<?> parent) {
confirmButton = null;
}
});
}
final Spinner textPositionSpinner = (Spinner) findViewById(R.id.text_position_spinner);
if (textPositionSpinner != null) {
final List<CharSequence> textPositions = new ArrayList<>();
textPositions.add("Default");
for (TextPosition textPosition : TextPosition.values()) {
textPositions.add(textPosition.name());
}
final ArrayAdapter<CharSequence> textPositionAdapter = new ArrayAdapter<>(AccountKitLoginActivity.this, android.R.layout.simple_spinner_dropdown_item, textPositions);
textPositionSpinner.setAdapter(textPositionAdapter);
textPositionSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(final AdapterView<?> parent, final View view, final int position, final long id) {
// that
if (position > 0) {
textPosition = TextPosition.valueOf(textPositionSpinner.getSelectedItem().toString());
} else {
textPosition = null;
}
}
@Override
public void onNothingSelected(final AdapterView<?> parent) {
textPosition = null;
}
});
}
} else if (isReverbThemeSelected()) {
advancedUISwitch.setChecked(true);
Toast.makeText(AccountKitLoginActivity.this, R.string.reverb_advanced_ui_required, Toast.LENGTH_LONG).show();
} else {
advancedUIOptionsLayout.setVisibility(View.GONE);
}
}
});
}
Aggregations