public View getView(int position, View convertView, ViewGroup parent) { Address addr = poiDataPublisher.getAddress(position); if (addr == null || addr.getType() != Address.TYPE_RECENT_POI || addr.getPoi() == null) { return convertView; } Poi poi = addr.getPoi(); Stop stop = addr.getStop(); if (convertView == null) { convertView = mInflater.inflate(R.layout.place_list0normalitem, null); } Context context = AndroidPersistentContext.getInstance().getContext(); PlaceListItem item = (PlaceListItem) convertView; item.init(PlaceListItem.TYPE_NORMAL); item.setIndicatorIcon(R.drawable.list_icon_see_all_unfocused); if (poi != null && poi.getBizPoi() != null) { BizPoi bizPoi = poi.getBizPoi(); if (bizPoi.getCategoryLogo() != null && bizPoi.getCategoryLogo().length() > 0) { int iconId = context .getResources() .getIdentifier( bizPoi.getCategoryLogo(), "drawable", AndroidPersistentContext.getInstance().getContext().getPackageName()); if (iconId != 0) { item.setIndicatorIcon(iconId); } } } customizeAddPlaceListItem(item); if (poi.getBizPoi() != null) { String title = poi.getBizPoi().getBrand(); item.setAddressVisibility(View.GONE); item.setBrandName(title); String distStr = UiFactory.getInstance() .getDisplayDistance(addr, poiDataPublisher.getAnchorStop(), true); item.setDistance(distStr); } String addrText = ""; if (stop != null && addr.isValid()) { addrText = stop.getFirstLine(); } item.setLastLine(addrText); return item; }
private TnScreen createCustomAddressScreen(int state) { int type = this.model.getInt(KEY_I_PLACE_OPERATION_TYPE); Address address = (Address) this.model.get(KEY_O_SELECTED_ADDRESS); final Context context = AndroidPersistentContext.getInstance().getContext(); CitizenScreen screen = UiFactory.getInstance().createScreen(state); addPlaceCustomView = AndroidCitizenUiHelper.addContentView(screen, R.layout.add_place_custom); if (address == null) { return screen; } TextView title = (TextView) addPlaceCustomView.findViewById(R.id.commonTitle0TextView); title.setText(getScreenMainResource(state, type)); Button doneButton = (Button) addPlaceCustomView.findViewById(R.id.commonTitle0TextButton); doneButton.setText(R.string.addplace_custom_done); doneButton.setVisibility(View.VISIBLE); AndroidCitizenUiHelper.setOnClickCommand(this, doneButton, CMD_CUSTOM_PLACE_DONE); ImageView icon = (ImageView) addPlaceCustomView.findViewById(R.id.addplaceCustomIcon); icon.setBackgroundResource(R.drawable.list_icon_see_all_unfocused); Poi poi = address.getPoi(); if (poi != null && poi.getBizPoi() != null) { BizPoi bizPoi = poi.getBizPoi(); if (bizPoi.getCategoryLogo() != null && bizPoi.getCategoryLogo().length() > 0) { int iconId = context .getResources() .getIdentifier( bizPoi.getCategoryLogo(), "drawable", AndroidPersistentContext.getInstance().getContext().getPackageName()); if (iconId != 0) { icon.setBackgroundResource(iconId); } } } this.model.put(KEY_S_PLACE_LABEL, address.getLabel()); ViewGroup editAddressViewGroup = (ViewGroup) addPlaceCustomView.findViewById(R.id.addplaceCustomFilterContainer); addAddressEditView(editAddressViewGroup); if (type == ICommonConstants.PLACE_OPERATION_TYPE_EDIT || type == ICommonConstants.PLACE_OPERATION_TYPE_ADD) { addressEditView.requestFocus(); } TextView firstLineView = (TextView) addPlaceCustomView.findViewById(R.id.addplaceCustomFirstLine); TextView secondLineView = (TextView) addPlaceCustomView.findViewById(R.id.addplaceCustomSecondLine); String displayText = address.getDisplayedText(); if (displayText == null || displayText.length() == 0 || containsLatLon(displayText)) // Unkown address just with lat/lon { ResourceBundle bundle = ResourceManager.getInstance().getCurrentBundle(); addressEditView.setText( bundle.getString(IStringDashboard.RES_STRING_UNKNOWN, IStringDashboard.FAMILY_DASHBOARD)); firstLineView.setText( context.getString( R.string.addplace_location_info, address.getStop().getLat() / 100000.0d, address.getStop().getLon() / 100000.0d)); } else { addressEditView.setText(address.getLabel()); firstLineView.setText(address.getStop().getFirstLine()); } secondLineView.setText( ResourceManager.getInstance().getStringConverter().convertSecondLine(address.getStop())); categoryListAdapter = new CustomPlaceCategoryAdapter(addPlaceCustomView.getContext()); categoryList = (ListView) addPlaceCustomView.findViewById(R.id.addplaceCustomCategoryList); categoryList.setOnScrollListener( new OnScrollListener() { @Override public void onScrollStateChanged(AbsListView view, int scrollState) {} @Override public void onScroll( AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) { resetKeyboard(); } }); categoryList.setItemsCanFocus(false); categoryList.setChoiceMode(ListView.CHOICE_MODE_SINGLE); categoryList.addFooterView(CreateNewCategoryItem()); categoryList.setAdapter(categoryListAdapter); categoryList.setDivider(null); int selectedIndex = this.model.getInt(KEY_I_SELECTED_CATEGORY_INDEX); categoryList.setItemChecked(selectedIndex + categoryList.getHeaderViewsCount() + 1, true); return screen; }