2016-04-05 13 views
1

ile değiştirilir ve Android Studio aşağıdaki uyarıyı almış edilebilir:Uyarı: Geçenlerde android gelişiminde lambdas desteklemek için retrolambda kütüphanesini kullanmaya başladıktan Ödemeli arama

Ödemeli arama ile değiştirilebilir Can .

Bu inceleme, akım api çağrıları ile değiştirilebilen foreach döngülerini bildirir.

// mGeofenceList is a List<Geofence> 
mGeofenceList = new ArrayList<>(); 
    // GeofenceUtils.GeofenceObjects.entrySet() is a HashMap<String, LatLng> 
    for (Map.Entry<String, LatLng> entry : GeofenceUtils.GeofenceObjects.entrySet()) { 
     mGeofenceList.add(new Geofence.Builder() 
       .setRequestId(entry.getKey()) 
       .setCircularRegion(
         entry.getValue().latitude, 
         entry.getValue().longitude, 
         GeofenceUtils.GEOFENCE_RADIUS_IN_METERS) 
       .setExpirationDuration(GeofenceUtils.GEOFENCE_EXPIRATION_IN_MILLISECONDS) 
       .setTransitionTypes(Geofence.GEOFENCE_TRANSITION_ENTER | 
         Geofence.GEOFENCE_TRANSITION_EXIT) 
       .build()); 
    } 

Soru: Nasıl ödemeli çağrı ile değiştirebilirsiniz şöyle

Benim kodudur?

GÜNCELLEME:

// method stream() cannot be found  
mGeofenceList.addAll(GeofenceUtils.GeofenceObjects.entrySet().stream() 
      .map(entry -> new Geofence.Builder() 
      .setRequestId(entry.getKey()) 
      .setCircularRegion(
        entry.getValue().latitude, 
        entry.getValue().longitude, 
        GeofenceUtils.GEOFENCE_RADIUS_IN_METERS) 
      .setExpirationDuration(GeofenceUtils.GEOFENCE_EXPIRATION_IN_MILLISECONDS) 
      .setTransitionTypes(Geofence.GEOFENCE_TRANSITION_ENTER | 
        Geofence.GEOFENCE_TRANSITION_EXIT) 
      // Collectors cannot be found 
      .build()).collect(java.util.stream.Collectors.toList())); 

Ve şimdi o yöntem akışı(), Koleksiyonerler çözemezse söylüyor: Ben alt basıldığında + girdiğinizde aşağıdaki kod dönüştürdü. Tamir edilebilir mi? Bazı ithalat ifadeleri ekleyebilir miyim? Veya şu anda retrolambda tarafından desteklenmiyor mu?

GÜNCELLEME: SOLVED, aşağıdaki cevaba bakınız.

+0

ziyareti bu http://stackoverflow.com/questions/23127445/how-to-suppress-can-be-replaced-with-foreach-call -haring –

+0

@harshad, Ben bu cevabı gördüm ve sorumu ile ilgisi yok. –

+1

Alt + Enter'a tıklayın ve ardından –

cevap

2

Sorunun altında yorum yapan herkese teşekkür ederiz. Bu kütüphanenin bir yardımı ile sorunu çözüldü: https://github.com/aNNiMON/Lightweight-Stream-API yerine YourCollection.stream (...) göreceksiniz Java 8 uygulamasında

Stream.of (YourCollection) . Her iki yol da bir Akış oluşturulur. Bu kütüphane ile

Final çalışma kodu:

// stream() changed to Stream.of(...) as per library specs 
mGeofenceList.addAll(Stream.of(GeofenceUtils.GeofenceObjects.entrySet()) 
       .map(entry -> new Geofence.Builder() 
       .setRequestId(entry.getKey()) 
       .setCircularRegion(
         entry.getValue().latitude, 
         entry.getValue().longitude, 
         GeofenceUtils.GEOFENCE_RADIUS_IN_METERS) 
       .setExpirationDuration(GeofenceUtils.GEOFENCE_EXPIRATION_IN_MILLISECONDS) 
       .setTransitionTypes(Geofence.GEOFENCE_TRANSITION_ENTER | Geofence.GEOFENCE_TRANSITION_EXIT) 

       // Collectors works without prefix 
       .build()).collect(Collectors.toList())); 
İlgili konular