use of de.geeksfactory.opacclient.searchfields.BarcodeSearchField in project opacclient by opacapp.
the class BiBer1992 method search.
@Override
public SearchRequestResult search(List<SearchQuery> queryList) throws IOException {
if (!initialised) {
start();
}
nameValuePairs.clear();
int count = 1;
for (SearchQuery query : queryList) {
if ((query.getSearchField() instanceof TextSearchField || query.getSearchField() instanceof BarcodeSearchField) && !query.getValue().equals("")) {
nameValuePairs.add(new BasicNameValuePair("CNN" + count, "AND"));
nameValuePairs.add(new BasicNameValuePair("FLD" + count, query.getValue()));
nameValuePairs.add(new BasicNameValuePair("REG" + count, query.getKey()));
count++;
} else if (query.getSearchField() instanceof DropdownSearchField) {
nameValuePairs.add(new BasicNameValuePair(query.getKey(), query.getValue()));
}
}
nameValuePairs.add(new BasicNameValuePair("FUNC", "qsel"));
nameValuePairs.add(new BasicNameValuePair("LANG", "de"));
// but
nameValuePairs.add(new BasicNameValuePair("SHOW", "20"));
// result
// gives 50
nameValuePairs.add(new BasicNameValuePair("SHOWSTAT", "N"));
nameValuePairs.add(new BasicNameValuePair("FROMPOS", "1"));
return searchGetPage(1);
}
use of de.geeksfactory.opacclient.searchfields.BarcodeSearchField in project opacclient by opacapp.
the class SearchFragment method saveSearchQuery.
public List<SearchQuery> saveSearchQuery() {
saveHomeBranch();
List<SearchQuery> query = new ArrayList<>();
if (fields == null || view == null) {
return null;
}
for (SearchField field : fields) {
if (!field.isVisible()) {
continue;
}
ViewGroup v = (ViewGroup) view.findViewWithTag(field.getId());
if (field instanceof TextSearchField) {
EditText text;
if (((TextSearchField) field).isFreeSearch()) {
text = etSimpleSearch;
} else {
if (v == null)
continue;
text = (EditText) v.findViewById(R.id.edittext);
}
query.add(new SearchQuery(field, text.getEditableText().toString().trim()));
} else if (field instanceof BarcodeSearchField) {
if (v == null)
continue;
EditText text = (EditText) v.findViewById(R.id.edittext);
query.add(new SearchQuery(field, text.getEditableText().toString().trim()));
} else if (field instanceof DropdownSearchField) {
if (v == null)
continue;
Spinner spinner = (Spinner) v.findViewById(R.id.spinner);
if (spinner.getSelectedItemPosition() != -1) {
String key = ((DropdownSearchField) field).getDropdownValues().get(spinner.getSelectedItemPosition()).getKey();
if (!key.equals("")) {
query.add(new SearchQuery(field, key));
}
}
} else if (field instanceof CheckboxSearchField) {
if (v == null)
continue;
CheckBox checkbox = (CheckBox) v.findViewById(R.id.checkbox);
query.add(new SearchQuery(field, String.valueOf(checkbox.isChecked())));
}
}
return query;
}
use of de.geeksfactory.opacclient.searchfields.BarcodeSearchField in project opacclient by opacapp.
the class SearchFragment method buildSearchForm.
protected void buildSearchForm(Map<String, String> restoreQuery) {
String skey = "annoyed_" + app.getLibrary().getIdent();
if (app.getLibrary().getReplacedBy() != null && !"".equals(app.getLibrary().getReplacedBy()) && sp.getInt(skey, 0) < 5 && app.promotePlusApps()) {
rlReplaced.setVisibility(View.VISIBLE);
ivReplacedStore.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
try {
Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse(app.getLibrary().getReplacedBy().replace("https://play.google.com/store/apps/details?id=", "market://details?id=")));
startActivity(i);
} catch (ActivityNotFoundException e) {
Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse(app.getLibrary().getReplacedBy()));
startActivity(i);
}
}
});
sp.edit().putInt(skey, sp.getInt(skey, 0) + 1).apply();
} else {
rlReplaced.setVisibility(View.GONE);
}
llFormFields.removeAllViews();
llAdvancedFields.removeAllViews();
llExpand.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
setAdvanced(!advanced);
}
});
rlSimpleSearch.setVisibility(View.GONE);
tvSearchAdvHeader.setVisibility(View.GONE);
int i = 0;
if (fields == null) {
return;
}
for (final SearchField field : fields) {
if (!field.isVisible()) {
continue;
}
ViewGroup v = null;
if (field instanceof TextSearchField) {
TextSearchField textSearchField = (TextSearchField) field;
if (textSearchField.isFreeSearch()) {
rlSimpleSearch.setVisibility(View.VISIBLE);
tvSearchAdvHeader.setVisibility(View.VISIBLE);
etSimpleSearch.setHint(textSearchField.getHint());
} else {
v = (ViewGroup) getActivity().getLayoutInflater().inflate(R.layout.searchfield_text, llFormFields, false);
TextView title = (TextView) v.findViewById(R.id.title);
title.setText(textSearchField.getDisplayName());
EditText edittext = (EditText) v.findViewById(R.id.edittext);
edittext.setHint(textSearchField.getHint());
if (((TextSearchField) field).isNumber()) {
edittext.setInputType(InputType.TYPE_CLASS_NUMBER);
}
if (((TextSearchField) field).isHalfWidth() && i >= 1 && !(fields.get(i - 1) instanceof TextSearchField && ((TextSearchField) fields.get(i - 1)).isFreeSearch())) {
ViewGroup before = (ViewGroup) view.findViewWithTag(fields.get(i - 1).getId());
llFormFields.removeView(before);
llAdvancedFields.removeView(before);
v.setTag(field.getId());
View together = makeHalfWidth(before, v);
v = null;
if (field.isAdvanced()) {
llAdvancedFields.addView(together);
} else {
llFormFields.addView(together);
}
}
}
} else if (field instanceof BarcodeSearchField) {
BarcodeSearchField bcSearchField = (BarcodeSearchField) field;
v = (ViewGroup) getActivity().getLayoutInflater().inflate(R.layout.searchfield_barcode, llFormFields, false);
TextView title = (TextView) v.findViewById(R.id.title);
title.setText(bcSearchField.getDisplayName());
EditText edittext = (EditText) v.findViewById(R.id.edittext);
edittext.setHint(bcSearchField.getHint());
ImageView ivBarcode = (ImageView) v.findViewById(R.id.ivBarcode);
ivBarcode.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
barcodeScanningField = field.getId();
callback.scanBarcode();
}
});
if (((BarcodeSearchField) field).isHalfWidth() && i >= 1 && !(fields.get(i - 1) instanceof TextSearchField && ((TextSearchField) fields.get(i - 1)).isFreeSearch())) {
ViewGroup before = (ViewGroup) view.findViewWithTag(fields.get(i - 1).getId());
llFormFields.removeView(before);
llAdvancedFields.removeView(before);
v = makeHalfWidth(before, v);
}
} else if (field instanceof DropdownSearchField) {
DropdownSearchField ddSearchField = (DropdownSearchField) field;
if (ddSearchField.getDropdownValues() == null) {
continue;
}
v = (ViewGroup) getActivity().getLayoutInflater().inflate(R.layout.searchfield_dropdown, llFormFields, false);
TextView title = (TextView) v.findViewById(R.id.title);
title.setText(ddSearchField.getDisplayName());
Spinner spinner = (Spinner) v.findViewById(R.id.spinner);
spinner.setAdapter(((OpacActivity) getActivity()).new MetaAdapter<DropdownSearchField.Option>(getActivity(), ddSearchField.getDropdownValues(), R.layout.simple_spinner_item));
// Load saved home branch
if (field.getMeaning() == Meaning.HOME_BRANCH) {
String selection;
if (sp.contains(OpacClient.PREF_HOME_BRANCH_PREFIX + app.getAccount().getId())) {
selection = sp.getString(OpacClient.PREF_HOME_BRANCH_PREFIX + app.getAccount().getId(), "");
} else {
try {
selection = app.getLibrary().getData().getString("homebranch");
} catch (JSONException e) {
selection = "";
}
}
if (!selection.equals("")) {
int j = 0;
for (DropdownSearchField.Option row : ddSearchField.getDropdownValues()) {
if (row.getKey().equals(selection)) {
spinner.setSelection(j);
}
j++;
}
}
}
} else if (field instanceof CheckboxSearchField) {
CheckboxSearchField cbSearchField = (CheckboxSearchField) field;
v = (ViewGroup) getActivity().getLayoutInflater().inflate(R.layout.searchfield_checkbox, llFormFields, false);
CheckBox checkbox = (CheckBox) v.findViewById(R.id.checkbox);
checkbox.setText(cbSearchField.getDisplayName());
}
if (v != null) {
v.setTag(field.getId());
if (field.isAdvanced()) {
llAdvancedFields.addView(v);
} else {
llFormFields.addView(v);
}
}
i++;
}
llExpand.setVisibility(llAdvancedFields.getChildCount() == 0 ? View.GONE : View.VISIBLE);
if (restoreQuery != null) {
loadQuery(restoreQuery);
}
}
use of de.geeksfactory.opacclient.searchfields.BarcodeSearchField 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.BarcodeSearchField 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;
}
Aggregations