2 回答
TA贡献1784条经验 获得超2个赞
您可以添加最初设置为false的标志,并在if语句操作代码内将标志设置为true。在该部分代码之后,将其打印到控制台。
然后遍历适当的测试用例,并检查其是否真实存在。
TA贡献1840条经验 获得超5个赞
添加一个布尔标志。
private void whereAreYou(final List<location> locations) {
loadingprogress.setVisibility(View.INVISIBLE);
boolean locationMatchFound = false; //boolean flag
for (int i = 0; i < this.cities.size(); i++) {
final location loc= locations.get(i);
Location loc1 = mLastLocation;
Location loc2 = new Location("");
loc2.setLatitude(loc.getLat());
loc2.setLongitude(loc.getLng());
float distanceInMeters = loc1.distanceTo(loc2);
int distanceInKm = (int) (distanceInMeters / 1000);
if (distanceInKm <= Integer.parseInt(currentclub.getRadius())) {
locationMatchFound = true; //boolean flag set to true if location found
uploadInformationToUserProfile(loc.getName());
}
}
if (!locationMatchFound){
//Call your other method.
}
}
添加回答
举报