use of de.geeksfactory.opacclient.searchfields.DropdownSearchField in project opacclient by opacapp.
the class SearchFragment method loadQuery.
public void loadQuery(Bundle query) {
if (query == null) {
return;
}
for (SearchField field : fields) {
if (!field.isVisible()) {
continue;
}
ViewGroup v = (ViewGroup) view.findViewWithTag(field.getId());
if (v == null) {
continue;
}
if (field instanceof TextSearchField) {
EditText text;
if (((TextSearchField) field).isFreeSearch()) {
text = etSimpleSearch;
} else {
text = (EditText) v.findViewById(R.id.edittext);
}
text.setText(query.getString(field.getId()));
} else if (field instanceof BarcodeSearchField) {
EditText text = (EditText) v.findViewById(R.id.edittext);
text.setText(query.getString(field.getId()));
} else if (field instanceof DropdownSearchField) {
Spinner spinner = (Spinner) v.findViewById(R.id.spinner);
int i = 0;
if (((DropdownSearchField) field).getDropdownValues() == null) {
continue;
}
for (DropdownSearchField.Option map : ((DropdownSearchField) field).getDropdownValues()) {
if (map.getKey().equals(query.getString(field.getId()))) {
spinner.setSelection(i);
break;
}
i++;
}
} else if (field instanceof CheckboxSearchField) {
CheckBox checkbox = (CheckBox) v.findViewById(R.id.checkbox);
checkbox.setChecked(Boolean.valueOf(query.getString(field.getId())));
}
}
if (barcodeScanningField != null && scanResult != null) {
ViewGroup v = (ViewGroup) view.findViewWithTag(barcodeScanningField);
EditText text = (EditText) v.findViewById(R.id.edittext);
text.setText(scanResult.getContents());
barcodeScanningField = null;
scanResult = null;
}
}
use of de.geeksfactory.opacclient.searchfields.DropdownSearchField in project opacclient by opacapp.
the class Littera method addAdvancedSearchFields.
protected void addAdvancedSearchFields(List<SearchField> fields) throws IOException, JSONException {
final String html = httpGet(getApiUrl() + "&mode=a", getDefaultEncoding());
final Document doc = Jsoup.parse(html);
final Elements options = doc.select("select#adv_search_crit_0").first().select("option");
for (final Element option : options) {
final SearchField field;
if (SEARCH_FIELDS_FOR_DROPDOWN.contains(option.val())) {
field = new DropdownSearchField();
addDropdownValuesForField(((DropdownSearchField) field), option.val());
} else {
field = new TextSearchField();
((TextSearchField) field).setHint("");
}
field.setDisplayName(option.text());
field.setId(option.val());
field.setData(new JSONObject());
field.getData().put("meaning", field.getId());
fields.add(field);
}
}
use of de.geeksfactory.opacclient.searchfields.DropdownSearchField in project opacclient by opacapp.
the class Littera method addSortingSearchFields.
protected void addSortingSearchFields(List<SearchField> fields) throws IOException, JSONException {
final String html = httpGet(getApiUrl() + "&mode=a", getDefaultEncoding());
final Document doc = Jsoup.parse(html);
for (int i = 0; i < 3; i++) {
final Element tr = doc.select("#sort_editor tr.sort_" + i).first();
final DropdownSearchField field = new DropdownSearchField();
field.setMeaning(SearchField.Meaning.ORDER);
field.setId("sort_" + i);
field.setDisplayName(tr.select("td").first().text());
field.addDropdownValue("", "");
for (final Element option : tr.select(".crit option")) {
if (option.hasAttr("selected")) {
field.addDropdownValue(0, option.attr("value"), option.text());
} else {
field.addDropdownValue(option.attr("value"), option.text());
}
}
fields.add(field);
}
}
use of de.geeksfactory.opacclient.searchfields.DropdownSearchField in project opacclient by opacapp.
the class Pica method addParameters.
protected int addParameters(SearchQuery query, List<NameValuePair> params, int index) throws JSONException {
if (query.getValue().equals("") || query.getValue().equals("false")) {
return index;
}
if (query.getSearchField() instanceof TextSearchField || query.getSearchField() instanceof BarcodeSearchField) {
if (query.getSearchField().getData().getBoolean("ADI")) {
params.add(new BasicNameValuePair(query.getKey(), query.getValue()));
} else {
if (index == 0) {
params.add(new BasicNameValuePair("ACT" + index, "SRCH"));
} else {
params.add(new BasicNameValuePair("ACT" + index, "*"));
}
params.add(new BasicNameValuePair("IKT" + index, query.getKey()));
params.add(new BasicNameValuePair("TRM" + index, query.getValue()));
return index + 1;
}
} else if (query.getSearchField() instanceof CheckboxSearchField) {
boolean checked = Boolean.valueOf(query.getValue());
if (checked) {
params.add(new BasicNameValuePair(query.getKey(), "Y"));
}
} else if (query.getSearchField() instanceof DropdownSearchField) {
params.add(new BasicNameValuePair(query.getKey(), query.getValue()));
}
return index;
}
use of de.geeksfactory.opacclient.searchfields.DropdownSearchField in project opacclient by opacapp.
the class SISIS method parseDropdown.
private void parseDropdown(Element dropdownElement, List<SearchField> fields) throws JSONException {
Elements options = dropdownElement.select("option");
DropdownSearchField dropdown = new DropdownSearchField();
if (dropdownElement.parent().select("input[type=hidden]").size() > 0) {
dropdown.setId(dropdownElement.parent().select("input[type=hidden]").attr("value"));
dropdown.setData(new JSONObject("{\"restriction\": true}"));
} else {
dropdown.setId(dropdownElement.attr("name"));
dropdown.setData(new JSONObject("{\"restriction\": false}"));
}
for (Element option : options) {
dropdown.addDropdownValue(option.attr("value"), option.text());
}
dropdown.setDisplayName(dropdownElement.parent().select("label").text());
fields.add(dropdown);
}
Aggregations