AFCoreJavaBridge

A bridge object that provides a Java-friendly interface to the AFCore Kotlin library. This object is intended to be used by Java code that needs to interact with the AFCore library. It exposes all the public functions of AFCore as static methods, using {@link AFCallback} for asynchronous operations.

Initialization

Before using any other functions, you must initialize the AFCore library. This is typically done in your Application's onCreate method.

Java Example:

import com.advantahealth.api.AFCore;
// ... other imports

public class MyApplication extends Application {
@Override
public void onCreate() {
super.onCreate();
AFCore.initialize("apiKey","BaseUrl","swApiKey","swBaseUrl");
}
}

Login

To authenticate a user, use the login method.

Java Example:

import com.advantahealth.util.AFCoreJavaBridge;
import com.advantahealth.util.AFCallback;
// ... other imports

public class LoginActivity extends AppCompatActivity {
// ...
private void attemptLogin(String username, String password) {
AFCoreJavaBridge.login(username, password, new AFCallback<Boolean>() {
@Override
public void onSuccess(Boolean success) {
if (success) {
// Login successful, navigate to next screen
} else {
// Login failed, show error message
}
}

@Override
public void onError(Throwable cause) {
// Handle error (e.g., network issue, server error)
Log.e("LoginActivity", "Login error", e);
}

Functions

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
fun fetchHealthDataByDate(day: Int, month: Int, year: Int, callback: AFCallback<HealthData>)
Link copied to clipboard
Link copied to clipboard
fun getFacilitiesByViewPort(upperLeftLat: Double, upperLeftLng: Double, lowerRightLat: Double, lowerRightLng: Double, callback: AFCallback<List<MapMarker?>>)
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
fun getNearbyFacilities(latitude: Double, longitude: Double, callback: AFCallback<List<MapMarker?>>)
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
fun loginWithCredentials(username: String, password: String, callback: AFCallback<AFResult>)
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
fun submitAutomaticVisit(visitType: VisitType, timestampInSeconds: Long, latitude: Double, longitude: Double, facilityId: String, timeSpentInSeconds: Long, callback: AFCallback<AFResult>)
Link copied to clipboard
fun submitFitAtHomeSelfie(media: ByteArray, timestampInSeconds: Long, lat: Double? = null, lng: Double? = null, callback: AFCallback<AFResult>)
Link copied to clipboard
fun submitSelfReport(facilityId: Int, timestampInSeconds: Long, timeSpentInSeconds: Int, latitude: Double? = null, longitude: Double? = null, atFacility: Boolean = false, callback: AFCallback<AFResult>)
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
fun updateFacility(id: Int, verified: Boolean, callback: AFCallback<AFResult>)
Link copied to clipboard
fun updateFcmToken(deviceId: String, callback: AFCallback<Boolean?>)
Link copied to clipboard