Search in sources :

Example 1 with OnItemSelected

use of butterknife.OnItemSelected in project apps-android-commons by commons-app.

the class SingleUploadFragment method onLicenseSelected.

@OnItemSelected(R.id.licenseSpinner)
void onLicenseSelected(AdapterView<?> parent, View view, int position, long id) {
    String licenseName = parent.getItemAtPosition(position).toString();
    // Set selected color to white because it should be readable on random images.
    TextView selectedText = (TextView) licenseSpinner.getChildAt(0);
    if (selectedText != null) {
        selectedText.setTextColor(Color.WHITE);
        selectedText.setBackgroundColor(Color.TRANSPARENT);
    }
    String license;
    if (getString(R.string.license_name_cc0).equals(licenseName)) {
        license = Prefs.Licenses.CC0;
    } else if (getString(R.string.license_name_cc_by).equals(licenseName)) {
        license = Prefs.Licenses.CC_BY_3;
    } else if (getString(R.string.license_name_cc_by_sa).equals(licenseName)) {
        license = Prefs.Licenses.CC_BY_SA_3;
    } else if (getString(R.string.license_name_cc_by_four).equals(licenseName)) {
        license = Prefs.Licenses.CC_BY_4;
    } else if (getString(R.string.license_name_cc_by_sa_four).equals(licenseName)) {
        license = Prefs.Licenses.CC_BY_SA_4;
    } else {
        throw new IllegalStateException("Unknown licenseName: " + licenseName);
    }
    setLicenseSummary(license);
    SharedPreferences.Editor editor = prefs.edit();
    editor.putString(Prefs.DEFAULT_LICENSE, license);
    editor.commit();
}
Also used : SharedPreferences(android.content.SharedPreferences) TextView(android.widget.TextView) OnItemSelected(butterknife.OnItemSelected)

Aggregations

SharedPreferences (android.content.SharedPreferences)1 TextView (android.widget.TextView)1 OnItemSelected (butterknife.OnItemSelected)1