当前位置: 首页>>代码示例>>Java>>正文


Java NetworkUtil.get方法代码示例

本文整理汇总了Java中com.nextgis.maplib.util.NetworkUtil.get方法的典型用法代码示例。如果您正苦于以下问题:Java NetworkUtil.get方法的具体用法?Java NetworkUtil.get怎么用?Java NetworkUtil.get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.nextgis.maplib.util.NetworkUtil的用法示例。


在下文中一共展示了NetworkUtil.get方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: fillExtent

import com.nextgis.maplib.util.NetworkUtil; //导入方法依赖的package包/类
public void fillExtent() {
    try {
        mExtent = new GeoEnvelope();
        String url = NGWUtil.getExtent(mConnection.getURL(), mRemoteId);
        HttpResponse response =
                NetworkUtil.get(url, mConnection.getLogin(), mConnection.getPassword(), false);
        if (!response.isOk())
            return;
        JSONObject extent =
                new JSONObject(response.getResponseBody()).getJSONObject(JSON_EXTENT_KEY);
        double x = Geo.wgs84ToMercatorSphereX(extent.getDouble(JSON_MAX_LON_KEY));
        double y = Geo.wgs84ToMercatorSphereY(extent.getDouble(JSON_MAX_LAT_KEY));
        mExtent.setMax(x, y);
        x = Geo.wgs84ToMercatorSphereX(extent.getDouble(JSON_MIN_LON_KEY));
        y = Geo.wgs84ToMercatorSphereY(extent.getDouble(JSON_MIN_LAT_KEY));
        mExtent.setMin(x, y);
    } catch (IOException | JSONException ignored) { }
}
 
开发者ID:nextgis,项目名称:android_maplib,代码行数:19,代码来源:LayerWithStyles.java

示例2: fillFromNGW

import com.nextgis.maplib.util.NetworkUtil; //导入方法依赖的package包/类
protected void fillFromNGW(Map<String, String> dataMap, IProgressor progressor) throws IOException, NGException, JSONException {
    if (!mNet.isNetworkAvailable()) { //return tile from cache
        throw new NGException(getContext().getString(R.string.error_network_unavailable));
    }

    if(null != progressor){
        progressor.setMessage(getContext().getString(R.string.message_loading));
    }

    Log.d(Constants.TAG, "download layer " + getName());
    HttpResponse response =
            NetworkUtil.get(NGWUtil.getResourceMetaUrl(mCacheUrl, mRemoteId), mCacheLogin,
                    mCachePassword, false);
    if (!response.isOk()) {
        throw new NGException(NetworkUtil.getError(mContext, response.getResponseCode()));
    }
    JSONObject geoJSONObject = new JSONObject(response.getResponseBody());
    JSONObject lookupTable = geoJSONObject.getJSONObject("lookup_table");
    JSONObject itemsObject = lookupTable.getJSONObject("items");
    for (Iterator<String> iter = itemsObject.keys(); iter.hasNext(); ) {
        String key = iter.next();
        String value = itemsObject.getString(key);
        dataMap.put(key, value);
    }
}
 
开发者ID:nextgis,项目名称:android_maplib,代码行数:26,代码来源:NGWLookupTable.java

示例3: doInBackground

import com.nextgis.maplib.util.NetworkUtil; //导入方法依赖的package包/类
@Override
protected HttpResponse doInBackground(Integer... params) {
    if (!mNet.isNetworkAvailable())
        return new HttpResponse(NetworkUtil.ERROR_NETWORK_UNAVAILABLE);

    try {
        mLayerId = params[0];
        return NetworkUtil.get(QMS_GEOSERVICE_URL + mLayerId + QMS_DETAIL_APPENDIX, null, null, false);
    } catch (IOException e) {
        e.printStackTrace();
    }

    return new HttpResponse(NetworkUtil.ERROR_DOWNLOAD_DATA);
}
 
开发者ID:nextgis,项目名称:android_maplibui,代码行数:15,代码来源:CreateFromQMSLayerDialog.java

示例4: fillCapabilities

