Back to project page KangarooImageSearch.
The source code is released under:
MIT License
If you think the Android project KangarooImageSearch listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.nickrasband.kangarooimagesearchv2; //from ww w. j a v a 2 s. c om import java.util.Locale; import android.app.Activity; import android.content.Intent; import android.os.Bundle; import android.view.Menu; import android.widget.EditText; import android.widget.Spinner; public class SettingsActivity extends Activity { private SettingsData settingsData; private EditText etSiteFilter; private Spinner spinnerImageType; private Spinner spinnerImageSize; private Spinner spinnerColorFilter; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_settings); // Retrieve settings from main activity. Intent data = getIntent(); settingsData = (SettingsData)data.getSerializableExtra("settings"); setSettingsValues(); } // Get references to views and set their initial values. private void setSettingsValues() { // Create references to spinner views. spinnerImageType = (Spinner)findViewById(R.id.spinnerImageType); spinnerImageSize = (Spinner)findViewById(R.id.spinnerImageSize); spinnerColorFilter = (Spinner)findViewById(R.id.spinnerColorFilter); // Set the selected spinner item. int index = settingsData.getImageTypeIndex(); if (index != -1) spinnerImageType.setSelection(index); index = settingsData.getColorFilterIndex(); if (index != -1) spinnerColorFilter.setSelection(index); index = settingsData.getImageSizeIndex(); if (index != -1) spinnerImageSize.setSelection(index); // Initialize the site search field. etSiteFilter = (EditText)findViewById(R.id.etSiteFilter); etSiteFilter.setText(settingsData.siteSearch); } public void onBackPressed() { // TODO - make sure this is a valid domain. String site = etSiteFilter.getText().toString(); if (site != null) { settingsData.siteSearch = site; } else { site = ""; } // Set the settings data values. settingsData.imageColor = spinnerColorFilter.getSelectedItem().toString().toLowerCase(Locale.US); settingsData.imageSize = spinnerImageSize.getSelectedItem().toString().toLowerCase(Locale.US); settingsData.imageType = spinnerImageType.getSelectedItem().toString().toLowerCase(Locale.US); Intent data = new Intent(); data.putExtra("settings", settingsData); setResult(RESULT_OK, data); finish(); } @Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.settings, menu); return true; } }