Java Code Examples for com.nextgis.maplib.util.FileUtil#deleteRecursive()

The following examples show how to use com.nextgis.maplib.util.FileUtil#deleteRecursive() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ClearCacheTask.java    From android_maplibui with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
protected Void doInBackground(File... path) {
    if (path.length > 0) {
        if (path[0].exists() && path[0].isDirectory()) {
            File[] data = path[0].listFiles();
            int c = 0;
            for (File file : data) {
                publishProgress(++c, data.length);
                if (file.isDirectory() && MapUtil.isParsable(file.getName()))
                    FileUtil.deleteRecursive(file);
            }
        }
    }

    return null;
}
 
Example 2
Source File: LayerFillService.java    From android_maplibui with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public boolean execute(IProgressor progressor) {
    try {
        VectorLayer vectorLayer = (VectorLayer) mLayer;
        if (null == vectorLayer)
            return false;
        File meta = new File(mPath.getParentFile(), NGFP_META);

        if (meta.exists()) {
            String jsonText = FileUtil.readFromFile(meta);
            JSONObject metaJson = new JSONObject(jsonText);
            //read fields
            List<Field> fields = NGWUtil.getFieldsFromJson(metaJson.getJSONArray(NGWUtil.NGWKEY_FIELDS));
            //read geometry type
            String geomTypeString = metaJson.getString("geometry_type");
            int geomType = GeoGeometryFactory.typeFromString(geomTypeString);
            vectorLayer.create(geomType, fields);

            if (GeoJSONUtil.isGeoJsonHasFeatures(mPath)) {
                //read SRS -- not need as we will be fill layer with 3857
                JSONObject srs = metaJson.getJSONObject(NGWUtil.NGWKEY_SRS);
                int nSRS = srs.getInt(NGWUtil.NGWKEY_ID);
                vectorLayer.fillFromGeoJson(mPath, nSRS, progressor);
            }
        } else
            vectorLayer.createFromGeoJson(mPath, progressor); // should never get there
    } catch (IOException | JSONException | SQLiteException | NGException | ClassCastException e) {
        e.printStackTrace();
        setError(e, progressor);
        notifyError(mProgressMessage);
        return false;
    }

    if (mDeletePath)
        FileUtil.deleteRecursive(mPath);

    return true;
}
 
Example 3
Source File: Table.java    From android_maplib with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public boolean delete()
{
    FileUtil.deleteRecursive(mPath);
    if (mParent != null && mParent instanceof LayerGroup) {
        LayerGroup group = (LayerGroup) mParent;
        group.onLayerDeleted(mId);
    }
    return true;
}
 
Example 4
Source File: MapBase.java    From android_maplib with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public boolean delete()
{
    for (ILayer layer : mLayers) {
        layer.setParent(null);
        layer.delete();
    }

    mLayers.clear();

    return FileUtil.deleteRecursive(getFileName());
}
 
Example 5
Source File: LayerFillService.java    From android_maplibui with GNU Lesser General Public License v3.0 4 votes vote down vote up
public void cancel() {
    if (mLayer != null)
        mLayer.delete();
    else if (mLayerPath != null)
        FileUtil.deleteRecursive(mLayerPath);
}