public void testAddRequestArgs_syncStops() {
   requestItem = new RequestItem(IServerProxyConstants.ACT_SYNC_STOPS, proxy);
   requestItem.params = new Vector();
   Address address = new Address();
   Stop stop = new Stop();
   stop.setCity("EAST BOSTON");
   stop.setCity("US");
   stop.setProvince("MA");
   address.setStop(stop);
   Vector addresses = new Vector();
   addresses.add(address);
   FavoriteCatalog favoriteCatalog = new FavoriteCatalog();
   favoriteCatalog.setName("sports");
   Vector categories = new Vector();
   Vector receivedAddresses = new Vector();
   categories.add(favoriteCatalog);
   requestItem.params.add(0, 131712312L);
   requestItem.params.add(1, addresses);
   requestItem.params.add(2, addresses);
   requestItem.params.add(3, categories);
   requestItem.params.add(4, receivedAddresses);
   try {
     proxy.addRequestArgs(requestVector, requestItem);
   } catch (Exception e) {
     fail(e.toString());
   }
   ProtocolBuffer pb = (ProtocolBuffer) requestVector.get(0);
   assertEquals(1, requestVector.size());
   //        Assert.assertArrayEquals(synStops_data, pb.getBufferData());
   assertEquals(IServerProxyConstants.ACT_SYNC_STOPS, pb.getObjType());
 }
Пример #2
0
  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);
    }
  }
Пример #3
0
    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 testAddRequestArgs_syncStops_exception_lessParames() {
   requestItem = new RequestItem(IServerProxyConstants.ACT_SYNC_STOPS, proxy);
   requestItem.params = new Vector();
   Address address = new Address();
   Stop stop = new Stop();
   stop.setCity("EAST BOSTON");
   stop.setCity("US");
   stop.setProvince("MA");
   address.setStop(stop);
   Vector addresses = new Vector();
   addresses.add(address);
   requestItem.params.add(0, 131712312L);
   requestItem.params.add(1, addresses);
   requestItem.params.add(2, addresses);
   try {
     proxy.addRequestArgs(requestVector, requestItem);
   } catch (IllegalArgumentException e) {
     illegalArgumentException = e;
   } catch (Exception e) {
     fail(e.toString());
   } finally {
     assertNotNull(illegalArgumentException);
   }
 }