Search in sources :

Example 1 with CLE2DataManager

use of com.here.android.mpa.customlocation2.CLE2DataManager in project here-android-sdk-examples by heremaps.

the class MapFragmentView method purgeLocalStorage.

private void purgeLocalStorage() {
    clearMap();
    // get instance of the data manager
    CLE2DataManager dataManager = CLE2DataManager.getInstance();
    // create purge local storage task
    CLE2Task<CLE2OperationResult> task = dataManager.newPurgeLocalStorageTask();
    // start purging
    task.start(new CLE2Task.Callback<CLE2OperationResult>() {

        @Override
        public void onTaskFinished(@Nullable CLE2OperationResult cle2OperationResult, @NonNull CLE2Request.CLE2Error cle2Error) {
            if (cle2Error.getErrorCode() != CLE2Request.CLE2Error.CLE2ErrorCode.NONE) {
                Toast.makeText(m_activity, "Error : " + cle2Error.getErrorMessage(), Toast.LENGTH_LONG).show();
            } else {
                Toast.makeText(m_activity, "Operation completed successfully.", Toast.LENGTH_SHORT).show();
            }
        }
    });
}
Also used : CLE2OperationResult(com.here.android.mpa.customlocation2.CLE2OperationResult) CLE2Task(com.here.android.mpa.customlocation2.CLE2Task) CLE2Request(com.here.android.mpa.customlocation2.CLE2Request) CLE2DataManager(com.here.android.mpa.customlocation2.CLE2DataManager)

Example 2 with CLE2DataManager

use of com.here.android.mpa.customlocation2.CLE2DataManager in project here-android-sdk-examples by heremaps.

the class MapFragmentView method uploadLayer.

/**
 * Upload all layer data to remote storage
 */
private void uploadLayer() {
    if (m_geometryList.isEmpty()) {
        Toast.makeText(m_activity, "List of geometries cannot be empty.", Toast.LENGTH_LONG).show();
        return;
    }
    // get instance of the data manager
    CLE2DataManager dataManager = CLE2DataManager.getInstance();
    // create upload layer task
    CLE2Task<CLE2OperationResult> task = dataManager.newUploadLayerTask(m_layerEdit.getText().toString(), m_geometryList);
    // start uploading
    task.start(new CLE2Task.Callback<CLE2OperationResult>() {

        @Override
        public void onTaskFinished(@Nullable CLE2OperationResult cle2OperationResult, @NonNull CLE2Request.CLE2Error cle2Error) {
            if (cle2Error.getErrorCode() != CLE2Request.CLE2Error.CLE2ErrorCode.NONE) {
                Toast.makeText(m_activity, "Error : " + cle2Error.getErrorMessage(), Toast.LENGTH_LONG).show();
            } else {
                Toast.makeText(m_activity, "Operation completed successfully.", Toast.LENGTH_SHORT).show();
            }
        }
    });
}
Also used : CLE2OperationResult(com.here.android.mpa.customlocation2.CLE2OperationResult) CLE2Task(com.here.android.mpa.customlocation2.CLE2Task) CLE2Request(com.here.android.mpa.customlocation2.CLE2Request) CLE2DataManager(com.here.android.mpa.customlocation2.CLE2DataManager)

Example 3 with CLE2DataManager

use of com.here.android.mpa.customlocation2.CLE2DataManager in project here-android-sdk-examples by heremaps.

the class MapFragmentView method downloadLayer.

/**
 * Download all layer data to remote storage
 */
private void downloadLayer() {
    clearMap();
    // get instance of the data manager
    final CLE2DataManager dataManager = CLE2DataManager.getInstance();
    final String layerName = m_layerEdit.getText().toString();
    // create download layer task
    CLE2Task<CLE2OperationResult> task = dataManager.newDownloadLayerTask(layerName);
    // start downloading
    task.start(new CLE2Task.Callback<CLE2OperationResult>() {

        @Override
        public void onTaskFinished(@Nullable CLE2OperationResult cle2OperationResult, @NonNull CLE2Request.CLE2Error cle2Error) {
            if (cle2Error.getErrorCode() != CLE2Request.CLE2Error.CLE2ErrorCode.NONE || cle2OperationResult == null) {
                Toast.makeText(m_activity, "Error : " + cle2Error.getErrorMessage(), Toast.LENGTH_LONG).show();
                return;
            }
            Toast.makeText(m_activity, "Operation completed successfully.\n" + "Number of downloaded objects is " + cle2OperationResult.getAffectedItemCount(), Toast.LENGTH_SHORT).show();
            // now fetch geometry from local storage
            CLE2Task<List<CLE2Geometry>> fetchTask = dataManager.newFetchLocalLayersTask(Collections.singletonList(layerName));
            fetchTask.start(new CLE2Task.Callback<List<CLE2Geometry>>() {

                @Override
                public void onTaskFinished(@Nullable List<CLE2Geometry> cle2Geometries, @NonNull CLE2Request.CLE2Error cle2Error) {
                    if (cle2Error.getErrorCode() != CLE2Request.CLE2Error.CLE2ErrorCode.NONE || cle2Geometries == null) {
                        Toast.makeText(m_activity, "Error : " + cle2Error.getErrorMessage(), Toast.LENGTH_LONG).show();
                        return;
                    }
                    for (CLE2Geometry geometry : cle2Geometries) {
                        CLE2PointGeometry pointGeometry = (CLE2PointGeometry) geometry;
                        m_geometryList.add(pointGeometry);
                        MapMarker mapMarker = new MapMarker(pointGeometry.getPoint());
                        m_map.addMapObject(mapMarker);
                    }
                }
            });
        }
    });
}
Also used : MapMarker(com.here.android.mpa.mapping.MapMarker) CLE2Request(com.here.android.mpa.customlocation2.CLE2Request) CLE2Geometry(com.here.android.mpa.customlocation2.CLE2Geometry) CLE2OperationResult(com.here.android.mpa.customlocation2.CLE2OperationResult) CLE2Task(com.here.android.mpa.customlocation2.CLE2Task) NonNull(androidx.annotation.NonNull) ArrayList(java.util.ArrayList) List(java.util.List) CLE2DataManager(com.here.android.mpa.customlocation2.CLE2DataManager) CLE2PointGeometry(com.here.android.mpa.customlocation2.CLE2PointGeometry) Nullable(androidx.annotation.Nullable)

Aggregations

CLE2DataManager (com.here.android.mpa.customlocation2.CLE2DataManager)3 CLE2OperationResult (com.here.android.mpa.customlocation2.CLE2OperationResult)3 CLE2Request (com.here.android.mpa.customlocation2.CLE2Request)3 CLE2Task (com.here.android.mpa.customlocation2.CLE2Task)3 NonNull (androidx.annotation.NonNull)1 Nullable (androidx.annotation.Nullable)1 CLE2Geometry (com.here.android.mpa.customlocation2.CLE2Geometry)1 CLE2PointGeometry (com.here.android.mpa.customlocation2.CLE2PointGeometry)1 MapMarker (com.here.android.mpa.mapping.MapMarker)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1