Example #1
0
  private void updateLocation(String devId) {
    LocationModel lm = LocationModel.getInstance();
    List<Location> locList = lm.getLocations(devId);
    Location prevLoc = null;
    Location currLoc = locList.get(locList.size() - 1);

    if (locList.size() > 1) {
      prevLoc = locList.get(locList.size() - 2);
      GeoPoint p = new GeoPoint(prevLoc.getLatitude(), prevLoc.getLongitude());
      prevLocationsOverlay.addItem(p, prevLoc.getInfo(), prevLoc.getInfo());
    }

    MapView mapView = (MapView) findViewById(R.id.mapview);

    GeoPoint myPoint1 = new GeoPoint(currLoc.getLatitude(), currLoc.getLongitude());
    currLocationOverlay.removeAllItems();
    currLocationOverlay.addItem(myPoint1, currLoc.getInfo(), currLoc.getInfo());

    mapView.getController().setZoom(13);
    mapView.getController().animateTo(myPoint1);
    mapView.invalidate();
  }
Example #2
0
  public View getView(int position, View convertView, ViewGroup parent) {
    ViewHolder holder;
    // Get the current location object
    LocationModel lm = (LocationModel) getItem(position);

    // Inflate the view
    if (convertView == null) {
      convertView = mInflater.inflate(R.layout.item, null);
      holder = new ViewHolder();
      holder.title = (TextView) convertView.findViewById(R.id.it_location_title);
      holder.description = (TextView) convertView.findViewById(R.id.it_location_description);

      convertView.setTag(holder);

    } else {
      holder = (ViewHolder) convertView.getTag();
    }

    holder.title.setText(lm.getName());
    holder.description.setText(lm.getDescription());

    return convertView;
  }
Example #3
0
  private void doDebug() {
    double slat = 34.103395;
    double slon = -118.237057;

    Location loc =
        new Location(
            (int) (slat * 1000000),
            (int) ((slon + 0.01 * debugIdx) * 1000000),
            "point" + Integer.toString(debugIdx));
    LocationModel.getInstance().add("testId", loc);

    updateLocation("testId");
    debugIdx++;
  }
  public static LocationModel get_MoveHighlight_Location_By_(byte rc) {
    LocationModel res = new LocationModel();
    if (rc >= 100) {
      if (rc == 101) {
        res.x = 710;
        res.y = 12;
      } else if (rc == 100) {
        res.x = 710;
        res.y = 237;
      }
      return res;
    }

    int xx = 680;
    int yy = 240;
    int diff = 50;
    if (rc <= 6) {
      res.x = (xx - (diff * rc));
      res.y = yy;
      return res;
    }
    if (rc <= 12) {
      res.x = (xx - (diff * rc));
      res.y = yy;
      res.x = res.x - 50;
      return res;
    }
    xx = -20;
    yy = 15;
    if (rc <= 18) {
      res.x = (xx + (diff * (rc - 12)));
      res.y = yy;
      return res;
    }
    if (rc <= 24) {
      res.x = (xx + (diff * (rc - 12)));
      res.y = yy;
      res.x = res.x + 50;
      return res;
    }
    return res;
  }
  public static LocationModel get_Checker_Location_By_(int board_position, int roll_position) {
    LocationModel result = new LocationModel();
    if (board_position
        == 0) // وقتی موقعیت بردپوزیشن صفر باشه یعنی میخوایم مکان هیت شده های سفید رو بهمون بده
    {
      result.x = 335;
      result.y = 80;
      return result;
    }
    if (board_position
        == -1) // وقتی موقعیت بردپوزیشن منهای یک باشه یعنی میخوایم مکان هیت شده های سیاه رو بهمون
    // بده
    {
      result.x = 335;
      result.y = 292;
      return result;
    }

    if (board_position == 101) {
      result.x = 711;
      result.y = (12 - 10) + (roll_position * 10);
      return result;
    }
    if (board_position == 100) {
      result.x = 711;
      result.y = (404) - (roll_position * 10);
      return result;
    }

    result.board_Postion = board_position;
    result.roll_Position = roll_position;
    if (board_position <= 12) {
      int ydec = 30;
      int c = 1;
      result.x = 683 - (board_position * 50);
      result.y = 406 - (roll_position * ydec);
      if (board_position > 6) result.x -= 50;
    }
    if (board_position > 12) {
      int ydec = 30;
      int c = 1;
      result.x = -17 + ((board_position - 12) * 50);
      result.y = -15 + (roll_position * ydec);
      if (board_position > 18) result.x += 50;
    }
    return result;
  }