-
Notifications
You must be signed in to change notification settings - Fork 248
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #232 from dronekit/feature_solo_shots_api
Feature solo api
- Loading branch information
Showing
90 changed files
with
1,193 additions
and
729 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 30 additions & 3 deletions
33
ClientLib/src/main/java/com/o3dr/android/client/apis/Api.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,39 @@ | ||
package com.o3dr.android.client.apis; | ||
|
||
import com.o3dr.android.client.Drone; | ||
|
||
import java.util.concurrent.ConcurrentHashMap; | ||
|
||
/** | ||
* Common interface for the drone set of api classes. | ||
* Created by Fredia Huya-Kouadio on 7/5/15. | ||
*/ | ||
interface Api { | ||
public abstract class Api { | ||
|
||
protected interface Builder<T extends Api> { | ||
T build(Drone drone); | ||
} | ||
|
||
/** | ||
* Retrieves the api instance bound to the given Drone object. | ||
* @param drone Drone object | ||
* @param apiCache Used to retrieve the api instance if it exists, or store it if it doesn't exist. | ||
* @param apiBuilder Api instance generator. | ||
* @param <T> Specific api instance type. | ||
* @return The matching Api instance. | ||
*/ | ||
protected static <T extends Api> T getApi(Drone drone, ConcurrentHashMap<Drone, T> apiCache, Api.Builder<T> apiBuilder){ | ||
if(drone == null || apiCache == null) | ||
return null; | ||
|
||
T apiInstance = apiCache.get(drone); | ||
if(apiInstance == null && apiBuilder != null){ | ||
apiInstance = apiBuilder.build(drone); | ||
final T previousInstance = apiCache.putIfAbsent(drone, apiInstance); | ||
if(previousInstance != null) | ||
apiInstance = previousInstance; | ||
} | ||
|
||
interface Builder<T extends Api> { | ||
T build(); | ||
return apiInstance; | ||
} | ||
} |
36 changes: 0 additions & 36 deletions
36
ClientLib/src/main/java/com/o3dr/android/client/apis/ApiUtils.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.