import org.evergreen_ils.accountAccess.AccountAccess;
import org.evergreen_ils.accountAccess.SessionNotFoundException;
import org.evergreen_ils.globals.GlobalConfigs;
+import org.evergreen_ils.searchCatalog.Organisation;
import org.evergreen_ils.searchCatalog.RecordInfo;
import org.evergreen_ils.searchCatalog.SearchCatalogListView;
import org.evergreen_ils.views.AccountScreenDashboard;
}
});
+ // kcxxx: factor this out
+ int homeLibrary = 0;
+ if (AccountAccess.getAccountAccess() != null) {
+ homeLibrary = AccountAccess.getAccountAccess().getHomeLibraryID();
+ }
ArrayList<String> list = new ArrayList<String>();
for (int i = 0; i < globalConfigs.organisations.size(); i++) {
- list.add(globalConfigs.organisations.get(i).padding
- + globalConfigs.organisations.get(i).name);
-
- if (globalConfigs.organisations.get(i).level - 1 == 0)
+ Organisation org = globalConfigs.organisations.get(i);
+ list.add(org.padding + org.name);
+ if (org.id == homeLibrary) {
selectedOrgPos = i;
+ }
}
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
- android.R.layout.simple_spinner_item, list);
+ R.layout.spinner_layout, list);
orgSelector.setAdapter(adapter);
-
orgSelector.setSelection(selectedOrgPos);
-
orgSelector.setOnItemSelectedListener(new OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> arg0, View arg1, int ID,
long arg3) {
-
selectedOrgPos = ID;
-
}
+ @Override
public void onNothingSelected(android.widget.AdapterView<?> arg0) {
}
});
}
});
- int selectedPos = 0;
+ //kcxxx: factor this out
+ int selectedOrgPos = 0;
int homeLibrary = 0;
if (AccountAccess.getAccountAccess() != null) {
homeLibrary = AccountAccess.getAccountAccess().getHomeLibraryID();
}
ArrayList<String> list = new ArrayList<String>();
- Log.d(TAG, "Org scanning ...");
- if (globalConfigs.organisations != null) {
- for (int i = 0; i < globalConfigs.organisations.size(); i++) {
- Organisation org = globalConfigs.organisations.get(i);
- list.add(org.padding + org.name);
- if (org.id == homeLibrary)
- selectedPos = i;
+ for (int i = 0; i < globalConfigs.organisations.size(); i++) {
+ Organisation org = globalConfigs.organisations.get(i);
+ list.add(org.padding + org.name);
+ if (org.id == homeLibrary) {
+ selectedOrgPos = i;
}
}
- Log.d(TAG, "Org scanning ...done");
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
layout.spinner_layout, list);
choseOrganisation = (Spinner) findViewById(R.id.chose_organisation);
choseOrganisation.setAdapter(adapter);
- choseOrganisation.setSelection(selectedPos);
- choseOrganisation
- .setOnItemSelectedListener(new OnItemSelectedListener() {
- @Override
- public void onItemSelected(AdapterView<?> arg0, View arg1,
- int ID, long arg3) {
- // select the specific organization
- search.selectOrganisation(globalConfigs.organisations
- .get(ID));
- }
-
- @Override
- public void onNothingSelected(AdapterView<?> arg0) {
+ choseOrganisation.setSelection(selectedOrgPos);
+ choseOrganisation.setOnItemSelectedListener(new OnItemSelectedListener() {
+ @Override
+ public void onItemSelected(AdapterView<?> arg0, View arg1,
+ int ID, long arg3) {
+ search.selectOrganisation(globalConfigs.organisations.get(ID));
+ }
- }
+ @Override
+ public void onNothingSelected(AdapterView<?> arg0) {
+ }
- });
+ });
}