import com.nextgis.maplib.util.NetworkUtil; //导入方法依赖的package包/类
protected void fillCapabilities()
{
    mSupportedTypes.clear();
    try {
        String sURL = mURL + "/resource/schema";
        HttpResponse response = NetworkUtil.get(sURL, getLogin(), getPassword(), false);
        if (!response.isOk())
            return;
        JSONObject schema = new JSONObject(response.getResponseBody());
        JSONObject resources = schema.getJSONObject("resources");
        if (null != resources) {
            Iterator<String> keys = resources.keys();
            while (keys.hasNext()) {
                int type = getType(keys.next());
                if (type != NGWResourceTypeNone) {
                    if (mSupportedTypes.isEmpty()) {
                        mSupportedTypes.add(type);
                    } else if (!isTypeSupported(type)) {
                        mSupportedTypes.add(type);
                    }
                }
            }
        }
    } catch (IOException | JSONException e) {
        e.printStackTrace();
    }
}
 
开发者ID:nextgis,项目名称:android_maplib,代码行数:28,代码来源:Connection.java

示例5: fillStyles

import com.nextgis.maplib.util.NetworkUtil; //导入方法依赖的package包/类
public void fillStyles()
{
    mStyles = new ArrayList<>();
    try {
        String sURL = mConnection.getURL() + "/resource/" + mRemoteId + "/child/";
        HttpResponse response =
                NetworkUtil.get(sURL, mConnection.getLogin(), mConnection.getPassword(), false);
        if (!response.isOk())
            return;
        JSONArray children = new JSONArray(response.getResponseBody());
        for (int i = 0; i < children.length(); i++) {
            //Only store style id
            //To get more style properties need to create style class extended from Resource
            //Style extends Resource
            //mStyles.add(new Style(styleObject, mConnection);
            JSONObject styleObject = children.getJSONObject(i);
            JSONObject JSONResource = styleObject.getJSONObject("resource");

            JSONArray interfaces = JSONResource.getJSONArray("interfaces");
            for (int j = 0; j < interfaces.length(); j++) {
                if (interfaces.getString(j).equals("IRenderableStyle")) {
                    long remoteId = JSONResource.getLong("id");
                    mStyles.add(remoteId);
                    break;
                }
            }
        }
    } catch (IOException | JSONException e) {
        e.printStackTrace();
    }
}
 
开发者ID:nextgis,项目名称:android_maplib,代码行数:32,代码来源:LayerWithStyles.java

示例6: fillPermissions

import com.nextgis.maplib.util.NetworkUtil; //导入方法依赖的package包/类
public void fillPermissions()
{
    try {
        String sURL = mConnection.getURL() + "/api/resource/" + mRemoteId + "/permission";
        HttpResponse response =
                NetworkUtil.get(sURL, mConnection.getLogin(), mConnection.getPassword(), false);
        if (!response.isOk())
            return;
        mPermissions = new JSONObject(response.getResponseBody());
        if (!mPermissions.has(Constants.JSON_RESOURCE_KEY))
            mPermissions = null;
    } catch (IOException | JSONException e) {
        e.printStackTrace();
    }
}
 
开发者ID:nextgis,项目名称:android_maplib,代码行数:16,代码来源:Resource.java

示例7: getBitmap

import com.nextgis.maplib.util.NetworkUtil; //导入方法依赖的package包/类
@Override
public Bitmap getBitmap(TileItem tile) {
    if (!mExtentReceived) {
        HttpResponse result = null;
        try {
            AccountUtil.AccountData accountData = AccountUtil.getAccountData(mContext, getAccountName());
            result = NetworkUtil.get(NGWUtil.getExtent(accountData.url, mRemoteId), getLogin(), getPassword(), false);
            if (!result.isOk()) {
                throw new IllegalStateException("");
            }
            JSONObject extent = new JSONObject(result.getResponseBody()).getJSONObject(JSON_EXTENT_KEY);
            double x = Geo.wgs84ToMercatorSphereX(extent.getDouble(JSON_MAX_LON_KEY));
            double y = Geo.wgs84ToMercatorSphereY(extent.getDouble(JSON_MAX_LAT_KEY));
            mExtents.setMax(x, y);
            x = Geo.wgs84ToMercatorSphereX(extent.getDouble(JSON_MIN_LON_KEY));
            y = Geo.wgs84ToMercatorSphereY(extent.getDouble(JSON_MIN_LAT_KEY));
            mExtents.setMin(x, y);
            mExtentReceived = true;
        } catch (IOException | JSONException | IllegalStateException ignored) {
            if (result != null && result.getResponseCode() == 404)
                mExtentReceived = true;
        }
    }

    if (mExtents.intersects(tile.getEnvelope()))
        return super.getBitmap(tile);

    return null;
}
 
开发者ID:nextgis,项目名称:android_maplib,代码行数:30,代码来源:NGWRasterLayer.java


注:本文中的com.nextgis.maplib.util.NetworkUtil.get方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。