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; }
public void onScreenUiEngineAttached(final TnScreen screen, int attached) { int type = this.model.getInt(KEY_I_PLACE_OPERATION_TYPE); int state = this.model.getState(); if ((type == ICommonConstants.PLACE_OPERATION_TYPE_EDIT || type == ICommonConstants.PLACE_OPERATION_TYPE_ADD) && state == STATE_CUSTOM_PLACE) { if (screen != null && attached == ITnScreenAttachedListener.AFTER_ATTACHED) { TeleNavDelegate.getInstance().setOrientation(TeleNavDelegate.ORIENTATION_UNSPECIFIED); TeleNavDelegate.getInstance() .callAppNativeFeature( TeleNavDelegate.FEATURE_UPDATE_WINDOW_SOFT_INPUT_MODE, new Object[] {PrimitiveTypeCache.valueOf(false), PrimitiveTypeCache.valueOf(true)}); try { if (addressEditView != null) { EditText editText = (EditText) addressEditView.getDropDownField().getNativeUiComponent(); AndroidActivity androidActivity = (AndroidActivity) AndroidPersistentContext.getInstance().getContext(); InputMethodManager imm = (InputMethodManager) androidActivity.getSystemService(Context.INPUT_METHOD_SERVICE); imm.showSoftInput(editText, InputMethodManager.SHOW_IMPLICIT); } } catch (Exception e) { } } else if (attached == DETTACHED) { TeleNavDelegate.getInstance() .callAppNativeFeature(TeleNavDelegate.FEATURE_UPDATE_WINDOW_SOFT_INPUT_MODE, null); } } }
private void updateCurrentLocationItem() { Context context = AndroidPersistentContext.getInstance().getContext(); PoiDataWrapper poiDataWrapper = (PoiDataWrapper) this.model.get(KEY_O_POI_DATA_WRAPPER); Stop anchor = null; Address currentAddress = (Address) this.model.get(KEY_O_CURRENT_ADDRESS); String lastline = null; if (currentAddress != null) { anchor = currentAddress.getStop(); // If this anchor have no firstline this is an address with unknown label. } if (anchor == null) { anchor = poiDataWrapper.getAnchorStop(); } if (anchor == null) { lastline = context.getString(R.string.addplace_current_location_loading); } else { lastline = anchor.getFirstLine(); if (lastline == null || lastline.length() == 0) { lastline = context.getString( R.string.addplace_location_info, anchor.getLat() / 100000.0d, anchor.getLon() / 100000.0d); } } if (!lastline.equals(currentLocationItem.getLastLine())) { currentLocationItem.setLastLine(lastline); } }
private View CreateNewCategoryItem() { Context context = AndroidPersistentContext.getInstance().getContext(); View newCategoryButton = LayoutInflater.from(context).inflate(R.layout.add_place_new_category, null); AndroidCitizenUiHelper.setOnClickCommand(this, newCategoryButton, CMD_ADD_CATEGORY); return newCategoryButton; }
private void customizeAddPlaceListItem(PlaceListItem item) { Context context = AndroidPersistentContext.getInstance().getContext(); LinearLayout indicatorViewGroup = (LinearLayout) (item.findViewById(R.id.placeList0NormalItemNumberIndicatorViewGroup)); indicatorViewGroup.setGravity(Gravity.CENTER_VERTICAL); ((LinearLayout.LayoutParams) indicatorViewGroup.getLayoutParams()).topMargin = 0; }
private void resetKeyboard() { Context context = AndroidPersistentContext.getInstance().getContext(); InputMethodManager imm = (InputMethodManager) context.getSystemService(context.INPUT_METHOD_SERVICE); if (imm.isActive()) { TeleNavDelegate.getInstance() .callAppNativeFeature(TeleNavDelegate.FEATURE_UPDATE_WINDOW_SOFT_INPUT_MODE, null); } }
private View createCurrentLocationItem() { Context context = AndroidPersistentContext.getInstance().getContext(); currentLocationItem = (PlaceListItem) LayoutInflater.from(context).inflate(R.layout.place_list0normalitem, null); currentLocationItem.init(PlaceListItem.TYPE_NORMAL); currentLocationItem.setIndicatorIcon(R.drawable.list_icon_current_unfocused); currentLocationItem.setAddressVisibility(View.GONE); currentLocationItem.setBrandName(context.getString(R.string.addplace_current_location_label)); View background = currentLocationItem.findViewById(R.id.placeList0NormalItem); background.setBackgroundResource(R.drawable.add_place_list_item_background); updateCurrentLocationItem(); customizeAddPlaceListItem(currentLocationItem); return currentLocationItem; }
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; }